Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

timed serial data transmission

Solved!
Go to solution

I need to send out serial transmissions continuosly at different time periods and between the transmissions I also need to look for data being recieved.

 

At the moment I have got things working by first setting up my serial coms port and then feeding this into 3 seperate while loops where data is sent out at different times. Loop 1 running at 80ms loop 2 at 160ms and loop 3 at 340ms. Data is read back in loop 2 after a wait period of 20ms.

 

This config works sort of ok but occasionally I loose data on the read.

 

Is there a better way of doing this?

 

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 1 of 7
(4,991 Views)

send out the data in just one loop and wait only as long as you need for the next transmit,

Don't use wait until multiple ms because that one has an upredictable first wait.

use a compare with the system clock each 10 ms, or use a wait multiple of 20 ms and check if you need to send something.

 

Reading is done in a separate while and only the data you expect and is available, so check for Number of bytes available

 

good luck

greetings from the Netherlands
0 Kudos
Message 2 of 7
(4,986 Views)

Hi Albert

 

I have put the time function into a loop as suggested and also put a check for multiple time that triggers a case statement. The main loop would hold the fastest serial write with the case statement holding the first delayed serial write and so on.

 

Problem is the case statement does not function at an exact multiple of the main loop and an error slowly builds.

 

Thanks Jack

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 3 of 7
(4,972 Views)

I'm sorry for not telling exactly how to do this but you only need one wait until multiple in your program.

I'll prepare an example for you, but give me a day.

greetings from the Netherlands
0 Kudos
Message 4 of 7
(4,968 Views)

I have taken out the two of the wait until multiple so just the one. What is happening is that the 2 outputs are in sync when first started but when the case resets at 50 the count goes out by 1 and then after next 50 count it goes out by 2 and so on with error increasing.

 

There is something really obvious I am missing here,

 

thanks Jack 

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 5 of 7
(4,965 Views)
Solution
Accepted by topic author jack1

Hi

 

Indeed, you don't have to reset the starttime.

And only if you run more than I believe 49 days you should take care of the reset of the timing.

And make sure that all messages are sent within the time connected to the wait multiple.

even better take the gmd (in this case 20ms) to have as much time to sent stuff.

 

greetings from the Netherlands
Message 6 of 7
(4,953 Views)

Albert

 

Thanks for solution and sorry for delay in reply, works a treat. Had to do a bit of juggling with the serial read because I found it had to always follow one specific write or errors occasional appeared in the read data.

 

Cheers

 

Jack

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 7 of 7
(4,879 Views)