|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#17
|
|||
|
|||
|
Re: Need help with PWM 1-2ms pulse control
on the software side, heres my take.
I read that you want to map the analog pot directly to the pwm out right, so heres what I'd do: pwm01 = Get_Analog_Value(rc_ana_in01) >> 2; Now for the question on having two "sets". Assuming you are getting full 10 bits range now and you want two sets char set = 1; // set to 0 for the other set, or hook a switch up to this variable. if(set == 1) { // 127 to 254 pwm01 = (Get_Analog_Value(rc_ana_in01) >> 3) + 127; } else { // 127 to 0 pwm01 = 127 - (Get_Analog_Value(rc_ana_in01) >> 3); } maybe you need to add some casting above but on overall it should be correct. Explanation: Get_Analog_Value(rc_ana_in01) >> 3 Previously it was '>> 2', because I'm doing a bit shift so that the range from 0-1023 becomes 0-254 (8bits) Now its >>3 as I'm sizing the range to 0-127 (7 bits) to be used in the calculation to scale set 1 (127 to 254) or set 2 (127 to 0). |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with operator control | d25inferno | Programming | 1 | 18-02-2008 11:36 |
| we need help with PWM problem in autonomous | steve d | Programming | 7 | 03-02-2008 12:46 |
| Help with automatic relay control | DRH2o | Programming | 5 | 23-01-2008 18:13 |
| We need help with joystick control | Team ICE #1611 | Control System | 4 | 24-01-2005 15:57 |
| hey need some help with writing a code please help me here | magical hands | Programming | 9 | 01-01-2004 21:46 |