[bascom] How to control RC servo motor with BASCOM-AVR?
From |
"Satz Pills" <satz@mailcityasia.com> |
Date |
Sun, 14 Jan 2001 15:10:04 +0800 |
Organization |
MailCity Asia (http://www.mailcityasia.lycos.com:80) |
Hi Albert,
If you're new to controlling r/c servos with uC ans Bascom,
may I suggest that you try the 'pulseout' command. You
use it taking into account the following characteristics of
r/c servos:
1. If no pulses are sent to the servo, it remains motionless
2. 1 & 2ms pulses move it to either end; 1.5ms to mid posn
3. Interpulse interval can be around 40ms
4. A pulse stream of 20 pulses is sufficient to move it to
the desired position.
The following code demonstrates the above. It causes 2
servos to oscillate end to end indefinitely. Pls also take
a look at the pulseout command in the help file.
$regfile = "2313def.dat"
$crystal = 3994370 '4MHz
Dim I As Byte , Pulsewidth As Integer , Switch As Bit
Config Portb = Output 'PORTB all output pins
Portb = 0 'all pins 0
Switch = 0
Do
Pulsewidth = 1000 : If Switch = 1 Then Pulsewidth = 2000
For I = 0 To 20 'Generate a 20-pulse pulsestream
Pulseout Portb , 0 , Pulsewidth 'Control servo on pin 0
Pulseout Portb , 1 , Pulsewidth 'Control servo on pin 1
Waitms 40 'Interpulse interval
Next
Switch = Not Switch
Waitms 100 'Wait a bit
Loop 'loop forever
-----Original Message-----
From: Albert Goodwill [mailto:albertgoodwill@yahoo.com]
Sent: Wednesday, 10 January 2001 11:44 PM
To: bascom@grote.net
Subject: [bascom] How to control RC servo motor with BASCOM-AVR?
Hi
Is there any publicly available code to control remote
control servo motor(s) (those used in model aircrafts,
small robots etc) in BASCOM-AVR?
I think RC servo motors use ??-2ms pulses. Is that
something that AVR's PWM function handels?
Any help please?
Thanks...
Get your FREE Email at http://www.mailcityasia.com