LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper motor oscilates in reverse using Arduino

I have a VI which I’m using to drive 3 stepper motors. A signal is read from a potentiometer using an Arduino, processed and then used for the speed input to a stepper motor which is driven by the same arduino. The input signal to the stepper motor is an integer number in the range of -250 to +250. If the input value is 0 the motors are stationary, if the input is positive the motors are driven forwards, if the input signal is negative the motors should be driven in reverse.

 

My problem is that if the input signal is negative the motors oscillate and do not reverse. The motors work correctly going forward and stop correctly. The inputs to the case structure are correct and when using a negative input in an attempt to reverse the motors the signal is always negative, I cannot see the signal becoming positive at any point using the probe feature. The same behaviour occurs on all three motors. the oscillation is approximately equal to the number of steps, but i can't be sure on this and it might just be a coincidence, also the input signal has a small amount of noise in it, i.e if the potentiometer is left stationary the input value will range from say 100 to 103, values changing 2-3 times per second (seen using a indicator).

 

If i remove the signal input and replace it with a control value the motor turns correctly in reverse, i.e remove the line connecting Base Input to the stepper driver icon and replace it with a control inside the case structure. This suggests to me that it is not a hardware problem. The true/false values used to drive the case structure are working correctly.

 

I have attached a copy of the code and images of the motor driver feature.

 

Has anyone had similar problems or does anyone have any suggestions.

 

 

Labview version: 2012

Arduino type: Mega

 

Download All
0 Kudos
Message 1 of 12
(6,867 Views)

Why don't you use an H bridge/driver with your digital outputs controlling the direction, then you don't have to output a neg PWM signal? and have you checked  the arduino if you can ouput a neg signal with an Oscope?

0 Kudos
Message 2 of 12
(6,849 Views)

apok,

 

Thanks for your suggestion.

 

I an not an expert on labview or with control systems, and so am trying to keep it simple. Currently I have code and hardware that nearly works and I'd rather try and resolve my current issues and not have to learn how a H-bridge works and how to implement it. Obviously, if there is some reason why my current implementation is inappropriate and will not work then I will consider other options, but I would like to understand why the current implementation does not work.

 

My testing shows that the motor will turn in reverse if supplied a negative input value (from control) its just that it oscillates when supplied on from a variable. This leads me to think that my hardware is OK, but I have an error in the labview code. Please let me know if you think that this is an incorrect assumption.

 

 

0 Kudos
Message 3 of 12
(6,816 Views)

how are you connecting to the motor from the arduino, what circuit is in between? and again.....have you measured the output arduino signal for your neg PWM? i suspect you can't...and that will be your problem (unless you go through some external voltage inverter op amp). that is why i suggested using the H bridge, much easier to implement

0 Kudos
Message 4 of 12
(6,806 Views)

@Carlr wrote:

apok,

 

Thanks for your suggestion.

 

I an not an expert on labview or with control systems, and so am trying to keep it simple. Currently I have code and hardware that nearly works and I'd rather try and resolve my current issues and not have to learn how a H-bridge works and how to implement it. Obviously, if there is some reason why my current implementation is inappropriate and will not work then I will consider other options, but I would like to understand why the current implementation does not work.

 

My testing shows that the motor will turn in reverse if supplied a negative input value (from control) its just that it oscillates when supplied on from a variable. This leads me to think that my hardware is OK, but I have an error in the labview code. Please let me know if you think that this is an incorrect assumption.

 

 



H-bridge driver is a hardware item, not LabVIEW - other poster is talking about your physical connection and related circuitry.  You don't need to do that, your hardware is fine.  Your problem is the logic you have implemented (including the portion to the LEFT of the section of code you've shown in your image. You simply need to update it so that negative values can be passed in the wire.  See attached image, items circled in RED will prevent any negative values and replace them with a zero.  You just need to adjust that logic and what you have just outside of it.

 

-DP

(And by the way, you have changed the logic from what I had suggested earlier - by doing that you are now constantly writing to the stepper motors except for when it has to write a Zero.  instead of only writing when you change input value.  Much better/easier way of doing that is in the second image. I don't have all your subVI so one of the block is missing - shown with a "?" as its icon.)

 

Untitled.png

 

 

Here's how you could improve your code logic (on FALSE side you'd simply pass the wire values):

 

