12F675 + servo + analog command
Moderator: Benj
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
12F675 + servo + analog command
Hello;
I use flowcode V4 and I have "problem" with a servo, a 12F675 and an analog command.
I send my flowcode about the 12F675 to drive a servo with an analog command.
I use an analog signal 0/ 5 volts, but in the flowcode, I create an offset of 4 volts
this new analog signal is used to drive a servo via the Pic12F675.
I want :
0 ° rotation for 4 volts
10 % rotation for 4.1 volts
20 % rotation for 4.2 volts
...
...
90 % rotation for 4.9 volts
100 % rotation for 5 volts
I do not understand 2 points
- why my servo works from 4.4 volts and not from 4 volts ( 255 equal 5 volts ==> 200 equal 4 volts ?????)
- I have no plage to drive the servo.
Can you explain me, can you help me?
Thanks.
helesmes in France.
I use flowcode V4 and I have "problem" with a servo, a 12F675 and an analog command.
I send my flowcode about the 12F675 to drive a servo with an analog command.
I use an analog signal 0/ 5 volts, but in the flowcode, I create an offset of 4 volts
this new analog signal is used to drive a servo via the Pic12F675.
I want :
0 ° rotation for 4 volts
10 % rotation for 4.1 volts
20 % rotation for 4.2 volts
...
...
90 % rotation for 4.9 volts
100 % rotation for 5 volts
I do not understand 2 points
- why my servo works from 4.4 volts and not from 4 volts ( 255 equal 5 volts ==> 200 equal 4 volts ?????)
- I have no plage to drive the servo.
Can you explain me, can you help me?
Thanks.
helesmes in France.
- Attachments
-
- TRAVAIL_servomoteur_675.fcf
- (13 KiB) Downloaded 329 times
- 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: 12F675 + servo + analog command
Hello,
I have made some amendments to your file and it should now work as expected.
I have made some amendments to your file and it should now work as expected.
- Attachments
-
- TRAVAIL_servomoteur_675.fcf
- (8 KiB) Downloaded 347 times
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
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
Re: 12F675 + servo + analog command
benj; Thank you for this answer.
As you tell me, the servo works correctly, but this is the servo in Flowcode.
I meet an other problem, Flowcode does not allow me "to translate" the file in hexa, so I can not try with a real servo on the HP Board.
Thank you. helesmes;
As you tell me, the servo works correctly, but this is the servo in Flowcode.
I meet an other problem, Flowcode does not allow me "to translate" the file in hexa, so I can not try with a real servo on the HP Board.
Thank you. helesmes;
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
Re: 12F675 + servo + analog command
benj; Thank you for this answer.
As you tell me, the servo works correctly, but this is the servo in Flowcode.
I meet an other problem, Flowcode does not allow me "to translate" the file in hexa, so I can not try with a real servo on the HP Board.
Thank you. helesmes;
As you tell me, the servo works correctly, but this is the servo in Flowcode.
I meet an other problem, Flowcode does not allow me "to translate" the file in hexa, so I can not try with a real servo on the HP Board.
Thank you. helesmes;
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: 12F675 + servo + analog command
I thought you need two CCP channels for PWM. So It wont work with 12F675?
I created an article on driving a servo using timer0 instead of a servo component:
http://www.matrixmultimedia.com/article.php?a=435
Ideally if you have a chip that is capable, then it's much easier using the inbuilt servo component.
I can help you to get it working with 12F675 if you like?
Martin
I created an article on driving a servo using timer0 instead of a servo component:
http://www.matrixmultimedia.com/article.php?a=435
Ideally if you have a chip that is capable, then it's much easier using the inbuilt servo component.
I can help you to get it working with 12F675 if you like?
Martin
Martin
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
Re: 12F675 + servo + analog command
*********************************medelec35 wrote:I thought you need two CCP channels for PWM. So It wont work with 12F675?
I created an article on driving a servo using timer0 instead of a servo component:
http://www.matrixmultimedia.com/article.php?a=435
Ideally if you have a chip that is capable, then it's much easier using the inbuilt servo component.
I can help you to get it working with 12F675 if you like?
Martin
**********
*********************************
Martin, thank you for your answer.
I am going to try to adapt your flowcode for my problem with the 16F88.
But if you can find a chip which works with the pic 12F675, I thank you
Regards.
helesmes
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: 12F675 + servo + analog command
Hi helesmes,
Here's a flowchart that uses a 12F675 and 19.6609MHz crystal, since that what you have set your flowchart to.
0 and 4V will give a pulse duration of 1ms every 20ms.
>4 to 5V will give a pulse duration between 1.1mm and 2ms
This will not have the same resolution as either built in servo, or a target device that runs at 48MHz.
But I am working on one with a higher resolution for 12F675, and if it works I will post it when ready.
Martin
Here's a flowchart that uses a 12F675 and 19.6609MHz crystal, since that what you have set your flowchart to.
0 and 4V will give a pulse duration of 1ms every 20ms.
>4 to 5V will give a pulse duration between 1.1mm and 2ms
This will not have the same resolution as either built in servo, or a target device that runs at 48MHz.
But I am working on one with a higher resolution for 12F675, and if it works I will post it when ready.
Martin
- Attachments
-
- Servo Controller1 FC4 16F675.fcf
- (9.5 KiB) Downloaded 349 times
Martin
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
Re: 12F675 + servo + analog command
medelec35 wrote:Hi helesmes,
Here's a flowchart that uses a 12F675 and 19.6609MHz crystal, since that what you have set your flowchart to.
0 and 4V will give a pulse duration of 1ms every 20ms.
>4 to 5V will give a pulse duration between 1.1mm and 2ms
This will not have the same resolution as either built in servo, or a target device that runs at 48MHz.
But I am working on one with a higher resolution for 12F675, and if it works I will post it when ready.
Martin
Martin, thank you very much, I am going to try this flowchart.
Helesmes
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
Re: 12F675 + servo + analog command
hello Martin,
may I send you 2 flowchart?
in the first, ( base675 correcteplageservomoteur1)
the servo runs correctly,
when I fix "plage" with a value, the servo goes to his position, here
with "plage" = 40==> the position of the servo is "min
with "plage" = 140 ==> the position of the servo is max,
and I am "happy", I "solve" my problem.
**************
**************
But in the second ( envoi_disturb)
when I try to use an analog value, the servo does not run.
With the analog command, I choose the working:
analog value = 0 to 4 volts ==> servo is in position min
from 4 to 5 volts, the angle is divided in 20
so I try with one octet
5 volts ==> 255
from 0 to <4 volts, I put 40 in "plage"
4 volts ==> 204 ==> I put the value 40 in "plage" for the rotation
4.05 volts ==> 257 ==> I put the value 45 in "plage"
4.1 volts ==> 209 ==> value 30 in "plage"
etc to 5 volts ==> "plage" = 140.
Can you explain the place I make my "bug", I look for, but I do not find, I do not understand.
Thanks and regards.
helesmes.
may I send you 2 flowchart?
in the first, ( base675 correcteplageservomoteur1)
the servo runs correctly,
when I fix "plage" with a value, the servo goes to his position, here
with "plage" = 40==> the position of the servo is "min
with "plage" = 140 ==> the position of the servo is max,
and I am "happy", I "solve" my problem.
**************
**************
But in the second ( envoi_disturb)
when I try to use an analog value, the servo does not run.
With the analog command, I choose the working:
analog value = 0 to 4 volts ==> servo is in position min
from 4 to 5 volts, the angle is divided in 20
so I try with one octet
5 volts ==> 255
from 0 to <4 volts, I put 40 in "plage"
4 volts ==> 204 ==> I put the value 40 in "plage" for the rotation
4.05 volts ==> 257 ==> I put the value 45 in "plage"
4.1 volts ==> 209 ==> value 30 in "plage"
etc to 5 volts ==> "plage" = 140.
Can you explain the place I make my "bug", I look for, but I do not find, I do not understand.
Thanks and regards.
helesmes.
- Attachments
-
- envoi_disturb_12f675Flowcode1.fcf
- (14.99 KiB) Downloaded 341 times
-
- Flowcode v5 User
- Posts: 15
- Joined: Thu Dec 01, 2011 6:33 pm
- Location: France / Nord
- Has thanked: 3 times
Re: 12F675 + servo + analog command
hello Martin,
I send you the first flowchart which runs.
may I send you 2 flowchart?
in the first, ( base675 correcteplageservomoteur1)
the servo runs correctly,
when I fix "plage" with a value, the servo goes to his position, here
with "plage" = 40==> the position of the servo is "min
with "plage" = 140 ==> the position of the servo is max,
and I am "happy", I "solve" my problem.
**************
**************
But in the second ( envoi_disturb)
when I try to use an analog value, the servo does not run.
With the analog command, I choose the working:
analog value = 0 to 4 volts ==> servo is in position min
from 4 to 5 volts, the angle is divided in 20
so I try with one octet
5 volts ==> 255
from 0 to <4 volts, I put 40 in "plage"
4 volts ==> 204 ==> I put the value 40 in "plage" for the rotation
4.05 volts ==> 257 ==> I put the value 45 in "plage"
4.1 volts ==> 209 ==> value 30 in "plage"
etc to 5 volts ==> "plage" = 140.
Can you explain the place I make my "bug", I look for, but I do not find, I do not understand.
Thanks and regards.
helesmes.
I send you the first flowchart which runs.
may I send you 2 flowchart?
in the first, ( base675 correcteplageservomoteur1)
the servo runs correctly,
when I fix "plage" with a value, the servo goes to his position, here
with "plage" = 40==> the position of the servo is "min
with "plage" = 140 ==> the position of the servo is max,
and I am "happy", I "solve" my problem.
**************
**************
But in the second ( envoi_disturb)
when I try to use an analog value, the servo does not run.
With the analog command, I choose the working:
analog value = 0 to 4 volts ==> servo is in position min
from 4 to 5 volts, the angle is divided in 20
so I try with one octet
5 volts ==> 255
from 0 to <4 volts, I put 40 in "plage"
4 volts ==> 204 ==> I put the value 40 in "plage" for the rotation
4.05 volts ==> 257 ==> I put the value 45 in "plage"
4.1 volts ==> 209 ==> value 30 in "plage"
etc to 5 volts ==> "plage" = 140.
Can you explain the place I make my "bug", I look for, but I do not find, I do not understand.
Thanks and regards.
helesmes.
- Attachments
-
- base 675_correcte_plage_servomoteur1.fcf
- (6 KiB) Downloaded 340 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: 12F675 + servo + analog command
Hi helesmes,
I have corrected both of your flowcharts for you. The problem was you had the timer0 interrupt set at 1:64 which means the interrupt is accessed evey 3.3ms (300Hz). So evey 3.3ms port A0 goes high for just over 1 ms. A servo requires between 1 & 2 ms pulse every 20ms. So to get round this I have altered timer0 to 150Hz. In the timer0 interrupt macro there is a divide by 3:
So now port A0 is high every 20ms.
By the way I do like the different way you are controlling the servo.
Its something for me to remember.
Flowchart with ADC you may need to alter formula slightly since minimum pulse is 0.7 ms approx
Martin
I have corrected both of your flowcharts for you. The problem was you had the timer0 interrupt set at 1:64 which means the interrupt is accessed evey 3.3ms (300Hz). So evey 3.3ms port A0 goes high for just over 1 ms. A servo requires between 1 & 2 ms pulse every 20ms. So to get round this I have altered timer0 to 150Hz. In the timer0 interrupt macro there is a divide by 3:
Code: Select all
if count>=3
By the way I do like the different way you are controlling the servo.
Its something for me to remember.
Flowchart with ADC you may need to alter formula slightly since minimum pulse is 0.7 ms approx
Martin
- Attachments
-
- envoi_disturb_12f675Flowcode2.fcf
- (15 KiB) Downloaded 342 times
-
- base 675_correcte_plage_servomoteur2.fcf
- (6 KiB) Downloaded 333 times
Martin