so I built the adafruit motorshield
and its all working running this test code:
#include <AFMotor.h>
AF_Stepper motor(200, 1); // set up motor specs
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor.setSpeed(70); // set motor speed to 10 rpm
}
and I am using a 10K variable resistor
so reading the value from the analog pin will produce 1024 possible values
my stepper motor requires 200 steps to complete 1 revolution
the motor is going to open and close a turbo actuator, and from fully open to fully closed it requires about 9 revolutions of the motor shaft.
and I want the pot to control the position of the actuator, so as the reading on the analog pin the stepper steps forward, and if the value decreases the stepper steps back.
I plan to add two microswitches to act as feedback "stops" on either end of the actuator travel, but for now I am having trouble envisioning this code
should I build a linear relationship stepped "map"
that basically says..
pairs up a set of analog pin values with a stepper position
and based on the values from the last loop moved the stepper backward or forward. This method is going to be very sawtoothed
but will allow me to change the "curve" of the actuator action
weighting the bottom end of the scale or the middle etc..
or can a algorithm be written that evaluates all 1024 values for analogRead and moves the stepper within the pre-defined range:
9 complete revolutions (1800 steps) from open to close or 1.757 steps for every value read from analogRead
I have been searching for hours thru the forums trying to find a starting point.. :o