LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Inaccuracy in running stepper motor with arduino interface for Labview compared to plain arduino code

LIFA will not work with most L298 type motor shields.  LIFA will only work with Easy Drive boards and possibly with Adafruit motor shields.  To use a L298 you will need to get a sketch that runs on a Arduino board and create a Labview VI to control a step motor.  If you tell us what motor shield you are using or if you are using a do it yourself  L298 board we can help you find a sketch that will work with what you have?

hrh18918

Message 11 of 19
(1,711 Views)

Hello sir. Let me share what i did so far.

i am trying to control the stepper motor with an IC of l298N which i did myself on the breadboard. I already try it and it is working fine. I did try with the sample of one revolution from the arduino.

My problem here is that i have to control it using labview. I wanted to do a simple coding before interfacing it in my final prototype and GUI.

i am trying to say an angle and then the motor has to move accordingly. I also have got the sample vi on the labview example.

Using LIFA, i try to upload and edit the code. I dont know how to upload it. should i take snapshot.

/*********************************************************************************

**

**  LVFA_Firmware - Provides Basic Arduino Sketch For Interfacing With LabVIEW.

**

**  Written By:    Sam Kristoff - National Instruments

**  Written On:    November 2010

**  Last Updated:  Dec 2011 - Kevin Fort - National Instruments

**

**  This File May Be Modified And Re-Distributed Freely. Original File Content

**  Written By Sam Kristoff And Available At www.ni.com/arduino.

**

*********************************************************************************/

/*********************************************************************************

**

** Includes.

**

********************************************************************************/

// Standard includes.  These should always be included.

#include <Wire.h>

#include <SPI.h>

#include <Servo.h>

#include <Stepper.h>

#include "LabVIEWInterface.h"

const int stepsPerRevolution = 150;  // change this to fit the number of steps per revolution

                                     // for your motor

                                   

// initialize the stepper library on pins 8 through 11:

Stepper myStepper(stepsPerRevolution, 8,9,10,11);   

int pic16f877 =3;

int L293D=4;

int pic16f877_state;

int L293D_state;

int posit;

/*********************************************************************************

**  setup()

**

**  Initialize the Arduino and setup serial communication.

**

**  Input:  None

**  Output: None

*********************************************************************************/

void setup()

  // Initialize Serial Port With The Default Baud Rate

  syncLV();

  // Place your custom setup code here

  // set the speed at 60 rpm:

  myStepper.setSpeed(80);

 

  pinMode(pic16f877,OUTPUT);

  pinMode(L293D,OUTPUT);

 

  digitalWrite(pic16f877,LOW);

  digitalWrite(L293D,LOW);

 

 

}

/*********************************************************************************

**  loop()

**

**  The main loop.  This loop runs continuously on the Arduino.  It

**  receives and processes serial commands from LabVIEW.

**

**  Input:  None

**  Output: None

*********************************************************************************/

void loop()

{  

  // Check for commands from LabVIEW and process them.  

  pic16f877_state = digitalRead(pic16f877);

  L293D_state = digitalRead(L293D);

  checkForCommand();

  // Place your custom loop code here (this may slow down communication with LabVIEW)

 

 

  

  

   if(pic16f877_state==HIGH)

   {

     if(posit==0)

     {

       myStepper.step(stepsPerRevolution);

      

       posit=1;

     }

     if(posit==2)

     {

       myStepper.step(-stepsPerRevolution);

       posit=1;

     }

    

   }

  

   if(L293D_state==HIGH)

   {

     if(posit==0)

     {

       myStepper.step(stepsPerRevolution);

       myStepper.step(stepsPerRevolution);

       posit=2;

     }

      if(posit==1)

     {

       myStepper.step(stepsPerRevolution);

       posit=2;

     }

    

   }

  if(acqMode==1)

  {

    sampleContinously();

  }

}

0 Kudos
Message 12 of 19
(1,711 Views)

Actually the code of the PIC all that. This is specifc QR code which i want to be sorted. I did my whole GUI in labview where i am decoding the qr code using vision acquisition. Hence i wanted to use lifa so that

once that specific qr code is scanned and is matched, it is sorted using a rotated wheel type motored by a stepper accordingly to the specific compartment.gty.JPG

0 Kudos
Message 14 of 19
(1,711 Views)

my previous posts were left unawered

hrh1818

Nathan_B.

Dear Sir

i saw your comment for the stepper motor. Actually i am trying to control the stepper motor using the LIFA. My problem is that i did the coding separetely in arduino and also did my circuit.

But now i am having problem like how to integrate this coding to LIFA.

Hope to hear from you soon

0 Kudos
Message 15 of 19
(1,711 Views)

I can mot help you with modifying LIFA for use with an L298N IC.

hrh1818

0 Kudos
Message 16 of 19
(1,711 Views)

Okay Sir

Is there any recomendation of it sir. Because i try to check online but couldnt make my own

coding successful

Hope to hear a positive response.

0 Kudos
Message 17 of 19
(1,711 Views)

There is an example for the L298 in Documents.

hrh1818

Message 18 of 19
(1,711 Views)

Dear Sir

thank you very much for replying. Sir i cant see any document which you are refering too.

Can you please guide me again

thank you

0 Kudos
Message 19 of 19
(1,711 Views)