取消
显示结果 
搜索替代 
您的意思是: 

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.

下载全部
0 项奖励
1 条消息(共 22 条)
5,192 次查看

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 项奖励
2 条消息(共 22 条)
5,185 次查看

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 项奖励
3 条消息(共 22 条)
5,181 次查看

Hi rockabilly,

 

I'm talking about VISAConfigureSerialPort

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 项奖励
4 条消息(共 22 条)
5,178 次查看

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 项奖励
5 条消息(共 22 条)
5,161 次查看

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 项奖励
6 条消息(共 22 条)
5,157 次查看

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 项奖励
7 条消息(共 22 条)
5,153 次查看

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 项奖励
8 条消息(共 22 条)
5,146 次查看

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

0 项奖励
9 条消息(共 22 条)
5,138 次查看

The problem still exists 😞

0 项奖励
10 条消息(共 22 条)
5,110 次查看