Shop OBEX P1 Docs P2 Docs Learn Events
Testing a stepper but no torque — Parallax Forums

Testing a stepper but no torque

T ChapT Chap Posts: 4,217
edited 2006-06-13 06:40 in BASIC Stamp
I just hooked up a BS2P40 to a LIN engineering 4218L Nema 17 stepper to learn how to run motors directly off a processor. I found the schematic below somewhere and it works in a functional sense, surely not enough current though. The motor is spinning around smoothly using the code shown, but it has absolutely no torque, and this is supposedly their "high torque" 17 version.

With the code shown below, I can't start it up sith less that PAUSE 3, but once it is running at 3, it will accerate using PAUSE 2, but pause 1 will not run, just vibrates. There must be something I am overlooking. Maybe the small transistors are't enough to give it enough torgue, but that shouldn't stop if from spinning faster? Maybe not the best logic.

Maybe somebody will see something I am missing. Lets assume that it is the small transistors, that is easily solved. But, what about the slow RPM due to the slow speed of the stamp? I am having a hard time thinking of a way to send this code sequence and faster.

[noparse][[/noparse]code]


COIL1A VAR OUT0 'red coil1
COIL1B VAR OUT1 'blue coil 1

COIL2A VAR OUT2 'green coil 2
COIL2B VAR OUT3 'black coil 2

MAIN:
'RAMPS UP FROM HERE
COIL1A = 1
PAUSE 3
COIL1A = 0
COIL2A = 1
PAUSE 3
COIL2A = 0
COIL1B = 1
PAUSE 3
COIL1B = 0
COIL2B = 1
PAUSE 3
COIL2B = 0

LOOP2:
COIL1A = 1
PAUSE 2
COIL1A = 0
COIL2A = 1
PAUSE 2
COIL2A = 0
COIL1B = 1
PAUSE 2
COIL1B = 0
COIL2B = 1
PAUSE 2
COIL2B = 0
GOTO LOOP2
617 x 506 - 76K

Comments

  • T ChapT Chap Posts: 4,217
    edited 2006-06-09 01:50
    There was a mistake in that schematic, here is the correct version. Note that when COIL1A input is HIGH, the transistor turns on to supply the 12v to and simultaneously turns on transistor 1 of the ULN2003, taking the the opposite side of the COIL1 to GND.

    The motor coil sequence actually running is:

    COIL1A 1
    COIL1A 0
    COIL2A 1
    COIL2A 0
    COIL1B 1
    COIL1B 0
    COIL2B 1
    COIL2B 0

    1 is energized, 0 is off
    602 x 461 - 75K
  • T ChapT Chap Posts: 4,217
    edited 2006-06-09 02:00
    I left out the second part of the question which is, how do people usually write acceration and deceleration code? I am looking for a way to tell the motor to go to a position, but I want it to ramp up and decel to the position. I will get an encoder soon to experiment with getting pusles back into the Stamp, and will then figure out the best way to have the motor keep track of where it is relative to home. I assume that would involve the Stamp continuously counting pulses when it is told to move in either direction, and a variable that is always being added to and subtracted from?

    I would want the motor to at any point be able to calculate where it is, apply an acceration curve, ramp up to speed, decel to the position. I may be asking to much for the Stamp to do already. I probably will have to get an SX experiment board for this.
  • bennettdanbennettdan Posts: 614
    edited 2006-06-09 02:22
    Why use a encoder with a stepper motor you sould be able to know how far you went by how many pulses the stepper motor recieves. Looks like you have the 8 wire motor why not try 4 N-channel mosfets to pulse the negative lead of each coil directly from your stamp instead of the small transistors and the chip you have. I have a small motor working that way. I used the IR510 mosfets from radioshack just because I didnt want to order just mosfets for my project. I could give you my schematic if you need it. Also how have you got the pins connected to the curcuit you provided?
  • LarryLarry Posts: 212
    edited 2006-06-09 02:31
    Some things to think about.

    Make sure you know the difference between Bipolar and unipolar steppers and have code that matches the stepper you are using. If you have a unipolar stepper, just run +12v to the common wires, and switch the coils to ground with your Darlingtons. An NPN transistorworks better as a sink rather than a source for the load. Google "Jones on Stepping Motors" to see your options.

    torque and speed work against each other with steppers. If you try to go fast(especially from a dead stop), you will get less torque. If you try to go TOO fast, you will skip steps. Try adjusting your pause statements to a bit more time between moves.I If you want higher top speed, you need to "ramp up" the speed over timewith code that gradually decreases the time between steps. The reverse for deceleration.

    You code appears to only excite one coil at a time. Try coil sequences that excite more than one. , Jones will also show sequencing options, or look at some code here:
    http://www.me.umn.edu/courses/me2011/robot/technotes/stepper/

    There are sequences that excite two coils, and sequences that alternate between one and two coils (half step).



    You'll Know if your UNL2003 is too small if it gets real hot (or worse, the magic blue smoke gets out).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • T ChapT Chap Posts: 4,217
    edited 2006-06-09 03:59
    Well the ULN2003 is running cool, the trannys are hot. It is a bipolar stepper, 4 wires. I am familiar with the Jones notes, but still haven't gotten any closer to making this thing have some power. I have tried a lot of combos of code, trying two coils at one, then one, then two. The tech at Lin wan't any help really, no notes on sequences available, at least with the person I spoke with, nice products but not so informative with the techs.

    At least it turns smoothly, so I can experment with some code. I am trying to get a system sorted out to send out X number of pulses at Y spacing, and find out how to modify the spacing between pulses with a variable.
  • bennettdanbennettdan Posts: 614
    edited 2006-06-09 04:13
    If you are using the bipolar a H-bridge on each winding might help you out unless you only want it to run in one direction.
  • LarryLarry Posts: 212
    edited 2006-06-09 04:36
    The ULN 2003 isn't the right chip to run a Bipolar stepper. Each coil requires an H-bridge to run it properly, and you can't configure the Darlingtons in that chip to make 2 proper h-bridges.
    bipolar junction Transistors need to be used in PNP--NPN pairs to worked properly in an H-bridge


    A better choice to drive your stepper would be a 293 B/D ,298, or 754410 IC, or a 297-298 pair.

    I refer you back to Jones:
    http://www.cs.uiowa.edu/~jones/step/circuits.html

    especially the section on "Practical Bipolar Drive Circuits"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Larry) : 6/9/2006 4:40:18 AM GMT
  • bennettdanbennettdan Posts: 614
    edited 2006-06-09 07:22
    Hey try this it will only get you one direction but should give you plenty of torque also you can get the parts from radioshack. Be sure to heatsink the mosfets. To reverse the stepper you will need a H-Bridge on each coil to make that happen.

    Try this code also

    Run:
    High 1
    Low 0
    Pause 4
    High 0
    Low 1
    Pause 4
    Goto Run

    Post Edited (bennettdan) : 6/9/2006 7:30:02 AM GMT
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-06-09 08:37
    What is the Voltage rating on the motor?

    Most steppers can be run at 150 - 200% of that rating, praticularly at high speeds.

    How many steps/rotation is the motor described as?
    (48 is common, but it may be more)
    Steppers aren't usually known as speed demons, and pushing it much beyond 200 - 300 RPM may be difficult.

    If you find that PAUSE 2 works, but PAUSE 1 doesn't, it may mean you've passed the speed it can work at reliably(may change with a higher voltage) then you may want to try a 'microadjustment' of the ime. Maybe adding a FOR NEXT loop that just increments a counter to waste a bit of time in addition to the PAUSE 1 instruction?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • T ChapT Chap Posts: 4,217
    edited 2006-06-09 08:46
    Thanks for the info guys. I finally got a sequence from the web that runs with a slight bit of power over what I had. My circuit isn't a great one but it works for testing with a minimum of parts that I could find in town.

    This code working pretty good just to get motion, I think with a real driver it will have some good power.

    The Nib mentioned in the code below is as follows:

    A = COIL 1 A
    B = COIL 1 B
    C = COIL 2 A
    D = COIL 2 B




    MOTOR VAR OUTA

    Main:

    motor = %0101
    PAUSE 3
    motor = %0110
    PAUSE 3
    motor = %1010
    PAUSE 3
    motor = %1001
    PAUSE 3
    GOTO main


    Now that I can make it move in several modes, I want learn what is the best chip do this with, even at the lowest pause speed the Stamp is too slow unless there is a better way to send the pulses than what I described above. I will likely try it with an SX.

    Is there a way to set a variable for the pause time so that it can be set logrithmically with a formula? Too bad the pause time can't be smaller than 1, that would help too.
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-06-09 09:18
    The BS2P series does about 12.000 instructions/second, right?

    That means about 12instructions for every mS(PAUSE uses mS timing), so wasting a bit of time to equal the time you want shouldn't be that difficult.
    (Not all instructions executes at the same rate, so some experimentation is needed)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • bennettdanbennettdan Posts: 614
    edited 2006-06-09 22:07
    In a bipolar stepper they usually use a H-bridge to control each coil because to reverse the motor you change the polarity to the coils. The curcuit I gave you should pulse the coils 2 times faster than the curcuit you have. Also if you want to speed yours up set the transistors going to positive on all the time and pulse only the low side transistors and to reverse the motor turn on the low side all the time and pulse the high side.
  • WigginsWiggins Posts: 2
    edited 2006-06-12 19:20
    I have found that if you use the PULSOUT command on an unused pin, it works very well for short pauses.
  • T ChapT Chap Posts: 4,217
    edited 2006-06-12 19:40
    Here is the Hbridge I just breadboarded. The torque was incredible until the 12v wall supply smoked. I used a chip for the controll called EDE1204 which is pretty cool, I think it is a PIC of some sort that is packaged as a controller with some neat features.

    I'll try the Pulsout and see what that does, it would be great ot be able to find a way to exceed 1 millisecond options. Maybe the SX will allow decimal points for pause times.
    1000 x 644 - 149K
    597 x 385 - 63K
  • bennettdanbennettdan Posts: 614
    edited 2006-06-12 21:32
    Good that you found that the H-bridge curcuit. What are you using for your clock curcuit?(CLK1 and CLK2)?
  • T ChapT Chap Posts: 4,217
    edited 2006-06-12 22:37
    I am using a 4 megahertz resonator, simply take the center lead to GND, and both of the other leads to the clk input. I am now changing out the circuit to use an IR2184 mosfet driver per a pro's suggestion, seems I have some "shoot though" causing a lot of heat and damage. Also changing out to a power mosfet instead of the NPN. I'll update in a few days when the parts get in. The early tests before the damaged parts was very promising.
  • bennettdanbennettdan Posts: 614
    edited 2006-06-13 02:10
    originator99 do you mind posting your code for your last run? Do you let the stamp pulse now or is it handled in the pic chip you have ? Also are you not using a PNP for the high side of the coil? That I would think would be where you are pulling the extra current.
  • T ChapT Chap Posts: 4,217
    edited 2006-06-13 04:33
    The circuit I am building now will use the Stamp sending out the Step pulses plus Direction pulse, plus Half/Whole command as needed. So the new code will be something like Direction = 1 HalfStep = 1 then followed by teh number of pulses to get to the desired position. I will be including various labels that will ramo up and ramo down the pause times with a variable. There may be some slight chance I can find a way to use Pulse out with a method to send specific pulse numbers out with specific psuedo "pause" times as well for ramping. As it is you are limitied to 1 ms of pausetime between pulses, so if you are trying to half step, or micro step you wont get any rpm's with a Stamp using 1ms pauses. Somebod may know atrick for Pulseout, or maybe a circuit that can divide the pulses outof the stamp by some value to get x pulses per 1 Stamp pulse out, then micro stepping can be handled.

    I'll post what I come up with in a few days along with the new circuit a CNC motor guru is helping me with that will be pretty slick. It will use the EDE 1204, the IR2184 mosfet driver and 8 power 12amp power mosfets. These other guys are saying not to bother with NPN/PNP trannys for a number of reasons.
  • bennettdanbennettdan Posts: 614
    edited 2006-06-13 06:40
    Cool let me know how it is going.
Sign In or Register to comment.