Catherine's Lab

Servo motors are not really friendly. -alex

JOO YOUN's 4th week

Nanna - Oops, sorry I realized I forgot to post things on the labs page. Everything I do gets continually documented in my journal: Nanna's Journal

min's analog out

Chris - I had a hard time getting my head around pulsing the servo motor. I got frustrated because I wanted to know what the pulse looked like and how the servo used the pulse. I broke out the oscilloscope and took a look. It was worth it. 5v's On or Off. I like oscilloscopes. I still don't know how the servo uses that pulse, exactly. I wired in a pot that determines the 'throw' of the motor - the closer to zero it is the bigger the throw, and the closer to 255, the less the motor moves. I also tried some PWM with LEDs?. I could get them to ramp up, but not in the right order/timing I was looking for. I focused too much on both pulsing the servo and PWMing? LEDs? that I didn't get to FREQOUT, which is a bummer. I wanted to make some tunes.

Shiu-Feng - hm....I need more time working with code... :( week4

===========================

- Rolf:

October 6, 2005

Analog Output: Servo Control using a potentiometer

Enclosed is the code and a diagram

Code:

DEFINE OSC 4

DEFINE adc_bits 8

define adc_clock 3 'internal clock

DEFINE adc_sampleus 20 'check input

adcon1 = %00000010

trisa = %11111111

OUTPUT portd.0

PulseWidth?? VAR BYTE 'info for the servo motor

PulseMax?? CON 250 '=180 degree

pulseMin CON 50 '= start at 0 degree

RefreshPeriod?? CON 20

adcVar VAR BYTE

ServoSpeed?? VAR BYTE

start:

HIGH portd.0

Pause 500

low portd.0

PAUSE 500

HIGH portd.0

PAUSE 500

LOW portd.0

PulseWidth?? = pulseMin

main:

ADCIN 0, adcVar

ServoSpeed?? = adcVar/16

LOW portd.1

PULSOUT portd.1, PulseWidth??

PAUSE RefreshPeriod??

IF PulseWidth?? > PulseMax?? THEN

    pulseWidth = pulseMin

ELSE

    PulseWidth?? = PulseWidth?? + ServoSpeed??

Endif

GOTO main

=====================================

Jury Hahn

Jury Hahn


Page last modified February 07, 2006, at 11:53 PM