Liste der Anhänge anzeigen (Anzahl: 1)
Also die Schaltung sieht so aus:
Anhang 19542
und das Programm:
Code:
$regfile = "m8def.dat"
$crystal = 8000000
'the internal oscillator of 8 Mhz was choosen in the fusebits
$baud = 19200
Osccal = &HAE
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 32 ' default use 32 for the SW stack
$framesize = 50 ' default use 50 for the frame space
'Ports Deklarieren
Relais1 Alias Portc.0
Config Relais = Output
Rs485dir Alias Portd.2
Config Rs485dir = Output
Rs485dir = 0 ' Empfangsmodus
Taster1 Alias Pinc.2
Config Taster1 = Input
Portc.2 = 1 'PullUp-Widerstand einschalten
Taster2 Alias Pinc.3
Config Taster2 = Input
Portc.3 = 1 'PullUp-Widerstand einschalten
Stromsensor Alias Pinc.4
Config Stromsensor = Input
Portc.4 = 1 'PullUp-Widerstand einschalten
$timeout = 100000
'System-Timer für periodische Encoder-Abfrage
Config Timer0 = Timer , Prescale = 256
On Timer0 Isr_timer0
Enable Timer0
Const Timer0_reload = 250
Config Debounce = 30
'Interrupt Daten wurden empfangen
'On Urxc Onrxd 'Interrupt-Routine setzen (Daten über Uart empfangen)
'Enable Urxc 'Interrupt URXC einschalten
'Interrupt Daten wurden gesendet
On Utxc Ontxd
Enable Utxc
Enable Interrupts 'Interrupts global zulassen
'Variablendeklaration
Dim Teilnehmeradresse As Byte
Teilnehmeradresse = 10
'MainLoop
Do
Loop
On_taster1:
Toggle relais
'SENDETEST
Rs485dir = 1
Waitms 50
Printbin Teilnehmeradresse ; Teilnehmeradresse;
Return
Ontxd:
Waitms 50
Rs485dir = 0
Return
'Timer 0
Isr_timer0:
Timer0 = Timer0_reload
Debounce Taster1 , 0 , On_taster1 , Sub
Return
End