When selecting an I/O schema for your Motion Control System, it is often desirable to have a flexible, powerful option which can evolve with your design. Slice I/O is intended to handle variety and change. Slice I/O is an expandable set of I/O blocks which can be modeled into the vision of your system.
Slice I/O is comprised of a communications block with attached segments of Digital and Analog IO. In slices of 2-16 IO, you can add blocks to meet the demands of your system. Bellow is a sample SynqNet Slice I/O Node attached to the controller without any other drives.
All examples below will be based on the above system:
The following shows the Slice I/O as seen in RapidSetup.
Using Slice I/O: There are basically two ways to reference I/O. You can decide to use either one available: 1. Addressing relative to nodes. 2. Addressing relative to segment.
Here are a list of the 9 Node based Access Functions: DigitalInGet(bitNumber) Single bit access based on number by Node. DigitalOutGet(bitNumber) Single bit access based on number by Node. DigitalOutSet(bitNumber, value) Single bit access based on number by Node.
DigitalInGet(startingBit, numberToCollect) - A range of bit(s) accessed by Node. DigitalOutGet(startingBit, numberToCollect) - A range of bit(s) accessed by Node. DigitalOutSet(startingBit, numberToSet, value) - A range of bit(s) accessed by Node.
AnalogInGet(channel) - A channel which is referenced by Node. AnalogOutGet(channel) - A channel which is referenced by Node. AnalogOutSet(channel, value) - A channel which is referenced by Node.
Here is the list of 9 Segment based Access Functions: SegmentDigitalInGet(segmentNumber, bitNumber) Single bit access based on number by Segment. SegmentDigitalOutGet(segmentNumber, bitNumber) Single bit access based on number by Segment. SegmentDigitalOutSet(segmentNumber, bitNumber, value) Single bit access based on number by Segment.
SegmentDigitalInGet(segmentNumber, startingBit, numberToCollect) - A range of bit(s) accessed by Segment. SegmentDigitalOutGet(segmentNumber, startingBit, numberToCollect) - A range of bit(s) accessed by Segment. SegmentDigitalOutSet(segmentNumber, startingBit, numberToSet, value) - A range of bit(s) accessed by Segment.
SegmentAnalogInGet(segmentNumber, channel) - A channel which is referenced by Segment. SegmentAnalogOutGet(segmentNumber, channel) - A channel which is referenced by Segment. SegmentAnalogOutSet(segmentNumber, channel, value) - A channel which is referenced by Segment.
I will give several examples of reading and writing Digital IO to make you more comfortable with these function calls.
Input Example 1: Now as an example lets say that you want to get the state of the input bits (3, 4 and 5) on Segment 1. (Our state table as seen from RapidSetup)
The code would be as follows: printf("State of the input bits for the Segment 1: 0x%x.\n", io->SegmentDigitalInGet(1, 3, 3));
The display for the above code would be as follows. This display is in hexadecimal which means that bits 3, 4 and 5 on segment 1 are low.
Input Example 2: Now lets say that you want to get the state of the input bits (0-7) on Segment 1. (Using different values, our state table as seen from RapidSetup)
Running the following command: printf("State of the input bits for the Segment 1: 0x%x.\n", io->SegmentDigitalInGet(1, 0, 8));
The output would be as follows:
A return of 14 from our function call:
0 0 0 1 0 1 0 0 is binary for the hexadecimal address representation 14 as displayed above.
Input Example 3: Reading a different section (bits 2, 3, 4) of the same slice. (Using the same state table as Example 2.)
Running the following command: printf("State of the input bits for the Segment 1: 0x%x.\n", io->SegmentDigitalInGet(1, 2, 3));
The output would be as follows:
The reason is as follows:
The Binary is 1 0 1 and the hexadecimal address would be 0x5 as displayed above.
Input Example 4: Here is another different section (1, 2, 3, 4, 5) of the same slice but with reference by relationship to the Node rather than a Segment. (Using the same state table as Example 2.)
As there are 8 Digital inputs on Segment 0, Segment 1s digital inputs are numbered 8-15. Therefore (Segment 1 Digital Input 1) is the same as (Node Digital Input 9) and so on.
Running the following command: printf("State of the input bits for the Segment 1: 0x%x.\n", io->DigitalInGet(9, 5)); The output would be as follows:
The reason is as follows:
The Binary is 0 1 0 1 0 and the hexadecimal address would be 0xa as displayed above.
Output Example 1: Set the state of the output bits (1 and 2) on Segment 2 to HIGH. (Our desired state table as seen from RapidSetup)
In this case, the bit representation would be as follows:
The hexadecimal value for the above bit representation is 0x6 from bit 0 or 0x3 from bit 1.
The code would be as follows: io->SegmentDigitalOutSet(2, 0, 4, 0x6, true); -or- io->SegmentDigitalOutSet(2, 1, 2, 0x3, true);
Output Example 2: Now changing bit 0 and bit 3 to be HIGH. (Our desired state table as seen from RapidSetup)
In the case above the bit representation would be as follows:
The hexadecimal value for the above bit representation is 0x9.
Call the following method: io->SegmentDigitalOutSet(2, 0, 4, 0x9, true);
Output Example 3: Reading an Output is similar to reading Inputs. (Our state table as seen from RapidSetup)
Passing the following code: printf("State of the output bits (0 and 3) for Segment 2: 0x%x. ", io->SegmentDigitalOutGet(2, 0, 4));
This will display below: 0x9 which is 1001 in binary meaning that bits 0 and bit 3 are HIGH.
Please review the Slice I/O sample applications available at www.roboticsys.com/rapidcode/examples.php for a full example of proper use.