Driving a stepper motor with a Picaxe 08M2

I'm trying to drive a stepper motor available on Ebay http://www.ebay.com/itm/2pcs-DC-5V-Stepper-Motor-ULN2003-Driver-Test-Module-Board-28BYJ-48-for-Arduino-/221347325924?pt=LH_DefaultDomain_0&hash=item33895427e4
It is not clear whether it is Unipolar or Bipolar but with the motor they include a circuit board as shown below. I wonder if I could drive it with a Picaxe 08M2. Any input, suggestion will be appreciated.
STEPPER.jpg
The complete circuit and code I have in mind are shown below.
ALEX STEPPER.jpg
Code:
#picaxe 08m2
setfreq m4				'Set PIC clock at 4MHz
Symbol Paus = W0
DirsC = %10111
PinsC = 0
Paus=500
Do	
	PinsC=%10010
	Pause Paus
	PinsC=%10001
	Pause Paus
	PinsC=%00101
	Pause Paus
	PinsC=%00110
	Pause Paus
	Loop
 

AllyCat

Senior Member
Hi,

Yes, that motor is well-known on this forum (and generally well-liked). It is unipolar so quite easy to drive, particularly with the included driver board. I haven't used an 08M2 for that application but your code looks plausible.

BUT, do note that it has a built-in (step-down) gearbox (with a fair amount of backlash) so with a "paus" of 500 (ms) it wiill probably rotate at less than one revolution per minute (maybe even nearer an hour).

Cheers, Alan.
 

Hemi345

Senior Member
Did you intentionally wire additional LEDs on the input side of the ULN2003? Why not leave them out and use the LEDs that are included on the little circuit board that comes with the stepper?

Like Alan stated, start with a much smaller pause between steps. Something in the neighborhood of 5-10ms.
 

binary1248

Senior Member
I saw this thread then went to Ebay and bought the same, two for $6. No need for them, I just miss playing with steppers. Maybe I'll build a giant clock face ????
 

binary1248

Senior Member
Here is a quick and dirty, but very simple test program. This stepper is very slow with the 60:1 reduction at 5V. But lots of torque.
Read the imbedded notes for more detailed info .
Although this was with a 40X2
Hope this helps any who are stuck getting this little puppy to run.:)
'
Code:
'Simple Demo stepper mtr unipolor, 1/2 step.
'28byj-48  stepper has internal gear reduction, aprox 60:1
'
' Will use the Lookup/Lookdown methode later
'LOOKUP offset,(data0,data1...dataN),variable
'Offset - is a variable/constant which specifies which data# (0-N) to 
'place in Variable.
'
'4 Nov 2014   Paul
' With delay per step set at 1.28 ms (scoped) it takes about 2 seconds for a complete revolution (1/2 step mode)
' It takes approximatly 510 X 8 half steps for one revolution
'
' Wired to pixaxe 40X2 as follows (thru ULN2003)
'Pin 40(B.7) to Blue wire
'Pin 39(B.6) to Pink wire
'Pin 38(B.5) to Yellow wire
'Pin 37(B.4) to Orange wire
'Clockwise rotation test.
'
#picaxe 40x2
symbol step_dely  = w2  'w2
mainx:
'	

	let dirsa = %11111111
 	let dirsb = %11111111	'switch ports to output
 	let dirsc = %11111111
 	let dirsd = %11111111	'
main:

	let Step_dely = 75 '1000 us delay between steps,
			'***NOTE*** pauseus is not accurate at this short duration
main2:
	for w0=1 to 510   '510 x 8 aprox number of 1/2 steps for 1 revolution
'Clockwise rotation
	pauseus Step_dely let pinsb=%10000000 	
	pauseus Step_dely let pinsb=%11000000  
	pauseus Step_dely let pinsb=%01000000  
	pauseus Step_dely let pinsb=%01100000  	
	pauseus Step_dely let pinsb=%00100000 
	pauseus Step_dely let pinsb=%00110000 
	pauseus Step_dely let pinsb=%00010000 	
	pauseus Step_dely let pinsb=%10010000  
	next 
	'
	pause 1000	'1 sec stop rotation.
