Project Help!!

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
robbo
Posts: 1
Joined: Fri Feb 20, 2009 10:57 am
Contact:

Project Help!!

Post by robbo »

Hi,

I'm working on a project for college using two sevro motors. I'm looking to control them using a PIC 16F84A and I'm having difficulty writing the progam. Can anyone help?

Thanks a million...

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Project Help!!

Post by Sean »

You need to be able to produce two accurate pulse outputs ranging from 1ms to 2ms (in experiments we found 0.7ms to 2.3ms could be used).

Each servo only requires one pulse every 20ms. These could be controlled simultaneously or sequentially depending on the timing functions being used. The remainder of the time is free for your main program to perform other tasks (sample control signals, drive displays etc.).

You will need to decide whether your program needs to use the hardware timer TMR0 to provide the timing functions (possibly involving interrupts), or if you can use program delay loops.

It would be useful to create a timer function that can generate a delay of 0 to 1ms (approx) when passed a parameter between 0 and 255 (approx 4us per count). This could be called twice for each servo: firstly to provide the initial 1ms delay, secondly to add the adjustable position control part of the signal.

Turning the servo control output on immediately before the first delay, and turning it off immediately after the second delay, should provide the required signal for each individual servo.

If the two servo control signals have been gnerated sequentially, there could be between 16ms and 18ms before the next set of control signals is required (this timing does not need to be as accurate as the individual position control pulse timings).

Post Reply