View Single Post
  #5   Spotlight this post!  
Unread 25-02-2004, 11:05
Phil_Lutz's Avatar
Phil_Lutz Phil_Lutz is offline
Phil Lutz
#0851 (Froggers)
Team Role: Mentor
 
Join Date: Jan 2004
Location: El Segundo, CA
Posts: 67
Phil_Lutz is on a distinguished road
Send a message via Yahoo to Phil_Lutz
Re: Using a switch to control a PWM

If the servo is "twitching" just on the startup of the code then you are okay.
This is just the servo going to it's initial position.

If the Servo is always twitching it might be a low backup battery.

For a transmission shifter you are best to have it on one switch.
0=low gear, 1=high gear

Also, make sure to stop the motorfor a few loops before shifting, and start the motors back up (to selected speed) after th3e servo has had a chance to move.

The psuedocode would look like this

Code:
// Motor speed 160 In Low Gear
Shift button changed  // have static store last value
Store Motor Speed     // in static for later use
Stop Motor               // 127, neutral
Move Servo    // 0-254 or 254-0  
  count loops for 10 (.2 secs, servo moves full throw in .11)
Start Motor
// Shift on the fly, You got to love it
Setup #defines to track the various points in the shift and switch/case through the shift process.

Hope this helps.

Phil

Last edited by Phil_Lutz : 25-02-2004 at 11:13. Reason: change text