03-04-2024 11:39 AM
Hi,
I'm making a VI that reads data coming from Arduino UNO at 9600 bauds to color a graduated bar according to its value. However, I'm getting a -1073807360 error which I can't solve as I don't know the reason. I always get a 0.23 in the string output in VISA read function. I would also like to know if type cast "type" must have a value different from 0 or whatever. I don't understand why it shows "0" if I only want to cast string to single precision.
Find attached the VI.
Thanks!
03-04-2024 01:20 PM - edited 03-04-2024 01:20 PM
a couple of things:
03-04-2024 01:25 PM
1. I used a timed loop because I want to control how many times it inputs data. The idea is to have a sampling frequency of 50 Hz.
2. I don't understand what you mean. I saw a tutorial and thought it was just open VISA->read VISA->close VISA. Are you talking about a block I have to add somewhere?
Thanks!
03-04-2024 01:55 PM
@bitsandscience wrote:
1. I used a timed loop because I want to control how many times it inputs data. The idea is to have a sampling frequency of 50 Hz.
2. I don't understand what you mean. I saw a tutorial and thought it was just open VISA->read VISA->close VISA. Are you talking about a block I have to add somewhere?
Thanks!
1. Your Arduino is setting the sampling rate. The VISA Read will sit there and wait up until the timeout or the termination character is read. Therefore, the Arduino is what is actually setting the loop rate. Timed Loops also bring in all kinds of other issues and overhead that you do not need. Convert the Timed Loop to a normal While Loop.
2. Use the VISA Configure Serial Port instead of the VISA Open. This way, you can make sure you are using the proper settings (baud rate, termination character, timeout, etc.).
3. Could you supply your Arduino code? I question your messaging protocol. Either your protocol needs a lot of tweaks or you are converting the data incorrectly on the LabVIEW side.
03-04-2024 02:04 PM
1. OK, I thought it was going to be slow without a timed loop, that's why I put it like that. I will change it, then.
2. OK.
3. Sure, here it is (can't attach it):
Thanks a lot!
03-05-2024 05:36 AM - edited 03-05-2024 05:38 AM
Nice and simple sketch. Now the Serial.PrintLn converts your number into an ASCII format before transmitting. So to interpret the data, you need to use Fract/Exp String To Number since it is designed interpret ASCII.
Here is how I would do your LabVIEW code in order to read the data as it comes in and properly interpret it. As discussed earlier, use a While Loop instead of a Timed Loop. Use Fract/Exp String To Number to convert the message to a number. The Case Structure can accept integers and use ranges, making the coloring a lot easier to read.
03-05-2024 05:58 AM
Thanks for the advice, but I am still getting the same error out from VISA configure serial port, even from the design you attached.
I also set this in Arduino:
03-05-2024 06:23 AM
Since the Arduino is not receiving anything, its timeout is not required.
You are getting an "Unknown System Error". Do you have the port opened in another application, such as the Arduino interface?
03-05-2024 06:27 AM
Okay, so no timeout.
No, the serial monitor/serial plotter is closed every time I run labview VI. Even if I close the Arduino IDE, it gets same error.
03-05-2024 12:58 PM
Okay, rebooting PC was the solution.
Thanks a lot 😉