So there are a wide variety of linear actuators from the automotive hot rod industry that are relatively cheap and powerful made by Autoloc. Here's the manual for one of their series:
http://www.truckshop.com/files/instructions/autoloc/LA.pdf
These can go from a couple inches to a foot or more and move several hundred pounds depending on model. There isn't any PWM control of them, however. But they do have built in hall effect sensors that appear to be a fairly high resolution. Biggest drawback is that there probably isn't a great way to control speed, they are what they are. But for my application, the speed is fine.
What I want is to connect one to an Arduino Leonardo and a motor shield. I'll use the relay circuit shown in the Autoloc manual and simply control the relays with the motor outputs (and that part is really already done anyway because we currently have this setup via manual control just like the manual). I've already tested connecting the hall effect sensor to an interrupt pin and using that to blink LED13 when the state changes (running the actuator manually with switches for now, NOT with the Arduino). From this, I can tell the hall effect sensor is pretty high resolution, but how high I'm not entirely sure. I thought maybe it would be something like 10 pulses per inch of movement, but it's a good bit higher than that. I don't think it's so high that we have to worry about the Arduino being fast enough to handle it, mind you, but the resolution is pretty good.
So what I want to do is end up with a serial interface to the actuator. My thought is that when the Arduino boots up the first thing it does is retract until the pulses stop for X amount of time (the actuator seems to have internal limit, as it certainly doesn't seem to mind you holding the button currently to retract with it fully retracted). That'll get it "home."
Then it extends until it stops extending for X amount of time and counts how many pulses it got. Now we have "distance." Then it retracts completely again to home.
Then it goes "ready." That probably means an output to the serial port saying "ready" or similar. Then it goes into command mode, where it waits for a command to move to a position. I'm thinking just an 8 bit position is fine, so basically you send it some number from 0-255 with a carriage return to terminate the command. It does the math and starts extending or retracting until it gets to the right position (based on the number of pulses). It then sends another message that the new position is complete and it's ready for another command.
So it needs some bounds checking, I think, since I doubt these pulses are going to be 100% perfect the same count from one end to the other every time, so it knows to just stop at the end and start the position count from scratch after no pulses for X amount of time.
This seems like it might be a pretty generic motion control kind of problem, but I've searched and haven't found anything that seemed terribly close. What I know is that while I know a little bit of programming in C, I'm NOT really a programmer. I'm pretty good at modifying things that are somewhat close, but when I look at things like how to use timers on the Arduino, my eyes start to glaze over a bit.
So anyone got any pointers to anything close? Or do I need to just start digging in with Nick's sample frequency counter code? That seemed to be the closest thing to the hard parts of this, but is a long way from everything.
--Donnie