Fusion Series controllers support up to two ports of 8-bit digital input/output, allowing users to read and control 5V digital signals using only a few simple commands. When used for digital input applications, Fusion controllers are capable of reading inputs such as switches, magnet sensors, and other contact closure devices. Digital output makes it easy to control LEDs and some logic circuits at very high speed.
Port Direction
The first step in using the Digital I/O features of Fusion series controllers is a complete understanding of port direction. Each 8-bit port may be configure to read inputs, write outputs, or both in combination. When the port is set to all inputs, 8 switches can be read as long as the input does not exceed 0 to 5 Volts DC. When the port is set to all outputs, 8 LEDs can be controlled by software, allowing you to turn each LED on or off in any combination. It’s easy to mix inputs and outputs, allowing users to read 4 switches and control 4 LEDs. Each I/O line on the Fusion controller may be configured to input or output, but you must set the status of all 8 I/O lines at one time using a single command. Here’s an example:
236 2 255 Set I/O Lines 1 to 8 to Input Rx: 255
236 2 0 Set I/O Lines 1 to 8 to Output Rx: 0
236 2 15 Set I/O Lines 1-4 to Input, 5-8 to Output Rx: 15
The third byte in the Port Direction command is used to set the Digital Input or Output state of all 8 data lines on the I/O port. Here’s how you decide what this value should be:
Each I/O bit has a value associated, as shown below:
IO 8 IO 7 IO 6 IO 5 IO 4 IO 3 IO 2 IO 1
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
128 64 32 16 8 4 2 1
Each of these 8 bits may be On or Off:
1 = On = Input
0 = Off = Output
If we turn on every other bit, we get this:
IO 8 IO 7 IO 6 IO 5 IO 4 IO 3 IO 2 IO 1
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
In Out In Out In Out In Out
1 0 1 0 1 0 1 0
128 0 32 0 8 0 2 0
Bits 8, 6, 4, and 2 will be turned On, setting them to Input, the other bits will remain off, setting them to output.
Now we add the bits together:
128 + 32 + 8 + 2 = 170
Now we send the command:
236 2 170 Sets I/O Line 0 to Output
Sets I/O Line 1 to Input
Sets I/O Line 2 to Output
Sets I/O Line 3 to Input
Sets I/O Line 4 to Output
Sets I/O Line 5 to Input
Sets I/O Line 6 to Output
Sets I/O Line 7 to Input
Controller responds with: Rx: 170
In the screen shot above, the 8-Bit I/O Port was configured for input and output. I/O Lines 1, 3, 5, 7 are Outputs while I/O Lines 2, 4, 6, 8 are set to Inputs. The value 85 was written to the port, turning on I/O Lines 1, 3, 5, and 7 (these lines can be used to drive LEDs). Inputs 2, 4, 6, and 8 can be used to read switches, and will light RED if the input is high and you click the “Read from Port” button.
Port 1 Commands
Value can be any number from 0 to 255, and follows the 8-Bit binary standard.
236 0 Write Output values to output bits of I/O port Rx: [Output Value]
236 1 Read Input value from input bits of I/O Port Rx: [Input Value]
236 2 Set Port Direction Command Rx: [Direction Value]
Port 2 Commands
Value can be any number from 0 to 255, and follows the 8-Bit binary standard.
236 0 [Value] 2 Write Output values to output bits of I/O port Rx: [Output Value]
236 1 2 Read Input value from input bits of I/O Port Rx: [Input Value]
236 2 [Value] 2 Set Port Direction Command Rx: [Direction Value]
EEPROM Memory
EEPROM Memory stores the state of each port when power is first applied to the controller.
Please review the Fusion EEPROM Quick Start Guide for complete details.
EEPROM Memory Locations
280 Stores the Direction of Port 1
281 Stores the On/Off Status of Each Bit of Port 1
282 Stores the Direction of Port 2
283 Stores the On/Off Status of Each Bit of Port 2