LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XON /XOFF (software handshaking Vd hardware handshaking)

Solved!
Go to solution

Hi Guys,

 

i am trying to transmitt data from the microcontroller to the computer using max232 for RS232 connection . i have a DB9 male on the board.i only used 2 pins for that goal.(pin2 and pin5) .

 

my questions are as follows..

1 - do i have to select any value for XON/XOFF(software handshaking) while i havent used any kind of hardware handshaking ? do i have to put their values as default zero ?

 

2 - what is the best value for the input buffer size if i am trying to acquire an ECG signal  through a serial port with 19200 baude rate ? 

 

i am really confused .. :S

 

 

 

 

Bill David
0 Kudos
Message 1 of 7
(9,565 Views)

Hi shangal!

 

A serial port may use signals in the interface to pause and resume the transmission of data. For example, a slow printer might need to handshake with the serial port to indicate that data should be paused while the mechanism advances a line.


Common hardware handshake signals (hardware flow control) use the RS-232 RTS/CTS or DTR/DSR signal circuits. Generally, the RTS and CTS are turned off and on from alternate ends to control data flow, for instance when a buffer is almost full. DTR and DSR are usually on all the time and, per the RS-232 standard and its successors, are used to signal from each end that the other equipment is actually present and powered-up. However, manufacturers have over the years built many devices that implemented non-standard variations on the standard, for example, printers that use DTR as flow control.

 

Another method of flow control (software flow control) uses special characters such as XON/XOFF to control the flow of data. The XON/XOFF characters are sent by the receiver to the sender to control when the sender will send data, that is, these characters go in the opposite direction to the data being sent. So during sw handshaking your receiver (the PC) transmits data to the uC.

Because of this, if you would lik to use sw handshaking, you have to connect the PIN3 transmit signal too.

In my opinion there is no need for any handshaking in this project, because the PC is fast enough to receive the packets sent by the uC. (maybe this answers your 1st question) So in your VI you choose "none" for flow control.

 

More about serial communication: http://en.wikipedia.org/wiki/Serial_port

More about RS-232: http://en.wikipedia.org/wiki/Rs232

A very easy example circuit for max232: http://sodoityourself.com/max232-serial-level-converter/  (I think you use something similar too.)

 

Let us see the sw part of the serial communication:

 

If you search for "serial" in Ni example finder, there will be a lot of useful, ready to use examples, like these:

Advanced Serial Read and Write.vi; Basic 2 port Serial Write and Read.vi; Basic Serial Read and Write.vi; and a lot more...

I thnik, using these you can create a VI, that suits the needs of your application.

 

 

Answer for your 2nd question: 

 

You can set the buffer size with the VISA Set I/O Buffer Size Function, after configuring the serial port. (Advanced Serial Read and Write.vi is a good example for this)

The mask input of this VI sets which buffer size to set. If you want to use the receive buffer, you have to set this input to 16.

 

The size input of this VI sets the buffer size. You have to set size slightly higher than the amount of data you expect to transmit or receive. The default is 4096 byte, so if the baoud rate of your communication is 19200 bit/sec, the default buffer size could be enough big too. But using the error out of the VI you can test, if an overflow occurs, so you can specify a bigger buffer size.

 

Of course if an application requires a specific buffer size for performance reasons and the VISA implementation cannot guarantee that size, you have to use some form of handshaking to prevent overflow conditions.

So if your buffer isn't big enough for the incoming data, you can tell the uC to pause the transmittion of data. 

 

I hope my answer will help you to develop the communication part of your project, if you have any questions, don't hesitate to post them.

 

Best regards,

CLA, CLED
Message 2 of 7
(9,535 Views)

Dear BalazsNagy

 

a special thanks to you, for the information you provided . your were the best help . 

 

concerning the first question ( xon/xoff)  : you convinced me not to put any kind of handshaking .coz as u said the pc is able to receive the incomming amount of data. 

 

concerning the second question . i think that the experiment will give me the answer . i will try with different input buffer size (higher than 4096) as long as i am using a signaling rate of 19200b/s and i will let you know what will happen.

 

 

thank you very much .


Bill David
0 Kudos
Message 3 of 7
(9,523 Views)

Hi shangal!

 

Did you manage to set up a proper working communications? Could you use the examples?

Have you any questions regarding to them or to your topic?

 

BR,

CLA, CLED
0 Kudos
Message 4 of 7
(9,504 Views)

Dear BalazsNagy

sorry for being late yes i tried the examples provided by advanced VISA read and write and i can understand it very well but still do not know how and where to take the signal from ..and how to apply filtering techniques as well as FFT. concerning the handshaking i dont use it anymore . because i only used 2 pins of the db9 male . pin2 to transmitt the data to the PC. and pin 5 connected to the ground. but never used the pin3 to tell the microcontroller to stop sending data . i will try to put the input buffer size higher the expected amount of incomming data.

but the thing that confuses me is that overflow could happen in 2 cases .when the buffer size is small compared to the data. and when the buffer size also is too big. 

 

any suggestions ?

Bill David
0 Kudos
Message 5 of 7
(9,494 Views)
Solution
Accepted by topic author Bildavid

Hi David!

 

When using buffers, two types of errors can occur related to the sizes of the buffer.

If the size is too small, and we overwrite the data in the buffer, the overflow error occurs.

If the size is big enough, and you read a specified value of elements (byte count input of VISA read function) it can occur, that the buffer becames empty, and the Read VI still wants to read, because the read amount of data did not reach the given value. This is called underflow.

 

I think in your case, (since you don't use handshaking) it would be good, to test some different buffer sizes, and of course different byte count input values of VISA read function.

 

Have you any questions regarding to your original subject about handshaking?

If you have any other questions about serial communication, but with an other subject, please open a new topic.

 

Best regards,

CLA, CLED
0 Kudos
Message 6 of 7
(9,480 Views)

Hi BalazsNagy

 

Well that makes the statement  veryCLEAR thank you very much .  

 

REGARDS.

Bill David
0 Kudos
Message 7 of 7
(9,470 Views)