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?
Synchronious servo throttle control
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Synchronious servo throttle control
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
H. Appeldorn
- Posts: 2
- Joined: Sun Oct 04, 2009 7:06 pm
Re: Synchronious servo throttle control
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
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
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Synchronious servo throttle control
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?
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;Martin