LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: How to read Serial Data from Arduino using labview VISA?

Hi guys = )

 

I Hope you can help me...

 

I'm creating a monitor in Labview to view some information about some gas sensors and temperature sensor (MQ2, MQ125 and DHT22)..

 

The first thing i have done was creating the C code... It's working fine, i can see the results in the Serial monitor...

 

The problem starts when i run on Labview. The whole thing becomes a mess. The infos showed me are totally wrong ...

 

Can someone PLEASE help me?

 

I tried to run the code in parts (for example, if run only the MQ2 gas sensor .VI , or only the temperature .VI and it works fine).

 

The problem starts when i run all the codes informations in one single labview file.

 

I'm uploading the code in C and the .VI hoping someone can give me a hand to solve this issue.

 

Thanks !!!

Download All
0 Kudos
Message 1 of 24
(4,042 Views)

Hi marmaduke,

 

why don't you clean up your VI?

Then you would notice those 3 wait functions, which all wait for 1000ms in parallel.

Or you would notice you duplicated code 4 times just to read 4 values: use a loop to call the same code several times!

(One source of the problem might be the use of BytesAtPort: you are only reading messages partly. At 9600baud it takes ~10ms to transfer 10 chars, but you are checking the received bytecount each millisecond. Your VI works just how you have it programmed to work!)

 

The infos showed me are totally wrong ...

What is wrong? What is shown?

Can you attach any examples of what you expect to receive and what you receive instead from your device?

 

On your VI:

- DON'T USE BytesAtPort IN YOUR VI! Simple set VISARead to read 99 bytes, it will stop the reading at the TermChar you are using in both Arduino and LabVIEW code!

- Why are there so many control/indicators without a label? NEVER delete the label: you may hide it in the frontpanel…

 

check.png

What about this one?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 24
(4,013 Views)

When i said the information were totally messed up, i meant the informations showed me (temperature, humidity, gases level...) were not working properly..

Labview was just showing 'anything'...

 

 

Capture.PNG 

 

LOL, did you really remade my whole code just in this?

 

Can i have this .VI, please?

 

There is a few components in you remade code i dont know yet. So i want use you code to study.

If you like to share with me, of course 😉

0 Kudos
Message 3 of 24
(4,000 Views)

GerdW gave you a snippet.  Copy that image to your harddrive and drag it onto an empty diagram and you will have the code.  That snippet was made with LabVIEW 2017, so you will need a newer version to open it.


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 4 of 24
(3,997 Views)

Hi marmaduke,

 

it's a snippet in my previous message…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 24
(3,996 Views)

Like this?

Capturar.PNGSorry i have never heard before in this snippet

0 Kudos
Message 6 of 24
(3,994 Views)

Hi Mamarduke,

 

did you follow my link into the LabVIEW help?

 

Anyway: which function don't you know? All I added was an IndexArray, all the rest is from your original VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 24
(3,992 Views)

I did it!

 

Now i'm going to test the code 😉

 

Thanks!

0 Kudos
Message 8 of 24
(3,991 Views)

I opened you code in a new VI.

 

When i run the code i'm not receiving any info.. 

 

error.PNG

 

I tested in the serial monitor and i can call the informations:

 

arduino.PNG

 

Maybe there is something wrong in the C code?

 

I'm looking for some C code errors, but so far i got nothing.

0 Kudos
Message 9 of 24
(3,981 Views)

I realized when I go to run the VI, the information appears very fast and it fades. I think it stays for 3 seconds and disappear.

 

I think there may be something wrong with the code, the only problem is that on the serial monitor I can see the information.

 

 

0 Kudos
Message 10 of 24
(3,976 Views)