Helmutt
- 9th March 2008, 08:54
1st off I would like to say thank you to all for these forums, It has helped me solve many many issues so far.
I am new to the PIC world but have made leaps and bounds so far.
Ok. What I am trying to do is control the limits of a servo based on the position of two pots. To give a whole over view of the application I am trying to make a replacement power valve controller for a 2 stroke motorcycle. This being my 1st real Pic project, Im having more than my fare share of issues, but working through them, so any help is greatly appreciated.
Im trying to use 16f690 chip because I think I need the AD converter to handle the pot command.
But so the simplified version of the code I am going with is. I am still struggling with the RPM pick up, but one problem at a time. I am replacing the RPM input with a simple low high switch to help simplify testing. I know this isn't the fastest code method due to the pulse pause, but... It should be well quick enough.
Servo VAR Portc.5 'The servo being used is a Futaba Digital RC Servo.
Scale VAR Byte
Pulse VAR Byte
RinTot VAR Porta.2
Potin VAR Porta.4
potvar VAR Byte
RPMin VAR portc.4
RPM VAR Word
POT RinTOT, 255, Scale 'According to docs. By setting the scale to 255, then useing the max resistance of the pot it will give a correct scale? Store this on start up to use later.
Loop:
POT Potin, Scale, potvar
IF RPMin=1 THEN
PULSOUT Servo, potvar 'I should only get a useable value between 100-200, so effectively limiting my pot, through, I droped the scaling until I could get this fixed.
PAUSE 18 'The pause for the servo input.
ELSE
PULSOUT Servo, 100 'Go back to the lowest pulse position.
PAUSE 18
ENDIF
GOTO Loop
END
Ok so I get servo active and locked, if I change it to go to a fixed pulse time on RPM press it works. But once the pot is added in I get nothing. I am probably making a really dumb mistake. So if you do help, Thank you.
I have read so many different ways of doing this I am very very lost now. I tried some functions with the A/D converters but didn't get very far. Then I read many different approaches to converting the Pot to something useable. Tried some plug and drop in methods, with other code.. So maybe its my way of wiring. Both of my reference books I use have two totally different ways of doing it. So I'm very very confused now. SO again Thank you.
I drew how I was wiring the pot in if I am screwing that up as well :(, But I am horrible at drawing on a computer so its pretty rough, but gives the idea.
Thank you all so very much for even taking the time to look at this.
I am new to the PIC world but have made leaps and bounds so far.
Ok. What I am trying to do is control the limits of a servo based on the position of two pots. To give a whole over view of the application I am trying to make a replacement power valve controller for a 2 stroke motorcycle. This being my 1st real Pic project, Im having more than my fare share of issues, but working through them, so any help is greatly appreciated.
Im trying to use 16f690 chip because I think I need the AD converter to handle the pot command.
But so the simplified version of the code I am going with is. I am still struggling with the RPM pick up, but one problem at a time. I am replacing the RPM input with a simple low high switch to help simplify testing. I know this isn't the fastest code method due to the pulse pause, but... It should be well quick enough.
Servo VAR Portc.5 'The servo being used is a Futaba Digital RC Servo.
Scale VAR Byte
Pulse VAR Byte
RinTot VAR Porta.2
Potin VAR Porta.4
potvar VAR Byte
RPMin VAR portc.4
RPM VAR Word
POT RinTOT, 255, Scale 'According to docs. By setting the scale to 255, then useing the max resistance of the pot it will give a correct scale? Store this on start up to use later.
Loop:
POT Potin, Scale, potvar
IF RPMin=1 THEN
PULSOUT Servo, potvar 'I should only get a useable value between 100-200, so effectively limiting my pot, through, I droped the scaling until I could get this fixed.
PAUSE 18 'The pause for the servo input.
ELSE
PULSOUT Servo, 100 'Go back to the lowest pulse position.
PAUSE 18
ENDIF
GOTO Loop
END
Ok so I get servo active and locked, if I change it to go to a fixed pulse time on RPM press it works. But once the pot is added in I get nothing. I am probably making a really dumb mistake. So if you do help, Thank you.
I have read so many different ways of doing this I am very very lost now. I tried some functions with the A/D converters but didn't get very far. Then I read many different approaches to converting the Pot to something useable. Tried some plug and drop in methods, with other code.. So maybe its my way of wiring. Both of my reference books I use have two totally different ways of doing it. So I'm very very confused now. SO again Thank you.
I drew how I was wiring the pot in if I am screwing that up as well :(, But I am horrible at drawing on a computer so its pretty rough, but gives the idea.
Thank you all so very much for even taking the time to look at this.