goto main2
 
Last edited:
Here is a quick and dirty, but very simple test program. This stepper is very slow with the 60:1 reduction at 5V. But lots of torque.
Read the imbedded notes for more detailed info .
Although this was with a 40X2
Hope this helps any who are stuck getting this little puppy to run.:)
Nice job Binary. Thank you for sharing
 

binary1248

Senior Member
Yes, they are cheap and slow, but in full step mode mine seems very predictable. In full step mode I let it run both directions (1/2 rotation, [180 degrees] every 5 sec) for over 12 hours with no accumulated error that I could see on my setup. Of couse this is with no load as shown in the attached picture .
In 1/2 step mode I could not get repeatable results but that may have been a error in my code because during reversal you must start with the same step pattern as you stopped with.
stepper001.JPG
Here is the code.
Code:
'Motor is 28BYJ-48   5 Volt windings
'stepper is 11.25 degrees per full step
'gear reduction is 63.68395:1
'approx 4076 steps/rev (1/2 step mode)
'
'Use of 'lookup' command for step position
' Nov 11 2014  PEH
'
#picaxe 40x2

symbol singlestep=3
symbol halfstep=8
symbol delay=3
symbol repeats=255    'X4 = step pattern repeats for 1/2 turn (approx)
'
'
symbol stepcount=b0
symbol counter =w4
symbol cycctr =w5
symbol pattern = b2
'
dirsb=%11110000		'port b 7,6,5,4 as outputs
				' PHYSICAL PINS 40,39,38,37
'
do
'single (fullstep) FORWARD


  for counter = 0 to repeats
    for stepcount = 0 to singlestep	'index to step pattern
     lookup stepcount,(%00010000,%00100000,%01000000,%10000000),pattern 'get current step pattern 
      pinsb=pattern
     ' debug
	pause delay
    next stepcount
  next counter
  '
  '
      cycctr=cycctr+1
	sertxd("Cycle count is ",#cycctr,13,10) 
'  debug
  pause 1000
  
  'single (fullstep) REVERSE
  for counter = 0 to repeats
    for stepcount = 0 to singlestep	'index to step pattern
     lookup stepcount,(%00010000,%10000000,%01000000,%00100000),pattern 'get current step pattern 
      pinsb=pattern
    '  debug
	pause delay
    next stepcount
  next counter
  pause 1000
  '
  '
      cycctr=cycctr+1
	sertxd("Cycle count is ",#cycctr,13,10)  'display cycle count on PC
'  debug
 
  
  
 loop
 
Last edited:

erco

Senior Member
If you call 6 RPM livin'... :)

Believe it or not, my video shows the max speed I could somewhat reliably achieve even running this 5V motor at close to 12 volts on full step drive (two coils always on). It still missed steps occasionally, which shows up pretty obviously in that slotted wheel demo. I can believe that slowing down increases their reliability, but they are pretty glacial to start with. I do teaching and education, and this motor isn't going to wow people and make them aspire to get one.
 

binary1248

Senior Member
Yes, it is very slow, but my application would be for analog style large meter display where speed but small light and low cost will be primary factor.
I also only recommend this unit for it's low cost and it's included driver board only for learning about one type of stepper (Unipolor).
 

newplumber

Senior Member
Although this a old thread but I second ERCO's quote
Those steppers are cheap, slow, weak, unreliable, fragile and frustrating. They miss steps even with little or no load. Play with them then move on to a real stepper before you get terminally frustrated.
because I tried everything to make it reliable ....whats funny is they are cheap but with my latest tests ... they seem to jigger (in other words move horribly inconsistent)
I even placed the whole thing (motor) soaked in oil and it still wasn't my friend ...but i did get better results if I slowed the step speed to the same speed as the hour hand on a clock :)
so along with erco ... I will be moving along ... prolly a different wrong path :)
 
Top