LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Controling a DC motor with encoder on back

Hi hrh1818

Thanks for your patience.

For me LIFA is something that connects arduino to labview. Right?

It is right that with labview I can start and stop and increase/decrease speed in the dc motor.

If i put motor working in forward and getting a pulse each 1cm, then in all ruler (300cm) I will get 300 pulses in about 10 secounds, for me excelent.

With this pulses I can calibrate the position in ruler and send a "order" to save data from encoder and IR sensor.

Do you believe that if I change the wheel from the encoder to count 1 pulse each revolution the labview gets all pulses without looses?

By the way "There is lot more Arduino code available that will work with Labview than there is code that will work with LIFA.", Help me find it please.

Once again thanks.

cpalha

0 Kudos
Message 11 of 46
(2,469 Views)

cpalha wrote:

For me LIFA is something that connects arduino to labview. Right?

Yes but there are limitations.  One of the biggest limitations is the speed of communication via serial.  Also, not all Arduino functions are implemented (more below).

cpalha wrote:

It is right that with labview I can start and stop and increase/decrease speed in the dc motor.

If i put motor working in forward and getting a pulse each 1cm, then in all ruler (300cm) I will get 300 pulses in about 10 secounds, for me excelent.

With this pulses I can calibrate the position in ruler and send a "order" to save data from encoder and IR sensor.

Do you believe that if I change the wheel from the encoder to count 1 pulse each revolution the labview gets all pulses without looses?

The point is that if you do it that way then you will not stop right when you detect that you are at your desired position.

Also, Controlling the speed is not so straight forward.  You can control how much power you send to the motor but that does not always equate to speed.

cpalha wrote:

By the way "There is lot more Arduino code available that will work with Labview than there is code that will work with LIFA.", Help me find it please.

He just means that there are many functions in Arduino that are not yet implemented (and many would not be efficient to implement) in Arduino (in a general, non-speciallized version of LIFA).  I have implemented many Arduino functions that are not natively included in LIFA but I've only done this when it's needed.

You can certainly learn how to implement functions by editing the firmware and creating new LabVIEW functions based on existing firmware and LabVIEW functions

0 Kudos
Message 12 of 46
(2,469 Views)

What about a different approach and using a stepper motor to drive your rail?  With a stepper motor you eliminate all the problems of counting Quadrature encoder pulses.  Plus you can be sure your IR measurement and counts refer to exactly the same location.

What is the size of your DC motor?

hrh1818

0 Kudos
Message 13 of 46
(2,469 Views)

Hi hrh1818

The stepper has speed enough? I have possibility to control it with labview?

This board that I have to control de dc motor works in the stepper?

http://www.dfrobot.com/index.php?route=product/product&product_id=69#.UKFv1-TtRg g

My DC motor is

  http://www.dfrobot.com/index.php?route=product/product&path=47_110&product_id=63 4#.UKFvEuTtRgg

I have the possibility to buy this one

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Robotics/42BYGHM809.PDF

What is the maximum RPM tha I will have?

How many analog ports it will need?

Best regards

cpalha

0 Kudos
Message 14 of 46
(2,469 Views)

Be careful with stepper motors. Compared to dc motors they are much weaker and generate more heat.

Simply said they are bad motors.

Controlling a dc motor should be done in the Arduino where LabVIEW generates the commands and the Arduino controls speed etc.

So try to get used to the arduino with arduino software (c programming but made relatively easy).

then think about a specific sketch program and minimize communication.

No strings (except for commands you can use characters) and no difficult parameters.

When you need position as 1 count per revolution use a 16 bit integer and you have a lot of range.

You probably can keep the 300 pulse per revolution also.

But try to implement as little as possible in the arduino but all of the control.

See it as a controller that you give commands like goto pos x, and read position.

good luck

greetings from the Netherlands
0 Kudos
Message 15 of 46
(2,469 Views)

Thanks Albert

The problem is that I have some knowledge in labview and nothing, but nothing in arduino programming.

I will see if it will be easy applying a switch on/off near the wheel after the gearbox and it will give me 1 pulses per revolution....

CPalha

0 Kudos
Message 16 of 46
(2,469 Views)

You say"

"The stepper has speed enough? I have possibility to control it with labview?"

The stepper motor you provided a link to will have a maximum speed in the range of 50 to 100 RPM.

LIFA has built in support only for Big Easy type of stepper drivers. 

You say"

"This board that I have to control de dc motor works in the stepper?"

The DC motor controller board you have can control 2 DC motors or one stepper motor.  When uused with a stepper motor it is not compatible with LIFA

You say:

"I have the possibility to buy this one

What is the maximum RPM tha I will have?

How many analog ports it will need?"

The maximum RPM will be in the range of 50 to 100.

The number of digital pins required will depend upon the type of stpper driver purchased. It will be either 2 or 4 pins.

Normally a stepper driver for the type of stepper motor you provided a link to uses a DC power supply with a much higer outout voltge than the voltage rating of the stepper motor and uses current limiting.  In the literature you will see the term chopper driver applied to this type of driver. This is the type of stepper driver you will need to buy if you used the stepper motor you provided a link to. 

Based on the above comments I second your effort to add a sensor at the gear box output shaft that will produce one pulse per revolution.  But because LIFA doesn't have built in pulse detection capability there are some things you can do to help LIFA.  Don't use a mechanical switch.  Swittch bounce makes it harder to reliably detect a 0 to 1 or 1 to 0 transistion.   The output of the sensor must be a square wave with approximately a 50% duty cycle.   LIFA can not detect a very narrow pusle.

hrh1818

0 Kudos
Message 17 of 46
(2,469 Views)

Two VIs are attached.  DigitalSpeedTest.VI measures how fast LIFA can sample a digital pin.  On my computer it is approximately 1000/8 or 125 times per second.   Your mileage may vary.  TransistionSpeedTest.VI demonstrates a method for determing when the input to a digital pin changes state.  The method come from:

<https://decibel.ni.com/content/docs/DOC-1047

In your application you do not need to use a Digital Waveform Graph.  I used it because it was very helpful when testing the application

In digital speedtest set "Digital Pin" and "Digital I/O PIn to a digital pin of your choice.  They both need to be set to the same digital pin. 

In transistionspeedtest set "Digital Pin" and "Digital I/O PIn to a digital pin of your choice.  They both need to be set to the same digital pin. Set "Mode" to either Rising Edge, Falling Edge or Any Edge.

hrh1818

Download All
0 Kudos
Message 18 of 46
(2,469 Views)

Hi hrh1818

Thanks once again.

Can you please send me a lower version (I have labview10)?

king regards

cpalha

0 Kudos
Message 19 of 46
(2,469 Views)

Attached are versions compatible with Labview 2010.  Most likely you will need to open the front panel of the Init sub  VI to set the COM port.

Note the following calculations are based on the results obtained on my computer.  You should adjust the results if the sampling rate on your computer is significantly different.

The digitalspeedtest2010.VI provides insight into the calibration accuracy obtainable when using one pulse per revolution of the output motor shaft.  With a maximum sampling rate of 125 samples per second there could be as much as a 8 millisecond variation in detection of when the actual pulse occured.  250 RPM is 4.17 revolutions per second and 0.24 seconds per revolution. There for the variation in the angular measurement could be as large as

(0.008/0.24) * 360 = 12 degreees.    If yu need better accuracy the easiest thing to do is run the motor at a lower spped when calibrating. 

With a spacing of 8 miiliseconds between smples the pulse width of the one pulse per revoution has to be greater than 8 milliseconds tp be able to reliably detect the pulse.  Hence instead of havig the rotation of the output shaft produce a pulse it should produce a square wave.   The folowing suggestion is contrary to what I said in a previous message.  I now suggest you use two micro switches loacated 180 degrees apart, a disk with a cam that momentarily operates each mico switch and a 74279 SR latch circuit to debounce the micro switches.  For the swtch debouncing circuit see:

<http://www.eng.uwaterloo.ca/~tnaqvi/downloads/DOC/sd192/SwitchDebouncing.htm>

hrh1818

Download All
0 Kudos
Message 20 of 46
(2,469 Views)