PIC and Servos

Dear Group,

I have a question. I am building a robot with 12 Servo motors from Hitec; type HITEC-311. Yesterday, I programmed a PIC 16F84A 20 MHz and put it inside of a breadboard to control these 12 servos and I saw that sometimes some servos don't respond to commands, just move slightly to the clockwise side. I thought it might be because of the contacts and I made a PCB board this morning and I soldered everything fine and I saw the same effect again. I replaced the servos with other and the problem isn't in servos. I don't know what can it be? Did anybody on the group have same problems as I? I assumed the PIC but I changed it and same problems accure! Can it be because it hasn't to much current for all 12 servos for the signal?? I appreciate any help.

Thank you very much

Best regards, Refik Hadzialic

Reply to
Refik Hadzialic
Loading thread data ...

btw. I use a 6V 5000 mAh rechargeable NiCd battery. The battery is ok

Reply to
Refik Hadzialic

How about you post a link to your schematic and code. OK??

My car is not work> Dear Group,

Reply to
hamilton

Sorry pal :)

Thx, Here is the schematic url

formatting link
(the schematic isn't really the best but you will understand it). Everything should be wired fine because just one servo from 12 moves slightly..

Here is the code: 'DEFINE OSCILLATOR DEFINE OSC 20 'DEFINE LEFT LEGS SYMBOL LM1 = PORTB.0 SYMBOL LM2 = PORTB.1 SYMBOL LM3 = PORTB.2 SYMBOL LU1 = PORTB.3 SYMBOL LU2 = PORTB.4 SYMBOL LU3 = PORTB.5

'DEFINE RIGHT LEGS SYMBOL RS1 = PORTB.6 SYMBOL RS2 = PORTB.7 SYMBOL RS3 = PORTA.0 SYMBOL RU1 = PORTA.1 SYMBOL RU2 = PORTA.2 SYMBOL RU3 = PORTA.3 MAIN: PULSOUT LM1, 450 PULSOUT LM2, 450 PULSOUT LM3, 450 PULSOUT LU1, 450 PULSOUT LU2, 450 PULSOUT LU3, 450

PULSOUT RS1, 450 PULSOUT RS2, 450 PULSOUT RS3, 450 PULSOUT RU1, 450 PULSOUT RU2, 450 PULSOUT RU3, 450 PAUSE 9 GOTO MAIN END

Thank you Best regards, Refik

Reply to
Refik Hadzialic

hiya,

are your signals correct? some outputs of PIC processors are open- collector and need a pull up to function. furthermore, can you rewrite the program to shut the problems out one by one? debugging 12 of them at the same time can be a real PITA

greetz

fripster

Reply to
Fripster

Do you have something to drive those servos? Leaving the signal from the PIC to try to power the motors is a rather tall order and almost certainly requires more current than the PIC can source.

---Keith Lehman University of Wisconsin - Milwaukee

Reply to
Keith Lehman

Reply to
Refik Hadzialic

Reply to
Refik Hadzialic

Ahhh,

What language is this ?????

What is a PULSOUT ???

You are correct, the schematic is lousy.

Refik Hadzialic wrote:

Reply to
hamilton

I assume you're using one of the PicBasic compilers since you're using PULSOUT to control your servos. You need to setup a loop that will apply pulses to each servo, and keep pulses on the servo for a longer duration.

@ 20MHz PULSOUT has a resolution of ~2uS. If you're using PicBasic, then you'll also want to setup the pulse for logic 1 or logic 0 by first setting or clearing each pin used with PULSOUT.

PULSOUT works by toggling the I/O-pin twice, so the initial state of the pin determines the polarity of the pulse.

I.E.

LOW RS1 ' Clear RS1 output pin PULSOUT RS1, 450 ' Output a high going pulse on RS1 for 450 x 2uS

This creates a single 900uS high going pulse out on RS1 by toggling RS1 from low to high, then back low.

Your code as-is moves on to pulse the next servo too quickly to have any noticeable affect on a previous servo since It leaves too big a gap between pulse updates. You need roughly a 50-60Hz update time.

Your code as-is

Example; __________ | | PULSOUT RS1, 450 ----------| 900uS |----------------900us x 11 more servos = 9.9mS before pulsing RS1 again.

Almost 10mS before you pulse each servo.

You probably aren't going to reliably control 12 servos simultaneously using PicBasic and a 20MHz clock.

Have a look in our Micro-Bot section at the link below for servo control routines.

formatting link
This bot uses only two servos, but the code is all in PicBasic Pro, and will give you an idea how it works. There's a table at the bottom of the page showing PULSOUT resolution for different clock speeds.

You can find code examples & schematics for IR navigation, servo control, sonar range finding, remote control, hardware PWM, distance measurement, and a few more by clicking on the Back to Index links on the same page.

Hope this helps.

Regards,

-Bruce snipped-for-privacy@rentron.com

formatting link

Reply to
<tech

Pulsout sends HIGH to the pin if it was low, if it was high it sends low. The time you depend so(PULSOUT LM1, 450) 450 * 2 us because i use an OSC of

20 MHz! Bruce explained it under your post better than I.

Reply to
Refik Hadzialic

Yup, I use PBP. Thx for the code. I will try it out and play with it I hope I will solve it somehow :)

Thank you Bruce very much

Reply to
Refik Hadzialic

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.