LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial data Read in using RS 232

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(4,562 Views)

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. 

 

 

 


0 Kudos
Message 2 of 10
(4,543 Views)

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.

0 Kudos
Message 3 of 10
(4,532 Views)
Solution
Accepted by velkumar10

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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 10
(4,506 Views)

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 "<" & ">".

0 Kudos
Message 5 of 10
(4,430 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(4,417 Views)

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.

Download All
0 Kudos
Message 7 of 10
(4,258 Views)

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?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(4,216 Views)
Solution
Accepted by velkumar10

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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 10
(4,213 Views)

Dear crossrulz,

 Thank you for your help. Now my program works fine.

0 Kudos
Message 10 of 10
(4,202 Views)