Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RS232 Starting Transmission

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,492
Please let me know I am learning RS232 Protocol I know many things about RS232 but stuck in thing. In simulation, I used Arduino UNO, Virtual Terminal and Oscilloscope and I am using Arduino Sketch 'DigitalReadSerial' but I want to know that when I send '1' it sends with start bit, data, stop bit but other bits are showing in oscilloscope what are them?
Please find attachment when I sent '1' and other is '0'.

Sending 'A' is an example but actually I sent '1' and '0'.
 

Attachments

  • EDABoardPIC1.png
    EDABoardPIC1.png
    33.4 KB · Views: 110
  • EDABoardPIC2.png
    EDABoardPIC2.png
    38.8 KB · Views: 107
  • Part1a_PIC5.gif
    Part1a_PIC5.gif
    3.9 KB · Views: 117

Please show waveforms in readable size with time base information so we can interpret it.

The 'A' transmission example uses uncommon 7-O-1 (7 data bits, odd parity, 1 stop bit) format, also unusual right-to-left direction. Oscilloscope waveforms are always left-to-right.

'0' and '1' characters are normally send as ASCII codes 30 and 31 hex, using 10 bits in common 8-N-1 format (1 start bit, 8 data bits, 0 parity bits, 1 stop bit). The oscilloscope waveforms seem to extend over more than 10 or 11 bit times, it's not clearly what's exactly transmitted. My guess is three characters each, the number and carriage return + line feed. Would be much clearer if you send only one number character.

True, the code uses Serial.println(buttonState);, so carriage return + line feed are send along with 0/1.
--- Updated ---

You can use serial.print() instead of serial.println().
 
Last edited:
Please show waveforms in readable size with time base information so we can interpret it.

The 'A' transmission example uses uncommon 7-O-1 (7 data bits, odd parity, 1 stop bit) format, also unusual right-to-left direction. Oscilloscope waveforms are always left-to-right.

'0' and '1' characters are normally send as ASCII codes 30 and 31 hex, using 10 bits in common 8-N-1 format (1 start bit, 8 data bits, 0 parity bits, 1 stop bit). The oscilloscope waveforms seem to extend over more than 10 or 11 bit times, it's not clearly what's exactly transmitted. My guess is three characters each, the number and carriage return + line feed. Would be much clearer if you send only one number character.

True, the code uses Serial.println(buttonState);, so carriage return + line feed are send along with 0/1.
--- Updated ---

You can use serial.print() instead of serial.println().
Ok. Now I am sending.
I
Code:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  Serial.print('1');
  delay(100);        // delay in between reads for stability

}
 

Attachments

  • EDABoardPIC3.png
    EDABoardPIC3.png
    121.4 KB · Views: 107

Fine, now it's a single RS232 8-N-1 frame, sent bits are 0 10001100 1.

1 start bit 0,
8 data bits for hex 31, starting with LSB
1 stop bit 1
--- Updated ---

Baud rate is 9600, bit time of 104 µs.
 
Fine, now it's a single RS232 8-N-1 frame, sent bits are 0 10001100 1.

1 start bit 0,
8 data bits for hex 31, starting with LSB
1 stop bit 1
--- Updated ---

Baud rate is 9600, bit time of 104 µs.
Yes exactly means it is consists of start bit 8-data bits stop bit if we add println it will contain carriage return+line feed and it will display as in decimal
049 013 010
 

Right. I'd however prefer hex notation 0x31 0x0d 0x0a because it can be directly translated to 4-bit nibbles and data bits.
 
Right. I'd however prefer hex notation 0x31 0x0d 0x0a because it can be directly translated to 4-bit nibbles and data bits.
Ok good.
Thanks for helping.
--- Updated ---

Please let me know about delay in between receive and re-transmitted charater when I hit any character i.e 'a' , '3' or any the delay appers in between receive and re-transmitted delay why?
--- Updated ---

Code:
char data;
void setup() {
 Serial.begin(9600);
}

void loop() {
  if(Serial.available()){
    data = Serial.read();
    Serial.print(data);
  }
}
 

Attachments

  • TxRxDelayPart1b.png
    TxRxDelayPart1b.png
    132.1 KB · Views: 106
Last edited:

Serial.available doesn't become true before the stop bit is received. Thus retransmit is always delayed by 1 frame length, plus code execution delay.
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top