Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

arduino

hello,

 

i'm using arduino duemilanove to communicate with arduino,i want to send strings over serial which have the format

"A$$$B###X",where $$$ and ### is any number between 0 and 180,

ive written arduino code to intepret the following string and do the needful ,and the arduino sends back a character 'Z' when it requires the next string ,i'm using the advanced serial read write vi to do the job by connecting the string to write to the string i make using my vi ,while labview sends data to the serial properly and arduino interprets it correctly ,it doesn't do this at every instant ,sometimes the vi may work and sometimes it may not and labview doesn't send the frame back when arduino sends back the character 'Z' ,another problem is that labview continously writes the frame to the serial which resets the arduino every few seconds (around 10 seconds) ,so i want labview to write the string only after the sum of $$$+### /or when labview sends back 'Z'

please help  

0 Kudos
Message 1 of 8
(4,024 Views)

Did you modify the example to better suit your needs.

 

I posted a modified example last week... I will find it and post a link to it.

 

What I suspect is happening is the serial port not getting fully read because it is not reading the port in a loop.

You would modify the example to allow waiting for a relatively long period (greater than 10 sec) due to the slow response.

 

If the above info is incorrect, you can post your code so that we can review it.

0 Kudos
Message 2 of 8
(4,022 Views)
0 Kudos
Message 3 of 8
(4,020 Views)

no i havent modified the code,the timeout problem is solved when i give a very large delay,there's another problem ,for which ill post the screenshots in some time

 

0 Kudos
Message 4 of 8
(4,015 Views)

Giving it a very large delay may solve your immediate problem, but is not the correct solution as it may either slow down the program in the future, should it become faster or not work if the wait time increases.  You should monitor the serial port at relatively short intervals (ie: 100ms). Since it has a long wait period, you could put a loop to monitor until the data arrives and then go to the loop which will actually read it. 

 

In other words, a loop with a timeout (higher value than present time delay - a control to change it later) which has the "Bytes at Serial Port".  If greater than 0 or timedout, exit.  Go to the next loop and read the serial port.  This 2nd loop would also have a "Bytes at Serial Port".  Read until there is no more data at the buffer.

0 Kudos
Message 5 of 8
(4,005 Views)

the harware works fine wen i use the advanced serial read write vi indiviually without putting it in the vi that has the code for processing images ,but when i do link it with the vi which doesimageprocessing and generates the string ,the vi hangs the video used for processing doesn't play at all ,plus the hardware also doesn't work

0 Kudos
Message 6 of 8
(3,993 Views)

the harware works fine wen i use the advanced serial read write vi indiviually without putting it in the vi that has the code for processing images ,but when i do link it with the vi which doesimageprocessing and generates the string ,the vi hangs the video used for processing doesn't play at all ,plus the hardware also doesn't work

Download All
0 Kudos
Message 7 of 8
(3,992 Views)

the harware works fine wen i use the advanced serial read write vi indiviually without putting it in the vi that has the code for processing images ,but when i do link it with the vi which doesimageprocessing and generates the string ,the vi hangs the video used for processing doesn't play at all ,plus the hardware also doesn't work

0 Kudos
Message 8 of 8
(3,992 Views)