Overclockers Australia Forums
OCAU News - Wiki - PC Database - QuickLinks - Job Search - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Specific Hardware Topics > Electronics


Sign up for a free OCAU account and this ad will go away!
Reply
 
Thread Tools
Old 1st November 2009, 12:03 AM   #1
Goth Thread Starter
They're in the kernel!
 
Goth's Avatar
 
Join Date: Jun 2002
Location: Melbourne
Posts: 7,714
Default Stepper motor controller

I've built a stepper motor controller based on an Allegro A3977.

I want a relatively high-precision microstepping controller for CNC work.


Click to view full size!


(The schematic does not show all the ground pins on the chip, but they're all connected)

The DC power rail running the steppers is 24 V.

This is the stepper motor being driven.

According to the A3977 datasheet, the maximum value of current limiting is set by ItripMax = Vref/ 8 Rs.
Rs = 0.5 ohms, and the stepper motor's max coil current is 400 mA.
Therefore, I've set the Vref to 1.5-1.6 V.

If the PFD voltage is between 0.6 and 0.21 Vdd, the chip will operate
in mixed-decay mode. I set it to give 2 V, which is 0.4 Vdd, assuming
that mixed decay mode is OK.

Just for testing purposes, I whipped up a couple of lines of Arduino code, since I needed something to generate the clock signal anyway.

Code:
// Test program for A3977 stepper controller boards

// Pin mapping to physical hardware:
int home = 2;
int dir = 3;
int enable = 4;
int reset = 5;
int step = 6;
int led = 13;

// Square wave frequency (in Hertz), change if you like.
int frequency = 10;

// Half the period, in mS.
int halfPeriod = 1000 / (2 * frequency);

void setup()
{                
    pinMode(home, INPUT); // Output from the chip home, can be ignored.
    pinMode(dir, OUTPUT);
    pinMode(enable, OUTPUT);     
    pinMode(reset, OUTPUT);     
    pinMode(step, OUTPUT);     
    pinMode(led, OUTPUT);

    digitalWrite(dir, HIGH);        // Pick which direction you like.
    digitalWrite(enable, LOW);      // Active low enable. Must be low to make it go. 
                                                    // It's pulled high in hardware so it will not
                                                    // go due to floating noise on the clock if
                                                    // the cable is disconnected.
    digitalWrite(reset, HIGH);     // Active low reset. Keep it high normally.
    digitalWrite(step, LOW);       // Start off with it in some defined state.
    digitalWrite(led, LOW);        // The pin 13 LED is in the same state as
                                                // the stepper clock so we can watch it.
}

void loop()                     
{
    // The pin 13 LED is in the same state as the stepper clock so we can watch it.
    digitalWrite(step, HIGH);
    digitalWrite(led, HIGH);
    delay(halfPeriod);
    digitalWrite(step, LOW);
    digitalWrite(led, LOW);
    delay(halfPeriod);
}
The current being drawn off the 24 V supply is a pretty constant 250 mA or so.

However, the motor is not spinning as expected.

The stepper motor is making a high-pitched whine, and you can feel it "ticking" or "throbbing" internally - like it's trying to turn - but the shaft is not turning.

I might have guessed this was caused by the windings being connected out of phase - but I tried swapping one with no effect.

Does anyone have any ideas as to how to fix this?

Cheers.
__________________
"How is anyone supposed to know that this isn't just a bunch of crap?" - Richard Feynman.

Last edited by Goth; 1st November 2009 at 12:15 AM.
Goth is offline   Reply With Quote
Old 1st November 2009, 12:12 AM   #2
Menthu_Rae
Member
 
Menthu_Rae's Avatar
 
Join Date: Mar 2002
Location: Northern Beaches, Sydney
Posts: 3,826
Default

So you're definitely energising the windings in the right order?

Also keep in mind that there will be a maximum speed you can step the motor at - since the windings need time to energise fully. Likewise there is a de-energising time.

Just make sure you're not stepping the motor too fast - what happens if you slow your rotation speed right down?
__________________
System Specs: Q6600 G0 @ 3.2GHz (8 x 400MHz), TR Ultra 120EX, 4GB G-Skill PI PC2-8500 w/Dominator Fan, Asus P5K Premium, 768MB XFX GeForce 8800 Ultra, Creative SoundBlaster Audigy2 ZS Platinum Pro, 1x 150GB WD Raptor, 2x 750GB/1x 1TB/1x 1.5TB Seagate 7200.11 HDDs, 2x Pioneer DVR-212BKs, 2x Zalman ZMMFC-1 Plus, BenQ FP241W 24" LCD, Logitech Z-680 5.1 Speakers, Lian Li PC-A71B, 8x Scythe SFF21G, 850W Silverstone DA850 PSU. Over 40 Trades.
Menthu_Rae is online now   Reply With Quote
Old 1st November 2009, 12:14 AM   #3
Goth Thread Starter
They're in the kernel!
 
Goth's Avatar
 
Join Date: Jun 2002
Location: Melbourne
Posts: 7,714
Default

Quote:
Originally Posted by Menthu_Rae View Post
So you're definitely energising the windings in the right order?
I tried swapping the phase of one winding relative to the other, and swapping both windings.

All the sequencing stuff is done inside the silicon.

Quote:
Also keep in mind that there will be a maximum speed you can step the motor at - since the windings need time to energise fully. Likewise there is a de-energising time.

Just make sure you're not stepping the motor too fast - what happens if you slow your rotation speed right down?
So, you think a 10 Hz clock is too fast?
__________________
"How is anyone supposed to know that this isn't just a bunch of crap?" - Richard Feynman.
Goth is offline   Reply With Quote
Old 1st November 2009, 1:46 AM   #4
Menthu_Rae
Member
 
Menthu_Rae's Avatar
 
Join Date: Mar 2002
Location: Northern Beaches, Sydney
Posts: 3,826
Default

Yeah your 50ms delay (from 10Hz square wave) seems fine.

Everything I'm looking at here seems fine - though I am not 100% on all the resistor values you've selected that circuit diagram - but the logic of it all seems fine.

One thing I can say is take very careful note of the timings in the datasheet for the A3977. Just go back through and make sure you're setting all the right pins high/low at the right time(s) relative to each other.

Hopefully someone else a bit more experienced can see something that I'm not seeing. I'm interested to know what the problem is - so if you figure it out, make sure you post it up
__________________
System Specs: Q6600 G0 @ 3.2GHz (8 x 400MHz), TR Ultra 120EX, 4GB G-Skill PI PC2-8500 w/Dominator Fan, Asus P5K Premium, 768MB XFX GeForce 8800 Ultra, Creative SoundBlaster Audigy2 ZS Platinum Pro, 1x 150GB WD Raptor, 2x 750GB/1x 1TB/1x 1.5TB Seagate 7200.11 HDDs, 2x Pioneer DVR-212BKs, 2x Zalman ZMMFC-1 Plus, BenQ FP241W 24" LCD, Logitech Z-680 5.1 Speakers, Lian Li PC-A71B, 8x Scythe SFF21G, 850W Silverstone DA850 PSU. Over 40 Trades.
Menthu_Rae is online now   Reply With Quote
Old 1st November 2009, 3:20 PM   #5
dakiller
Member
 
dakiller's Avatar
 
Join Date: Jun 2001
Location: NarreWarren, Melb
Posts: 4,728
Default

I don't have any experience with this IC, but from the symptoms it sounds like it is oscillating, I had this issue with the stepper controller I built.

Sticking a shunt resistor inline with the motor coils and putting a cro on that should show the current waveform that it is outputting, which may lead you in the right direction in solving the problem.

I fixed my oscillating issues by placing an RC circuit in parallel with the motor coils, the large inductance of the motors can cause lots of issues with feedback control systems. I don't really know how to calculate the ideal values, but 100ohm and 1uF were effective for me
__________________
In memory of
Cheers

Z
dakiller is offline   Reply With Quote
Old 1st November 2009, 5:21 PM   #6
mobs
Member
 
Join Date: Jul 2009
Posts: 57
Default

I have used these successfully before, perhaps you can get something from its schematic:

http://www.schmalzhaus.com/EasyDriver/
mobs is offline   Reply With Quote
Old 8th November 2009, 3:13 PM   #7
Pyro
Member
 
Pyro's Avatar
 
Join Date: Jul 2001
Location: Lambton
Posts: 2,383
Default

Tried alternating the frequency? Sounds like it's too low, perhaps.
__________________
I now have a blog.
Pyro is offline   Reply With Quote
Old 8th November 2009, 3:58 PM   #8
Goth Thread Starter
They're in the kernel!
 
Goth's Avatar
 
Join Date: Jun 2002
Location: Melbourne
Posts: 7,714
Default

Quote:
Originally Posted by Pyro View Post
Tried alternating the frequency? Sounds like it's too low, perhaps.
Yeah, got it working now, actually
__________________
"How is anyone supposed to know that this isn't just a bunch of crap?" - Richard Feynman.
Goth is offline   Reply With Quote
Old 8th November 2009, 5:59 PM   #9
Odje
Member
 
Odje's Avatar
 
Join Date: Jun 2001
Location: Sydney
Posts: 1,975
Default

So what was the problem?
__________________
There are only 2 reasons why you should run,
1. If you are being chased or
2. If you are on fire
Odje is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 3:26 PM.


eXTReMe Tracker
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd. - This page served to you by: surf
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!