07-04-2024 05:22 AM
Hello everyone,
I am now trying to use Labview to implement reading voltage data from a sensor on the analog port of an Arduino, then performing PID control, converting the output of the PID to a PWM signal and then returning it to the digital port of the arduino to control an electromagnet using visa write. Since I don't have the actual device yet, I can't verify that my program is correct. Now my question is how the VISA wiring should be done? Is my program connected correctly?
Lip
07-04-2024 05:51 AM
Hi 9528,
@9528 wrote:
Now my question is how the VISA wiring should be done?
Is my program connected correctly?
To learn about serial communication using VISA you should watch this video.
To verify "correct connection" you need to debug your program. We cannot do this as long as you don't provide any code…
07-04-2024 06:01 AM
Hi GerdW,
Thanks for the reply, here's the code.
Best regards,
9528
07-07-2024 07:51 PM
1. Do watch the video linked to above. It will show you a lot of what you are doing wrong.
2. Do NOT use a False constant for the loop stop condition. The loops will never stop, which means you are never doing any clean-up of the VISA resource. Add a Stop button to your front panel and use it to stop your loop.
3. No need for the Sequence Structure. Data Flow will dictate the run order.
4. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis). I am assuming you are using the Serial.PrintLn() on the Arduino. So just tell the VISA Read to read more bytes than you ever expect in a message and you will get the full value.
5. I do not see a need for the Producer/Consumer here. Just do the read, process the value, and write the result back all in a single loop.
6. Due to the VISA Read waiting for a message, you do not need a wait in your loop. The loop will iterate at the rate of the Arduino sending messages.
7. You should append a Line Feed to your message before writing it so that your Arduino can key off of the Line Feed to know when it has the full message.