Shop OBEX P1 Docs P2 Docs Learn Events
Stepper motor problem — Parallax Forums

Stepper motor problem

Kurt FinnieKurt Finnie Posts: 21
edited 2012-04-30 18:07 in Propeller 1
I'm having trouble with stepper motor code that previously worked.

I'm using a Proto board, UNL2003A Darlington array, Mitsubi 12v 100 ohm 5-lead unipolar stepper motor (purchased from Parallax) and 12v 1A linear regulated power supply (wall wort).

The schematic shows the basic full-stepping code.
'test4

'This test uses a program that worked previously with the same unipolar Mitsumi 5-lead
'stepper motor (purchased from Parallax), 12 volt 1A linear regulated power supply,
'ULN2003 darlington array and propeller proto board.

' PPB           Darlington                  Motor           
' P3 ->  ULN2003.1, ULN2003.14 -> Phase 4 (yellow)                    
' P2 ->  ULN2003.2, ULN2003.13 -> Phase 3 (brown)
' P1 ->  ULN2003.3, ULN2003.12 -> Phase 2 (orange)
' P0 ->  ULN2003.4, ULN2003.11 -> Phase 1 (black)
' VSS -> ULN2003.9, ULN2003.10 -> (red) and +12v 
   
CON
  _CLKMODE      = XTAL1 + PLL16X
  _XINFREQ      = 5_000_000
                                                                                
VAR
  long  stpIdx                          'loop counter, step pointer
                                
PUB Main
   dira[0..3]~~                         'make pins outputs
   outa[0..3]~                          'make pins low
        
   repeat                                 'Turns stepper at a fast rate indefinitely
     stepFwd      
     waitcnt(clkfreq/10 + cnt)
      
'   pause(1000)
   
'   repeat 12                            'Turns stepper in reverse direction at a slower rate
'     stepRev      
'     waitcnt(clkfreq/5 + cnt)    
          
PRI stepFwd
   stpIdx := ++stpIdx // 4                 ' point to next step
   outa[0..3] := Steps[stpIdx]           ' update outputs

PRI stepRev
   stpIdx := (stpIdx + 3) // 4             ' point to previous step
   outa[0..3] := Steps[stpIdx]           ' update outputs

PRI pause(ms) | c                        
   c := cnt                                      ' sync with system counter
   repeat until (ms-- == 0)                ' repeat while time left
     waitcnt(c += clkfreq / 1000)        ' wait 1 ms

DAT
  Steps  byte %0011, %0110, %1100, %1001     'Full step



I have proven:
Connectivity at all junctions where I should have it.
+12v and the red stepper motor wire are attached to Common pin 10 on the Darlington array.
The Darlington ground pin is attached to VSS on the proto board.
The P0-P3 pins toggle high, then low, when measured between I/O pin and VSS.
The stepper motor wires are black, orange, brown, and yellow and are attached (in order) to P0.. P3.
The voltage between the amplified side pins and VSS is 0.6v. I believe that proves the pins sinked... allowing flow.

I replaced the proto board with a development board, swapped Darlington arrays, stepper motors, power supplies and used different I/O pins... without success.

What am I missing here?
What should I try?
How do I know the Darlington arrays are/aren't fried... and how would that happen. I understand the Darlington has built-in resistors to protect from over-current.

An observation: If I remove the red stepper motor common wire and measure voltage between +12v and VSS, I get 16.2v. How is that happening.

Full-stepping is just fine for my application and I have plenty of pins to do everything else I need.

