. .

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #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):

    Click image for larger version. 

Name:	tanh_plot.gif 
Views:	3030 
Size:	2.5 KB 
ID:	10870

    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.
    Old router build log here. New router build log here. Lathe build log here.
    Electric motorbike project here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. BUILD LOG: operation cnc
    By kingcreaky in forum DIY Router Build Logs
    Replies: 174
    Last Post: 14-08-2013, 06:14 PM
  2. maximum deflection - sanity check
    By dsc in forum Gantry/Router Machines & Building
    Replies: 6
    Last Post: 11-02-2013, 09:33 AM
  3. sanity check - constant running, loads and more
    By dsc in forum Stepper & Servo Motors
    Replies: 4
    Last Post: 26-11-2012, 12:26 PM
  4. Toroidal transformer voltages - sanity check needed!
    By m_c in forum General Electronics
    Replies: 16
    Last Post: 03-10-2011, 08:34 PM
  5. I am questioning my sanity....
    By irving2008 in forum General Discussion
    Replies: 16
    Last Post: 11-02-2010, 01:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •