Somewhere in Greece, someone did something never done beforeâŚ
Seen those things before?
Thing: 1
Thing: 2
Thing: 3
Oh, you have! You bought one of them you say? Oh⌠Donât worry, I did too.
They did the job, yeah. But we paid for them much. Really much. And while our whole project would cost less than 60 bucks or euros without them, they slapped as in the face, then took our money and ran ⌠our precious motorsâŚ
The revenge has comeâŚ
Seen those things before?
Thing: 1
Thing: 2
Thing: 3
Oh, you have! You bought one of them you say? Oh⌠Donât worry, I did too.
They did the job, yeah. But we paid for them much. Really much. And while our whole project would cost less than 60 bucks or euros without them, they slapped as in the face, then took our money and ran ⌠our precious motorsâŚ
The revenge has comeâŚ
We all love steppers! They do some really nice things.
1) They ran great CNC systems, that make all kinds of goods!
2) They play music, sometimes better than humans!
Basically They do only those two things but they are enoughâŚ
We, people, often control them via computers or microcontrollers and make them do those nice things and live happily together.
Steppers differ from DC motors structurally and behaviorally. They have 4 control wires (instead of 2) and, in order to make the rotor move, you have to apply voltage to some combinations of them, and change the combinations over small (really small) time intervals (maybe every 0.01 seconds or less).
Why is that, you may ask. But it is for PRECISION! The god of productive machinery! Every time you drive the stepper wires with a correct combination the rotor moves by a certain amount of degrees⌠That way you can tell where the rotor is by just measuring how many such voltage combinations you have applied to the motor. Knowing the position of something without any kind of feedback is Really Something!!!
(You can read much more here. There is a decent explanation of microstepping inside. the thing that this project CANâT do at the time of writing)
1) They ran great CNC systems, that make all kinds of goods!
2) They play music, sometimes better than humans!
Basically They do only those two things but they are enoughâŚ
We, people, often control them via computers or microcontrollers and make them do those nice things and live happily together.
Steppers differ from DC motors structurally and behaviorally. They have 4 control wires (instead of 2) and, in order to make the rotor move, you have to apply voltage to some combinations of them, and change the combinations over small (really small) time intervals (maybe every 0.01 seconds or less).
Why is that, you may ask. But it is for PRECISION! The god of productive machinery! Every time you drive the stepper wires with a correct combination the rotor moves by a certain amount of degrees⌠That way you can tell where the rotor is by just measuring how many such voltage combinations you have applied to the motor. Knowing the position of something without any kind of feedback is Really Something!!!
(You can read much more here. There is a decent explanation of microstepping inside. the thing that this project CANâT do at the time of writing)
Step 2: Stating the ProblemâŚ
So, as you may have realized, steppers are a hassle to use and control. All those wires, voltages, combinations and degrees/step are simply too much for a human to control.
And when it comes to CNCing, computers find it hard too. It is difficult even for computers, to control all the above combined with the needs of a CNC device: steady velocity, measured acceleration, simultaneous motion and taking a note of every rotor at any given time.
But when we face problems with multitasking we have the most elegant solution (when it comes to engineering):
Split the tasks to more than one worker. And that happened. The computer got rid of anything that has to do with voltages and combinations of wires. A simple interface was given to the computer so it could communicate with the motor. An interface that only contains 2 signals. A Step signal that every time it goes High (edge triggering) the motor has to move 1 âstepâ and a Direction signal that decides at which direction would be the step (ex: High for CW, Low for CCW).
So this is the Step/Dir interface.
Now a second device was needed to translate the Step/Dir signals to actual 4-wire signals, move the motor and generally do the hard work. This device is the Stepper Controller. And as of today, only one type of this device exists commercially: the hardware one. It uses H-bridges along with some kind of hardware logic, and other tricks ending up to quite complicated device. So it isnât that cheap too⌠They can reach even 60 euros or more for multiple motors.
So, the first reaction when I got an idea about how to program Attinies was âWhy hasnât anyone made a software controller, by just coding the combinations in an Attiny85â (There have been some success with Attiny2313 by another Instructable and a sole attempt with Attiny85 that isnât very satisfying)
Step 4: The Circuit
And when it comes to CNCing, computers find it hard too. It is difficult even for computers, to control all the above combined with the needs of a CNC device: steady velocity, measured acceleration, simultaneous motion and taking a note of every rotor at any given time.
But when we face problems with multitasking we have the most elegant solution (when it comes to engineering):
Split the tasks to more than one worker. And that happened. The computer got rid of anything that has to do with voltages and combinations of wires. A simple interface was given to the computer so it could communicate with the motor. An interface that only contains 2 signals. A Step signal that every time it goes High (edge triggering) the motor has to move 1 âstepâ and a Direction signal that decides at which direction would be the step (ex: High for CW, Low for CCW).
So this is the Step/Dir interface.
Now a second device was needed to translate the Step/Dir signals to actual 4-wire signals, move the motor and generally do the hard work. This device is the Stepper Controller. And as of today, only one type of this device exists commercially: the hardware one. It uses H-bridges along with some kind of hardware logic, and other tricks ending up to quite complicated device. So it isnât that cheap too⌠They can reach even 60 euros or more for multiple motors.
So, the first reaction when I got an idea about how to program Attinies was âWhy hasnât anyone made a software controller, by just coding the combinations in an Attiny85â (There have been some success with Attiny2313 by another Instructable and a sole attempt with Attiny85 that isnât very satisfying)
Attiny85 is a microcontroller. It contains a processor, some RAM, some free space, to save and load things, and offers some of its processorâs register bits as IO pins.
Here lies the problem. Attiny85 has 8 pins at its DIP package, 2 of them being power supply. And you may assume that the rest are pure IO. Thatâs wrong. Well, almost, wrong⌠The 5 of the remaining pins are IO and there is that 1 pin that is used for RESET (if you bring it Low the microcontroller will restart). To make things worse, RESET pin is connected to some register, so it has the potential to BE an IO pin. There is also a fuse inside the microcontroller that decides if this pin is used for RESET or IO. BUT if you change the fuse (the famous RSTDSBL) to use the pin as IO, the microcontroller canât be reset again and, on top of it, it canât be reprogrammed.
Now, back to the stepper controller device. It needs 2 pins, to read the incoming Step and Dir signals, and 4 to connect the stepper motor wires (or the base of some transistors to amplify the power delivered to the motor) and do the actual voltage combinations. So a controller needs (*at least*) 6 pins.
You see it, donât you? The way god created things has made our little Attiny85 to be incapable of being used as a stepper controller properly. Until NowâŚ
Here lies the problem. Attiny85 has 8 pins at its DIP package, 2 of them being power supply. And you may assume that the rest are pure IO. Thatâs wrong. Well, almost, wrong⌠The 5 of the remaining pins are IO and there is that 1 pin that is used for RESET (if you bring it Low the microcontroller will restart). To make things worse, RESET pin is connected to some register, so it has the potential to BE an IO pin. There is also a fuse inside the microcontroller that decides if this pin is used for RESET or IO. BUT if you change the fuse (the famous RSTDSBL) to use the pin as IO, the microcontroller canât be reset again and, on top of it, it canât be reprogrammed.
Now, back to the stepper controller device. It needs 2 pins, to read the incoming Step and Dir signals, and 4 to connect the stepper motor wires (or the base of some transistors to amplify the power delivered to the motor) and do the actual voltage combinations. So a controller needs (*at least*) 6 pins.
You see it, donât you? The way god created things has made our little Attiny85 to be incapable of being used as a stepper controller properly. Until NowâŚ
Step 4: The Circuit
For more detail: Attiny85 As a Step/Dir Stepper Motor Controller