Untitled.png

 

 

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 5 of 12
(6,787 Views)

@BTC_Admin wrote:


H-bridge driver is a hardware item, not LabVIEW - other poster is talking about your physical connection and related circuitry.  You don't need to do that, your hardware is fine...

how do you know his hardware connection is fine? do you know what it is? are you going on a hunch? we need Jeff's 8 ball here....(just kiddn jeff)

 

how do you know he is not connected to lemon or bananna interface? sheeeesh!

 

and he still did not answer if he has a neg PWM signal...remember: software/hardware is half the battle my friend (are you a computer science major?)

0 Kudos
Message 6 of 12
(6,774 Views)

@apok wrote:

@BTC_Admin wrote:


H-bridge driver is a hardware item, not LabVIEW - other poster is talking about your physical connection and related circuitry.  You don't need to do that, your hardware is fine...

how do you know his hardware connection is fine? do you know what it is? are you going on a hunch? we need Jeff's 8 ball here....(just kiddn jeff)

 

how do you know he is not connected to lemon or bananna interface? sheeeesh!

 

and he still did not answer if he has a neg PWM signal...remember: software/hardware is half the battle my friend (are you a computer science major?)


 

Did you bother reading his entire post?

 

1. He mentioned that his "input signal" is an integer in the range -250 to +250... Hence simply an I16 number, he is NOT speaking of any hardware input signal.

2. He mentions "If i remove the signal input and replace it with a control value the motor turns correctly in reverse, i.e remove the line connecting Base Input to the stepper driver icon and replace it with a control inside the case structure. This suggests to me that it is not a hardware problem. The true/false values used to drive the case structure are working correctly." - This implies that his hardware works.

 

And

 

3.  Even in his second post he repeated to you that "the motor will turn in reverse if supplied a negative input value (from control)" which you again ignored!

 

So you see - not only that one of my degrees is in Electrical Engineering with over 24 years of industry experience in this line, I'm even able to comprehend simple sentences! Someone with a lower number of total posts than you doesn't necessarily translate into them knowing less than you, there is no need to start posting intimidating messages... even if you had 50,000+ posts.

 

-DP

(However, I was incorrect in my explanation on items circled in red on my first image - I meant to say that it will allow only negative values to go through and replace any positive number with a 0 - this is most likely why the motor doesn't reverse when wire values are fed.)

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 7 of 12
(6,760 Views)

@BTC_Admin wrote:

Did you bother reading his entire post?

 

...Someone with a lower number of total posts than you doesn't necessarily translate into them knowing less than you, there is no need to start posting intimidating messages... even if you had 50,000+ posts.

 


  • "Someone with a lower number of total posts than you doesn't necessarily translate into them knowing less than you,"...never meant to imply any such thought, regardless of the number of postings...please except my apologies to you and any members I have offended by my rash attitude and intimidating posts. I take responsibility with no excuses on my part....
0 Kudos
Message 8 of 12
(6,745 Views)

No worries, its all good!  (and thank you!)

 

-DP

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 9 of 12
(6,726 Views)

Hi,

 

Thanks for the above replies, however i'm still stuck.
I have drasticaly simplified my controller to make it easier to understand and eliminate any other potential errors.

 

To be clear on my problem, using the attached simple case the stepper motor speed should be driven by the signal read by the arduino from the potentiometer.
If it is positive the motor should rotate forward, if it is negative the motor should rotate backwards, if it is 0 the False case is activated and the motor stops.

 

The Input signal reads integer values of -250 to 250. The case structure has been tested and it working correctly. 

 

If i run the VI as shown in Simple-True.jpg the motor is driven by the potentiometer signal and rotates in the forward direction correctly, the speed varying with input value. However, if supplied with a negative value to motor oscilates.

 


If the motor is driven by the controller "Stepper Speed Input" then the motor moves correctly in both forward and reverse, with the speed coresponding to the controler value. The values used were in the same range as those previously supplied by the "Input Signal".

 

I beleive that my hardware is correct as the motor works correctly when driven by the controller. What i can't understand is what is the difference between driving it by the controler and driving it by the input signal, further more why will it work in positive direction, but not the negative when driven by the input signal? Could this be a software bug? it seems to be behaving illogicaly.

 

I'm using Labview 2012, i have attached the code for this simplified case.

 

 

 

0 Kudos
Message 10 of 12
(6,716 Views)