LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Baud rate sample rate

Can anyone explain the relationship of baud rate and sample rate??  I have a pressure flow meter that samples every 10 ms.  My baud rate is 38400.  Which, if I understand all the stuff I read means a "symbol (??), every 260 ms??  Baud rate doesn't seem fast enough...260 vs 10.  The reason I ask is that I used the simple Read/Write serial vi shipped w LV7.1.   I put the write.vi>wait before read ~10 ms.vi>read.vi inside a do while loop.  The open.vi and close.vi are outside this loop so I'm not opening and closing it everytime.  Inside the loop I create a array of data that is read from the read.vi.  When the user hits the stop button the data is writen to an excel file.  Sometimes in the file I get a number of zeros.  The meter is constantly reading a pressure much greater than zero!!  Could my baud rate be too slow such that I'm trying to read over the serial port and theres nothing there yet because my baud rate can't keep up to my sample rate??

 

This maybe for a diff post.  Inside my while loop I'm reading data at a 10 ms rate.  I need this for data crunching.  I'm also trying to display it to the user...  doesn't do well trying to look at display at a rate of 10 msec.  Can I update my display at a rate that is reasonable to read ( 200 ms maybe) yet not affect the sample/data collection rate??

Thanks

See screen shots

Download All
0 Kudos
Message 1 of 15
(12,677 Views)

The sample rate is how often the pressure/flow meter updates its measured/outputed value.

 

BAUD rate is how fast the meter can communicate with the outside world.  Your BAUD rate is 38400 bits per second.  Thats a touch over 26uS (micro seonds) per bit.  Assuming 1 Start, 8 Data and 1 Stop bit, that adds up to approx 260uS to transmit a single byte of data.

 

You send the command, wait 10mS and then read what is in the buffer.  I believe you are getting zeros when it takes the meters longer than 10ms to reply to a command.  Exactly what model of meter are you using?

0 Kudos
Message 2 of 15
(12,652 Views)

TSI 4000.  I started looking at the output from the 4000 in LV Read.vi.  put a probe.  When I request a single piece of data..ie pressure.. at times it sends 2.  There isn't a pattern.  Troubleshooting now.

0 Kudos
Message 3 of 15
(12,645 Views)

Any chance the meter sends an acknowledgement to the command before sending the requested data?

0 Kudos
Message 4 of 15
(12,643 Views)

Another thing.  You said it takes longer than 10 milli to reply.  Aren't the specs good??  Baud rate and sample rate I guess aren't guaranteed?

0 Kudos
Message 5 of 15
(12,642 Views)

Book says "OK" CR LF.  Going to look into parsing that.  I just wanted to make sure it wasn't my baud rate conflicting w my sample rate w what I was trying to do.  Thanks for that simple explaination.

0 Kudos
Message 6 of 15
(12,640 Views)

You can estimate how long it takes to transmit the command to the meter.  You can estimate how long it takes to transmit the reply.  The real question is how long does it take the 4000 to respond to a request for data.  It is not instant. It may very well be that it returns the next new sample of data it takes after you send the request.  Since all data transmitted from the meter uses the 'LF' terminator, I suggest that you enable the termination character and set it to be 'LF'/0x0A.  This will allow you to remove the delay and the 'Bytes at port' and just do a read.  Read will terminate when the 'LF' terminator is received or the port times out.  Let the first read verify that the 'OK' is received.  If it is then a second read will get the actual response.

0 Kudos
Message 7 of 15
(12,638 Views)

Would you mind explaining better or point me to a help file?? I found the enable of term character and set it to be 'LF' but what does  read have to do w it??  If I don't have them enabled even thought the device sends them I won't see them ??  Is that what you're getting at??

 

Since all data transmitted from the meter uses the 'LF' terminator, I suggest that you enable the termination character and set it to be 'LF'/0x0A.  This will allow you to remove the delay and the 'Bytes at port' and just do a read.  Read will terminate when the 'LF' terminator is received or the port times out.  Let the first read verify that the 'OK' is received.  If it is then a second read will get the actual response.

0 Kudos
Message 8 of 15
(12,605 Views)

Slightly out of context but may help resolve your problems...

 

Do you have a requirement to record every 10mS sample? Or are you trying to achieve 10mS  because the meter states it can? If you are populating a spreadhseet with these samples then that is a 100 records per second....

 

You indicate you are updating an indicator for the user to visually observe. I reckon 500mS refresh rate for that indicator is more then adequate, maybe this can also be the rate you update your spreadsheet as well?

0 Kudos
Message 9 of 15
(12,593 Views)

MarkDavid,

 

You need to know when to stop reading the port.  Right now you wait some period of time, see how many bytes are available and then read that many bytes.  Imagine a world where you didn't have to know how many bytes were being transmitted and you didn't have to know how long to wait before trying to read what was transmitted?

 

If you enable the termination character 0x0A, the read stops when the termination character is received or when the requested # bytes is received or a timeout occurs.  If you tell the VISA Read to read 1000 bytes and the tenth byte it reads is 0x0A, then the function will return only ten bytes. 

0 Kudos
Message 10 of 15
(12,582 Views)