Shop OBEX P1 Docs P2 Docs Learn Events
Wireless Controller — Parallax Forums

Wireless Controller

stamptrolstamptrol Posts: 1,731
edited 2005-09-07 03:52 in Robotics

Wireless Bin Level Indicator and Remote Operator

Submitted by Tom·Sisk

The wireless bin indicator was designed for a customer with a limestone quarry and kiln operation. The quarry operation produces limestone rock which is broken into pieces, burned in a vertical kiln then screened into various sizes for stockpiling. The stock piles are the feedstock for the production of agricultural lime, cement and other products.

The screened products of the kiln are stored in 5 elevated bins and transferred to storage piles by heavy duty Euclid off-road trucks. The trucks operate on a 10-hour per day cycle and ideally transfer 20 to 30 tons of product with each trip. Production can be affected if a truck does not keep the bins sufficiently emptied, allowing product to backup and causing plant stoppage until the backlog is cleared.

Although the plant has the bin levels transferred to the control room displays from the ultrasonic level transducers, there was no easy way for the truck driver to be given the same information.

The system I designed is made up of 2 parts. The first is an EnT board·which has a 12-bit A/D converter on board and an 8-channel analog multiplexer. The existing analog signals ( 4 - 20 mA ) are picked up from the plant's PLC ( Allan-Bradley SLC 500 ) and measured by the EnT. The information from the 5 bins is broadcast on demand to the second unit in the truck cab. The radio system used is a 900MHz, unlicensed, short range system called the Phantom by Murandi Communications.

The second unit is mounted in the truck cab and provides graphical readout using the 120 x 32 pixel graphics display. The display depicts 5 bins in a horizontal format with a dark bar graph representing the level in the bins. The radio transceiver is mounted inside the vehicle's windshield and is thus protected from the weather.

The truck-mounted equipment is secured with heavy-duty Velcro material to allow its easy transference to another vehicle if necessary. The Velcro attachment also allows the display to be turned so it is oriented vertically. When this is done, a mercury switch inside the display automatically switches the display to a taller but narrower display. To date, the horizontal display is preferred by the operator.

In operation, the truck unit is the master and polls the stationary unit. When the stationary unit "hears" the truck unit, it sends the bin data, updates the analog values and then waits for the next interrogation. The update cycle is repeated every few seconds. In this application the 2400 baud speed is ideal. Because the transceivers operate on line of site basis, programming was designed to allow the two radios to re-synchronize with each other whenever the signal is lost as the truck moves around the site. The display routinely gets updated while the truck is several hundred feet from the bin area.

A feature of the system is the ability of the truck mounted controller to be put into a "control" mode to allow the driver to send signals to remotely open the bin doors and load the truck. Previously this was accomplished by having the driver reach out the truck window and operate a switch. Programming is incorporated to make the opening of a bin door a "two-button" task. For safety, the signal is interrupted every 2 seconds so that loss of radio contact or other failure will not allow the unchecked delivery of product.




' {$STAMP BS2}

' Program Name: hav_bins_ctrl.bs2
' Last Update: Oct 12/2001 tjs

' Used in stationary unit of Gray/Lock remote bin indicator
' system. This unit receives queries from the truck unit and sends
' back bin level data. Additionally, it can receive commands to open
' and close the discharge door on any bin.

' Short range radio transmits via pin 16 (i.e. 9-pin connector)
' Receives data on pin 8 through current limiting resistor

' Outputs 0,1,2 are address of analog mux.Outputs 3,4,5,6,7 are
' contact outputs to open bin doors

·· adstor VAR Byte(5)········ ' bin level heights
·· x VAR Nib·············· ' mux counting variable
·· control VAR Byte
·· hop VAR Byte

·· config VAR Nib··········· ' variables for a/d control from 1298 app notes
····· startb VAR config.BIT0
····· sgldif VAR config.BIT1
····· oddsign VAR config.BIT2
····· msbf VAR config.BIT3
·· ad VAR Word·············· ' resultant from a/d conversion



·· rad_out CON 16········ ' pin for data out to radio
·· rad_out_par CON·· 396····· ' data out parameters 2400,8,n,1,true to use pin 2 of serial connector

·· rad_in CON 8········ ' pin for data in from radio
·· rad_in_par CON 396+$4000·· 'data in parameters 2400,8,n,1,inverted to use on pin 8

·· cs CON 11····· ' A/D control pins;4,5,6, for original EnT,11,10,9 for new board
·· clk CON 10
·· dio_n CON 9
·· oddsign = 1····· ' select INA, use oddsign=0 for INB

·· DIRA = %0111·· ' set mux address pins as outputs
·· adstor(5) = 123·· ' data check value
' ****************************** Main Program Start ************************************

mainloop:
·· FOR x = 0 TO 5
····· OUTA = x & %0111····· ' set mux address
····· GOSUB convert
····· adstor(x) = ad/16····· ' scale a/d result to 0 to 255
····· PAUSE 100
····· NEXT

