# Stepping Motor Angle Rotation using Logic IC's

#### q12x

Joined Sep 25, 2015
1,469
- This is more a challenge to myself and why not for some of you as well. I will try to make it myself alone but... it will be easier and faster with some more experienced help from you guys. As the title says, with logic IC's. I could/should make it with an arduino or my favorite PIC12F508. But... this is an exercise to learn a bit more about logic IC's.
- The logic or the pseudo-code if you will, of how this thing should work: -my initial thought is to establish a 0 dgr mark. And from that point of origin, step up or back, by means of -counting-, the desired stepper angle.
- The project will be very simple. I will put 6 buttons and each button press will --position-- the stepper at a certain angle. -Very simple task.
For this project I will use a very known commercial stepper motor 28byj-48 . It comes with an ULN2003 coil driver already.

This data here is found on internet, not mine!
Current: 160mA per winding (320mA in 4-step mode) Measured:250mA stopped, 200mA running fast.
Resistance: 31R per coil winding
Voltage: 5V DC
Configuration: 4coils/4phases with 5wires
Internal Gear reduction is 1/64
360° / 64 = 5.625° for 1 step
MY wire color is different from other models I see on internet. This is my model and its wire color arrangement.

I hope this wire color code still apply on my model that I have.

I'll have to make it run first ! I never powered this 5wire stepper. I receive them a few weeks ago.
I still have that prototype board I made with ALL NPN's tr's on it if you remember. That worked for only 4wires steppers. I never try it with a 5wire stepper. These will be the first to try on this particular stepper driving board.

Wish me luck.
Thank you.

Last edited:

#### q12x

Joined Sep 25, 2015
1,469
I just measured the coils Resistance.
And I get: Red wire is the center and from red to each other wire I get 23.5R
(I get 46.xR measuring other color wires/coils). So this confirms the wiring diagram is true with my real wiring. That is good !
The internet guy I copied his data, had 31R per coil winding. So mine will be a bit more power hungry, more amps per coil. Good to know as well.
-
I just power it up, through my prototype board. I managed to make it turn.
I put an additional wire as the positive 5V from the board to the red wire pin of the motor.
But the motor is warming up. It is running very silent, but I can feel it's vibrations when holding it in my hand. It is vibrating more, than it's turning.
The PSU is showing me 410mA when running 'fast' and very jumpy 500mA when running slow. The circuit board itself is eating alone, with no motor connected on it, some 100-110mA. So the motor itself must eat 300mA. Yah, like the other guy mentioned in his specs. This prototype board I have, the logic part of it is not continuously counting, but with a pause after finishes to count. Like 1,2,3,4, pause, then 1,2,3,4, pause, etc. I know this detail about it. Thats why the motor is vibrating a bit too much in my hand. Possibly why is getting warm as well. Hmmm It may be it. I was thinking it was not wired or commanded properly. But if it is turning, then it must be wired correctly. Hmmm....
The conclusion: - the stepper motor is turning.

Last edited:

#### sarahMCML

Joined May 11, 2019
222
I just measured the coils Resistance.
And I get: Red wire is the center and from red to each other wire I get 23.5R
(I get 46.xR measuring other color wires/coils). So this confirms the wiring diagram is true with my real wiring. That is good !
The internet guy I copied his data, had 31R per coil winding. So mine will be a bit more power hungry, more amps per coil. Good to know as well.
-
I just power it up, through my prototype board. I managed to make it turn.
I put an additional wire as the positive 5V from the board to the red wire pin of the motor.
But the motor is warming up. It is running very silent, but I can feel it's vibrations when holding it in my hand. It is vibrating more, than it's turning.
The PSU is showing me 410mA when running 'fast' and very jumpy 500mA when running slow. The circuit board itself is eating alone, with no motor connected on it, some 100-110mA. So the motor itself must eat 300mA. Yah, like the other guy mentioned in his specs. This prototype board I have, the logic part of it is not continuously counting, but with a pause after finishes to count. Like 1,2,3,4, pause, then 1,2,3,4, pause, etc. I know this detail about it. Thats why the motor is vibrating a bit too much in my hand. Possibly why is getting warm as well. Hmmm It may be it. I was thinking it was not wired or commanded properly. But if it is turning, then it must be wired correctly. Hmmm....
The conclusion: - the stepper motor is turning.
Hi again,
Are you using your original finished board with no modifications? If so, I think the problem may be that it is not suited to driving the unipolar stepper because of the phases of the drive signals.
If you think about the outputs of the 4017, at any one time, 3 out of the 4 drive signals are going to be low, which means that, via the inverters, 3 lower transistor are going to be ON, pulling current through coils that shoudn't be being driven. Also, 1 upper transistor is going to be on, and since you have the common point of the coils connected to +5V, you are effectively shorting out that coil, which may have bad affects on the magnetic fields within the motor.
I think the simplest thing to do would be to short circuit the base of each of the lower transistors to 0V, effectively taking them out of the circuit, and connecting the centre tap of the motor to 0V instead of +5V. This means only 1 coil would be energised at any one time.
P.S. See my post about the original motor driver.

