Page 1 of 1

Synchronious servo throttle control

Posted: Fri Mar 12, 2010 11:31 am
by H. Appeldorn
Since a vew months i m a user of Flowcode 4 (PIC). I ve started a project on a car engine V12 wich has two DC servo's for actuating the throttle. Important is that the throttle position of each valve is identic in course of motor damage.
Each of the 2 throtle motors has a position sensor (potentiometer)
There is a pedalposition potentiometer which gives the signal to the controler.

I ve configured with a PIC16F877a the A port (AD conversion) the pedalposition input and even the throttle position.
De difficulty i run into is that the range of the pedal position as even the throttleposition potmeters are not starting on zero, therefor the conversion to 8 bit will also not startin with "0"
This gives me difficulties in the calculation in order to let the throttle gain from "0"to "max"

Is there a possibillity to modify the range of the AD conversion so it would give a nice output?
Or must i develop a analog circuit in order to make the output voltage from the potentiometers from "0" to "5 volt"

Who can help me?

Re: Synchronious servo throttle control

Posted: Fri Mar 12, 2010 2:50 pm
by Benj
Hello,

If you need a nice output from the ADC then having the analogue voltage range of 0 - 5V is useful.

However if this is not possible then it is possible to use the VREF+ option by going into the Flowcode ADC component properties. The VREF+ pin will then need a fixed voltage to represent the maximum sample voltage eg 3V. the input will then be divided between 0 - 0V and 255 - reference voltage. Also note that the reference voltage should not go above 5V.

Some devices also have a VREF- pin that allows for a low reference to be added to represent 0. The Flowcode v4 ADC component cannot handle this but you should be able to use the code customisation to enable this feature in the C code.

The 16F877A has both the VREF+ and the VREF- pins available.

Re: Synchronious servo throttle control

Posted: Sun Mar 14, 2010 10:45 pm
by H. Appeldorn
Hello Ben,

Ok, i will try the Vref option and modify the calculations to define de "255" upper range level.
The suggested future optie to modify the C-code is for me not easy?
I understand from your writing that its possible to use on the PIC16F877 Vref+ and Vref- oututs to accomplisch a analog input range wich would fit the current senso outputs to a range biniar "0-255"?

Is there someone who can help me with this C-code item?

Sorry, my name is Henri

Re: Synchronious servo throttle control

Posted: Sun Mar 14, 2010 11:08 pm
by medelec35
This C code might work.Not tried it my self.
Just place C code block before Read ADC.
This code was suppose to be used with Flowcode V3 in place of sample ADC. Since Flowcode V4 does not have sample, perhaps someone who would know if this or a different
Solution word work?

Code: Select all

char ta, te, cnt;
adcon1 = 0x01;
ta = trisa;
trisa = trisa | 0x2F;
te = trise;
trise = trise | 0x07;
adcon0 = 0x81 | (0 << 3);
cnt =0;
while (cnt <40) cnt++;
adcon0 = adcon0 | 0x04;
while (adcon0 & 0x04) ;
trisa = ta;
trise = te;
adcon1 = 0x07;
adcon0 = 0x80;