09-06-2019 02:59 AM
Hi,
I'm very new user of Labview. I need to reset my Arduino only through my Labview. I have an arduino code which has just the normal pulses ON and OFF. I need to start my arduino when i press a button of Reset in it and my program runs. Now i need that reset press button in my Labview that if i press the button in VI of Labview my Arduino gets reset and program runs.
I m confused.
- Should i use Labview using interface with Arduino from Package Manager.
- Or Should i use my arduino code and make with VISA the whole program.
Which would easy way to do. Please reply me i need some help.
This is my code
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(7, OUTPUT);
}
int n=1;
int delay1=1; // delay of 1ms
void loop() {
// put your main code here, to run repeatedly:
int main_signal=2; int SC_signal=4; int cap_charge=3; int LC_signal=5; int relay_on=7;
digitalWrite(main_signal, LOW);
digitalWrite(SC_signal, LOW);
digitalWrite(cap_charge, LOW);
digitalWrite(LC_signal, LOW);
digitalWrite(relay_on, LOW);
if (n<=1) {
delay(delay1); //delay before the circuit operation (1000 = 1 sec)
digitalWrite(relay_on, HIGH);
delay(delay1*2*500);
//Nominal Phase
digitalWrite(main_signal, HIGH);
delay(delay1*5); // wait for 5ms
//Short-circuit Phase
digitalWrite(SC_signal, HIGH);
delay(delay1); // wait for 1ms
//Fault detected
digitalWrite(cap_charge, HIGH);
delay(delay1); // wait for 500mic-sec
//Counter-current phase
digitalWrite(cap_charge, LOW);
digitalWrite(main_signal, LOW);
delay(delay1); // 1ms delay between caapcitor charging and counter-current phase
digitalWrite(LC_signal, HIGH);
delay(delay1); // 1ms delay for counter_current pulse (LC Pulse)
digitalWrite(LC_signal, LOW);
delay(delay1*2); // delay between counter_current pulse and SC turn off pulse
digitalWrite(SC_signal, LOW);
delay(delay1*2*500);
digitalWrite(relay_on, LOW);
n=n+1;
}
digitalWrite(main_signal, LOW);
digitalWrite(SC_signal, LOW);
digitalWrite(cap_charge, LOW);
digitalWrite(LC_signal, LOW);
digitalWrite(relay_on, LOW);
}
09-06-2019 03:09 AM - edited 09-06-2019 03:11 AM
If you want LabVIEW to control the Arduino, then you need some method of communication (e.g. VISA).
The other option would be to have LabVIEW control the reset pin of the Arduino, but then you need some additional output device (e.g. a second Arduino or DAQ board, programmed to set a pin high when a button is pressed in LabVIEW). This requires more effort than the first suggestion so really doesn't have a significant benefit that I can immediately see.
So perhaps it is best to set up a serial port connection with the Arduino code, then have it accept a command and reset itself when the command is received.
I'd also suggest given your "n <= 1, n = n + 1" system that you could put all of the code in the setup() function and then the loop() only needs to check for the command.
Edit: After a few seconds more thought, I would instead suggest that you move the code to do stuff into a separate function, have the loop wait for the command via VISA, then call the function each time it is received. No resets necessary?
09-06-2019 03:20 AM
Can you please give me a rough idea from where i need to take a start.
It would be better if you can describe little in a VI. I would be very thankful to you. I have my hardware will see if it really work or not.
Edit:
Can i know how can i create separate function ?
Thanks
09-06-2019 03:30 AM - edited 09-06-2019 03:32 AM
Attached are two files which show an example for communicating with a power supply using an Arduino.
In practice, this boils down to LabVIEW sending messages via serial communication to the Arduino, then the Arduino setting various pins high or low.
The header file defines various functions to simplify reading the .ino file (uploaded as .c because the forum is being a pain...)
09-06-2019 03:37 AM
Thanks . I find the files i will see what i can understand from it. I m really a beginner. I need may be little time to understand Labview.
But thanks anyhow.