#### MisterBill2

Joined Jan 23, 2018
14,190
Post #3 hits at least one of the problems, which is that a driver for a 4-wire stepper, which uses a bipolar drive scheme, is totally different from the driver scheme for a five or six wire stepper, that uses a unipolar drive scheme. Normally a unipolar stepper is run in a half step mode, where either one or two windings are powered alternately. That provides twice as many steps with half the angle per step. So the truth table for driving is a bit tedious, and a bit of logic is required to generate the drive sequence from either a binary count or a decimal count.

#### sarahMCML

Joined May 11, 2019
222
Post #3 hits at least one of the problems, which is that a driver for a 4-wire stepper, which uses a bipolar drive scheme, is totally different from the driver scheme for a five or six wire stepper, that uses a unipolar drive scheme. Normally a unipolar stepper is run in a half step mode, where either one or two windings are powered alternately. That provides twice as many steps with half the angle per step. So the truth table for driving is a bit tedious, and a bit of logic is required to generate the drive sequence from either a binary count or a decimal count.
Yes, I did realise that there might be other problems along the way. But I thought that my suggestions in post #3 would at least get over some of the main hurdles with his current setup and get him started along the right lines.
He should really start from scratch with the ULN2003. Simpler all round!

#### q12x

Joined Sep 25, 2015
1,469
Aaah, steppers, the death of me. Thanks for the replies. I knew it is working funny. So its another cct specific for 5wire steppers. I built these things in the past, some decades ago. But I forget. I just (re)discovered the principle of operation and now I know what I have to do.
I find this movie on youtube that explains it very clearly:
(+) to A1 then (+) to A2 and again (+) to A1 then (+) to A2 and so on. This A1A2 sequence will rotate in one sense.
Using B1B2 sequence, will invert the motor sense.

Last edited:

#### q12x

Joined Sep 25, 2015
1,469
Im staying for 2 days on this circuit and ... is too hard for me.
TRY your LUCK and see if you can solve it. I can't. Im not THAT good with logic IC's.
Here is the general view of it.
Both cct's on the right side of the screen are functioning circuits. They are counting fine and then stop.
But main cct (in the left) needs some sort of logic I am not familiar with. Maybe you are?
- So... you see that X point. That's an output that will be connected to any of those A,B,C,D clock Inputs. Simple so far, right?
Here is the problem: We need also, to activate that Reset button as well. This Reset actually will be the first thing to activate and then link X to A for example. And hold on A until total counter time pass. Then deactivate from that A clock to a NC state.
So everything with a single button press. You see those x16,x32,x48,x64 buttons? Those are the 4 buttons to be linked and activated.
So pretty much when I press the x16 button, Reset function will activate, then X will be linked to A, then wait until count to 16 in this case, then deactivate X from A to a NC state.
Next, If I press x48 button, Reset function will activate, then X will be linked to C, then wait until count to 48 in this case, then deactivate X from C to a NC state.
What is the logic that can do all of these permutations?
I imagine it may be another function of a chip I didnt discovered yet. For sure it may be.

Tell me if it is extreme hard. I kind of see it this way, but maybe its my limited knowledge about logic ICs.
Thank you.
I attach the Proteus save file ! Download it and play in it.

#### Attachments

• 32.2 KB Views: 0
Last edited:

Joined Jul 18, 2013
26,629
Normally a unipolar stepper is run in a half step mode, where either one or two windings are powered alternately. That provides twice as many steps with half the angle per step.
The problem with 1/2 stepping is torque is drastically reduced.,

#### MisterBill2

Joined Jan 23, 2018
14,190
Isn't there a scheme where alternately one and then two windings are on? It has been quite a while since I had to create a stepper drive circuit, about 25 years, and so I might have lost a few of the details.
It used to be that Superior Electric had the very best descriptions of how to use and drive steppers. That was a while back, though, in the 1980's And all of their drivers used 7400 series TTL logic.

#### q12x