·· SERIN rad_in,rad_in_par,10000,no_dat,[noparse][[/noparse]WAIT ("tech"),control]
·· LOW 15
·· PAUSE 100
·· HIGH 15
·· IF control = "C" THEN contr_loop

·· PAUSE 200
·· SEROUT rad_out,rad_out_par,[noparse][[/noparse]"mmtom",adstor(0),adstor(1),adstor(2),adstor(3),adstor(4),adstor(5)]
·· 'pause 2000
·· 'serout outport,comparm,[noparse][[/noparse]12]
·· 'low 3
·· GOTO mainloop

no_dat:
·· LOW 14
·· PAUSE 100
·· HIGH 14
·· GOTO mainloop

contr_loop:
·· LOW 12
·· SERIN rad_in,rad_in_par,5000,mainloop,[noparse][[/noparse]WAIT ("bin"),hop]
·· HIGH hop
·· PAUSE 2000
·· LOW hop
·· HIGH 12
·· GOTO mainloop

' ********************· Subroutines ****************************


convert:

····· config=config | %1011
····· LOW cs
····· SHIFTOUT dio_n,clk,LSBFIRST,[noparse][[/noparse]config\4]
····· PAUSE 5
····· SHIFTIN dio_n,clk,MSBPOST,[noparse][[/noparse]ad\12]
····· HIGH cs
····· RETURN

#############################################


' {$STAMP BS2}

' Program Name: hav_truk_ctrl.bs2
' Last Update: Oct 12/2001 tjs

' Used in truck display unit of Havelock bin indicator

' Short range radio transmits data on pin 16 (i.e. 9-pin connector)
' Receives data on pin 15 through current limiting resistor

' Switches to control bin doors use p1 through p6
' Switch p0 acts as a Master Switch when sending commands to open bin doors
' p7 changes display from vertical to horizontal format

·· orient VAR Byte
·· lstart VAR Byte
·· botstart VAR Byte
·· height VAR Byte
·· stufin VAR Byte(5)
·· top VAR Byte
·· binsel VAR Byte
·· numbin VAR Byte
·· randnum VAR Word
·· x VAR Byte
·· y VAR Byte
·· z VAR Byte
·· config VAR Nib··········· ' variables for a/d control
····· startb VAR config.BIT0
····· sgldif VAR config.BIT1
····· oddsign VAR config.BIT2
····· msbf VAR config.BIT3
·· ad VAR Word

·· outport CON 8····· ' use pin 8 to drive display

'··· comparm con 84········ 'data rates set to 9600,8,n,true for talking
················ ' via RS-232 connector to display.

·· comparm CON 84+$4000·· ' inverted for talking to display directly off pin

·· rad_out CON 16········ ' pin for data out to radio
·· rad_out_par CON·· 396····· ' data out parameters 2400,8,n,1,true to use serial connector

·· rad_in CON 15········ ' pin for data in from radio
·· rad_in_par CON 396+$4000·· 'data in parameters 2400,8,n,1,inverted to use on pin

·· cs CON 11····· ' A/D control pins;4,5,6, for original EnT,11,10,9 for new board
·· clk CON 10
·· dio_n CON 9
·· oddsign = 1····· ' select INA, use oddsign=0 for INB

·· DIRA = %0111
' ****************************** Main Program Start ************************************
·· 'high 7

·· PAUSE 2000········ 'pause for display to power up

newscrn:
·· orient = "H"
·· SEROUT outport,comparm,[noparse][[/noparse]14]········ 'turn on back-light
·· SEROUT outport,comparm,[noparse][[/noparse]12]
·· SEROUT outport,comparm,[noparse][[/noparse]27,"V",65,13]·· 'reset origin to bottom left corner

·· SEROUT outport,comparm,20,[noparse][[/noparse]27,"E",15+64,13]·· 'load horizontal bin screen

·· IF IN7=0 THEN mainloop
·· orient = "V"
·· SEROUT outport,comparm,[noparse][[/noparse]12]········ 'clear screen
·· SEROUT outport,comparm,[noparse][[/noparse]27,"V",64,13]·· 'reset origin to top left corner (bot left when display is vertical)
·· SEROUT outport,comparm,[noparse][[/noparse]27,"E",14+64]·· 'load vertical display screen


mainloop:
·· IF IN0 = 1 THEN contr_loop
·· SEROUT outport,comparm,[noparse][[/noparse]16,67+64,"*"]········ ' display status
·· PAUSE 200
·· SEROUT rad_out,rad_out_par,[noparse][[/noparse]"tech","D"]·· '
·· SEROUT outport,comparm,[noparse][[/noparse]16,67+64,"+"]
·· SERIN rad_in,rad_in_par,4000,no_dat,[noparse][[/noparse]WAIT ("mmtom"),STR stufin\6]·· ' receive 6 bytes from bin unit
·· GOTO displ


no_dat:
·· SEROUT outport,comparm,[noparse][[/noparse]16,67+64,"#"]·· ' show there has been a comm failure
·· PAUSE 1000
·· GOTO mainloop

