Threaded View
-
27-11-2013 #14
Can't you just connect the button to one of the interrupt-on-change pins and make that a high priority interrupt? That will allow you to break from the delay function and stop the motor. You could also use a timer based interrupt instead of the delay - just set the timer pre-scalars so it overflows every 5ms (or whatever you need) and enable the relevant interrupt bit. That way the PIC can do something useful instead of twiddling it's thumbs for 5ms.
By stop you presumably mean increment PR2 to decelerate the motor in a controlled manner, otherwise you risk loosing synchronization particularly if the load inertia or speed are high. If you want the motion to be smoother, then instead of using constant acceleration you could set the derivative of acceleration ('jerk') to be an s-curve like tanh(x):
To do that, either use the (approximate) equation for that function or a lookup table to calculate the required PR2 value each time the timer interrupt occurs. I don't know what the purpose of this project is so not sure if this is necessary, but it's more interesting ;)Last edited by Jonathan; 27-11-2013 at 12:02 PM.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
BUILD LOG: operation cnc
By kingcreaky in forum DIY Router Build LogsReplies: 174Last Post: 14-08-2013, 06:14 PM -
maximum deflection - sanity check
By dsc in forum Gantry/Router Machines & BuildingReplies: 6Last Post: 11-02-2013, 09:33 AM -
sanity check - constant running, loads and more
By dsc in forum Stepper & Servo MotorsReplies: 4Last Post: 26-11-2012, 12:26 PM -
Toroidal transformer voltages - sanity check needed!
By m_c in forum General ElectronicsReplies: 16Last Post: 03-10-2011, 08:34 PM -
I am questioning my sanity....
By irving2008 in forum General DiscussionReplies: 16Last Post: 11-02-2010, 01:15 PM
Bookmarks