Servo position control

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
khaled yasin
Posts: 43
Joined: Sat Sep 13, 2008 10:36 pm
Contact:

Servo position control

Post by khaled yasin »

this is a servo position control program done by me....i don't know if it is correct so i hope someone check it for me and tell me if there is a mistake or and change that should be done...
the program will simply change the position of the servo when turning CW to turning CCW when reaching some defined position here is "100" just theoretically it means that it will reach 180 degrees in one position and then will go back and rotate another 180 degrees in the other side....any suggestions of how to develop this program???
do i have to use some kind of timer to avoid overflow because this program will keep timing like forever??
Attachments
Servo Position control.fcf
(4.5 KiB) Downloaded 348 times

chevy6600
Flowcode V4 User
Posts: 115
Joined: Fri Feb 22, 2008 6:38 pm
Contact:

Re: Servo position control

Post by chevy6600 »

Hi khaled yasin , i think you may need to start your PWM servo experimenting using the already available
programs from this forum, it is only my opinion mind you, i think your tackling your programing the wrong way ...too many jumps... using the program length to govern the speed of pulses etc.... I have put your program into proteus and took a screen grab of the oscilloscope. You can see that the timing is all wrong.
best of luck.
Attachments
screen grab1.jpg
screen grab1.jpg (109.5 KiB) Viewed 5842 times

khaled yasin
Posts: 43
Joined: Sat Sep 13, 2008 10:36 pm
Contact:

Re: Servo position control

Post by khaled yasin »

thank you for your help ....
but what do you mean by too many jumps?

chevy6600
Flowcode V4 User
Posts: 115
Joined: Fri Feb 22, 2008 6:38 pm
Contact:

Re: Servo position control

Post by chevy6600 »

Hi khaled yasini`m not saying that your program is not working because of too many jumps.
It is my understanding that if you can write programs without jumps, you would be writing better programs than those with jumps.
Are you aware that i wrote a program for servo control called `PWM engine for servo ` the link to it is here.
http://www.matrixmultimedia.com/mmforum ... 9667#p9667
I wrote it with a view to keep it as small and simple as possible.

khaled yasin
Posts: 43
Joined: Sat Sep 13, 2008 10:36 pm
Contact:

Re: Servo position control

Post by khaled yasin »

thanks again and yes i have seen your example PWM engine for a servo,am new to flow wcode and C-Pic programming but i try to understand more and more every day...actually i have a lot of questions that i want to ask about your example,i will again see it and try to understand how you wrote it,but i have a major problem which is that i use another pic type PIC16f877 and i need pin c1/c2 for PWM to be used for another task so i have to use another pins to control the servo....

khaled yasin
Posts: 43
Joined: Sat Sep 13, 2008 10:36 pm
Contact:

Re: Servo position control

Post by khaled yasin »

actually am building a fire fighting robot and i am facing a lot of problems in programming,,,,to see my robot outside design go to
http://letsmakerobots.com/frontpage/panel?page=0%2C7

second photo
look for "HOLY-HELL "A.F.F.R under the name khalchris

chevy6600
Flowcode V4 User
Posts: 115
Joined: Fri Feb 22, 2008 6:38 pm
Contact:

Re: Servo position control

Post by chevy6600 »

Hi khaled yasin just had a look at the web page you linked to, interesting stuff. I can see your problem using the capture/compare if you have already used the PWM function, i do not know what your using the pwm for but could you not use the servo pwm ?, as you would be able to use upto 8 servo pulses using my prog version. If your powering a motor with your pwm you could use one of the servo signals in my prog to power an `esc` from ` radio control electric's` to power the motor as your bound to use more circuitry to power the motor anyway.
Concerning the pic `877`, all you need do is download the data sheet from microchip and compare the registry words/addresses etc. with the 18f2620 data. It is also a valuable teaching source looking at the data sheets. I did not know how it was possible to program any microprocessor before i bought flowcode last February, i`m just a beginner. All you need to do is just read every thing
you can, i bought about Β£ 80 in books appart from browsing the internet, try to do one thing at a time....i see you ask about many things!....best of luck, i`m sure you will get there eventualy.

Post Reply