LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HC-SR04 with Arduino and NI-USB

I don't want to use LINX.Because it creates problem to run other codes on the same device (i.e. Arduino UNO/MEGA). As I mentioned before, I will use this HC-SR04 code as a subVI in my main code.

0 Kudos
Message 11 of 13
(674 Views)

Mr. GerdW

 

Would you help me to convert the Arduino code (attached) into LabView code? 

Thanks in Advance...

0 Kudos
Message 12 of 13
(657 Views)

Well what you have now is a time out error. This is determined by the timeout input to the VISA configure serial port.vi and is defaulted to 10 seconds.

This vi you are using is setup to stop or loop on one of 3 conditions:

A) the visa read.vi receives 500 bytes 

B) the visa read.vi does not see 500 bytes or a new line character (/n) after 10 seconds in which case it will error.

C) the visa read.vi receives a new line character (/n) which basically tells the vi that the message is complete. It will then loop and start over reading. This new line character is sent by the arduino and in this case by the second to last line; Serial.print ("/n");

 

I'm not sure how well the arduino IDE releases the COM port but you could try using the arduino ide serial monitor (without the vi running) to confirm the Uno is working properly. Then close the serial monitor and selecting the same COM port start your vi. 

 

 

Now Using LabVIEW 2019SP1 and TestStand 2019
Message 13 of 13
(647 Views)