PDA

View Full Version : Shifting with easyC


Erics626
01-24-2006, 06:11 PM
OK so here's my problem. Hopefully I explain to the best I can. We want to be able to shift our Dewalt transmissions attached to the CIM motors. We have a servo attached to the shifting plate of the transmission, and when the servo rotates, it shifts gear. Our default gear is second, and we have the servo set up so it is second gear at 127. We want the trigger button to up shift, and the thumb button to downshift. Our problem is that the transmission only switches gear when the trigger or thumb button are depressed. We want it so that when a trigger or thumb button is hit, it shifts gear and you do not have to hold the button down. Is there anyway to fix this. Any help would be appreciated. My email address is greendblink182@hotmail.com

Joe Johnson
01-24-2006, 06:58 PM
OK so here's my problem. Hopefully I explain to the best I can. We want to be able to shift our Dewalt transmissions attached to the CIM motors. We have a servo attached to the shifting plate of the transmission, and when the servo rotates, it shifts gear. Our default gear is second, and we have the servo set up so it is second gear at 127. We want the trigger button to up shift, and the thumb button to downshift. Our problem is that the transmission only switches gear when the trigger or thumb button are depressed. We want it so that when a trigger or thumb button is hit, it shifts gear and you do not have to hold the button down. Is there anyway to fix this. Any help would be appreciated. My email address is greendblink182@hotmail.com

I almost always have my switches work via edges not via states.

For example rather than:
If (switch==1) then PWMout = XXX else PWMout = YYY

I do this:
If (switchNow==1 and switchOld==0) then PWMout=XXX
Elseif (switchNow==0 and switchOld==1) then PWMout=YYY

The second case allows you to have other conditions change the state of the PWMout.

If you do things this way, what you want to do becomes trivial:
If (switchNow==1 and switchOld==0 and PWMout=XXX) then PWMout=YYY
Elseif (switchNow==1 and switchOld==0 and PWMout=YYY) then PWMout= XXX

The above pseudo code will allow you to use your switch to toggle between XXX & YYY states.

There are probably better ways to do this but I hope this will give you some idea of how it can be done.

Joe J.