LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware interrupt handling from Arduino

Hi all,

 

I am using LabVIEW to control an Arduino board. I am now using the LIFA interface but this question is not only LIFA related, solutions with LINX are more than welcome (and other solutions as well).

 

In my application I connect the Arduino UNO board to LabVIEW through USB. The Arduino control a stepper motor through a BigEasyDriver. The motor move in linear direction an object, until it reach the "home" position. The detection of the event "home position reached" is made through a simple button that change its digital value from 0 to 1 (5V). 

So, the ideal way to implement this would be using an interrupt: the Arduino move the motor and when the button change value, an interrupt is send and the Arduino stop the motor.

I know that the Arduino support the interrupts, so to implement this in Arduino's code would be possible.

 

Unfortunately, I cannot find a solution to make the same through LabVIEW. I know I could use a polling approach, but interrupts are much more elegant solution.

My aim would be control Arduino from LabVIEW and detect the interrupt that the button sent to Arduino through LabVIEW.

 

Is it possible?

 

Thank you for your help,

Matteo

 

0 Kudos
Message 1 of 3
(4,158 Views)

Yes it is possible but without the polling method, your solution will need to be written in C++ using the Arduino IDE.  LIFA and LINX both just are wrappers for communicating mostly by single point to the Arduino, but both have the source code of the firmware put on the device available and have a section where you can write your own code which can be any code.  I'd recommend getting what you want first working without LIFA, LINX or LabVIEW, then copy that code into the LIFA/LINX firmware adding your functionality to it.

 

https://playground.arduino.cc/Code/Interrupts

0 Kudos
Message 2 of 3
(4,113 Views)

@MatteoIcfo wrote:

Hi all,

 

I am using LabVIEW to control an Arduino board. I am now using the LIFA interface but this question is not only LIFA related, solutions with LINX are more than welcome (and other solutions as well).

 

In my application I connect the Arduino UNO board to LabVIEW through USB. The Arduino control a stepper motor through a BigEasyDriver. The motor move in linear direction an object, until it reach the "home" position. The detection of the event "home position reached" is made through a simple button that change its digital value from 0 to 1 (5V). 

So, the ideal way to implement this would be using an interrupt: the Arduino move the motor and when the button change value, an interrupt is send and the Arduino stop the motor.

I know that the Arduino support the interrupts, so to implement this in Arduino's code would be possible.

 

Unfortunately, I cannot find a solution to make the same through LabVIEW. I know I could use a polling approach, but interrupts are much more elegant solution.

My aim would be control Arduino from LabVIEW and detect the interrupt that the button sent to Arduino through LabVIEW.

 

Is it possible?

 

Thank you for your help,

Matteo

 


The problem with what you suggest is that there is always going to be latency between the arduino and LabVIEW due to the fact they talk over serial (USB).

 

The best option is it to code the interrupt for the limit switch on the arduino.

If you are controlling the motor via step and direction pulses, and it also has an enable line, I would approach like this:

 

Attach interrupt for the limit switch pin for the end you are travelling towards. If it gets triggered while you're stepping,, the ISR will kick in and set the enable line to disable the driver.

 

In the code that executes after a movement, you can check and reset the enable line (but by this point, all of the commanded pulses that would have smashed you into limit will have expired - it still will have pulsed but we wont have moved).

 

Now you can move away from the limit switch again (since we would now attach the interrupt for the opposite switch).

 

Shouldnt be too difficult to implement, it would be even easier if the motor drives have limit switch inputs for CW / CCW.

 

Deceased

0 Kudos
Message 3 of 3
(4,104 Views)