Lamp/Relay Driver for the Handy Cricket

Lamp/Relay Driver for the Handy Cricket

Features

 

How to Use the Lamp/Relay Driver

Plugging It In

The Lamp/Relay Driver for the Handy Cricket is quite easy to use. Start off by plugging it into your Handy Cricket. You can use either bus port – they're both the same.

Setting and Clearing Outputs

Now copy the following Logo driver procedures into your Cricket Programs window:

to set :n
  bsend $116 bsend 1 bsend :n - 1
end

to clear :n
  bsend $116 bsend 2 bsend :n - 1
end

Download to put this program into the Cricket, and then try it out using the Command Center. Type:

set 4

and you should see the output 4 light up on the driver board. The outputs are numbered from 1 to 7, slightly below and to the right of each output jack.

To turn off an output, use the clear command:

clear 4

Setting and Clearing All the Outputs

There are specific commands for setting and clearing all of the outputs at once. Copy these procedures into the Programs window:

to setall
  bsend $116 bsend 3
end

to clearall
  bsend $116 bsend 4
end

 

That's all there is to it! Pretty much any device that could be plugged directly into the Handy Cricket's motor output may be used with the Lamp/Relay Driver Board. There are some advanced features, which are described below, but for basic use, you are all set.

 

 

 

Advanced Features

This section explains advanced modes of the Handy Cricket LED Lamp Driver Board:

Load, Toggle, Rotate, and Shift Commands

The load command allows writing to all 7 outputs at once:

to load :n
  bsend $116 bsend 0 bsend low-byte :n
end

The low bit of the input is output 1, bit 6 of the input is output 7, and all other input bits are ignored.

There is a toggle command. This causes outputs to change state: outputs that are on turn off, and outputs that are off turn on:

to toggle
  bsend $116 bsend 5
end

There are a pair of rotate commands. These cause the output state to rotate to the left or right by one position. When rotating left, the state of output 1 moves to 2, 2 moves to 3, etc., and 7 wraps around to 1. When rotating right, 7 moves to 6, 6 to 5, etc., and 1 wraps around to 7.

to rotleft
  bsend $116 bsend 6
end

to rotright
  bsend $116 bsend 7
end

There are four shift commands. These cause the output state to rotate to the left or right by one position. When rotating left, the state of output 1 moves to 2, 2 moves to 3, etc., and output 7 is lost. There are two variants of the left-shift command. One variant shifts a "1" (output on) into output 1; the other shifts a "0" (output off) into this output.

The two right-shift commands work in an analogous fashion, shifting either 1 or a 0 into output 7 and moving all other outputs to the right.

to shift-left-0
  bsend $116 bsend 8
end

to shift-left-1
  bsend $116 bsend 9
end

to shift-right-0
  bsend $116 bsend 10
end

to shift-right-1
  bsend $116 bsend 11
end

Using Multiple Driver Boards on One Cricket

Each Lamp/Relay Driver Board may be hardwired to have an address number from 1 to 15. When the Driver Board ships from the factory, its address is set to 1. By changing the address (described below), multiple driver boards may be controlled from a single Handy Cricket. Any combination of boards with unique addresses may be used on a given Cricket.

All boards respond to an address of zero; that how the driver procedures given above function.

The address is set by cutting traces and wiring jumpers in the 4x3 bank of address bits illustrated below:

To set the address, each pad in the middle row of four pads is wired either to the logic "1" pad above it or the logic "0" pad below it. The left-most pad is the high bit of the address (bit 3, worth 8); the right-most pad is the low bit (bit 0, worth 1). The default wiring has the low bit set to 1 and the other three address bits set to 0, yielding an address of 1.

To set the board to a different address, cut the printed trace between the address pad and the logic pad, and then jumper the address pad to the desired logic pad. For example, to set the address to 9, cut the trace between the left pad and the logic 0, and jumper from the left pad to logic 1. This sets the high bit to 1, and leaves the remaining bits as they are, yielding an address of binary 1001, or 9 decimal.

Each of the commands shown above may be sent to a driver board with a particular address. The 4-bit address value is stuffed into the upper four bits of the command number.

The following modifications to the set and clear driver procedures show how to communicate with the Lamp/Relay Board by specific address. These new procedures, seta and cleara commands, take a board address along with the output to set or clear:

to seta :addr :n
  bsend $116 bsend :addr * 16 + 1 bsend :n - 1
end

to cleara :addr :n
  bsend $116 bsend :addr * 16 + 2 bsend :n - 1
end

Reading Output State

The following procedure reads the current output state of the driver board as a value from 0 to 127. Output 1 is bit 0 of the result (on=1; off=0); output 7 is bit 6 of the result:

to ledstate? :addr
  bsend $116 output bsr :addr * 16 + 12
end

Please note that you must use a non-zero address with the ledstate? command. In other words, you must refer to a specific board when requesting its state. This is to prevent more than one board from responding in the case of two or more boards plugged into the same Cricket.

Shift-and-Query Commands

When using the four shift commands described above, the bit being shifted "off the end" of the board is lost. There are four other shift commands that cause the driver board to report the state of the bit being shifted out.

These commands must be used with a specific non-zero driver board address. This is for the same reason as the ledstate? query—to prevent the case of multiple board responding at the same time.

to shift-left-0? :addr
  bsend $116 output bsr  :addr * 16  + 8
end

to shift-left-1? :addr
  bsend $116 output bsr  :addr * 16  + 9
end

to shift-right-0? :addr
  bsend $116 output bsr :addr * 16 + 10
end

to shift-right-1? :addr
  bsend $116 output bsr :addr * 16 + 11
end

to shift-left-0a :addr
  bsend $116 bsend :addr * 16 + 8
end

to shift-left-1a :addr
  bsend $116 bsend :addr * 16 + 9
end

to shift-right-0a :addr
  bsend $116 bsend :addr * 16 + 10
end

to shift-right-1a :addr
  bsend $116 bsend :addr * 16 + 11
end

With these commands, it is possible to make a light-chasing sequence that spans multiple boards. For example, suppose one Lamp/Relay Driver Board is address 1 and another is address 2. Then the following Logo statements will light up the low bit of board 1 and shift it up to the high bit of board 2:

seta 1 1
repeat 13 [ifelse shift-left-0? 1
             [shift-left-1a 2][shift-left-0a 2]
	   wait 1]

 

Technical Specifications

The Lamp/Relay Driver Board measures 2.45” x 1.05”. There are four mounting holes at the corners of a 2.25” x 0.85” rectangle.

The Driver Board uses a ULN2003 darlington transistor array device. Each output is rated for a maximum current of 500 mA, with total power dissipation for all outputs combined limited to 950 mW.

The Driver Board can be used with an external power supply by cutting the marked trace on the underside of the board and applying the supply voltage to the pads labeled “EXT PWR + –”. A voltage supply of up to 12v may be used. Please note that the trace on the underside of the board MUST be cut if external power is attached. Otherwise, the voltage will flow back into the main Cricket's supply and potentially burn out the circuits that require no more than 5v.


Last modified: Friday, 03-Sep-2004 14:07:43 PDT by fredm