So, ich bin fündig geworden:
Da gab's ein Prog von Jan-Peter Müller (LCD_DCFUhrsuche1_1.bas) für den RP5 mit Erweiterungsplatine (aber ohne CC2!):
Code:
' Jan-Peter Müller
' 28.12.2003
' DCFUhrsuche V 1.1
'
'
' --------------------------------------------------------------------------
' FUNKTION DES PROGRAMMS
' --------------------------------------------------------------------------
' Beispiel 1
' Robby wird hingestellt, und sucht sich das DCF-Signal selbstständig.
'
' Meine Messungen haben ergeben , dass das DCF-Modul von Conrad
' Best.-Nr.:641138 einen Erfassungsbereich von 60 Grad hat.
'
' Da Robby sich ja drehen kann , sucht er alleine das Signal !
'
' Achtung kann bis zu 20 Minuten dauern !!!!!!!!!!!!!!!!!!!!!!!!!
'
' Abruch nach 24 Minuten (evtl. kein Empfang)
'
' Anzeige der Minuten über LED 1...8 , auf der Erweiterungsplatine
' pro Minute ein LED
'
'---------------------------------------------------------------------------
'Hardware:
' Robby
' Erweiterungsplatine
' Experimentierplatine
' DCF-Modul Best.-Nr.:641138
'
'Achtung DCF-Modul im Abstand von ca. 5 cm montieren zur Experimentierplatine
' , sonst kein Empfang !!!!!!!!!!!!!!!!!!
'
'-----------------------------------------------------------------------
'RESOURCEN:
'Sie finden in allen Beispielen sämtliche Systemroutinen die zum Betrieb des
'Roboters notwendig sind.
'----------------------------------------------------------------------------
'--------------------------
'------ I/O PORTS ---------
'--------------------------
'- INTERFACE LCD/EXTPORT --
define sdio port[1]
define sclio port[3]
define strobe port[4]
define LSTROBE port[7]
'-- INTERFACE COM/NAV -----
define DATALINE port[1]
define CLOCKLINE port[2]
'-- CC2 INTERFACE -------
define CC2POWER port[8]
'------ LCD INTERFACE ------
define lcd_port byteport[2]
define lcd_rs port[14]
define lcd_rw port[13]
define lcd_e port[15]
'--------------------------
'------ SENSORS ---------
'--------------------------
define LIGHT_L ad[7]
define LIGHT_R ad[6]
define SYS_VOLTS ad[3]
define CHRG_CURRENT ad[2]
define SYS_CURRENT ad[1]
define MIC ad[4]
define TOUCH ad[5]
'---------------------------
'------ DRIVE -------------
'---------------------------
define SPEED_L da[1]
define SPEED_R da[2]
define REV_L port[6]
define REV_R port[5]
'--------------------------
'---- SYSTEM MEMORY -------
'--------------------------
'--- INTERFACE BUFFER ----
define LBYTE byte[1]
define HBYTE byte[2]
define SUBCMD byte[3]
'---- OPERATION DATA ------
define EXTPORT byte[4]
define LED1_F bit[29]
define LED2_F bit[30]
define LED3_F bit[31]
define LED4_F bit[32]
define SYSTEM_STATUS byte[5]
define LEDPORT byte[6]
define L1_F bit[41]
define L2_F bit[42]
define L3_F bit[43]
define L4_F bit[44]
define L5_F bit[45]
define L6_F bit[46]
define L7_F bit[47]
define L8_F bit[48]
'---- LCD DRIVER -------------
define lcd_buf byte[7]
define lcd_param byte[8]
'--------------------------
'---- USER MEMORY -------
'--------------------------
'--- BIN-DEZIMAL-CONVERTER ---
define hunderter byte [10]
define zehner byte[11]
define einer byte[12]
define value byte[13]
define minutealt byte [14]
'--- SYSTEMROUTINEN -----------
define PLM_SLOW &H01C2
define SYSTEM &H01C7
define LED_DRIVE &H01CA
define COMNAV &H0144
'- ERWEITERTE SYSTEM ROUTINEN -
define REVR &H0101 'ANTRIEB RECHTS RÜCKWÄRTS
define REVL &H0106 'ANTRIEB LINKS RÜCKWÄRTS
define FWDR &H010B 'ANTRIEG RECHTS VORWÄRTS
define FWDL &H0110 'ANTRIEB LINKS VORWÄRTS
define ROTR &H0115 'RECHTS DREHEN
define ROTL &H0119 'LINKS DREHEN
define REV &H011D 'RÜCKWÄRTS
define FWD &H0121 'VORWÄRTS
define COMNAV_STATUS &H0125 'UPDATED ALLE FLAGS IM STATUS-REGISTER
define ACS_LO &H01E0 'ACS POWER LO
define ACS_HI &H01E8 '
define ACS_MAX &H01F0 '
define SEND_TLM &H013A 'SENDET TELEMETRIE (CH=HBYTE,DATEN=LBYTE)
define SEND_SYSSTAT &H0134 'SENDET TLM KANAL 0,SYSTEM STATUS
'(FLAGS für ACS,FWD/REV, ACS_LO/HI/MAX)
'---------- INIT---------------
LSTROBE=off
gosub SUBSYS_PWR_ON:REV_L=on:REV_R=on:sys PLM_SLOW 'Muss immer im Programm stehen !
gosub lcd_init
beep 400,10,50
minutealt = minute
gosub LOFF
gosub LED4OFF
LBYTE=0
'----------------------------------------------------------
'- Programmanfang DEMO Uhrzeit Synchronisieren --
'----------------------------------------------------------
#start
gosub CLR_DISTANCE
'#LCD_Laufschrift '1.Zeile
lcd_param = &H80
lcd_buf = OFF
gosub LCD_WRITE
gosub Nachricht1 'Zeichenausgabe
for einer = 1 to 40 '40 mal nach Links schieben
lcd_port = 1
tog lcd_e
tog lcd_e
lcd_port = 8
tog lcd_e
tog lcd_e
pause 5
next einer
#loop
SPEED_R=0:SPEED_L=0
if hour <> 0 then goto ende 'Sprung wenn DCF-Uhr gestellt hat
'geht nicht zwischen 00:00:00 und 00:59:59 sorry!
if (minute - 4) = minutealt then gosub dreh1
if (minute - 8) = minutealt then gosub dreh1
if (minute - 12)= minutealt then gosub dreh1
if (minute - 16)= minutealt then gosub dreh1
if (minute - 20)= minutealt then gosub dreh1
if (minute - 24)= minutealt then goto Fehler
if minute = 1 then gosub L1ON 'LED 1 an , nach einer Minute
If minute = 2 then gosub L2ON 'LED 2 an , nach zwei Minuten
If minute = 3 then gosub L3ON 'LED 3 an , nach drei Minuten
If minute = 4 then gosub L4ON 'LED 4 an , nach vier Minuten
if minute = 5 then gosub L5ON 'LED 5 an
If minute = 6 then gosub L6ON 'LED 6 an
If minute = 7 then gosub L7ON 'LED 7 an
If minute = 8 then gosub L8ON 'LED 8 an
If minute = 9 then gosub L9ON 'LED 8 an und LED 1
If minute = 10 then gosub L10ON 'LED 8 an und LED 2
If minute = 11 then gosub L11ON 'LED 8 an und LED 3
If minute = 12 then gosub L12ON 'LED 8 an und LED 4
lcd_param = 2 : gosub lcd_gotoline
lcd_param = &H20 : gosub lcd_writechar '4 Leerzeichen
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
value=hour ' Ausgabe Stunden
gosub convert2
lcd_param = &H3A : gosub lcd_writechar ':
value=minute ' Ausgabe Minuten
gosub convert2
lcd_param = &H3A : gosub lcd_writechar ':
value=second ' Ausgabe Sekunden
gosub convert2
goto loop
#dreh1
gosub LOFF
gosub CLR_DISTANCE
minutealt=minute
SPEED_R=100:SPEED_L=100:sys ROTR 'Rotieren nach rechts
#rot1
SYS COMNAV_STATUS ';Abfrage des NAV
gosub L_DISTANCE 'Abfrage Linker Distanz-Sensor
if LBYTE >= 1 then return 'Wenn grosser 1 ,Sprung (60 Grad Drehung)
goto rot1 'Schleife, bis 1 erreicht ist
#ende
gosub LOFF
for einer = 50 to 250 step 5
beep einer,0,0:next
for einer = 50 to 250 step 5
beep einer,0,0:next
for einer = 50 to 250 step 5
beep einer,0,0:next
beep 200,1,1
gosub LCD_CLS
#loop1
lcd_param = 1 : gosub lcd_gotoline
lcd_param = &H20 : gosub lcd_writechar ' 3 Leerzeichen
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
value=hour ' Ausgabe Stunden
gosub convert2
lcd_param = &H3A : gosub lcd_writechar ':
value=minute ' Ausgabe Minuten
gosub convert2
lcd_param = &H3A : gosub lcd_writechar ':
value=second ' Ausgabe Sekunden
gosub convert2
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
on DOW gosub So,Mo,Di,Mi,Do,Fr,Sa
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = 2 : gosub lcd_gotoline
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
value=DAY ' Ausgabe Tag
gosub convert2
lcd_param = &H2E : gosub lcd_writechar '.
value=MONTH ' Ausgabe Monat
gosub convert2
lcd_param = &H2E : gosub lcd_writechar '.
value=YEAR ' Ausgabe Jahr
gosub convert2
goto loop1
#Fehler
gosub lcd_cls
lcd_param = 1 : gosub lcd_gotoline
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H4B : gosub lcd_writechar 'K
lcd_param = &H65 : gosub lcd_writechar 'e
lcd_param = &H69 : gosub lcd_writechar 'i
lcd_param = &H6E : gosub lcd_writechar 'n
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H45 : gosub lcd_writechar 'E
lcd_param = &H6D : gosub lcd_writechar 'm
lcd_param = &H70 : gosub lcd_writechar 'p
lcd_param = &H66 : gosub lcd_writechar 'f
lcd_param = &H61 : gosub lcd_writechar 'a
lcd_param = &H6E : gosub lcd_writechar 'n
lcd_param = &H67 : gosub lcd_writechar 'g
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
beep 200,1,50
beep 400,1,50
beep 600,1,50
end
'-------------------------------------------
'IIIIIII Nachricht 1 IIIIIIIIIII
#Nachricht1
gosub lcd_cls
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H20 : gosub lcd_writechar
lcd_param = &H43 : gosub lcd_writechar 'C
lcd_param = &H2D : gosub lcd_writechar '-
lcd_param = &H43 : gosub lcd_writechar 'C
lcd_param = &H4F : gosub lcd_writechar 'O
lcd_param = &H4E : gosub lcd_writechar 'N
lcd_param = &H54 : gosub lcd_writechar 'T
lcd_param = &H52 : gosub lcd_writechar 'R
lcd_param = &H4F : gosub lcd_writechar 'O
lcd_param = &H4C : gosub lcd_writechar 'L
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H52 : gosub lcd_writechar 'R
lcd_param = &H4F : gosub lcd_writechar 'O
lcd_param = &H42 : gosub lcd_writechar 'B
lcd_param = &H4F : gosub lcd_writechar 'O
lcd_param = &H54 : gosub lcd_writechar 'T
lcd_param = &H20 : gosub lcd_writechar '
lcd_param = &H52 : gosub lcd_writechar 'R
lcd_param = &H50 : gosub lcd_writechar 'P
lcd_param = &H35 : gosub lcd_writechar '5
return
'IIIIIIIIIII LED DRIVER IIIIIIIIIIIIIIIII
#LED1ON
LED1_F=on:goto EXTPORT_WRITE
#LED1OFF
LED1_F=off :goto EXTPORT_WRITE
#LED2ON
LED2_F=on:goto EXTPORT_WRITE
#LED2OFF
LED2_F=off:goto EXTPORT_WRITE
#LED3ON
LED3_F=on:goto EXTPORT_WRITE
#LED3OFF
LED3_F=off:goto EXTPORT_WRITE
#LED4ON
LED4_F=on:goto EXTPORT_WRITE
#LED4OFF
LED4_F=off:goto EXTPORT_WRITE
#LEDSOFF
EXTPORT=EXTPORT and &H0F
#EXTPORT_WRITE
SYS SYSTEM:pulse STROBE:RETURN
'--- LEDS AUF DER BASIS ERWEITERUNG ------
#L1ON
L1_F=on:goto LEDPORT_WRITE
#L1OFF
L1_F=off :goto LEDPORT_WRITE
#L2ON
L2_F=on:goto LEDPORT_WRITE
#L2OFF
L2_F=off :goto LEDPORT_WRITE
#L3ON
L3_F=on:goto LEDPORT_WRITE
#L3OFF
L3_F=off :goto LEDPORT_WRITE
#L4ON
L4_F=on:goto LEDPORT_WRITE
#L4OFF
L4_F=off :goto LEDPORT_WRITE
#L5ON
L5_F=on:goto LEDPORT_WRITE
#L5OFF
L5_F=off :goto LEDPORT_WRITE
#L6ON
L6_F=on:goto LEDPORT_WRITE
#L6OFF
L6_F=off :goto LEDPORT_WRITE
#L7ON
L7_F=on:goto LEDPORT_WRITE
#L7OFF
L7_F=off :goto LEDPORT_WRITE
#L8ON
L8_F=on:goto LEDPORT_WRITE
#L8OFF
L8_F=off :goto LEDPORT_WRITE
#LOFF
LEDPORT=0
#LEDPORT_WRITE
SYS LED_DRIVE:pulse LSTROBE:RETURN
'---------------------------------------------
#L9ON
gosub L8ON:gosub L1ON
return
#L10ON
gosub L8ON:gosub L2ON
return
#L11ON
gosub L8ON:gosub L3ON
return
#L12ON
gosub L8ON:gosub L4ON
return
'--------------------------------------------
'++++++++++++ CONVERT BINARY TO DECIMAL +++++++++++++++
#convert2
'zehner abfragen
zehner=(value-(hunderter*100))/10
lcd_param=zehner+&H30
gosub lcd_writechar
'einer abfragen
einer=value-(hunderter*100)-(zehner*10)
lcd_param=einer+&H30
gosub lcd_writechar
return
'---------------------------------------------------
#convert3
hunderter=value/100
if hunderter>0 then lcd_param=hunderter+&H30 else lcd_param=&H20
gosub lcd_writechar
'zehner abfragen
zehner=(value-(hunderter*100))/10
lcd_param=zehner+&H30
gosub lcd_writechar
'einer abfragen
einer=value-(hunderter*100)-(zehner*10)
lcd_param=einer+&H30
gosub lcd_writechar
return
'----------------------------------------
'------------- LCD ROUTINE -------------
'----------------------------------------
#LCD_INIT
' alle ports 0
lcd_port = OFF
' 8-Bit-Modus aktivieren
lcd_param=&H38 : gosub LCD_WRITECMD
' mit 8-Bit-Command in 4-Bit-Modus umschalten
lcd_port=&B00000010
tog lcd_e
tog lcd_e
' ab jetzt 4-Bit-Modus
lcd_param = &H28 : gosub LCD_WRITECMD
lcd_param = &H0C : gosub LCD_WRITECMD
' Display loeschen
#LCD_CLS
lcd_param = &H02 : gosub LCD_WRITECMD
lcd_param = &H01 : gosub LCD_WRITECMD
return
' Zeilenwechsel
#LCD_GOTOLINE
if lcd_param = 1 then lcd_param = &H80
if lcd_param = 2 then lcd_param = &HC0
goto LCD_WRITECMD
' LCD-Kommando
#LCD_WRITECMD
lcd_buf = OFF
goto LCD_WRITE
' Zeichenausgabe
#LCD_WRITECHAR
lcd_buf = &B00100000
' Kommando oder Zeichen an Display senden
#LCD_WRITE
lcd_port = lcd_buf or (lcd_param shr 4) ' Hi-Nibble
tog lcd_e
tog lcd_e
lcd_port = lcd_buf or (lcd_param and &H0F) ' Lo-Nibble
tog lcd_e
tog lcd_e
return
'--------------------------------------------
'-------------------- Wochentage für LCD-Ausgabe --------------------------
#So
lcd_param = &H53 : gosub lcd_writechar 'S
lcd_param = &H6F : gosub lcd_writechar 'o
return
#Mo
lcd_param = &H4D : gosub lcd_writechar 'M
lcd_param = &H6F : gosub lcd_writechar 'o
return
#Di
lcd_param = &H44 : gosub lcd_writechar 'D
lcd_param = &H69 : gosub lcd_writechar 'i
return
#Mi
lcd_param = &H4D : gosub lcd_writechar 'M
lcd_param = &H69 : gosub lcd_writechar 'i
return
#Do
lcd_param = &H44 : gosub lcd_writechar 'D
lcd_param = &H6F : gosub lcd_writechar 'o
return
#Fr
lcd_param = &H46 : gosub lcd_writechar 'F
lcd_param = &H72 : gosub lcd_writechar 'r
return
#Sa
lcd_param = &H53 : gosub lcd_writechar 'S
lcd_param = &H61 : gosub lcd_writechar 'a
return
'--------------------------------------------------------------
'IIIIII SYSTEMROUTINEN COMM/NAV SYSTEM IIIII
#GET_IRDATA
SUBCMD=1:sys COMNAV:return
#SEND_IRDATA
SUBCMD=0:sys COMNAV:return
#RC5
SUBCMD=4:sys COMNAV:LBYTE= HBYTE and &HFC
HBYTE=00:SUBCMD=2:sys COMNAV:return
#RC5_INT
SUBCMD=4:sys COMNAV:LBYTE= (HBYTE and &HFE)or 2
HBYTE=00:SUBCMD=2:sys COMNAV:return
#REC80
SUBCMD=4:sys COMNAV:LBYTE= (HBYTE or &H01)and&HFD
HBYTE=00:SUBCMD=2:sys COMNAV:return
#REC80_INT
SUBCMD=4:sys COMNAV:LBYTE= (HBYTE or &H03)
HBYTE=00:SUBCMD=2:sys COMNAV:return
'IIIIII SYSTEMROUTINEN SYSTEM IIIIIIIIIIII
#NO_ACS_INT
SUBCMD=4:sys COMNAV:LBYTE= HBYTE and &HFB
HBYTE=00:SUBCMD=2:sys COMNAV:return
#ACS_INT_200
SUBCMD=4:sys COMNAV:LBYTE= HBYTE or &H04
HBYTE=50:SUBCMD=2:sys COMNAV:return
#SUBSYS_PWR_ON
sdio=on:sclio=on:strobe=off:EXTPORT=(EXTPORT and &HFE)or 8
sys SYSTEM:return
#SUBSYS_PWR_OFF
EXTPORT=(EXTPORT and &HF7)or 1:sys SYSTEM
deact sdio:deact sclio:return
#CLR_DISTANCE
SUBCMD=3:sys COMNAV:return
#L_DISTANCE
SUBCMD=6:sys COMNAV:return
#R_DISTANCE
SUBCMD=7:sys COMNAV:return
'---------COM/NAV GERÄTETREIBER -------------
'syscode "p5driv12.s19"
Vielleicht hilft es beim Abgucken der Programmidee.
Bei mir half das Prog nicht so wirklich, weil mein Aufbau schon nach wenigen Minuten DCF-Empfang hatte (auch wenn das Modul nicht genau nach Frankfurt ausgerichtet war).
Gruß Dirk
Lesezeichen