10-01-2015 11:53 AM - edited 10-01-2015 12:11 PM
Hi NI community... I am currently finishing a project that uses LIFA. It is a parking lot system that uses servo as the entrance and exit gates. The front panel from Labview needs to display the slots that are occupied, while the code from Arduino IDE controls the occupancy of the slots (entry gates will not open if the slots reach the maximum space). When we run the Labview VI and Arduino code separately, they both work properly. Our problem is when I enter the arduino code to Labview_BASE and run them simultaneously, some errors occur. Is it proper to enter the code to LIFA_BASE so that we can arduino ide and labview vi co-exist on the arduino board? or there is another approach? hoping a hero can read this post. 🙂
10-01-2015 01:13 PM
Are you asking about modifying the Arduino source to have additional functionality, but also support LIFA? If so you can open the source in the Arduino IDE and you'll see some comments saying where you can modify the code. Keep in mind that for the LIFA stuff to work well you'll need to make sure you loop back through quickly, to see if there was a command from LabVIEW.
If you are talking about merging two VIs, then that too can generally be done but you'll need to post more information about what you want, what you have, and what errors you are seeing.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-01-2015 02:44 PM
thanks for responding... 🙂
in our project, there are two functions that we want to implement:
1. the indicator that a slot has been occupied (through a labview VI, the front panel)
2.the servo control for entry and exit gates, controlled by a switch[or any sensor] (through arduino IDE, the C codes)
They both function well when we run them separately.
Since the arduino board needs the Arduino file LIFA-Base in able for it to be controlled by a Labview VI, and I need the servo control (through the codes), I decide to copy these codes to the LIFA_Base file, and upload to the board. The servos function well, but the slot indicator got some error. I was wondering inserting code to the LIFA_Base is necessary or not. Let me upload the Arduino file and the VI. Hope you can help me.
10-01-2015 03:05 PM
10-01-2015 03:09 PM - edited 10-01-2015 03:09 PM
As I said you should be able to see clearly in the main of the Arduino source in the LIFA_Base.ini
// Place your custom loop code here (this may slow down communication with LabVIEW)
And I hope that comment is clear enough, you want to insert your C code in there that controls the servo control. Then you can use LIFA, or use your custom code. Again, you provided no code, and no errors. And no you don't need LIFA to use an Arduino with LabVIEW but it makes it easier, because much of the work is done for you.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-01-2015 03:11 PM
Sir/Ma'am? please correct me.
here's my arduino code and the VI. they both run properly when I play them separately. What procedure can you suggest me so that these two can function as one? I am just beginning to explore Arduino and Labview. Hope you can help me.
10-01-2015 03:24 PM
@Hooovahh wrote:
As I said you should be able to see clearly in the main of the Arduino source in the LIFA_Base.ini
// Place your custom loop code here (this may slow down communication with LabVIEW)
And I hope that comment is clear enough, you want to insert your C code in there that controls the servo control. Then you can use LIFA, or use your custom code. Again, you provided no code, and no errors. And no you don't need LIFA to use an Arduino with LabVIEW but it makes it easier, because much of the work is done for you.
I tried inserting the code to the LIFA_Base file, but, as I said earlier, something went wrong with the VI. The virtual LEDs in the VI blinks in an irregular manner. Maybe there's a certain step that I was not able to do? what do you think?
10-01-2015 03:39 PM
@ruaMaidrin wrote:
Sir/Ma'am? please correct me.
here's my arduino code and the VI. they both run properly when I play them separately. What procedure can you suggest me so that these two can function as one? I am just beginning to explore Arduino and Labview. Hope you can help me.
here's the arduino code in case the arduino file was not accesible.
10-01-2015 03:46 PM - edited 10-01-2015 03:46 PM
I don't have time to look into this too much, but your code has stright up delays like
delay(3000);
That's going to halt your ability to process requests from LabVIEW, you can't have that. There maybe other issues.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-01-2015 03:56 PM
My bad. that was the unedited one. this one was the correct code. I need the delay so that the servo will stay the up position for several seconds so that the "cars" can enter the parking lot. My problem is when i insert this code to the LIFA_Base, the LEDs on the VI keep on blinking.
/*from:
ParkingL02.pde
Arduining.com 08 JUL 2012
*/
#include <Servo.h>
Servo entryServo; // create servo object to control a servo
Servo exitServo;
#define entryServoPin 11
#define exitServoPin 12 //Connected to the servo motor.
#define Exit 10 //Pin connected to the EXIT button.
#define Entry 9 //Pin connected to the IN button.
#define CAPACITY 6 //Capacity of the parking lot.
#define BarLow 177 //Low position of the barrier.
#define BarUp 95 //Up position of the barrier.
void setup(){
entryServo.attach(entryServoPin);
exitServo.attach(exitServoPin); // attaches the servo.
pinMode(Exit, INPUT); // set "EXIT" button pin to input
pinMode(Entry, INPUT); // set "IN" button pin to input
digitalWrite(Exit, HIGH); // Connect Pull-Up resistor.
digitalWrite(Entry, HIGH); // Connect Pull-Up resistor.
entryServo.write(BarLow);
exitServo.write(BarLow); //Barrier in the low position
}
int Available= 7; // Number of places available.
//================================================================
void loop(){
if(digitalRead(Entry)==0)
{
if(Available != 0){
Available--;
entryServo.write(BarUp);
delay(3000);
entryServo.write(BarLow);
}
}
if(digitalRead(Exit)==0)
{
if(Available != CAPACITY){
Available++;
exitServo.write(BarUp);
delay(3000);
exitServo.write(BarLow);
}
}
}