LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino & NI-VISA

I'm trying to parse ASCII strings coming from Arduino as :

...

$TIDE,154,154,154.00,104.00
$TIDE,154,154,154.00,104.00
$TIDE,154,154,154.00,104.00
$TIDE,0,154,15.40,-34.60
$TIDE,0,154,30.80,-19.20
...
$TIDE is chosen for identity and followed by 4 numbers seperated by commas, each line ends with CR. Arduino sends data every 100ms through RS232 Shield to computer. I confirm that i receive data when i control with terminal software on PC.

 

It does not work, any help is appreciated.

Download All
0 Kudos
Message 1 of 22
(3,335 Views)

Hi rockabilly,

 

each line ends with CR.

Then you should set the CR as Termination Char in the VISASerialPortInit function!

Just read its help!

 

It does not work, any help is appreciated.

What is "it"? What does not work?

Do you get any error messages? Did you check those errors?

 

I guess the error will be gone once you use the correct TermChar! 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 22
(3,328 Views)

Dear GerdW,


There is no VISASerialPortInit Function in my block, how can i add it ? And how to alter the value from 0xA to 0xD ? Sorry cannot find a visual example showing step by step for newbies.

 

Thanks.

0 Kudos
Message 3 of 22
(3,324 Views)

Hi rockabilly,

 

I'm talking about VISAConfigureSerialPort

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 22
(3,321 Views)

Thank you, able to see values now on both four gauges. I also lowered the number to "250" attached to metronome symbol. But still buggy :

 

- Arduino sends ASCII data every 100ms

- LabView is showing them with delays (eg. i move the sensor but labview still show the old values with many delays, i also confirm it from debug line on bottom)

- All datas are set to zeros every second, so wrong values are shown

 

Thank you

0 Kudos
Message 5 of 22
(3,304 Views)

Hi rockabilly,

 

Arduino sends ASCII data every 100ms … LabView is showing them with delays … All datas are set to zeros every second

This is because of your "metronome" function! Get rid of this!

The VISARead will be sufficient as it already waits for the next message from your Arduino - that's one advantage of using a TermChar!

(You should also put some error handling in the loop, otherwise it might spin as fast as possible on error…)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 22
(3,300 Views)

I added termination char. as attached photo and removed metronome, but problem still continues, it goes to zero sometimes even data flows. My arduino code likes below :

 

...

ssSerial.print("$TIDE,");
ssSerial.print(sensorMin);
ssSerial.print(",");
ssSerial.print(sensorMax);
ssSerial.print(",");
ssSerial.print(average);
ssSerial.print(",");
ssSerial.println(offset);
delay(100);

...

 

"You should also put some error handling in the loop, otherwise it might spin as fast as possible on error…"

 

Could not understand error handling part 😞

0 Kudos
Message 7 of 22
(3,296 Views)

Hi rockabilly,

 

the problem with images is: we cannot debug them using LabVIEW!

 

When you want real (and better) help you should attach your VI! (Or atleast a snippet as this contains code too.)

 

it goes to zero sometimes even data flows. …Could not understand error handling part

Which data flows when you "go to zero"? How does the received string looks like?

Most often you will see the zero when there was a transmission error resulting in a conversion error later on.

To "handle errors" means to react on such errors programmatically!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 22
(3,289 Views)

VI exists on my first post, later i removed metronome etc. according to your help 🙂

0 Kudos
Message 9 of 22
(3,281 Views)

The problem still exists 😞

0 Kudos
Message 10 of 22
(3,253 Views)