Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Servo motion control with pic

Status
Not open for further replies.

g_canoglu

New Member
Hello Electronics community:

I am new in here if you haven't noticed :p. I am building a line following robot as a project for one of my classes. I was using a simple DC motor and a pic18f452. I programmed it and everything, in the end found out that the motors did not have enough torque. Now i learned that i could use servo motors to do the job. I researched about the motors and found out that its not just +V and ground. There is a control wire where pulses are sent through. Now i have to modify the code that i already have to suit the servos, just wondering how i would be able to achieve the pulses that im supposed to send. I am programming it in assembly, although i do have a lil knowledge of c i would like to keep to code in assembly for now. If anyone could help me by showing a sample code or guide me to a direction that'd be great.

PS: I was searching through the forums, damn there is alot of people building line followers.
 
1.RC Servo DC motor is simpler than DC motor if you want to control its position (because RC servo is made for this appliance).
2. RC servo DC motor has 3 wire (isn't it?): VCC,GND,and SIGN. VCC and GND is connected directly to your power source, no more to talk about it.
3. SIGN wire: if you supply it with a pulse (by a PWM module), the motor's position is control by the frequency (or the period) of the PWM pulse.
4. Just make a search on Google about RC servo motor control, you will find all.
 
It is unclear whether you intend to use the model servo motors for drive or for control, this is, steering. For steering, they should work fine without modification, as wonbinbk suggests. For drive, you will need to be aware that their rotation is physically limited to about 100 to 120 degrees. The stop can be removed, but then you need to deal with the feedback pot, which also limits rotation. I believe you will find some references on using the motors as drive motors, for example by replacing the feedback pot with a fixed resistor. Good luck.
 
Yes, im intending on using it as a driving motor and im also aware of the limitations of the unmodified servo. I needed help with programming. Like if 1.5ms pulse is the centre position and 2 ms pulse makes the motor turn continuously forward, what is the code that would generate the 2ms pulse. I got a book on this pic but it really is not clear at all:mad: . Just the pulse itself i got the rest of the program pretty much.
 
I am not familiar with programming the 18F452. However, virtually every tutorial I have seen for assembly gives an example for coding a PWM and/or servo. It is usually done by setting a pin high (bsf), delay loop, set pin low (bcf), delay loop, and then looping continuously or until some other event. It can also be done with the PWM hardware in some devices, and that process is more device specific. If you do not have a tutorial for your specific chip, I suggest that you look for servo examples done on the 16F84 or 16F628 chips. Regards.
 
I think ur problem is about PIC programming rite..so I think u will consider the programming language that u wanna used..I think better u look to PIC BASIC langguage it is better and easy..for servo controller u only need to set the PWM or pulses to the servo..

for more info about PIC BASIC..try this
www.melabs.com
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top