03-26-2016 04:58 AM - edited 03-26-2016 05:03 AM
Hi Guys,
Am trying to read data using Arduino. <LVL 1010> <LVL 0101> this are the data am passing from my arduino. When I pass this data, only <LVL 1010 > is processed in my labview where <LVL 0101> is ignored.
This are the different types of data, am going to pass from my arduino
<LVL XXXX>
<FED XXXX>
<ENS XXXX>
<TSS XXXX>
<RLY XXXX>
<LED XXXX>
<MSL XXXX>, where XXXX correspond to the binary value based on the status of the component attached to my arduino.
Please help me to fix this guys. I have attached my program snippet for your referene. Thank you in advance.
Solved! Go to Solution.
03-26-2016 05:15 AM - edited 03-26-2016 05:16 AM
Hi,
There's another way round to do this to lessen your development time.
https://www.labviewmakerhub.com/doku.php?id=libraries:linx:start
It's a LabVIEW toolkit. It uploads a generic firmware to talk to Arduino I/Os and then do rest of the processing in LabVIEW. You might have to migrate from RS-232 to USB with comes with Arduino.
03-26-2016 05:21 AM
Thank you for your reply.
For testing my program, am using Arduino. After my program gets completed without error am going to use PIC controller. So only am using NI VISA for serial communication.
03-26-2016 06:48 AM - edited 03-26-2016 06:49 AM
So you are not using a Line Feed as a termination character. That is fine since you can use the > as a termination character. So turn on your termination character on the VISA Configure Serial Port and set the termination character to be '>' (decimal 62, 0x3E). Then get rid of the Bytes At Port and wire and use a number larger than your largest message size. I would go with something like 20. So what will happen here is the VISA Read will read all of the bytes until one of the following happens: 1) the number of bytes you supplied has been read, 2) the termination character is encountered, 3) the designated timeout has occured (default is 10 seconds). So use the termination character to get an entire message. This will allow you to greatly reduce your logic.
Also, use an actual stop button instead of a toggle button defaulted to TRUE (meaning you will only iterate your loop once).
03-29-2016 05:07 AM
Thank you corssrulz.
Now program works fine, but am getting an error while reading the serial data. My arduino board transmit the data in between "-" for example: The serial data from my arduino board is like " -<ENS 0101>-<ENS 1010>-<ENS 0101>-<". Is there is any way for mentioning the start bit of the string or else any way for extracting the data from the string inbetween the symbol "<" & ">".
03-29-2016 05:21 AM
My advice is to get rid of the "-". It is not needed and just wastes time on your bus. But if you insist on keeping it, just add the "-" to the start of the format string input of the Scan From String.
04-13-2016 12:07 AM
Dear Crossrulz,
Thank's for your help. Yet I find some issue in my program while reading the data in normal mode , it works fine in hight mode. it shows error in scaning the string. I have used bytes at port in order to over come the error, but still program throws error. please help me with this.
04-13-2016 05:15 AM
velkumar10 wrote: it shows error in scaning the string. I have used bytes at port in order to over come the error, but still program throws error. please help me with this.
You really should NOT be using the Bytes At Port. Instead, you should tell the VISA Read to read a lot more bytes than you expect in your message. This will allow the termination character to stop the read.
So what does your serial data look like when you get the error?
04-13-2016 05:19 AM
Whoa, just saw something that makes no sense. You have a timeout of 10ms. You should set that to something more like 1 second (1000ms).
04-13-2016 05:36 AM
Dear crossrulz,
Thank you for your help. Now my program works fine.