11:38 pm
November 29, 2016
I just started playing with the LabView compiler using an Arduino Due. The Arduino Due has a clock speed of 84 MHz. I wrote a simple routine that writes a high then a low using Digital Write to a single pin. I tried several versions of this routine. The last was just a sequence structure sending an alternating high and low. It takes approximately 2 uSec or well over 100 clock cycles for the bit to toggle. (All the test routines, regardless of structure (loop, etc) gave me the same 2uSec time.)
I am aware that the digital write is a slow routine in the Arduino, but this is REALLY SLOW. Is there a work around? I need to quickly change a 16 bit parallel word. If I do that pin by pin, it will take a very long time. There is a port write command. Would it be faster to write to two (8 bit) ports?
Thanks, Cris
12:23 am
March 12, 2015
This is as expected. As referenced in the Compilers documentation, this VI uses the DigitalWrite Arduino function which has a lot of overhead for pin mapping. Refer here for more info. You can most certainly create your own LabVIEW wrapper around a custom Arduino library or just bare C code and can implement a faster routine as shown in the above link. Refer also to the porting an Arduino library section in the Compilers help manual for more information on how to do this. Also, there is an included Digital Write Port.vi you can try. This will access the whole port simultaneously. Although, under the hood uses similar pin/port mapping functions that make interfacing easier, so that may add some overhead still.
1:25 am
November 29, 2016
Steffan:
I saw that article in my searches regarding the DigitalWrite limitations. I was a little disappointed that the Arduino Due, which has a clock speed of 84MHz is not much faster than the 16MHz Arduino's for this operation.
This is a bit of a Catch 22 for me. I am an analog designer and have been using LabView for instrument control for several years. I was hoping your compiler would give me easy access to programming micro-controllers without having to get my hands dirty with C. I have already run into my first hurdle!
The Digital Write Port VI is a little confusing for the Arduino Due as it is a 32 bit chip, with ports that are 32 bits wide. (That is PB goes from PB0 to PB31 I am guessing that once I specifiy the starting pin number it will write to the next consecutive 7 bits of the 32 bit port?
Regards, Cris
5:49 am
March 12, 2015
The Compiler does abstract away the complexities of the Arduino language and allows you to use LabVIEW but you are still limited to the constraints of thew Arduino language. Therefore the limiting factor here is the Arduino DigitalWrite implementation, not the Compiler. But the Compiler does allow you to wrap simple C code with LabVIEW VIs so that may be your only option here, or look around for an existing Arduino library that already implements a higher performance digital write. If you are looking for higher performance, you will likely have to get your hands dirty. The Arduino functionality is more tailored for ease of use with the trade off of performance. As for the Digital Write Port.vi, I just took a look and that will only support AVR based micros, not the Due. The fundamental problem is that it uses the port manipulation Arduino functions, which are only supported on AVR. See here for more details. So your best bet is to look for or write a simple wrapper around direct access to a Due I/O port.
20
1 Guest(s)