uploading multiple programs to board w LabVIEW

Hi all -

I'm using LabVIEW and a Firgelli PQ-12-P linear actuator controlled by the Arduino Duemilanove. I have a small photodiode mounted on the Firgelli, and I want it to "sweep" across a few steps. The Firgelli takes a small step using EXTEND below, and a multimeter will takes a current reading at that point. It does this several times in a row. Then, the LabVIEW VI will decide which point (of Firgelli motion) the detector/multimeter recorded a maximum, and it will command the Firgelli to return to that point. (More things happen before or after this step, but this is the only step that talks to the Arduino.)

The problem is that this requires forward and backward motion, which are two seperate "bundles of code" (not sure of the correct term, sorry) below which EXTEND or RETRACT the Firgelli. I have no problem getting LabVIEW to repeatedly do one of the two motions (whichever was last uploaded on the Arduino board).

Basically I need to know how to use LabVIEW to do both. This would require an intermediary step - once it has taken all its readings in the forward (EXTEND) direction, pause and upload the RETRACT code, and then run that. How do you get LabVIEW to upload new code onto the board?


void(setup) {
//EXTEND

pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(10);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
}
void(loop)
{
}


and


void(setup) {
//RETRACT

pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(3, LOW); // switch 2 to 3
digitalWrite(2, HIGH); // switch 3 to 2
delay(10);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
}
void(loop)
{
}


I think you're asking the wrong question. Rather than switching programs by uploading, why not write a program that can do both and communicate with it, telling it what to do at a given time.

If you can open up a serial port from LabView (and you can :wink: ) then you can talk to the Arduino and send it commands from within LabView.

Have a look at the SerialCallResponse sample sketch for a basic start.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

'bundles of code' we call 'functions'

Thank you both.

RC, you are right, that does seem closer to what I want to do. I will play around with it, because I can actually read the position through the analog output.

So what I'm thinking now is that all LabVIEW needs to tell it is a position. Then my function reads analog out (to get position), followed by if an statement comparing the current value with the desired value. If true then extend; if false then retract.

Do you think this is the best way to proceed?

I don't need to draw any graphs so I think 90% of that example (hopefully!) I can ignore.

Yes, I think you have the idea now. You might want to implement some filtering to prevent "chattering", but worry about that when the time comes. There may already be built-in filtering in the system.

--
Need a custom shield? Let us design and build one for you.