Stepper motor controller

I couldn't find this answer anywhere so I hope I'm not repeating a similar thread.
My question is: - If you are making a simple three axis project with four wire steppers then why can't you do the step decoding with the Arduino? For each motor have four outputs, with each output dedicated to each wire of a stepper. Could you not then use software to phase them correctly. I know you would still need to buffer the digital outputs of the Arduino to get enough current for the steppers but this is a lot easier than building in further chips to do the decoding for you.

You could certainly do this. You would essentially be making a stepper motor controller at that point. Drop the Arduino board and use a bare ATMega328 for the final PCB, of course. Nothing wrong with the idea.

Of course, once you started adding certain functions (half-stepping, PID control, etc) - you might want to dedicate a single ATMega per motor, so that a single microcontroller isn't overtasked with too much work (they're cheap enough); this would require experimentation (for slower step rates it might not be an issue and a single one would suffice).

Finally, you likely want to do direct port control, and dedicate a port to each stepper; this would allow you to send a full coil "pattern" for each step, rather than use individual writes which might cause errors or other issues (driver circuit overheating or other possibilities?). If you used a single Arduino/ATMega, one of the ports is 8-bit, and you could use that one for the X/Y of the table, and another port for the Z-axis (unless you're not doing CNC or similar, and combining axes wouldn't be useful).

:slight_smile:

one of the ports is 8-bit,

No, that port includes the TX and RX lines that you don't want to use. There is no reason to use direct port access you can just do it with the normal digitalWrite()

why can't you do the step decoding with the Arduino

What makes you think you can't do it?

Why would you want to?

I tried controlling a stepper motor with just the arduino earlier tonight, but it seemed to take more components than using a motor controller chip - transistors, diodes, resistors that aren't needed with the driver chip. The chip only cost a few pounts and took minutes to set up - really easy to do.

Of course, I may have cocked something up or missed a simple trick to get it working with just the arduino but I found it loads easier using the chip.

No, that port includes the TX and RX lines that you don't want to use. There is no reason to use direct port access you can just do it with the normal digitalWrite()

I was thinking of this, but I wasn't sure and too lazy to look it up - but ultimately, so what?

If you were designing a motor-controller PCB using the ATMega as a controller, you wouldn't really care about those pins anyhow; for comms to it from another device, use SPI/I2C on other pins (one of those protocols, I think SPI, isn't it on 11/12/13 or something like that?).

That's what I was thinking. Of course, if you were going to do this with a straight Arduinio board (or similar device) which uses 0/1 for comms over serial or USB, then you probably would want to avoid it.

I would still think, though, that you could do more with direct port access than with the overhead of digitalWrite(), even if it didn't cause problems (but I would wonder if some kind of issue didn't occur, because instead of activating both coils at the same time, you would be doing one then a split-second later the other). I'm just guessing, though...

:slight_smile:

cowjam - you might want to if you couldn't find a driver/controller chip powerful enough to handle your stepper; some of those really large steppers can pull a heck of a lot of current, where only large FETs or the like with beefy heatsinks will do.

Of course, for a small stepper, a simple L298 or other jobber will work fine...and be easier (and potentially cheaper) to set up ultimately.

:slight_smile:

because instead of activating both coils at the same time, you would be doing one then a split-second later the other

True but if you consider the time constant of the inductive circuit you will see that this slight time delay is of nothing when you consider how long it takes the current to rise in the coils.

True but if you consider the time constant of the inductive circuit you will see that this slight time delay is of nothing when you consider how long it takes the current to rise in the coils.

That is true.

Aside from that, though, if you wanted to (or needed) have high speed stepping, wouldn't the overhead of doing (let's say for two steppers) 8 digitalWrite() calls be greater than doing one direct port write (8 bits), limiting the top speed of the step rate?

Then again, maybe that "top speed" would be so great, at 16 MHz, that even with digitalWrite() it would still be way faster than what the majority of steppers could handle...

it would still be way faster than what the majority of steppers could handle.

I would think so.

Thanks for the responses.
So it's just a matter of choice then really.
A lot of the steppers I've played with had 8 wires anyway so 3 axis would need a Mega for direct coupling (via buffers).
A few folk have advocated salvaging the steppers out of printers etc for small low power devices. Is it possible to also salvage the driver circuits out of these devices as well as the stepper? Then perhaps it would be a fairly simple job to couple these up to the Arduino. I like the idea of building a small CNC to make PCBs so these small steppers would be ideal for the job.

Is it possible to also salvage the driver circuits out of these devices as well as the stepper?

Yes it is possible but it is more difficult.

I like the idea of building a small CNC to make PCBs

Don't underestimate how difficult that will be (backlash problems) but good luck.

