| From | Lynndon Harnell <lynndonh@ecn.net.au> |
| Date | Sat, 16 Dec 2000 16:35:06 +1100 |
This Program is for BASCOM-AVR not the 8051, but I assume that it would be
similar. It communicates with an intelligent probe to take a couple level
readings.
'---------------------------------------------------------------------------
---
' Leak.BAS
' program to leak test probes using AT90SL2313
' compiled with BASCOM-AVR
'---------------------------------------------------------------------------
---
'
Dim S As Single
Dim R1 As Integer
Dim R As Integer
Dim B As Byte
Dim C(4) As Byte
Dim O(4) As Byte
Dim N As Byte
Dim Y(17) As Byte
Dim H As String * 2
Config Portd = &B00011110
set portd.5 'set pull up for pressure switch
Config Watchdog = 2048 'reset after 2048 mSec
Open "comd.1:19200,8,n,1" For Output As #2
Open "comd.0:19200,8,n,1" For Input As #1
Cls 'clear screen
Cursor Noblink
Cursor Off
Lcd " 1st 2nd diff"
For N = 1 To 4 'init cal and offest values
O(n) = 0
C(n) = 0
Next N
Gosub Reading
C(1) = Y(13) 'store cal values
C(2) = Y(14)
C(3) = Y(15)
C(4) = Y(16)
O(1) = Y(17) 'store offset values
O(2) = Y(18)
O(3) = Y(19)
O(4) = Y(20)
Gosub Pump
Gosub Reading 'get reading from probe
If R < 600 Then
Locate 1 , 1
Lcd "Bad leak or blockage"
Goto Finish
End If
R1 = R
Locate 2 , 1
Lcd R
Lcd "mm"
Wait 7
Gosub Reading 'get reading from probe
Locate 2 , 9
Lcd R
Lcd "mm"
R = R1 - R
Locate 2 , 17
Lcd R
Lcd "mm "
If R > 8 Then
Locate 1 , 1
Lcd "Check for leaks "
Goto Finish
End If
Finish:
Reset Portd.4
Do
Gosub Reading
Loop
Reading:
Start Watchdog
Locate 1 , 1
Cursor Noblink
Y(5) = 9
While Y(5) = 9 'repeat while A/D is busy
B = 177 'base checksum
For N = 1 To 4 'calulate new checksum
B = B + C(n)
B = B + O(n)
Next N
set Portd.2 'enable transmit
Print #2 , Chr(165) ; 'start byte
Print #2 , Chr(0) ; 'address
Print #2 , Chr(10) ; 'body lenght
Print #2 , Chr(2) ; 'op code
Print #2 , Chr(0) ; 'status
Print #2 , Chr(0) ; 'pad
Printbin #2 , C(1) 'cal value
Print #2 , Chr(0) ; 'port
Print #2 , Chr(0) ; 'pad
Printbin #2 , O(1) 'offset value
Print #2 , Chr(b) ; 'checksum
Reset Portd.2 'enable receive
For N = 1 To 21 'receive packet
Inputbin #1 , B 'get byte
Y(n) = B 'store value
Next N 'repeat
Waitms 200 'delay
Reset Watchdog
Cursor Blink
Wend
out &H60, y(7) 'store bytes in S for conversion to
float
out &H61, y(8)
out &H62, y(9)
out &H63, y(10)
S = S * 1000
R = S
Stop Watchdog
Cursor Noblink
Return
Pump:
B = 1
While B = 1
set portd.3
Waitms 5
Reset Portd.3
Waitms 15
B = Pind.5
Wend
set portd.4
Return
End
> -----Original Message-----
> From: owner-bascom@grote.net [mailto:owner-bascom@grote.net]On Behalf Of
> DPhil75325@aol.com
> Sent: Thursday, December 14, 2000 5:13 PM
> To: bascom@grote.net
> Subject: [bascom] RS485 8051 source code wanted
>
>
> as anybody done anything with rs485 or dmx 512
> if so please could i have a copy please e-mail me at Dphil75325@aol.com
>