displ:
·· IF IN7 = 1 THEN vloop··········· ' 1 (jumper p7 to 5v) for horizontal display, 0 for vertical


hmain:···················· ' use horizontal format
hop1:
·· lstart=8
·· botstart=4
·· height = stufin(0) MIN 44 MAX 255/11
·· top=botstart+height
·· GOSUB draw
hop2:
·· lstart=31
·· botstart=4
·· height = stufin(1) MIN 44 MAX 255/11
·· top=botstart+height
·· GOSUB draw
hop3:
·· lstart=57
·· botstart=4
·· height = stufin(2) MIN 44 MAX 255/11
·· top=botstart+height
·· GOSUB draw
hop4:
·· lstart=82
·· botstart=4
·· height = stufin(3) MIN 44 MAX 255/11
·· top=botstart+height
·· GOSUB draw
hop5:
·· lstart=106
·· botstart=4
·· height = stufin(4) MIN 44 MAX 255/11
·· top=botstart+height
·· GOSUB draw

GOTO mainloop


vloop:IF orient = "H" THEN newscrn········ ' come here if vertical format is chosen
vop1:
·· lstart=0
·· botstart=20
·· height = (stufin(0)*10) MIN 1 MAX 2550/25
·· top=botstart+height
·· GOSUB vdraw
vop2:
·· lstart=7
·· botstart=20
·· height = (stufin(1)*10)MIN 1 MAX 2550/25
·· top=botstart+height
·· GOSUB vdraw
vop3:
·· lstart=14
·· botstart=20
·· height = stufin(3)*10 MIN 1 MAX 2550/25
·· top=botstart+height
·· GOSUB vdraw
vop4:
·· lstart=21
·· botstart=20
·· height = stufin(3)*10 MIN 1 MAX 2550/25
·· top=botstart+height
·· GOSUB vdraw
vop5:
·· lstart=28
·· botstart=20
·· height = stufin(4)*10 MIN 1 MAX 2550/25
·· top=botstart+height
·· GOSUB vdraw
·· IF IN7 = 0 THEN newscrn··········· ' check to see if horizontal display is wanted
GOTO mainloop

contr_loop:···················· ' come here during a control loop; master button is detected
·· IF IN0=0 THEN newscrn
·· binsel = INL & %01111110
·· LOOKDOWN binsel,=[noparse][[/noparse]0,2,4,8,16,32,64],numbin
·· SEROUT outport,comparm,[noparse][[/noparse]12,"In Control Loop",CR,CR,"Bin to Open is ",DEC1 numbin]
·· numbin=numbin+2
·· PAUSE 200
·· SEROUT rad_out,rad_out_par,[noparse][[/noparse]"tech","C"]
·· PAUSE 100
·· SEROUT rad_out,rad_out_par,[noparse][[/noparse]"bin",numbin]
·· GOTO contr_loop


' ********************· Subroutines ****************************


convert:

····· config=config | %1011
····· LOW cs
····· SHIFTOUT dio_n,clk,LSBFIRST,[noparse][[/noparse]config\4]
····· PAUSE 5
····· SHIFTIN dio_n,clk,MSBPOST,[noparse][[/noparse]ad\12]
····· HIGH cs
····· RETURN


draw:
····· ' draw new bar in black
·· FOR y = botstart TO top········ ' get new height
····· FOR x = lstart TO lstart+6····· ' get new starting point
····· SEROUT outport,comparm,[noparse][[/noparse]27,"P",x+64,y+64]
····· NEXT
·· NEXT
·· SEROUT outport,comparm,[noparse][[/noparse]27,"I",64]·· 'Change ink colour to white
·· FOR y = 29 TO (top+1)········ 'Clear previous bar
····· FOR x = lstart TO lstart+6
····· SEROUT outport,comparm,[noparse][[/noparse]27,"P",x+64,y+64]
····· NEXT
·· NEXT
·· SEROUT outport,comparm,[noparse][[/noparse]27,"I",65]·· 'Change ink to black
·· RETURN

vdraw:
····· ' draw new bar in black, vertical
·· FOR x = botstart TO top········ ' get new height
····· FOR y = lstart TO lstart+2····· ' get new starting point
····· SEROUT outport,comparm,[noparse][[/noparse]27,"P",x+64,y+64]
····· NEXT
·· NEXT
·· SEROUT outport,comparm,[noparse][[/noparse]27,"I",64]·· 'Change ink colour to white
·· FOR x = 119 TO (top+1)········ 'Clear previous bar
····· FOR y = lstart TO lstart+3
····· SEROUT outport,comparm,[noparse][[/noparse]27,"P",x+64,y+64]
····· NEXT
·· NEXT
·· SEROUT outport,comparm,[noparse][[/noparse]27,"I",65]·· 'Change ink to black
·· RETURN

1044 x 600 - 130K
992 x 700 - 137K
639 x 688 - 52K

Comments

  • ManuelManuel Posts: 105
    edited 2005-09-07 03:52
    Nice project!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
Sign In or Register to comment.