Joined Sep 25, 2015
1,469
I assumed this will be easy, or at least intuitive. This project is not intuitive at all. Pity. I imagined I will solve the problems along the way. I recognize a big problem when I see one. And here I have a big one, using only logic gates. An extreme hard problem as I put it earlier.
- I will switch to arduino! I know I said --logic IC's only-- but it is the next logical step to do. To get out from the impasse.
Unless, someone will come with a solution, but I doubt it.

#### q12x

Joined Sep 25, 2015
1,469
Here is my progress but as I said, I will stop at it and leave it as it is.
I will concentrate on making it with arduino from now on.

#### sarahMCML

Joined May 11, 2019
222
What is the purpose of the circuit in post #7? Is it related to driving the unipolar stepper, but using a modified version of your old bipolar stepper? What is the whole design supposed to do when working correctly?

I can see a few ways to do what you want, but need some answers first.

1) Even if I enlarge the diagram in Irfanview, I cannot read some of the part numbers, they become too blurred.
2) Some don't have any part numbers, so I can't determine input polarities, etc.
3) Have you built this only in simulation or, if for real, on a breadboard or your unique cardboard method? I ask because it would determine the type of circuit I would try to design.

EDIT: Forget the first paragraph of the above. I was writing this as you posted your video!

Last edited:

#### q12x

Joined Sep 25, 2015
1,469
Yes, thank you @sarahMCML for taking interest in this cct.... I dont know what to say, really, other than I did my best.
What is the purpose of the circuit in post #7?
It is as the title of this thread is saying "Stepping Motor Angle Rotation using Logic IC's" - that's it's purpose. The idea.
I am using and presenting a 4wire stepper inside this simulation cct, but simply because I spend A DAY to make it work with a 5 wire and I couldnt. In the simulator. I had a TON of bugs from that particular motor, so I decided to remain with this 4wire one. At least in the simulation stage. In reality I will (probably) switch to a 5wire one as I originally intended.

1) Even if I enlarge the diagram in Irfanview, I cannot read some of the part numbers, they become too blurred.
2) Some don't have any part numbers, so I can't determine input polarities, etc.
I actually put a save file there...but you must have installed this Proteus software (which I can help you with if you want) and at least the version I have for the save file to load properly. Its version dependent.
But because you start to become a close friend to me, here is the logic circuit at very good resolution: (just for you)
(Click and zoom in the img, for the full hd view)

The coil driver doesn't matter. Only the logic.
'Some don't have any part numbers," - well, you must learn and understand this side of simulators. All of them! They usually use GP (general purpose) components. And some simulators actually use specific components with specific attributes. But all these special components derive from the GP components anyway, with small tweaks here and there. So the bottom line, use whatever component you want and you have in your arsenal. The simulator is only showing you 'the way', or at least is how I use it. I do not go into that level of designing, and actually choosing component value specifically. You must learn this side of me. I am a bit more generalist than specialized. When designing I mean. When Im specific, and I really want to use a specific purpose component, I will accentuate it to death ! But in general lines, I am a general person, haha.
3) Have you built this only in simulation or, if for real, on a breadboard or your unique cardboard method? I ask because it would determine the type of circuit I would try to design.
Only in simulation! I am only making it in reality after a succesful simulation. That is the role/idea of a simulator after all, no? To speed up the process, to give you that kick in the but, to put you on the right direction. Unfortunately this cct is incomplete or I may say a fail. Way too complicated at this point im presenting here (both in writing and video presentation). Eh well...
- Thank you @sarahMCML !

Last edited:

#### Papabravo

Joined Feb 24, 2006
19,825
I think the answer to your dilemma can be found in the study of finite state machines. The basic idea is that you have a set of "state variables" represented by the bits in a "state register". You also have a set of inputs and a set of outputs. At discrete points in time, you examine the present state and the inputs to compute a "next state" and new outputs. The problem of creating the "stepping" sequence for any kind of stepper motor can be approached in this fashion. The related problem of using an up/down counter to keep track of angular position can also be solved in this fashion.

Can this be done with MSI logic integrated circuits? Maybe, but it depends on the details.

For example: If you have a 200 steps per revolution stepper motor that you wish to half step, then you need a counter with states 0-399 or 1 grad per step. There are 400 grads in one revolution. the inputs to the counter are CW/CCW (Clockwise/Counter Clockwise) and a Clock signal. If CW/CCW=1 the counter counts up and if CW/CCW=0 it counts down.

#### sarahMCML

Joined May 11, 2019
222
Yes, thank you @sarahMCML for taking interest in this cct.... I dont know what to say, really, other than I did my best.