Good point about the back lash. Trying to drill holes with the right pitch etc would be the tricky bit. I'll cannibalise one of my old printers this weekend and see what I can find. Even maybe trying to put a thin ally table where the paper normally goes and fixing a tool holder on the print head. This could make things easier in one respect and that's the mechanic are part done and standard black and white pictures could be printer/cut. The difficulties are trying to find the signal on the print head that says start printing as this is likely to be a complex signal not only to start printing but controlling what colour and shade. I think my old HP has two print cartridges so if it works that would allow me to have two tools (miller and drill) set up at all times..hmmmm. Food for thought...hey where's my Arduino gone out of the project :slight_smile: oops... Still the PCB makers job would be to make PCB's for the Arduino so on topic sort of..

Well making a CNC miller from a printer is very ambitious, most people have trouble making a CNC miller out of a hand miller. See these notes:-

Don't underestimate how difficult that will be (backlash problems) but good luck.

And expensive to get rid of - ever seen the the prices for anti-backlash nuts for acme thread screws? Yikes!

;D

you touched the hot point! the back lash errors are cumulative , so if you want to start to build something good you will have to think on a scale that is not in the range of millimeters. but fractions of millimeters. And you should use tools as precise as much the machine you are building (al least), and in particular way a pcb milling machine should work under the 0.1 mm.
another matter is the probable step loss due to interrupts...

I hear you all and thanks for your comments.
I still have the idea though that if a printer can print a PCB with holes and everything aligned then the same gear 'should' be able to drill or mill the same providing the weight or loading put on the mechanism by the drill/mill set up isn't much greater than a full ink cartridge.
The other main problem I'd have if trying to use a printer set up is if i can detect when the ink was meant to be on then convert this signal to plunge the drill, but the ink will be on for fractions of a second where as the drill will be seconds so the printer will have tried to print several holes in the time it would take to drill one. So then I'd have to find a way of either slowing it down or providing feedback so it doesn't move on until each operation is complete.
If you use ball screws and the like then these are do able for a 80mm X 100 mm PCB set up but I agree they do get really silly money once you up the size.
Well for now then it looks like this is a thinking point for me to be back burnered. I was looking for a simple , cheap and easy way to knock out boards for my Arduino projects not make the PCB maker in to the project.

I still have the idea though that if a printer can print a PCB with holes and everything aligned then the same gear 'should' be able to drill or mill the same providing the weight or loading put on the mechanism by the drill/mill set up isn't much greater than a full ink cartridge.

The loading will be significantly more - the weight alone, plus side loading, is pretty high for a milling machine, even one just for PCB work. Perhaps if you could figure out a milling head that used a flex shaft or some other transmission system (air drill?) that didn't require a larger high-speed motor. Maybe you could do it using a pager motor, or some other mechanism? You might have to perform multiple passes...hmm. Now you have me thinking!

:slight_smile:

I was looking for a simple , cheap and easy way to knock out boards for my Arduino projects not make the PCB maker in to the project.

I don't need another project either! Argh!

;D

I had a thought on the back lash issue. I clicked on the link with the converting a hand mill and saw his problems on back lash. I think on a small lightweight device like this tightening up nuts or making the thread a lot closer fit is the wrong way to go. He gave me an idea when he said the Z axis didn't have a problem due to the weight of the drill. I'm thinking why not bias the X and Y axis in the same manner? For example have a small cable/string from the carriage over a pulley and connected to a weight. I think a weight would be better than a spring due to the uniformity of the load it would give. Could this give the same effect as the Z axis?

On the side loading issue. For PCBs this could be significantly reduced as you would only need the tinniest mill necessary to give electrical isolation IE you don't have to mill away all the copper not being used simply a small line between tracks is all that is needed and as you said if you couple this with multiple passes then a good quality mill bit wouldn't need much of a motor to achieve the depth required. You would still have to figure out a way of telling the printer hardware to slow down a bit. Some printer accept EPS or HPGL which can be coded with delays but it would be much easier if at all possible just to get a picture on the screen with any graphics package and send it to the printer as per normal with (as mentioned before) different colours for different cutting operations like milling in black and drilling in red.

Just had another thought on this topic. Using the printer as is and in place of the printer head (or cutting bit) use a blue ray (or other cutting) laser diode. The diode could be mounted in to an old print cartridge with enough room inside for any electronics need to switch On the diode when the black cartridge was meant to be printing. I'm not sure one of these diodes would have enough mW to actually burn off the excess copper but it would have enough to burn matt black paint. The idea being clean then spray the copper clad board with matt paint. Use the laser to burn off the paint and then in to the etching fluid to produce a lovely PCB. I d have to find a way of putting a solid piece of ally or wood through the printer with a hole cut in it just right for the PCB. This is instead of the top feeding paper but I think that's doable. Figure out how to discern if the black cartridge is meant to be printing or not and get it to turn on the laser again I don't think this should be too hard. Diodes on the bay of E for £3 ish. This project is sounding a lot more doable now..Ooops I don't think this is Arduino related at all now except maybe it's function is to make PCBs for Arduino projects. What do you think o learned ones ?

hmm plus a cover that stopped the laser light getting out and melting my eyes. :sunglasses: