Skip to main content

Odd Motor Behavior with OpenMoco? HELP!!!

bdodds's picture
Posted in

Hello! I'm new here and new to all of this stuff.

I have been building my own TimeLapse dolly with the OpenMoco Engine on an Arduino and seam to have run into a problem.

I have an Arduino Duemilanove, 2 EasyDriver 4.3, a SparkFun NEMA 17 stepper motor and an Anaheim Automation 17YPG 14x1 planetary gear box stepper motor.

I hooked it all up and loaded very basic Arduino code to run the motors as a test and every thing seams to run fine and it's easy to see the SparkFun motor doesn't have nearly the torque of the 17YPG.

The problem I'm having comes when I use the OpenMoco Engine and Slim to control the motors, they move, but have almost NO torque at all. I can stop the motor rotation with my finger tips with almost no effort... With the basic code test I could stop the SparkFun motor with some effort, but the 17YPG had so much torque it would not stop at all with my fingers.

Being so new at all this stuff I can't quite figure out why this would be... Please Help!

One other odd thing I noticed when playing with the home command in Slim. The motors will ramp up to go home, but stall (no movement) and they just buzz...

What am I doing wrong? Is there a setting in the code someplace I need to change?
(sorry if this is in the wrong forum...)

You would need to hardwire

You would need to hardwire them, as the only pins OM controls are STP, DIR, and ENABLE. I would try hardwiring it (by 'hardwiring' I mean using jumpers, or wires in a bread-board, don't solder them together =) to full step and try that.

As for the information, I agree, it is hard to get it all in one place, in the right place, where you can find it when you need it. I could put it all in one document, but then it'd get missed. Maybe a cheat-sheet is in order. Unfortunately, I tend to not have nearly as much time as I'd like for documentation, but slowly over time these kinds of forum posts help to clear up what information is most useful.

But yes, definitely, when it comes to steppers and chopping drivers (like the easydriver) you _want_ to run at higher voltages than the badge rating as it results in higher torque when you move at higher velocities. A lot of times you can also decrease the current draw of the motor as well when increasing the voltage.

Just make sure you give the 24V _only_ to the driver! Don't supply 24V to Vin on the arduino =) You only need to connect the GND from the ED to arduino, so you can effectively send signals to it. It can use a separate motor voltage supply.

!c

Well I hooked up my

bdodds's picture

Well I hooked up my EasyDriver (not the Arduino) to a 24 volts and it made no difference in the odd behavior at all as far as I can tell when running the OpenMoco Engine. :'(
It did however heat up both the EasyDriver and motor to the point where I could not touch anything without getting burnt. OUCH!

I also ran tests with my simple step code at a of "Delay(1)" and couldn't tell if there was any difference between 12 volts or 24 volts with that ether...

As far as I can tell, my EasyDriver is working, but I guess I will solder up the other one and try it next... Once the motor cools down.

Update: Per a conversation

bdodds's picture

Update: Per a conversation with Brian Schmalz about the EasyDriver, I wanted to test Step pulse speeds with a scope hookup as verification that the pulse was the expected speed.

using this code:

int STEP = 4;         // Set Step pin #
int DIR = 8;           // Set Direction pin #
int MS1 = 10;        // Set MicroStep1 pin #
int MS2 = 11;        // Set MicroStep2 pin #        

void setup()
{
  pinMode(DIR, OUTPUT);
  pinMode(STEP, OUTPUT);
  pinMode(MS1, OUTPUT);    
  pinMode(MS2, OUTPUT);
}
void loop()
{
  digitalWrite(MS1, LOW);
  digitalWrite(MS2, LOW);
  digitalWrite(DIR, LOW);

  digitalWrite(STEP, LOW);
  delay(10);               // added this delay so I could see a clear square pulse on the scope.
  digitalWrite(STEP, HIGH);
  delay(10);  
}

I tested with these delay settings: (The Arduino delay function is documented to be in Milliseconds if I'm not mistaken)

with a delay(10) the pulse jumped between 10 and 11ms on the scope. noisy pulse, hmmm.
with a delay(1) the pulse read around 2ms and was also kind of jumpy? Not good, but the motor run at both delay settings and only got a bit more noisy at the 1mS setting, but I didn't like the odd time reading and jumpiness so I decided to try the delayMicroseconds() function at 10000 and 1000 to see what would happen. Since delayMicroseconds(10000) should be the same as delay(10) I tested that first and the scope read a nice smooth 10ms pulse... Interesting... Next, I tested at delayMicroseconds(1000) and again I got what I expected to see on the scope a clean smooth 1ms pulse. In both cases though when using delayMicroseconds() the motor continued to run as before.

Could it be the Arduino delay() function is bugged?

Next I wanted to see how fast I could make the motor go by setting the delayMicroseconds() lower and lower.

at delayMicroseconds(600) the motor started to get very noisy, but did not stall and adjusting the current limit on the EasyDriver did nothing to silence it. Up to this point I had been testing with 12 volts, but since I had dug up my 0-30V 3A variable bench power supply to use instead of the 12v 1A wall wart PS I had been doing tests with before, I decided it was time to try booting the voltage. I got it up to 16 volts where the motor started to run quiet again and I noted the current in use displayed on my bench PS dropped from .14A to .09A.

Next at 500us the motor got very noisy again. I tried setting the current pot on the EasyDriver again with not much effect, so I left it centered and boosted the voltage up again. This time I got up to 24v and made the motor quiet again. The current in use display changed from .09A to .11A.

At 400uS it was noisy again and going from 24v to 30v didn't help much at all, but I stopped there since I didn't want to blow up the EasyDriver...

At 300uS the motor just stalled and buzzed like it does when running the OpenMoco Engine at full speed with the Home command or the motor 0 1 10000 command.

I also noted that if I took out the "delayMicroseconds(500)" that was in between the first digitalWrite(STEP, LOW); and second digitalWrite(STEP, HIGH); or even change it to be less than 500uS the motor got noisy and or stalled.

How fast does the OpenMoco Engine STEP pulse go when at full speed?
Can I change this max speed someplace?

I have also noted that when running simple code at 24 volts and 500uS for the last half hour the motor is still cool, unlike my earlier tests when it was so hot...

Now to solder up the other EasyDriver. (I know I keep saying that! :p )

Ok, so here's my take on a

Ok, so here's my take on a few points:

Yes, delay() is not as accurate as delayMicroseconds() see: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1271719397

Yes, you can change the max speed using the stepper min_stp and stepper max_stp commands like we talked about previously. They set the minimum delay between steps (in uS) and the max delay between steps (in uS). We have two so that we can control velocity to some degree (the max # of divisions between the min and max delays...)

The timing in the OM engine is not all that different than the timing in your code, see the code from http://openmoco.svn.sourceforge.net/viewvc/openmoco/OpenMocoComponents/TimeLapseEngine/branches/release-0.82/OpenMoco_Timelapse_Engine/OM_Motor_Control.pde?revision=117

for( int i = 0; i < steps ; i++ ) {

    digitalWrite(motor_pin, HIGH);
   
    if( i < shelf_lo ) {
     
        // we're ramping up to speed
      delay = ( delay_increment * ( shelf_lo - i ) ) + motor_min_step;
    }
    else if( i > shelf_hi ) {
        // we're ramping down from speed      
      delay = ( delay_increment * ( i - shelf_hi ) ) + motor_min_step;
    }
    else {
        // wer're moving at maximum speed
      delay = motor_min_step;
    }

    digitalWrite(motor_pin, LOW);
    delayMicroseconds(delay);
   
  } // end for loop

We note that the min HIGH pulse time for the A3967 is 1nS, the if/else chain and the entry into the digitalWrite(..., LOW) are guaranteed to take longer than that. So we note that high pulse will always be above the minimum, and then the uS delay happens after the pulse drops low.

The 'high' pulse time is arbitrarily timed as shown above, as we just need to ensure we exceed 1nS high pulse time. The time between bringing the pin low, and bringing it high again is determined by the current position in the step cycle compared to min_stp and max_stp. If you look at the code in the file linked above, you'll note that velocity ramping is achieved in a fairly simple manner by dividing up the movements request into three parts: accelerate, max speed, and decelerate. During the accelerate phase, the delay between steps moves from max_stp delay to min_stp delay, in a minimum of 1uS increments (max may be larger). It is possible that the max speed phase never occurs for short movements, and a partial accelerate is followed by a partial decelerate.

Now, obviously, there's nothing clean about the above code - the high time will vary based on where it is in the motion cycle, and the relationship between high and low is not enforced to be represented in any sane pattern (a low of 1uS could happen and possible be longer than the high pulse, should one set the min_stp delay to 1uS...) and the delays can be unknown. That being said, at the levels we're pushing motors at (the very low end of their performance), that shouldn't be a real problem.

With the above code, I've been using the 15Y001S-LW4 motors from Anaheim automation with my pan and tilt unit using 120:1 worm gearing, and they work great at speeds up to about 225uS delay with a load of several lbs using both ED 3's and 4's. Below this, things get sketchy until about 120-140uS which results in nothing but a high whine from the motor. In reality, with the additional bulk of the code, it's closer to 200-230uS range of actual delay down there.

I'm wondering if you don't have something crossed up when running the OM setup? Are MS1 and MS2 tied to ground or are they left floating or even worse - attached to pins for other functions? (I.e. do you re-wire the board/modify the OM engine firmware, or do you leave MS1 and MS2 attached to 10 and 11 with the default firmware? This would be a very bad idea, to say the least with an un-modified TL Engine sketch =)

!c

When I use a min_stp of 900

bdodds's picture

When I use a min_stp of 900 and 24volts, my 17YPG101S will move at that full speed, anything less than 900 and it stalls.
What are the Default values for stepper min_stp and stepper max_stp?
Is there a specific range between the MIN and MAX that I need to make sure is maintained when changing them?

I see here that your 15Y001S motors are rated 2.64V .4A. What voltage do you use and did you get the worm gearing from Anehime Automation as well?

It still seams odd that I can't get my motors to run even close to 250uS like your 15Y001S motors can.
Even the Dan Thompson EasyDriver 4.2 tutorial is setup to run the fastest at 200uS with a 12v SparkFun Motor like mine…

When running the OM engine, I tie MS1 and MS2 to ground to get full steps. Do you run your setup as full steps or do you use the default 1/8 steps? (or is that only the EasyDriver v4.2 that defaults to 1/8 steps?)

I see that pins 10-11 in the TL Engine sketch are motor direction pins for motor 2 and 3, so if I did accidentally leave them hooked up, it would not be that bad would it? Couldn't I even maybe use set the motor direction for 2 and 3 to make the pins go high or low? :p

By the way I got my 2nd EasyDriver setup up and running and it works just like the first one, so it's not whats been limiting me. I guess maybe I should return this motor and order one of the ones that takes 10 to 14 weeks to get with a lower voltage ratting and maybe even a higher gear ratio (mine is only 14 to 1)… 10 to 14 weeks is a LONG TIME to wait!!!

Got a new motor today from

bdodds's picture

Got a new motor today from Anehime Automation rated at 4.7 volts instead of the 12volt one.

Still no torque when used in OME at 12 volts, have to use 24 volts.
Still stalls when doing manual moves or sending home in OME unless I set min_stp to 900.

Time to walk away, and go for a walk I think...

Have you tried 1/8

Have you tried 1/8 microstepping? That's what I normally use. It shouldn't make _that_ much of a difference, especially as microstepping tends to reduce torque, but maybe it'll help will the acceleration and improve that part of the experience.

The odd thing is, I _know_ we have at least one person using the base configuration with the easydriver and the sparkfun stepper, without any issues at all.

!c

What are the Default values

bdodds's picture

What are the Default values for stepper min_stp and stepper max_stp? Is there a specific range between the MIN and MAX that I need to make sure is maintained when i change them?

This is very puzzling.

Is there anyway I can get verification of the motor part number used in the Dolly Prototype that seamed to work so well, as well as what voltage it was run at and the OME settings used?

Are you in the Los Angeles area? It would be handy to show my setup to someone in person so they can see what is happening first hand. or maybe I could email you photos or videos...

You probably missed it from

You probably missed it from the first comment, but the defaults are 400 and 1500. It doesn't matter their relationship, as long as the difference between the two is an even number. (Just to avoid loss due to rounding errors.) I generally prefer MAX to be at least 3x MIN.

For the Dolly: 17YPG302S. 12V, easydriver v4.2, default OMTLE settings.

I'm not in LA, but I will be joining xRez for their OpenMoco talk at Siggraph week after next. If you bring the motor and driver to the xRez kiosk, I could help you figure out what is going on. I'll be there at their booth with hardware and such. Otherwise, I'll have full electrical kit with me if we need to meet after-hours.*

* NOTE: I do not normally travel or do in-person support, LOL. But, I'm glad to help anyone who's near-by =)

!c

Is that xRez the thing

bdodds's picture

Is that xRez the thing happening on Monday July 26th? If so, I can't make it that day. I work longs days on Mondays and Tuesdays on a sitcom... :( Will you be there any other days? I think i will be there on Wednesday shooting show coverage with Alex Lindsay.

Just ordered a 17YPG302S-LW4-R19, should get it some time in october!

Today playing around with EasyDriver microstepping settings I discovered that my 17YPG101S runs smooth at 12v and even has some torque with the OMTLE default settings when running the EasyDriver at 1/8 steps (default for 4.2 board), but not when set to 1/4, 1/2 or Full steps... Not as much torque as when run on the basic code, but maybe usable torque.

I was also playing with my scope hooked to the STEP pin and noticed that changing the min_step and max_step settings doesn't seam to make any difference in the total HIGH time of the pulse sent by OMTLE to the EasyDriver always seams to only last 5 microseconds and drops off very ragged (not a clean square wave). Perhaps this is a clue?