'#=========================================================================== '# UU UU LL RRRRR II CCCCC HH HH CCCCCCC (c) 2008 '# UU UU LL RR RR II CC HH HH CCC '# UU UU LL RRRRR II CC HHHHHH CC Christian Ulrich (UlrichC) '# UU UU LL RR RR II CC HH HH CC URL:http://www.UlrichC.de '# UU UU LL RR RR II CC HH HH CCC '# UUU LLLLLL RR RR II CCCCC HH HH CCCCCCC eMail:Info@UlrichC.de '#=========================================================================== '# CU-TEMPLATE (MC-Source) alias cu-template(someone).bas Version 0.01 '#--------------------------------------------------------------------------- '# COPYRIGHTS '# This source code of http://www.ulrichc.de/ is licensed under the GNU/GPL '# '# You can redistribute it and/or modify it under the terms of the '# GNU General Public License as published by the Free Software Foundation; '# either version 2 of the License, or (at your option) any later version. '# See http://www.gnu.org/ '# '# Author:Christian Ulrich,(Germany)76448 Durmersheim Lk Rastatt,06.05.2008 '#--------------------------------------------------------------------------- '#--------------------------------------------------------------------------- '# NOTE '#--------------------------------------------------------------------------- '# Dieses Programm beschreibt ... '# Die Source basiert auf BASCOM Basic. '#--------------------------------------------------------------------------- '# This program describes ... '# The source is based on BASCOM Basic. '#--------------------------------------------------------------------------- '=================================================================================== 'CONTROLLER HW SETTINGS '=================================================================================== '$regfile = "m8def.dat" 'AVR Mega 8 '$regfile = "m16def.dat" 'AVR Mega 16 $regfile = "m32def.dat" 'AVR Mega 32 '$framesize = 32 'Stack '$framesize = 68 '$framesize = 82 $framesize = 128 '$swstack = 32 'Software Stack '$swstack = 68 '$swstack = 82 $swstack = 128 '$hwstack = 32 'Hardware Stack '$hwstack = 62 '$hwstack = 82 $hwstack = 128 'CRYSTAL '--------------------- '$crystal = 1000000 'Quarzfrequence 1 Mhz (internal crystal) '$crystal = 4000000 'Quarzfrequence 4 Mhz '$crystal = 8000000 'Quarzfrequence 8 Mhz '$crystal = 14318180 'Quarzfrequence 14.31818 Mhz $crystal = 16000000 'Quarzfrequence 16 Mhz '=================================================================================== 'Programm Config '=================================================================================== '=================================================================================== 'Declarations Subs/Functions '=================================================================================== '=================================================================================== 'CONTROLLER PIN SETTINGS AND GLOBAL VARS '=================================================================================== Dim I As Word 'Ports für linken Motor Config Pinc.6 = Output 'Linker Motor Kanal 1 Config Pinc.7 = Output 'Linker Motor Kanal 2 Config Pind.4 = Output 'Linker Motor PWM 'Ports für rechten Motor Config Pinb.0 = Output 'Rechter Motor Kanal 1 Config Pinb.1 = Output 'Rechter Motor Kanal 2 Config Pind.5 = Output 'Rechter Motor PWM Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down Tccr1b = Tccr1b Or &H02 'Prescaler = 8 '================================================================= ' Programm '================================================================= START_UP: 'Linker Motor ein Portc.6 = 0 'bestimmt Richtung Portc.7 = 1 'bestimmt Richtung Portd.4 = 1 'Linker Motor EIN I = 0 Do Pwm1b = I Waitms 40 I = I + 5 Loop Until I > 1023 Wait 1 Do Pwm1b = I Waitms 40 I = I - 5 Loop Until I < 1 Pwm1b = 0 'Linker Motor aus Portc.6 = 1 'bestimmt Richtung Portc.7 = 0 'bestimmt Richtung I = 0 Do Pwm1b = I Waitms 40 I = I + 5 Loop Until I > 1023 Wait 1 Do Pwm1b = I Waitms 40 I = I - 5 Loop Until I < 1 Pwm1b = 0 'Linker Motor aus 'Rechter Motor ein Portb.0 = 1 'bestimmt Richtung rechter Motor Portb.1 = 0 'bestimmt Richtung rechter Motor Portd.5 = 1 'rechter Motor EIN I = 0 Do Pwm1a = I Waitms 40 I = I + 5 Loop Until I > 1023 Wait 1 Do Pwm1a = I Waitms 40 I = I - 5 Loop Until I < 1 Pwm1a = 0 'Linker Motor aus Portb.0 = 0 'bestimmt Richtung rechter Motor Portb.1 = 1 'bestimmt Richtung rechter Motor I = 0 Do Pwm1a = I Waitms 40 I = I + 5 Loop Until I > 1023 Wait 1 Do Pwm1a = I Waitms 40 I = I - 5 Loop Until I < 1 Pwm1a = 0 'Linker Motor aus I = 0 Do Pwm1a = I Pwm1b = I Waitms 40 I = I + 5 Loop Until I > 1023 Wait 1 Do Pwm1a = I Pwm1b = I Waitms 40 I = I - 5 Loop Until I < 1 Pwm1a = 0 'Linker Motor aus Portc.6 = 0 'bestimmt Richtung Portc.7 = 1 'bestimmt Richtung Portb.0 = 0 'bestimmt Richtung rechter Motor Portb.1 = 1 'bestimmt Richtung rechter Motor I = 0 Do Pwm1a = I Pwm1b = I Waitms 40 I = I + 5 Loop Until I > 1023 Wait 1 Do Pwm1a = I Pwm1b = I Waitms 40 I = I - 5 Loop Until I < 1 Pwm1a = 0 'Linker Motor aus goto START_UP End
News Blog:
Gerade online:3 - Heute insgesamt:443