LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

GPS Code won't run at same time as Arduino LabVIEW code

Hi, everyone. I am using the Parallax instrument driver with the sample code (very few modifications). It works well with my GPS. I added the following code to the LIFA base:

if(Serial3.available()){

     Serial.write(Serial3.read());

}

With the added code in the LIFA base, the Arduino/LabVIEW code works well and the GPS LabVIEW code works well, but they will not run at the same time. I tried wiring the same VISA resource to the init.vis for the GPS and Arduino and still no luck. How can I make these 2 codes run together?

I have attached my working GPS code and the code where I combined the Arduino and GPS code.

Download All
0 Kudos
Message 1 of 14
(7,249 Views)

Where did you add

if(Serial3.available()){

     Serial.write(Serial3.read());

}

You cannot just transfer random data to LV on the same serial line that LIFA is using to talk to the Arduino.  It cause communicaiton to get out of sync.

-Sam K

0 Kudos
Message 2 of 14
(3,562 Views)

You have to integerate both operations in one single while loop.  Currently, if the GPS code gets executed, it is an infinite loop.

I don't understand why you would need to do anything with Serial 3 (or even any of the Arduino code) if both systems work independently in LabVIEW.  It seems to me that your only issue is your code in LabVIEW.

0 Kudos
Message 3 of 14
(3,562 Views)

Sam: I added it under the custom loop. While I had that added bit of code, the GPS LabVIEW code worked, the Arduino code worked, they just wouldn't initialize at the same time. If I can't send that data to LabVIEW on the same serial line, is there any way to use the same Arduino with the GPS and the LVIFA base?

0 Kudos
Message 4 of 14
(3,562 Views)

Nathan: The GPS plugs into a hardware serial port and then I have to send the data to LV, which I am currently doing through the main serial port. If there was a way to open Serial3, I would do it that way, but I have no clue how to set that up or if it's even possible

0 Kudos
Message 5 of 14
(3,562 Views)

I'm confused.  You can't run two independent devices from the same COM port.  Look in your device manager to see which COM port goes with which device (I didn't notice before that you were using the same resource).

0 Kudos
Message 6 of 14
(3,562 Views)

The GPS is hooked to the Arduino. Even though it's a different device, it is programmed through the Arduino. The GPS has rx and tx hooked to the tx and rx of an Arduino hardware serial port. So there is only one device plugged directly into the laptop and that is the 1 Arduino.

0 Kudos
Message 7 of 14
(3,562 Views)

Oh, I get it now.  When running the Parallax code it was actually communicating through the Arduino and not actually interacting with the Arduino itself.

You would need to create several (I don't really know how many at the moment) LabVIEW functions in LIFA to do all the interacting with the GPS module (each of these functions would then use Serial3 on Arduino to talk to it).  Therefore, you wouldn't use any of the Parallax VIs but would need to implement them within Arduino itself.

Maybe there is a better way, I don't know, I don't have any current experience using a secondary serial interface on Arduino via LabVIEW.

0 Kudos
Message 8 of 14
(3,562 Views)

Ahh see with my inexperience, I couldn't possibly do that in the time constraints I have. I was hoping there was an easier way

0 Kudos
Message 9 of 14
(3,562 Views)

If possible, I would just connect both directly to the PC and communicate with both of them via LabVIEW.  You could then use your code and simply just use each of the devices' own COM port.

0 Kudos
Message 10 of 14
(3,562 Views)