07-09-2010 04:15 PM
Hello Guys
I have a c routine on avr studio that programs a LP3907 buck converter via an arduino board (usb~com interface).
I am wondering if its possible in any way to develop a VI which will communicate to the com port used and write to the registers on the LP3907 via the arduino.?
I can use hyperterminal on my c code but it is a bit messy (and is not working yet...!), I am wondering if a VI is possible, as I can have radio buttons to program specific registers, (ie set the many voltages of the buck outputs).
of course I need to somehow entwine the C code into the VI also, so I think its going to be tricky.
any help is appreciated.
cheers.
07-09-2010 04:27 PM
You can compile your c code into a DLL and call it from Labview using the Call Library function. Where does I2C come into play?
07-09-2010 05:00 PM
hmmm, thats interesting.
ok, let me explain.
I got a pcb made to house my lp3907 IC, it communicates via I2C (TWI) to the arduino. The twi code is done in C, with avr studio and basically has control over the internal registers of the lp3907, I can progam all the buck outputs.
But I need to do it dynamically, on the fly, like hit some radio buttons for instant responses. rather than altering the code and flashing the hex file onto the arduino again.
I was figuring a labview VI could someone interact with my code across the com port used and do this for me..
does this make sense.?
regards.
07-09-2010 05:25 PM
Yes.
07-09-2010 05:50 PM
Ok, good.
so I can accomplish this with a vi, i never thought that was possible. I need to try this. how exactly does the vi interact with the c code ? I take it I can use a i/o communication block to access the arduino board on the com port?
07-09-2010 05:55 PM - edited 07-09-2010 05:56 PM
I think we're talking apples and oranges here. AVR Studio is used to create the code that is downloaded to a microcontroller. You do not interface this to LabVIEW, as the code runs on the microcontroller. Your microcontroller code would need to have serial interface routines to accept commands from an external program, such as LabVIEW. Then you can treat the Arduino board as an instrument (serial-based), and use VISA to send serial commands to it, as the serial port examples in LabVIEW show. You would need to create the commands (i.e., the protocol), and the parsing functions in AVR Studio to handle receipt of these commands over the serial port. The commands themselves can be anything you want, since you're creating them. LabVIEW would just send these commands (along with any associated parameters).
07-09-2010 06:39 PM
Glad you chipped in smerc. I had no idea what an arduino board was. I just accepted that he had some C code to be called from LV.
07-09-2010 06:46 PM
Concise!
Smerc- you show your true mastery again!
07-10-2010 05:33 AM
thanks guys...!!!!!
Smerc:
Does this seem overly difficult? as if its too much effort I will give it a miss. as at the minute I am pretty close to getting hyperterminal commands on c working (ie enter a register on hyperterminal and see responses on the buck outputs).
I have previously done a VI with a hameg meter reading voltage and current across its rs232, so im not too bad with labview , but if this is too difficult I would give it a miss.
Is there any code examples I could look at somewhere.?
cheers.
07-10-2010 10:32 AM
There are examples that ship with LabVIEW on how to communicate over the serial port. Just open the Example Finder (Help -> Find Examples) and search for serial. You'll need to provide the serial port configuration, and specify whether you're using termination characters for your responses from the board. Please remember that they are just examples and intended to give you the basic idea of how to do serial port programming in LabVIEW. You will need to adapt to your specific situation. You could also look at LVTerm, but keep in mind that's an old VI.