02-27-2015 08:09 AM
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 🙂
02-27-2015 08:22 AM
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.
02-27-2015 08:33 AM
"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
03-03-2015 03:39 AM
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,