PICAXE-08M Stepper Motor Driver Circuit

tracecom

Senior Member
Or, what is the program
that will control your circuit?

e
Here is the basic building block that runs the stepper.
Code:
'Drive unipolar stepper motor in single steps
'but with increased torque. PICAXE-08M

symbol delay = 3000		'pause duration (must be at least 1 ms.)
let dirs = %10110	'sets pins 4, 2, and 1 as outputs
				'pin 3 is always an input; pin 0 is always an output

cw:				'clockwise rotation
	let pins = %10001	'windings 2b and 1a
	pause delay
	let pins = %00011	'windings 2a and 1a
	pause delay
	let pins = %00110	'windings 1b and 2a
	pause delay
	let pins = %10100	'windings 2b and 1b
	pause delay
	goto cw		'endless loop
In my final code, there will be starts, stops, reversals, and some pauses, but it will all be based on this sequence.

I see on page 16 the schematic that shows using two outputs to drive the motor, and I understand how it works. It frees up two PICAXE outputs at the cost of four added resistors and some additional wiring. Because I am trying to fit all this on an AXE021, I don't know if I will have the board space. In addition, I don't have plans for the two newly freed PICAXE-08M outputs, but I suppose it's always good to have them available. I'll think it over.

What about the rest of the schematic? Do you see any errors?

Thanks.
 

eclectic

Moderator
I now see the logic
behind the four pin arrangement. :)

I'll leave circuit analysis to the experts,
except for:

please see p.6 of Manual 3.

You can parallel inputs and outputs
to spread the load.

e
 

Jamster

Senior Member
Might want to stick a jumper in between the picaxe serial out and the other IC as when you program it may cause unwanted effects and possibly destroy the other ic.
 

westaust55

Moderator
Separately connencting the four winding could allow half-stepping if desired where only one coil is energised at a time. This does reduce the torque available to turn the stepper motor on the half steps.
 

tracecom

Senior Member
Might want to stick a jumper in between the picaxe serial out and the other IC as when you program it may cause unwanted effects and possibly destroy the other ic.
It shouldn't be a problem on the input to the ULN2803A, but it might partially energize a winding on the motor. I'll add a jumper. Thanks.
 

tracecom

Senior Member
Why do you need four inputs,
when two will suffice?

e
I have it breadboarded and running using four inputs, but it won't be much trouble to try it with two. I have never used the toggle command, so it will be a learning experience. I'll give it a go. Thanks.
 

Jamster

Senior Member
The toggle command is probably the easiest command in the whole manual!!!:eek:
If a pin is high it makes it low and if it is low it makes it high, simples.
 

tracecom

Senior Member
I missspoke; it's not the toggle command that is puzzling. Rather it's the whole concept using toggle as explained on pp. 15-16 of manual 3. Before I tackle the code, does the logic of the attached shematic look like the schematic in the manual? (Due to physical constraints imposed by the AXE021, I can't use the first two Darlington circuits on the ULN2803A.)

Thanks.

ETA: Never mind. It works.
 

Attachments

Last edited:

westaust55

Moderator
Yes what you drew was correct.

As you subsequently found after biting the "bullet" - sometimes you just need to check the circuit twice and then turn on the power.

You might however also like to download the latest version of the PICAXE manual 3 for future referece.

Your page refernces are seemingly from V4.3 whereas since Dec 2010 rev Ed has issued manual 3 at V4.4.
 

tracecom

Senior Member
Your page refernces are seemingly from V4.3 whereas since Dec 2010 rev Ed has issued manual 3 at V4.4.
I have V4.4; in fact, I have all three manuals printed out and in a three ring binder. I don't know why I typed the wrong page numbers. Thanks.
 

tracecom

Senior Member
Assembled Prototype

Here is my finished stepper driver prototype. As you can see, I built it on an AXE021 Proto Board, which turned out to be a lot more difficult than I anticipated. Perhaps I tried to put too much on the PCB. In addition to the PICAXE-08M, it contains a 5v regulator, and an ULN2803A. Because the ULN2803A is an 18 pin IC, and the top and bottom rails on the PCB are power and ground, I had to use a 14 pin socket and let pins 1, 2, 17, and 18 hang over the top. The assembly doesn't look too bad on top, but there are three flywires on the bottom.
 

Attachments

Axel87

Senior Member
Found this post perusing information on how-to for my first stepper motor creation with the picaxe.
I noticed that you removed the diode from your original design to the finished one and replaced it with a capacitor.
Does anyone have any input as to why this was removed? ( I thought it was a good idea, but am learning :) )
Thanks!
 