Only in simulation! I am only making it in reality after a succesful simulation. That is the role/idea of a simulator after all, no? To speed up the process, to give you that kick in the but, to put you on the right direction. Unfortunately this cct is incomplete or I may say a fail. Way too complicated at this point im presenting here (both in writing and video presentation). Eh well...
- Thank you @sarahMCML !
It was U65, marked DTFF that I was concerned with, as I needed to know whether it was positive or negative, edge or level triggered! As I don't use simulators, (never have!), I needed to know whether my design would need to integrate with your existing hardware. Obviously, it doesn't!
What is U65 in the sim?

#### q12x

Joined Sep 25, 2015
1,469
It was U65, marked DTFF that I was concerned with, as I needed to know whether it was positive or negative, edge or level triggered!
What is U65 in the sim?

#### q12x

Joined Sep 25, 2015
1,469
I think the answer to your dilemma can be found in the study of finite state machines. The basic idea is that you have a set of "state variables" represented by the bits in a "state register". You also have a set of inputs and a set of outputs. At discrete points in time, you examine the present state and the inputs to compute a "next state" and new outputs. The problem of creating the "stepping" sequence for any kind of stepper motor can be approached in this fashion. The related problem of using an up/down counter to keep track of angular position can also be solved in this fashion.
So... what you are really-really telling me is that I should build (anything) with small steps, resolving each small problem in itself, and then adding every small resolved solution to the big picture. Thus resolving the original problem. Im sorry if I wasnt clear about this, I thought it is self explanatory, but I already did it in this fashion all this time. Bit by Bit, if you want. But some Bits are harder to resolve than anticipated. I call it "intuitive" building. But it appears is over my ears. Or I quit too soon, Or I really-really dont know how to dig deeper than I did already. Or Im not THAT smart. I know for sure there are small tricks, hidden diamonds, especially in this MSI logic (Medium Scale Integrated Circuits) design. Im pretty new to it so.... no, I dont know that much! This is the station where get down. Heh.
But... I know there are more experienced and WAAY more smarter people than me. I know. You may be one, who knows. If you know how to dig deeper than I did, then please, you are my guest to wet your hands in it. Im very curious what you may come with. Very curious! Until then, success and good luck. You will need it.

Last edited:

#### Papabravo

Joined Feb 24, 2006
19,825
So... what you are really-really telling me is that I should build (anything) with small steps, resolving each small problem in itself, and then adding every small resolved solution to the big picture. Thus resolving the original problem. Im sorry if I wasnt clear about this, I thought it is self explanatory, but I already did it in this fashion all this time. Bit by Bit, if you want. But some Bits are harder to resolve than anticipated. I call it "intuitive" building. But it appears is over my ears. Or I quit too soon, Or I really-really dont know how to dig deeper than I did already. Or Im not THAT smart. I know for sure there are small tricks, hidden diamonds, especially in this MSIC (Medium Scale Integrated Circuits) design. Im pretty new to it so.... no, I dont know that much! This is the station where get down. Heh.
But... I know there are more experienced and WAAY more smarter people than me. I know. You may be one, who knows. If you know how to dig deeper than I did, then please, you are my guest to wet your hands in it. Im very curious what you may come with. Very curious! Until then, success and good luck. You will need it.
So, are you more interested in generating the driving sequence for a particular kind of motor, or keeping track of the relative position?

#### MisterBill2

Joined Jan 23, 2018
14,190
For generating the drive sequence for a unipolar stepper motor, please consider that Superior Electric was selling the driver that did that using TTL flipflops and AND gates back in 1980. I believe that the circuit used two FFs and several 2 input and gates, but it may have used two of the dual FF IC devices.
Thus generating the required sequence with logic must not be that terribly difficult.
Given the number of systems they sold, there must be some circuits available to copy some place.

#### q12x

Joined Sep 25, 2015
1,469
So, are you more interested in generating the driving sequence for a particular kind of motor, or keeping track of the relative position?
For the moment, generating the driving sequence.
For generating the drive sequence for a unipolar stepper motor, please consider that Superior Electric was selling the driver that did that using TTL flipflops and AND gates back in 1980. I believe that the circuit used two FFs and several 2 input and gates, but it may have used two of the dual FF IC devices.
Thus generating the required sequence with logic must not be that terribly difficult.
Given the number of systems they sold, there must be some circuits available to copy some place.
I never heard of Superior Electric brand. But if you do have a circuit like they made, please pass it to me.
Thank you. I actually searched on the www for such cct made from logic gates but only arduino examples I found. People dont like to think anymore, dont they?