well i am working with a servo stepper motor circuit (a very old one, i am talking about 80's).
Its got two inputs:
Step Signal to control speed that i can bypass, the circuit has internal 200hz step signal generator to move motor at a speed
digital input (if high motor moves CW else CCW)
The motor is attached to a pressure control valve with a pressure sensor, and i can read the pressure. Now the problem is i need to set a particular pressure using motor. With pressure sensor i can get the pressure but i cannot get the location of motor or map pressure to motor position as pressure is not directly proportional to motor position and i want motor to stop at near accurate pressure. I may need a PID controller can any body help me out.
A PID control is when there are many influences from outside and the output signal has influence on the sensor reading.
When your pressure is always the same for a certain servo rotation, you can use the data from the graphs and do some curve fitting.
There is an article somewhere to use a list with a few samples. I think it is this one: Arduino Playground - MultiMap
Are you sure it is a servo ?
One signal is for CW and CCW, and the other for the number of steps ? I think it is a stepper motor.
If its got a step+direction interface it could be a stepper or a servo, but that's
not important since the problem you have to solve is the same.
I'd say go with PID if you want to match the measured pressure to a programmed
pressure. Given the fairly wide variation in response slope you'll need to compromise
with the PID factors (perhaps just P+modest I factor) to avoid instability. If the
system doesn't have to respond rapidly it will be easier to get working satisfactorily.
The output signal has to be converted into a step-rate, which suggests a simple DDS
(direct digital synthesis) approach:
int phase ; // DDS accumulator
int frequency ; // DDS rate
void set_output (int value) // output of PID drives this
{
frequency = map (value, MAX_OUT, -MAX_OUT, MAX_FREQ, -MAX_FREQ) ;
}
void loop ()
{
..
int oldphase = phase ;
phase += frequency ;
digitalWrite (direction_pin, frequency < 0) ;
if ((phase ^ old_phase) < 0) // detect roll-over by top bit changing
{
digitalWrite (step_pin, HIGH) ;
delayMicroseconds (10) ;
digitalWrite (step_pin, LOW) ;
}
delay (1) ; // allows max step rate of ~1kHz, corresponding to frequency == 0x8000
..
}
MarkT:
If its got a step+direction interface it could be a stepper or a servo, but that's
not important since the problem you have to solve is the same.
I'd say go with PID if you want to match the measured pressure to a programmed
pressure. Given the fairly wide variation in response slope you'll need to compromise
with the PID factors (perhaps just P+modest I factor) to avoid instability. If the
system doesn't have to respond rapidly it will be easier to get working satisfactorily.
The output signal has to be converted into a step-rate, which suggests a simple DDS
(direct digital synthesis) approach:
int phase ; // DDS accumulator
int frequency ; // DDS rate
void set_output (int value) // output of PID drives this
{
frequency = map (value, MAX_OUT, -MAX_OUT, MAX_FREQ, -MAX_FREQ) ;
}
void loop ()
{
..
int oldphase = phase ;
phase += frequency ;
digitalWrite (direction_pin, frequency < 0) ;
if ((phase ^ old_phase) < 0) // detect roll-over by top bit changing
{
digitalWrite (step_pin, HIGH) ;
delayMicroseconds (10) ;
digitalWrite (step_pin, LOW) ;
}
delay (1) ; // allows max step rate of ~1kHz, corresponding to frequency == 0x8000
..
}
Thanks Mark, i was looking for something like that. let me implement your technique.
I previously used Double tables but the results are not that accurate, some times error is greater than 2psi and i wanted something more accurate. Moreover it is really hard to match pressure up to 3 decimal places.