Paix

Senior Member
@Axel87, not replaced by, two separate issues I suspect.

The diode D1 was not required and constituted a voltage drop of 0.7V across the diode.

The electrolytic capacitor C5 I suggest is a bulk/decoupler, removing noise and acting as a voltage reservoir to prevent the +ve rail sagging in any way when the IC is switching. Similarly C6 is a decoupler for the Picaxe chip. I suggest that this 'standard decoupling' was probably added, not to make the circuit work, but to add a few guarantees and increase immunity to unanticipated noise.

Note: two types of capacitor are commonly used for decoupling, small ceramic 100nF which deal with the high frequency noise and 10uF to 100uF electrolytic capacitors that deal with potential supply voltage excursions due to instantaneous heavy current demand. The method of construction of electrolytic capacitors makes them less than ideal low ESR (Effective Series Resistance) components and the smaller ceramic covers the gap. Between them they effectively remove all the noise that the MCU and driver chips generate internally.

Decoupling is the icing on the cake. it's still a cake without it, but isn't complete and may not work quite as well either.

I hope that has helped your understanding.

Earlier I noticed someone mentioned that he had been a radio amateur in his youth and decoupling wasn't quite the same issue as it appears to be today. This is very true, as in the interlude fast logic switching devices have become the norm and they produce a lot of noise internally. It is not uncommon to decouple every package with a 100nF ceramic capacitor and a bulk decoupler on prime candidates or looking after small groups of packages. Quite a step up from previous analogue usage I suspect.

Zeroeth Commandment (programmers start at 0 and not 1) Thou shall consistently decouple, heavily! :)
 

Axel87

Senior Member
@Axel87, not replaced by, two separate issues I suspect.

The diode D1 was not required and constituted a voltage drop of 0.7V across the diode.

The electrolytic capacitor C5 I suggest is a bulk/decoupler, removing noise and acting as a voltage reservoir to prevent the +ve rail sagging in any way when the IC is switching. Similarly C6 is a decoupler for the Picaxe chip. I suggest that this 'standard decoupling' was probably added, not to make the circuit work, but to add a few guarantees and increase immunity to unanticipated noise.

Note: two types of capacitor are commonly used for decoupling, small ceramic 100nF which deal with the high frequency noise and 10uF to 100uF electrolytic capacitors that deal with potential supply voltage excursions due to instantaneous heavy current demand. The method of construction of electrolytic capacitors makes them less than ideal low ESR (Effective Series Resistance) components and the smaller ceramic covers the gap. Between them they effectively remove all the noise that the MCU and driver chips generate internally.

Decoupling is the icing on the cake. it's still a cake without it, but isn't complete and may not work quite as well either.

I hope that has helped your understanding.

Earlier I noticed someone mentioned that he had been a radio amateur in his youth and decoupling wasn't quite the same issue as it appears to be today. This is very true, as in the interlude fast logic switching devices have become the norm and they produce a lot of noise internally. It is not uncommon to decouple every package with a 100nF ceramic capacitor and a bulk decoupler on prime candidates or looking after small groups of packages. Quite a step up from previous analogue usage I suspect.

Zeroeth Commandment (programmers start at 0 and not 1) Thou shall consistently decouple, heavily! :)
Awesome response! Thank you for taking time to explain.
The more I look at this circuit the more confused I get.
If he has a 12v supply, why use an LM317? Is this also for regulation/filtering?
 

Paix

Senior Member
@Axel87, why use an LM317 Linear regulator?
I suspect that it was probably to hand. Tracecom probably has a number of them and uses them as a standard preferred device. It saves having 7805, 7809 etc. hiding away in multiple locations and doesn't take more than a couple of resistors to set the chosen output voltage, so it is eminently flexible.

