Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Program for controlling analog servo motor using PIC18F452

Status
Not open for further replies.

SolaiKannan

Junior Member level 1
Joined
Jan 19, 2012
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,401
i have bought a new analog servo motor and i need to program it using microcode studio using pic 18f452.

can anyone provide me a simple program to control the servo
 

Re: Analog servo control

It doesn't matter if the servo is analog or digital.
The only signal that may vary is the PWM frequency.
To make it turn, you should supply pulses of ~50Hz with a pulse width from 1 to 2 milliseconds.
The pulse width controls the angle - 1.5ms is center.
 

Re: Analog servo control

this is my coding and i was not able to control the motor well.

Code:
define osc 20

OUTPUT PORTB.0 

LOOP:
    
    PULSOUT 0,110
    PAUSE 1000
    
    PULSOUT 0,120
    PAUSE 1000
    
    
    PULSOUT 0,130
    PAUSE 1000
    
    PULSOUT 0,140
    PAUSE 1000
    
    PULSOUT 0,150
    PAUSE 1000
    
    PULSOUT 0,160
    PAUSE 1000
    
     PULSOUT 0,170
    PAUSE 1000
    
     PULSOUT 0,180
    PAUSE 1000
                  
     PULSOUT 0,190    
    PAUSE 1000
    
    
     PULSOUT 0,200
     PAUSE 1000
    GOTO LOOP
END

Use CODE Tags (# Button) when posting your code.
 
Last edited by a moderator:

I am unfamiliar with Microcode Studio and its language syntax.

However if the PULSOUT statement generates a single pulse, this is the issue.

The PWM wave must be constantly repeated for the servo to maintain a position.

Try repeatedly generating a particular pulse for a few seconds, before changing the duty cycle and moving the servo to a new position.

BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top