'**************************************************************** '* Name : FartingSkeleton.pbp * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 2015-08-13 * '* Version : 1.0 * '* Notes : * '* : * 'PIC16F690 ' @ ERRORLEVEL -306 ; turn off crossing page boundary message #IF __PROCESSOR__ = "16F690" #CONFIG cfg1 = _INTRC_OSC_NOCLKOUT ; Internal oscillator: I/O function on RA4/RA5 ;cfg1 = _FOSC_HS ; External oscillator: I/O function on RA4/RA5 cfg1 &= _WDT_OFF ; Watch Dog Timer Disabled cfg1 &= _PWRTE_OFF ; Power-up Timer Disabled ;cfg1 &= _MCLRE_OFF ; Master Clear Reset Disabled cfg1 &= _CP_OFF ; Program memory code protection is disabled cfg1 &= _CPD_OFF ; Data memory code protection is disabled ;cfg1 &= _BOD_ON ; Brown-out Detect Enabled ;cfg1 &= _IESO_OFF ; Internal External Switchover mode is disabled ;cfg1 &= _FCMEN_OFF ; Fail-Safe Clock Monitor is disabled __CONFIG cfg1 ; Set the configuration bits #ENDCONFIG #ELSE #MSG "Wrong Processor selected!" #ENDIF DEFINE OSC 8 DEFINE NO_CLRWDT 1 ' Don't waste cycles clearing WDT DEFINE WRITE_INT 1 Clear ' Clear RAM before entry '----[ Oscillator control ]------------------------------------------------------- OSCCON = OSCCON | %01110000 ' Include "modedefs.bas" INCLUDE "FartingSkeleton_Decl.pbp" INCLUDE "..\..\_Include\WTV020_Base.pbp" INCLUDE "FartingSkeleton_Init.pbp" pause 1000 HSEROUT [13, 10, "FartingSkeleton", 13, 10] HSEROUT ["Rst, BusyPin=", dec WTV020_BusyPin, 13, 10] gosub WTV020_Reset HSEROUT ["pause...", 13, 10] pause 1000 HSEROUT ["Ready!", 13, 10] 'Servo1 = SRV_MIN 'GOSUB SetServos 'pause 2000 FartPtr = 1 main: WTV020_CMD = FartPtr HSEROUT ["Play #", dec WTV020_CMD, 13, 10] gosub WTV020_Play ' gosub Shake ' pause 1000 pause 1000 FartPtr = FartPtr + 1 if FartPtr > 8 then FartPtr = 1 HSEROUT ["rollover!", 13, 10] pause 1000 endif goto main end '============Subroutines======================================================== '----[Convert Position in degrees to dutycycle]----------------------------- SetServos: ' Set Servo's dutycycles TMR1IE = 0 ' no ints during variable update TempW = Servo1 * CONST_1ms TempW = DIV32 POS_RANGE + CONST_1ms DutyHold1 = TempW TMR1IE = 1 RETURN Shake: Servo1 = SRV_MAX GOSUB SetServos pause 100 Servo1 = SRV_MIN GOSUB SetServos pause 100 Servo1 = SRV_MAX GOSUB SetServos pause 100 Servo1 = SRV_MIN GOSUB SetServos pause 100 Servo1 = SRV_MAX GOSUB SetServos pause 100 Servo1 = SRV_MIN GOSUB SetServos RETURN