The downside of using a linear regulator from a 12V supply is that as you pull more current in your load, that current runs in your regulator. Say that it's 1A, then 'nominally' (get-out clause!) 7V is being dropped across the regulator, 7W dissipated as heat for 5W in the load. This can be mitigated somewhat by putting a high wattage, low value resistor (5 to 10ohm) in the DC supply before the regulator. The resistor would drop some of the voltage and therefore dissipate some of the heat, but as the current rises the value of the resistor can restrict the available current resulting in a compromised design. So maybe a heat sink is a much better idea, but costing more than a 10 ohm 2W cermet resistor, which is also more likely to be in the bits box.

Note that the initial supply voltage of 12V is largely dictated by the requirement of U2, the ULN2803A motor driver chip and it's motor supply.

You are asking the right questions, so you must be learning and on the right track. it's just the detail that eludes you, but not for long I suspect.

@Tracecom, I hope that I haven't misrepresented your thinking in any way. It seems the crystal ball may be having a good day!
 

Axel87

Senior Member
@Axel87, why use an LM317 Linear regulator?
I suspect that it was probably to hand. Tracecom probably has a number of them and uses them as a standard preferred device. It saves having 7805, 7809 etc. hiding away in multiple locations and doesn't take more than a couple of resistors to set the chosen output voltage, so it is eminently flexible.

The downside of using a linear regulator from a 12V supply is that as you pull more current in your load, that current runs in your regulator. Say that it's 1A, then 'nominally' (get-out clause!) 7V is being dropped across the regulator, 7W dissipated as heat for 5W in the load. This can be mitigated somewhat by putting a high wattage, low value resistor (5 to 10ohm) in the DC supply before the regulator. The resistor would drop some of the voltage and therefore dissipate some of the heat, but as the current rises the value of the resistor can restrict the available current resulting in a compromised design. So maybe a heat sink is a much better idea, but costing more than a 10 ohm 2W cermet resistor, which is also more likely to be in the bits box.

Note that the initial supply voltage of 12V is largely dictated by the requirement of U2, the ULN2803A motor driver chip and it's motor supply.

You are asking the right questions, so you must be learning and on the right track. it's just the detail that eludes you, but not for long I suspect.

@Tracecom, I hope that I haven't misrepresented your thinking in any way. It seems the crystal ball may be having a good day!

Thank you for the informative response!
I cant tell you how awesome it is to have someone to take the time to give an in dept, informed response!

One more question, if I may. It kinda builds a little off the last.
My main concern with the diode, was as the 12v supply is connected to the common pin on the 2003 which, is also connected to GND.
I do notice that these are polarized caps, but wont these fail before a diode would? If either of these fail, is this not a dead short?
Please forgive me if I am overlooking some basics here :/
Thank you
 

Paix

Senior Member
@Axel87, check out the ULN2803A datasheet

The diode in the original diagram was connected from the +12 Ve rail to pin 10 on the ULN chip. It served no really useful purpose and was replaced by a direct connection, gaining that 0.7V that would otherwise be dropped across the diode, in the process. We mentioned that previously.
Code:
+12V -----+-------+
pin 10    |       |
          k      relay
         diode   coil
          a       | 
          |       |
          +-------o
          |
          output stage any one
          of pins 11 through 18
Hopefully this makes it clear.

Now on to the capacitor. This is connected between the +Ve rail and GND connection. It's purpose is bulk decoupling.

The value of the capacitor dictates that it be made with a technology which is by it's nature polarised. A standard electrolytic is the most common form and describes how the dielectric is fully formed.

These components are usually marked to indicate their negative terminal. They must be connected the correct way round or else the dielectric is in danger of breaking down, resulting in a possible catastrophic short. You have sussed that bit already though.

A capacitor is effectively an open circuit to a steady DC voltage across it and it will charge up quickly to provide a small voltage reservoir as mentioned earlier, but any switching noise which is AC will be conducted across the dielectric to Ground..
 

Axel87

Senior Member
Think I finally got the light bulb to finally light!

Thank you for the explanation!
Hope others will find this conversation useful as well
 
Top