Any Digital Designers Here?

wrmiller

Chief Tinkerer
H-M Supporter Gold Member
Joined
Mar 21, 2013
Messages
4,118
Want to manually control a stepper motor on a single axis. In this case the Z-axis. Similar to the controls on my friend's CNC machines.

Rotary encoder/Hall Effect on a large dial for manual input of up/down. Dial turned CW direction would be up, CCW would be down. Faster the dial is turned the faster the motor turns.

Three position switch for selecting tenths, hundredths, or thousandths. No readout needed as I have a DRO for the machine already. Maybe this station could be the input/output for a stepper motor driver? Then I'd just need the power supply and a motor.

Once an initial design is done, I'd layout the circuit on a proto board and do the testing. Once the testing is done and everything works. I'd need a final schematic, a pcb file that I could send out to a small quantity board house, and a parts list (BOM). Preferably through hole on the circuit board/components as my eyes and fine motor control are no longer good enough to solder surface mount components.

I don't have the hardware skills anymore to do this so I though I'd inquire here. Not expecting it to be free.

I'll ask some of the hardware guys at work next week to see if anyone is interested, but I thought I'd ask here first.

Bill
 
I am not that interested in extra work but this does sound useful. The HW / code is trivial. You can get an arduino that would do the trick for about $20. You would need a stepper, a driver like a Gecko, and the power supply for the stepper. I would suggest buying the driver already assembled as you will probably let the smoke out of quite a few parts building your own and it won't be any cheaper. A couple of years ago I built an AVR (the chip used in the arduino) based tachometer that uses a rotary encoder to set the diameter of the stock being turned. Pressing the encoder shaft toggled between mode (SFM, RPM, DIA), holding the shaft down while powering up put you in setup mode to set the number of pulses per revolution. The code for that plus driving the 4 digit 7-segment display was around 100 lines of code so what you want would be pretty simple. I am in the process of adding a stepper to my z-axis and I just received a couple of arduinos yesterday so I might give your idea a try. I work very slowly (way too many projects and too many forums like this to waste time on!). My guess is that you will have a solution long before I start but if not, you are welcome to any code I come up with.

Brian
 
I was playing with this the other day at work. All I did was to use a rotary encoder and have each pulse move a number of steps. I don't know about making the speed of the encoder set the amount of acceleration. You want to run the encoder off of an interrupt and you don't necessarily know the speed as the timing for the interrupt occurs outside the program flow (kinda). If you don't do it interrupt driven, you have to really be careful of the timing as the clock speed of the chip will be more of a limitation (assuming you are using the Arduino IDE/Language.)

The three positions for number of steps per pulse is a much easier solution than the speed of the pulse train as you can easily lose pulses. It sounds like you would lose pulses more than you really do as the steps are so small. When I get back to work, I can post what I had working the other day (it's on my computer at work.)

Depending on how much power you are trying to run, the little Pololu stepper drivers or the EasySteppers from sparkfun can run a fairly decent stepper. Adafruit has a motor controller board that can do several things: http://www.adafruit.com/products/1438 You can also run it off one of the L298 drivers that they already have shields for (Never personally used but lots of people use them) and not have to do any board development at all. They run a couple amps and can do a pretty good sized stepper.

I was going to pick up one of the nicer rotary encoders that sparkfun sells https://www.sparkfun.com/products/10790 that runs 200 pulse per revolution and is a bit more robust than the little one I was using.

http://bildr.org/2012/08/rotary-encoder-arduino/ has the easiest example (and worked the best from the ones I played with) I also liked it that it didn't need as much circuit as this one: http://www.hobbytronics.co.uk/arduino-tutorial6-rotary-encoder

The one on arduino.cc http://playground.arduino.cc/Main/RotaryEncoders didn't seem to work as smoothly.
 
Programmer here. Can't you just store the time of the last interrupt and calculate the interval when the new interrupt happens?
 
Programmer here. Can't you just store the time of the last interrupt and calculate the interval when the new interrupt happens?

Kinda. The problem is that when you start doing a lot of stuff in the interrupt handler and then you hit another interrupt during the handler. There is no buffer (nor would you want one.) You are going to lose stuff either way. Better just to make the handler as quick as possible and get out.

Edit:

The key point is that the code that the Arduino stuff generates is kind of unknown and not much clock speed. You can calculate the number of cycles per operation and see if you have enough time if you were doing it in assembly. I can't say what code is getting generated by the compiler. You could profile it and see how long it takes within a range of timing values but you cannot be really sure. Start having other things happen like another interrupt for some switches and stuff like that and you can get into an unknown state.

Realtime programming with interrupts can be a bit funky.
 
Last edited:
Excellent points. I've never done any real time stuff.

This thread is making me salivate. I've had the urge to get a stepper for my G0704 as a first step toward slowly converting it to CNC by building autofeed and jog into each axis, starting with the X. This kind of a thing is exactly what I was looking for.
 
When I was playing with it, the action on the stepper was really smooth. One of the earlier times I was doing it but it wasn't that great because the rotary encoder kept slipping out of the breadboard:

[video=youtube_share;igsxmkRfz5A]http://youtu.be/igsxmkRfz5A[/video]

It would be really simple to add to it to make a power feed as well.
 
It was mixed up with some other links before: http://bildr.org/2012/08/rotary-encoder-arduino/

This one works best. The one in the video was not interrupt driven and had a bunch of other resistors instead of using the internal pull up resistors on the arduino. Much simpler circuit, smoother action and lowered part count in the link from bildr.org.

The encoder was a 24 pulse that actually works pretty well but I am going to do it next time with a better encoder that has a bit better resolution. I think the really high resolution would be a problem (They have them up to 1000 pulse and beyond) The 200 pulse per rev is the same as most of the steppers so one revolution of the encoder should come out close to one rev of the stepper without microstepping. Just add a multiplier for the steps to get different rates.
 
I was thinking that the change in encoder rate (number of pulses/sec) is reflected in the number of pulses to the controller/motor. A 1:1 ratio if you will.

Faster encoder pulses directly causes faster step pulses (forgive me, I don't know stepper control. I do RTOS and SCSI code, not the servo on disk drives.). This isn't an accel/decel profile, it's just a pulse train, or so I think. What am I missing?

Isn't this where a ladder logic (?) or something can sample the encoder pulses as a function of time and simply drive a chip to output the same frequency to the controller? Sample period could be in the 10s of microseconds or even mili-seconds and still be sufficient for this.

When setting up my friends CNC for a Z-reference I would select the Z-axis, tenths, and rotate the dial until close to the workpiece, then switch to hundredths and get closer, then thousandths to a shim I had between the end mill and the workpiece. When I touched the shim, I removed it, added the thickness of the shim to the z location and called that zero. This is what I want to do with my z axis on my PM25. :)

I figured this could all be done in logic without any firmware?

EDIT: I don't know the size of stepper I'd need for my 25 (G0704 with blue paint), probably a 32 at least?

Bill
 
Last edited:
Back
Top