$crystal = 1000000 '******************************************************************************* '***** Servo Tester Program Version 1.0 **** '***** **** '***** By Earl Bollinger 10/20/2002 **** '***** **** '***** This program uses the BASCOM Basic Compiler **** '***** for Atmel AVR MCU's see www.mcselec.com for more **** '***** information about it. **** '***** **** '***** This program is for the Atmel AT90s2343 Risc MCU's (www.atmel.com)**** '***** It can be easily modified for other Atmel AVR chips. **** '***** For most AVR chips, changing the CPU clock speed and type **** '***** and adjusting the servo pulsewidth variables is all that is **** '***** needed. '***** **** '***** The program is setup to use the default 1mhz internal RC clock **** '***** option on the 2343 MCU. **** '***** PinB.4 is a dual purpose I/O pin depening on the **** '***** jumper, a LED indicator or a Servo Pulse signal output **** '***** PinB.0 is the fast or slow servo movement option **** '***** PinB.1 is the 1ms pulse option **** '***** PinB.2 is the 2,s pulse option **** '***** PinB.3 isn't used at this time, have a extra pin to do something **** '***** with, maybe a serial LCD, or a RCTimed potentiometer for **** '***** propotional testing purposes. **** '***** **** '***** Copyright 2002 DRPG Dallas Personal Robotics Group **** '***** licensed under the terms of the GNU GPL version 2 or later **** '******************************************************************************* Dim Servospeed As Integer Dim Negservospeed As Integer Dim I As Integer Dim Centerservo As Integer Dim Leftservo As Integer Dim Rightservo As Integer Config Pinb.4 = Output 'servo signal Config Pinb.0 = Input '2ms throw button Config Pinb.1 = Input '1ms throw button Config Pinb.2 = Input 'fast button Portb.4 = 0 Servospeed = 3 Negservospeed = -3 I = 0 Centerservo = 640 Rightservo = 430 Leftservo = 850 Wait 1 Loop: If Pinb.0 = 0 Then 'Slow Speed If Pinb.1 = 0 Then '1ms pulse out For I = Centerservo To Rightservo Step Negservospeed Pulseout Portb , 4 , I Waitms 20 Next End If If Pinb.2 = 0 Then For I = Centerservo To Leftservo Step Servospeed Pulseout Portb , 4 , I Waitms 20 Next End If If Pinb.1 = 1 And Pinb.2 = 1 Then Pulseout Portb , 4 , Centerservo Waitms 20 End If Else 'Fast speed If Pinb.1 = 0 Then '1ms pulses Pulseout Portb , 4 , Rightservo Waitms 20 End If If Pinb.2 = 0 Then Pulseout Portb , 4 , Leftservo '2ms pulses Waitms 20 End If If Pinb.1 = 1 And Pinb.2 = 1 Then '1.5ms pulses Pulseout Portb , 4 , Centerservo Waitms 20 End If End If Goto Loop End 'end program