05-18-2023 08:04 AM
Hi all,
I am working on some arduino/labview and hit a brick wall.
Currently the plan is to send some hex code from an arduino to labview using serial.
That works however I cant read it correctly with labview.
Any Ideas / suggestions would be much appriciated
🙂
05-18-2023 08:17 AM
@letmetry wrote:That works however I cant read it correctly with labview.
A bit better description of your problem would be useful. From the image you posted i can tell that you are trying to read and write at the same time on the same COM port, that will not work (at least not reliably). You are also closing the same reference twice, which probably results in an error when you stop your VI.
To read hex value, you can also wire a string indicator to VISA Read output and set it to show hex values instead of text.
05-18-2023 08:27 AM - edited 05-18-2023 08:28 AM
Better description:
I am sending a command to the arduino using labview "a" or "b" that part is easy.
Depending on what the arduino receives it will turn on a bank of relays, read the status of all the relays then send back a hex representation of the 64 possible states eg relay1on relay2off etc...
Here's an example of the expected hex return string:
"3F"
In this example, the hex value "3F" represents the status of six relays. Each bit in the byte corresponds to the status of a relay, with "1" indicating ON and "0" indicating OFF.
To interpret the "3F" hex value:
So, the expected interpretation of the hex return "3F" is that all six relays are ON.
Now the problem is I am not good at LabView Yet.
Honestly I have tried so many variations of this im getting lost
05-18-2023 08:28 AM
Please refer to the shipping example <LabVIEW>\examples\Instrument IO\Serial\Continuous Serial Write and Read.vi
05-18-2023 08:37 AM
Thanks for the reply much appreciated,
The continuous read write example does not read the hex correctly it simply reads 3F no matter what 😞
Also the more it is used the slower the arduino responds
05-18-2023 09:10 AM - edited 05-18-2023 09:10 AM
Might I recommend a video on serial communications in LabVIEW. The second half specifically handles the binary/hex/raw data.
VIWeek 2020/Proper way to communicate over serial
05-18-2023 09:14 AM - edited 05-18-2023 09:38 AM
First watch this video: VIWeek 2020/Proper way to communicate over serial
Pay attention to the first part that covers ASCII data with a Termination Character.
But in general the Arduino is going to send the string "3F"
So you need to convert that String that to a Hex Integer and then to a Boolean Array
Use the Serial.PrintLn command to send your data from the Arduino as it adds a Termination Character for you.
Serial.println()
Description
Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n').
05-18-2023 09:18 AM
What exactly are you sending from the Arduino? Can you paste some code here. Or at least the Serial.print() part? What are you reading with the Serial Monitor of the Arduino IDE? Is it correct there?
05-18-2023 09:35 AM - edited 05-18-2023 09:41 AM
@Knight Of NI
Hi,
yes I have watched this but I cant find a way to apply it to my problem
Thanks
05-18-2023 09:52 AM