Quote Originally Posted by Robin Hewitt View Post
I had a notion that if I fitted cheap Chinese digital-scales to my mill I could stop worrying about backlash, stalled steppers, losing my zero etc. I could fit an automatic tool height detector and that positioning pendant I have always wanted, maybe leave it open ended so I could add other input devices I haven't thought of yet.

I now have a little computer board which the PC can talk to. It reads 3 digital scales, drives 3 stepper motors, has a serial port to talk to the digi phase converter. Also SSR relay outputs to switch the suds and the main motor, plus 3 auxilliary ports for plugging in additional doo-dads.

I've got the scales reading, haven't done their end sensors yet but that should be easy. Now working on the stepper control algorythm which sits on a timer interrupt...

Anyone still with me? Or am I the only one who does this kind of stuff? :D

Current plan is that each axis has two main variables, 'Where we are' WWA and 'Where we want to be' WTB. When the timer interrupt fires it does one axis out of 3. It compares WWA to WTB and if necessary steps in the appropriate direction.

May seems complicated for a stepper algorythm, until you remember that WWA can change at any moment should the digital scale for that axis chime in with a new absolute position. I have the scales hard wired for speed, a complete 24 bit location received interrupts the CPU and gets read as 3 pre-digested bytes.

On the last axis interrupt it does a more exhaustive test for position. If any axis is outside tolerance I don't update WTB for the next position so it does remedial steps until tolerance is satisfied. I think I have to allow a tolerance or it will get stuck. The screw resolution is .005 mm/step. The scale resolution is .00496mm, close enough that I can let the motors get a bit ahead of the scales. The scales report about 50 times a second, I usually do 300 steps/second so there has to be some leeway. If I can cut the tolerance to 3-4 steps I will be well within 1 thou accuracy.

Quite enough for now. Did anyone read this far?
I do this stuff and will do more when I can mill PCBs instead of having to etch them...right now I am designing stepper drivers and trying to decide which chip to go for... I was thinking L297/L298 is cheap and cheerful for now.

On your algorithm, you need to think about acceleration and deceleration and predictive placement since what you are creating is a closed loop servo system with a lag. Given that your scales read slower than the step speed if you are not to end up with a completely overdamped and sluggish solution you need to be considering the rate of change of scale value ds/dt as well as the actual value s.

I like the idea of a automated 'go to location' but how will this integrate with EMC2 or Mach3 or are you planning to treat the stepper/scale combo as a big servo?