Comments

  • Mark_TMark_T Posts: 1,981
    edited 2012-04-29 14:36
    Those pin numbers for the ULN2003A don't make sense, its a 16pin device.

    The 16V means the supply is not a linear regulated 12V supply, probably just raw smoothed or poorly regulated SMPS?

    Have you checked the motor pinout and the voltage of the supply under load?
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 14:46
    If you do not have it already, the 12V ground must be tied to GROUND of the ULN2003, as well as VSS from the Propeller.

    Additionally, is any of the coils energized while running your code?
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2012-04-29 15:06
    Mark_T,

    My Darlingtons have 18 pins (bought from Parallax), so ground is 9 and common is 10.
    The voltage measurement from the power supply output wires is steady at 12.0 volts.

    Idbruce,
    So I connect the Darlington ground (pin 9) to -12v as well as to VSS?
    How do I properly determine if any of the coils are energized? I'd guess not, because I can rotate the shaft and there is no change in torque.


    It never seemed right that -12v was never identified as part of the circuit.
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 15:15
    Kurt
    So I connect the Darlington ground (pin 9) to -12v as well as to VSS?

    Yes.
    How do I properly determine if any of the coils are energized?

    If it does not spin freely.
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2012-04-29 15:23
    OK,

    I'll connect the ground and fire up the code again.

    BTW, where in IN do you live?. Although I live in Knoxville, TN, I cruise through and around your state a dozen times a year.
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 15:53
    I live in Northwest IN, north of Merrville and east of Gary. When I was younger, I traveled through Knoxville several times.
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2012-04-29 16:10
    idbruce,

    The stepper is in motion... but it toggles one step forward and one step back x number of repeats. It's like the index isn't indexing.
    But at least it is in motion now!
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 16:46
    There are a couple possible reasons for this, but most likely the motor is wired incorrectly. However it is possible that you burned up a section of the ULN2003.
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 17:04
    Kurt

    I do not know which manufacturer made your ULN2003, but according to ST Microelectronics, you have that chip wired incorrectly.
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 17:08
    I see you told Mark T that it has 18 pins. Are you sure that is not a ULN2803 instead of a ULN2003???
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 17:14
    If it is a ULN2803 then your wiring should be:


    ' P3 -> ULN2003.1, ULN2003.18 -> Phase 4 (yellow)
    ' P2 -> ULN2003.2, ULN2003.17 -> Phase 3 (brown)
    ' P1 -> ULN2003.3, ULN2003.16 -> Phase 2 (orange)
    ' P0 -> ULN2003.4, ULN2003.15 -> Phase 1 (black)
    ' VSS -> ULN2003.9, ULN2003.10 -> (red) and +12v

    instead of

    ' P3 -> ULN2003.1, ULN2003.14 -> Phase 4 (yellow)
    ' P2 -> ULN2003.2, ULN2003.13 -> Phase 3 (brown)
    ' P1 -> ULN2003.3, ULN2003.12 -> Phase 2 (orange)
    ' P0 -> ULN2003.4, ULN2003.11 -> Phase 1 (black)
    ' VSS -> ULN2003.9, ULN2003.10 -> (red) and +12v
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2012-04-29 17:46
    Dinner and 60 Minutes interrupted my attention but I'm back.

    It's wired right but my documentation is wrong. Under magnification and a lot of light, I determined the chip is a UNL2803A.
    The leads are wired to the lower pins of the Darlington, starting with VSS, P0, P1, P2 and P3.

    ' P3 -> ULN2003.5, ULN2003.14 -> Phase 4 (yellow)
    ' P2 -> ULN2003.6, ULN2003.13 -> Phase 3 (brown)
    ' P1 -> ULN2003.7, ULN2003.12 -> Phase 2 (orange)
    ' P0 -> ULN2003.8, ULN2003.11 -> Phase 1 (black)
    ' VSS and -12v -> ULN2003.9, ULN2003.10 -> (red) and +12v

    I tried changing the order in the Dat section but that didn't do anything.
    I don't see anything wrong with the code for StepFwd, StepRev or StpIdx.
    I suspect this is where having an oscilloscope would be useful, or four led's, to prove
    which circuits are powered up at any given time.
    I'll slow the cycle rate to 5 seconds or so, so that I can check the voltage on each pin before the next cycle. This should prove whether the Darlington array is damaged.
    In the meantime, I'll order more Darlington array chips.
  • idbruceidbruce Posts: 6,197
    edited 2012-04-29 19:16
    Kurt

    This code has not been tested, but I think it should work, providing the Prop and IC chip are okay.
    CON
      _CLKMODE      = XTAL1 + PLL16X
      _XINFREQ      = 5_000_000
      
    VAR
      Long Coil_Index
      Byte Coil_Array[4]
    PUB Main
      Coil_Array[0] := %0011
      Coil_Array[1] := %0110
      Coil_Array[2] := %1100
      Coil_Array[3] := %1001
      DIRA[0..3]~~
      OUTA[0..3]~
      StepForward(48, CLKFREQ / 10_000)
      WAITCNT(CLKFREQ / 10_000 + CNT)
      StepBackward(48, CLKFREQ / 10_000)
    
    PUB StepForward(Steps, StepDelay)
      Coil_Index := 0
      REPEAT Steps
        Coil_Index++
        IF Coil_Index == 4
          Coil_Index := 0      
        OUTA[0..3] := Coil_Array[Coil_Index]
        WAITCNT(StepDelay + CNT)       
    PUB StepBackard(Steps, StepDelay)
      Coil_Index := 0
      REPEAT Steps
        Coil_Index--
        IF Coil_Index < 0
          Coil_Index := 3      
        OUTA[0..3] := Coil_Array[Coil_Index]
        WAITCNT(StepDelay + CNT)
    
    
  • idbruceidbruce Posts: 6,197
    edited 2012-04-30 03:21
    Kurt

    In the code I provided, the incrementor and decrementor really should be moved to the end of the repeat loops in the functions.
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2012-04-30 05:54
    idbruce,

    The code in your post and my initial code have all turned illegible.
    Is there some way to make it legible again?
  • idbruceidbruce Posts: 6,197
    edited 2012-04-30 06:03
    Kurt

    I am assuming you mean uneditable. If so, I had that same problem also, but I do not know how to fix it. I have attached a copy of the code with the incrementor and decrementor placed appropriately.
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2012-04-30 18:07
    idbruce,

    I solved the problem. The darlingtons are fried!
    To prove that, I extended the cycle time to one step in 20 seconds and used an external timer to let me know when the next step occurred. That gave me enough time to get voltage measurements on all four pins and to document it before the next step. The code works just fine. Measuring from the amplified side of the darlington to VSS, I found that the P0 remained high throughout. I substituted the other darlington that I had been using, and found that P2 remained low throughout. I wasn't so disciplined a week or so ago and can understand that I zapped them somehow.

    I've ordered new chips and a few new proto boards and hope to move on shortly.

    I want to thank you for identifying the ground problem. I'm at a loss to understand how I got this stepper, two others and two other linear steppers moving at various speeds and directions without previously having this ground.

    Similarly, I don't understand how the code listing turned to jibberish, but it's now legible again and I see from your code that you are accomplishing the same thing but using a different approach. Thanks for all.

    I've got one other question on my mind but it's off-topic so I'll start another thread.

    Kurt
Sign In or Register to comment.