|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
One line power
I got the insane urge to eliminate if statements. Having done that, i had the urge to eliminate statements in general. The result? One line of code per track to make it flip and reverse, rescale the sticks, and ramp the speed to reduce motor wear and tear.
creepbit =creep.bit7 creep = abs(127-creep) hold = lt lt = (254-rt -lt *creepbit + lt)*creep/127-creep+127 min (lth-Ramp_Speed) max (lth+Ramp_Speed) rt = (254-rt -hold *creepbit + rt)*creep/127-creep+127 min (rth-Ramp_Speed) max (rth+Ramp_Speed) rth = rt max (254-Ramp_Speed-1) min (Ramp_Speed+1) lth = lt max (254-Ramp_Speed-1) min (Ramp_Speed+1) sure, it has some maintainance code before hand, but it works. Creep is usually a wheel input. If it is full forward everything works normally. Full reverse will flip and reverse the tracks. Anything inbetween will rescale the tracks and possibly flip and reverse them too. Lastly, it will prvent motor burn. I got bored. So sue me |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sprockets and Roller Chain Models | Madison | Inventor | 3 | 04-02-2003 11:51 |
| iParts on firstcadlibrary.com | Ed Sparks | Inventor | 3 | 08-01-2003 23:30 |
| URGENT!! Need OI power brick specs for 7AM demo tomorrow!!! | kmcclary | Electrical | 8 | 10-10-2002 10:56 |
| power of globe motor with gear box? | Ken Leung | Motors | 5 | 21-11-2001 13:43 |
| Max mechanical power of motors, how is it useful? | Ken Leung | Motors | 1 | 09-11-2001 14:15 |