I think your verbal description is wrong. As written, your output is always driven by input 2.
How are you making the transition from pot position to pulsewidth? Analog or digital input?
How are you driving the output? Let's assume PULSOUT and further assume a 20 MHz clock for a 2 uSec PULSOUT step size.
Assuming two pots, their ends each connected to +5V and ground, with the wiper coming to analog inputs, then the input will be a word between 0 and 1023.
The output needs to be a word between 500 and 1000 centred on 750 to allow for the servo range of 1000 uSec to 2000 uSec with 2 uSec steps.
Psuedocode follows
Servo var portb.0 ' or whatever
Position1 var word
Position2 var word
Output var word
Start:
GetPot1Position:
read analog value where 512 = pot central
store in word variable Position1
GetPot2Position:
read analog value and store in word Position2
Width1 = (Position1 - 12)/2 'now in the range 0 to 506 with 250 = centre
Width2 = (Position2 - 12)/2 ' don't worry about the small offset
if (width1 < 248) OR (width1 > 252) then ' allow for non exact centering
output = width1 + 500
else
output = width2 + 500
endif
LOW servo ' VITAL you set servo to 0 beforehand - try not doing it!
PULSOUT pin, Output
pause 20
goto start
Bookmarks