LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapsed time block is not synchronized with Acquisition Time Using FT232 instead of UNO R3 Atmega16

Hi,

I have an Arduino clone using FT232 USB/Serial communication. My code uses digital pins to create pulses. When one of the pins generates the pulse, there is a counter that gets incremented. The pulse is generated using simulated signal blocks. The timing for the simulated signal block is set to  simulate the acquisition time. When I use Arduino UNO R3 to run the code, everything is fine. However, when I use my clone that has FT232 USB/Serial communication with Arduino Duemilanove bootloader, the elapsed time block and acquisition time in the simulated signal block are not synchronized and my counter does not increment as it should. (as shown in pic1.jpg) pic2.jpg shows the correct indicator response by using Arduino Uno R3. I suspect it has to do with the FT232 USB/Serial communication. As I don't understand much about how the serial communication interface is implemented, may anyone please help me out? I have also included the code (sample.vi).

Thanks!

Download All
0 Kudos
Message 1 of 7
(4,955 Views)

It looks like I have to step through Sammy's code....Should I also try older version of the LIFA? If so, where can I find the link? Anyone out here? Thanks so much.

Simon

0 Kudos
Message 2 of 7
(3,550 Views)

I wonder if the race condition is causing this.  To prevent a race condition and possibly erratic behavior, you must have all LIFA VIs inline.  I.e. all LIFA VIs should use the resource wire coming from the output of another LIFA VI.  This also means that there will be only a single Close VI (which is likely causing issues once the loop stops.

0 Kudos
Message 3 of 7
(3,550 Views)

There's no race condition when running with UNO R3. Everything works the way it should. I am seeing problems when I use FT232 chip for usb/serial communication. Do you know if anyone has used duemilanove with LIFA in the past? Duemilanove uses FT232 instead of Atmega8/Atmega16.

If I can only have one close VI, how do I enable multiple digital pins at the same time? For example, I want digital pin 13 and 12 to go high at the same time.

Thanks again.

0 Kudos
Message 4 of 7
(3,550 Views)

Generally, I would not recomend older versions of LIFA.  All version of LIFA are available through the package manager.  However, you must realize that if you use any version prior to 2.0 it requires an older version of the Arduino IDE (pre 1.0).

There may be issues also due to the relatively slow communication over serial.  Response times will get worse as your frequency increases.

0 Kudos
Message 5 of 7
(3,550 Views)

Just because you are not experiencing issue with the way you have it does not mean that there is no race condition.  Using two digital write pins in parallel in LabVIEW does not make the pins change simultaneously because the communication with the Arduino is serial.

The closest you can get to syncing two pins is setting both values in-line in the firmware (requires a custom LIFA function).

There is an input for board type and one of them is for the Duemillenova.  I've not personally used it and I'm not sure of the differences (since I've mostly dealt with Uno and Mega).

EDIT:  One other thing that I noticed is that you only need to set the pin mode once (before the loop).  That should speed up execution a little bit inside the loop.

0 Kudos
Message 6 of 7
(3,550 Views)

Hey thanks, Nathan. I set the pin mode before the loop and everything works. I just dont understand why the time is synchronized with UNO R3 but not with duemilanove even when I am setting the pin mode infinite number of time. I don't see how the counter for the global time that is used by simulated signal is affected by setting the pin mode infinite number of time. It is ticking slower than the elapsed time's time counter, causing the time shown in the elapsed time indicator to drift away from the time shown on the x-axis of the simulated signal waveform chart. Thanks again.

0 Kudos
Message 7 of 7
(3,550 Views)