×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

C code to control servos

C code to control servos

C code to control servos

(OP)
Hello everyone,
I am traying to write a programe ro control the servo movement in the C language. If any of you has an idea about this please let me know. Thank you.

RE: C code to control servos

What do you want to know? What are you looking for?

RE: C code to control servos

(OP)
hey Til, how are you diong,
first of all thanks for replying to me. I want to know
thw exact commands to control the servos that are
attached to the HC11 ports. I attended to programe
these servos using interactive C but i discovered that
its not going to work. So i decided to use C language
and i spent two days researching the internet for C
commands with no luck. Can you send me these commands
please or a sample program so i can use it as a gaide.
Thank You
Moaweya

RE: C code to control servos

Well, I suppose you have your motor connected to a parallel port of the HC11 (let's say PORTB for this example).

You have to write to the port B with the proper value to control the proper bits in the proper order.

If you use the original configuration of the HC11, the port B is located at address 0x1004.

So, you define a 8 bit pointer variable to point to this address and you change the content of this pointer with the value you need.

function()
{
   volatile char *portBPtr = (volatile char *) 0x1004;

   ...
   *portBPtr = 0;     /* Clear all bits of port B */
   *portBPtr |= 0x4;  /* Set bit 2 of PORT B */
   *portBPtr |= 0x10; /* Set bit 4 of PORT B */
   *portBPtr &= ~0x4; /* Clear bit 2 of PORT B */
   *portBPtr &= ~0x10; /* Clear bit 4 of PORT B */
   ...
}

Hope it helps!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources