Welcome! Log In Create A New Profile

Advanced

Stop/Resume function?

Posted by Benni 
Stop/Resume function?
January 14, 2010 11:43AM
Hi,

I'm currently thinking of building a repstrap which should work with Servos. As I have an Arduino I want to use the original reprap firmware.
If you send a pulse to the stepperdrive the firmware knows that the stepper made one step! But if I use Servos i need a feedback that confirms the motor made his way. So i wanted to stop the firmware after the pulse for the stepper was sent to resume when i got the feedback from the encoder.
I wanted to use an Atmega or ATiny which controlls an Dual H-Bridge and the encoders, and then tells the actual motherboard to resume.

Is that possible or do you know other / better solutions?
Re: Stop/Resume function?
January 14, 2010 01:30PM
I don't think you want to wait for the pulse. What happens if the motor takes too long to reach your signal and you start losing bits on other encoders or dropping comms bytes, etc. Or the axis jams and now the firmware has to wait forever.

Typically, servos use some form of PID. The encoder gives you the current physical position; you record the target position you want the motor to reach, and adjust the signal to the motor to reduce that error as fast as possible.

See the Wikipedia entry on PID for the standard PID algorithm, with nice graphs to help visualize how it might work.

I've contemplated servos myself, and I think a reprap could probably get away with just the "P" portion of PID.
Re: Stop/Resume function?
January 14, 2010 04:59PM
I've created the new wiki page "Servo" for notes.
[objects.reprap.org]

Almost all of the wiki is world-edittable, so anyone reading this can have a go at editting it into shape.
Re: Stop/Resume function?
January 14, 2010 06:45PM
google "pid without a phd" for a nice article
Re: Stop/Resume function?
January 15, 2010 09:22AM
As I use an DC-motor with an rotary encoder which has no other electronics i have to implement all the stuff about the current position.

But I'm still having a question: If I use Servos which are controller via the P or PI technique I have to change the orignal reprap firmware not to send the step-pulses but the target position?Or should I buffer the step pulses?

Sorry for my bad english!
Re: Stop/Resume function?
January 15, 2010 10:44AM
You need to use the step pulses to increment or decrement a variable that represents the target position. You also use the shaft encoder to maintain another variable that is actual position. You feed the difference of these two variables into a PID algorithm and use the output to control the PWM and direction of the DC motor.


[www.hydraraptor.blogspot.com]
Re: Stop/Resume function?
January 15, 2010 12:14PM
Ah ok thanks. Now i got it -.-


But isn't it possible which this solution that the positioning of the X-Y-axis could be still in progress when the firmware puts the Z axis one stage up?

thanks for all your answers!
Re: Stop/Resume function?
January 15, 2010 12:26PM
>> But isn't it possible which this solution that the positioning of the X-Y-axis could be still in progress when the firmware puts the Z axis one stage up?

Yes. You treat your PID device as a stepper with minimim response delays to attain the target positions. You could also just code each motor with a 'ready' bit, and then advance to the next motor step configuration only when all motors indicate ready; something like:


LOOP FOREVER
  ...
  // Execute all logic to adjust the next target position for all servos,
  // but only if all servos have reported they are ready.
  IF motor_1_ready && motor_2_ready && ...
  THEN
    set_next_target_state_on_all_motors();

  // These will set the motor_X_ready bits to true if target achieved.
  perform_motor_1_PID();
  perform_motor_2_PID();
  perform_motor_3_PID();
  ...

END LOOP

Re: Stop/Resume function?
January 15, 2010 12:38PM
Quote
and then advance to the next motor step configuration only when all motors indicate ready

That was exactly what i ment by stopping and resuming. You guys helped me a lot! Thanks!
Re: Stop/Resume function?
January 15, 2010 01:56PM
One clarification here -- I listed the "is_motor_X_ready" technique as a sample.. there exist many other heuristics that have higher performance; In abstract, you want to move to the next state when some function returns 'true'. You might want to try a distance formula or cpu cycle counter.... I believe the current code uses timers for step durations; this simulates servos where you happen to know the exact duration of a 'step' and pretend to know how far that actually translated into a physical rotation.
Sorry, only registered users may post in this forum.

Click here to login