question about write to serial

I want to write this string to the serial, but the signal is wrong. How to wirte this code? Thank you!!!

댓글 수: 4

Taylor
Taylor 2024년 11월 4일
It's hard to say what's going wrong without knowing what device you're writing to. Is app.SerialObject defined as a property in the app? If you can share the app code that would be great.
Walter Roberson
Walter Roberson 2024년 11월 4일
Did you remember to take into account Start Bit and Stop Bit?
Did you remember to take into account that bits are transmitted "least significant bit" first? (which is "right to left" compared to the usual way of writing bit sequences)
Did you remember to take into account that binary 0 is transmitted as MARK condition ("on") and binary 1 is transmitted as SPACE ("off") condition?
Weiyue
Weiyue 2024년 11월 5일
편집: Weiyue 2024년 11월 5일
Dear Walter Roberson, thank you for your answer. I found the question is that each 8-bits data has a start bit and stop bit as you said. So if there are some ways to remove the start bit and stop bit to make the signal continuous? Thank you very much!
Walter Roberson
Walter Roberson 2024년 11월 5일
When you are measuring the wire signal levels of RS232, then the Start and Stop bits are unavoidable.
Side note: the Start bit is a different length than the Stop bit. I seem to recall that the Stop bit is half of the length of other bits.

댓글을 달려면 로그인하십시오.

답변 (1개)

Supraja
Supraja 2024년 11월 11일

0 개 추천

Hi,
It seems like sending deimal values inside the function would help in this case.
Please use the code as below:
write(app.SerialObject, [85, 86, 87, 88], "uint8"); % Decimal equivalents of binary numbers
Refer to 'write' function documentation below for further reference:
I hope this helps!

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2024년 11월 4일

답변:

2024년 11월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by