I2CChip.com: BL233 as an 8 bit I/O Port

Simple control from the PC:

Contents So you just want to read a couple of pins and control a couple of relays?

The BL233 has 2 commands that let you use its pins directly. If you aren't using the I2C bus, this gives you and easy 8 bit I/O port

  • "O" to Output
  • "Q" to Query pins
  • "I" to check the Interrupt/Alert pin

  You can also use some pins as I2C and some as direct I/O


Reading a Pin

The QUERY PINS command "Q" reads back all 8 pins of the BL233 IC as 2 hex digits. eg:

send "Q", adaptor replies with "F0 [LF]"

By default all pins are inputs. You can make some pins outputs by setting the tristate byte using the O command.

The "I" command checks the interrupt pin, and can also be used to sense a single external line, as well as running a stored interrupt routine. Note that the Q command sees all the pins including the RS232 pins etc.

Since the I2C bus has pullup resistors, you can directly drive the input from a relay contact or opto coupler. Make sure that you add noise filtering. It will be more reliable to read an input several time and debounce in software. Using a single reading is noise prone, and not good practice.


Output Direct to Pins

The O command writes to directly to the 8 pins.

O [Output DATA] [tristate]

eg

O F0 00

Sets port data to F0, all pins as outputs

Tristate bits=0 are outputs.

The first operation should write set the tristate byte, but thereafter you only need to write the port data.

Any pins used for serial buses must be left as Data=0, Tristate=1.


Single Pin Output

If you are just using ONE pin only try this:

"S" will make SDA LOW, "P" will make SDA high. (START and STOP)

However as soon as you send "G" to select another bus, this one will be returned to the STOP state, ie SDA high.

This driver turns the relay ON when SDA LOW. This is chosen because the I2C bus will be High after reset.


Latching Relay

Latching relays draw less power, and can hold thier state through power interruptions. There are 2 kinds, signle and double coil. We recomend the SINGLE COIL type. It is more sensitive, and easier to drive.

To drive a latching relay you need a narrow pulse to change the state. A typical relay changes state in 5 ms. The BL232 IC has a built in delay command. This is ideal for pulsing a relay on.

Using the delay and pause routines from the BL232 ensures correct timing, regardless of what the PC and software does.

:<command to turn relay coil on> D0010 <command to turn coil off><EOL>

":" tells the interpreter to wait for EOL char before executing the line. "D0010" delays 0x10 ms (16ms). Eg connect a single coil latching relay between P0 and P1. To set the relay

:O 01 D0010 O 00 <EOL>

To reset the relay:

:O 02 D0010 O 00 <EOL>


Network Security Device

In a factory where the correct operation of machinery is vital for economic and safety reasons, todays LAN's are a major problem. WINDOWS viruses can transfer through inocuous operations like file sharing, without web-browsing or email being involved. Firewalls are often relied upon, but the same firewalls are used everywhere in the world, when one is cracked, every network using them becomes vulnerable.

Nevertheless, it is desireable for machines to be on the lan, and able to access the internet.

The Network Fuse is a hardware solution. A critical machine, or subsection of the network is connected through a relay to the LAN. An I2C-2-PC is used to control the relay. When access is needed, the relay is turned on.

This solution is secure, because is is customised. Every script kiddie can find the latest Windows vulnerabilty. No one knows what special hardware lives where on your LAN.

Using it From Excel

See the Realterm example. All you have to do is send the control string from excel

Back to Top
Back to Home

Contact Information

sales@i2cchip.com
http://www.i2cchip.com
Phone +64 21 623-402

Back to Top

Comments and Suggestions

Please send us mail telling us what you think about this page and how we might improve it.

Back to Top