Linear Actuator Position Control

Oh, and I'll add this. I think I outlined a system with too much logic on the Arduino (not that it can't be done, just that it doesn't need to be). I think it should probably be a bit more simple. Something like:

Power up, await command.

Initialize command does:
. Full retract
. Full extend, counting pulses
. Full retract, counting pulses
. Compare and maybe average the pulse count, return count or return error if difference is more than some threshold

Extend X pulses:
. bounds check to make sure command can be completed, return error if not (or maybe just fully extend and return fully extended state)
. extend until pulse count reached
. return amount extended

Retract X pulses:
. same as above the other direction

Fully extend (why not?):
. obvious

Fully retract:
. obvious

I think that simplifies the code greatly. I think the only part I don't feel comfortable with is using a timer to interrupt the "action" and return an error or know when we're fully extended or retracted. But I think even that part I can probably figure out. So unless someone knows of code out there to do this (which is seeming unlikely), I'll start working on it in the next couple days and just post my progress as I go.

Anyway, the above will let the real control software (which will be on a connected PC of some kind) know the "distance" in pulses in the initialize phase and it can have some calibration from there (like you input the distance the thing can travel physically) and just do the math on that end for how much it wants the thing to raise and lower.

To fill in the last gap, what this is going to do is raise and lower the front end of a bicycle trainer to simulate climbing. It's actually quite common when spinning indoor on a "real" bike that's attached to a rear wheel trainer to elevate the front end to simulate climbing during intervals because you do change slightly the way you engage muscles as the bike tilts under your body. And there are computer control programs that can change trainer resistance on the fly (TrainerRoad.com, for one, and Golden Cheetah for an open source solution), so I want to add the ability to let it also change the incline of the bike if you so choose.

--Donnie