LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Guage Indicator keeps resetting to 0, after a string is recieved!

 Hi there,

 

I am very new to LABView, this is one of my first projects. I have designed a very basic VI for a weather station. I am using a Decimal String to Number function to convert serial values from my anemometer to show on the wind guage on my front panel. However, with every rotation of my anemometer (which gives me a wind speed) it resets to zero before the next pulse. This makes the indicator switch back and forth from the output value to zero.

 

Is there anyway I can prevent this? I am sorry if I can't really word my question well.

 

Thanks,

Sheraz 🙂

0 Kudos
Message 1 of 4
(2,568 Views)

Recieved String is going blank, isn't it?

 

I'm not seeing a loop.  If you are using the Run Continuous button to run this VI, you really should stop that.  You should have a While Loop to loop through your code until you tell it to stop, typically with a stop button wired up to the termination node of the loop.

 

You should also only initialize and close your port once.  The initialize should be before the loop and the close after the loop.  You can do whatever reads and writes inside the loop.

 

For your VISA Read, increase the number of bytes you are reading.  I would set it to something larger than the largest sized message you could recieve.  The VISA Read will stop the read when it sees the termination character (a Line Feed right now).

 

You also do not need the sequence structure.  Chain up the functions with the VISA Resource and Error wires.


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 2 of 4
(2,556 Views)

 

"with every rotation of my anemometer (which gives me a wind speed) it resets to zero before the next pulse"

Does the anemometer reset to zero and is transmitting a zero back to you? 

 

What EXACTLY is your anemometer transmitting to you in the string you are reading in. By exactly I mean every byte including line feeds and Carriage Return. Turn on the '\' code display for the "Received String 2" indicator.

 

I suspect there is a Carriage Return at the end of the string that you are not reading in with the 4 bytes. So the next time you read you are only reading in the termination character that you did not correctly read in the first time. The Decemal String To Number then outputs a zero.

 

Research "termination character" setting in VISA

Omar
0 Kudos
Message 3 of 4
(2,548 Views)

Hi SherrySan,

I fully agree with the suggestions given above. If you are running your code by using "Run Continuously" your indicators might be set to clear everytime the VI is run, so that is a possibility for the clearing of your indicator, but usually it is not set in LabVIEW by default as far as I remember. So the most likely possibilities are that you need to read more bytes and put everything in a while loop or your device simply outputs in this way.

In any case, put down the functionality of your device down, so inputs and expected outputs and then see if you are getting that from your Arduino. You usually need to be running some arduino sketch on it to be able to obtain data from the Arduino for example in the I2C configuration. Feel free to correct me if you are not using an Arduino but I have a strong hunch that you are as I have done a similar application for a MEMS device. If you are running some kind of sketch you might have found an example how to do it online, are you getting the same values on the Arduino through Serial Monitor as in LabVIEW? This can help you narrow down the problem.

Kind Regards,

Applications Engineer
National Instruments UK & Ireland

0 Kudos
Message 4 of 4
(2,493 Views)