I/O Demonstration Hardware

Following on from the previous post where an interface to physical I/O was described, I have made some further progress on this project.  Below is a short video of the implementation of this physical I/O on a Raspberry Pi single board computer with PiFace Digital I/O board (http://www.piface.org.uk/products/piface_digital/).

In this demonstration, the following Instruction List (IL) application is running that performs a bit shift of a value through output channels – This demonstration application also incorporates the calling of C-based functions in the form of the rotate-left (ROL) and logical AND mask (AND_MASK) operations.

PROGRAM rolio_il

  VAR
    Output0 AT %QX0: BOOL;
    Output1 AT %QX1: BOOL;
    Output2 AT %QX2: BOOL;
    Output3 AT %QX3: BOOL;
    Output4 AT %QX4: BOOL;
    Output5 AT %QX5: BOOL;
    Output6 AT %QX6: BOOL;
    Output7 AT %QX7: BOOL;
  END_VAR
  VAR
    Value: BYTE;
  END_VAR

  (* Set and rotate bits through a byte variable *)

  LD Value
  EQ BYTE#0
  JMPCN Rotate
  LD BYTE#1
  ST Value
  JMP Output

Rotate: CAL ROL( Value, INT#1 )
  ST Value

  (* Set output lines 0 through to 7 based upon byte variable *)

Output:

  (* Copy bit 0 to output 0 *)
  CAL AND_MASK( Value, BYTE#1 )
  GT BYTE#0
  ST Output0

  (* Copy bit 1 to output 1 *)
  CAL AND_MASK( Value, BYTE#2 )
  GT BYTE#0
  ST Output1

  (* Copy bit 2 to output 2 *)
  CAL AND_MASK( Value, BYTE#4 )
  GT BYTE#0
  ST Output2

  (* Copy bit 3 to output 3 *)
  CAL AND_MASK( Value, BYTE#8 )
  GT BYTE#0
  ST Output3

  (* Copy bit 4 to output 4 *)
  CAL AND_MASK( Value, BYTE#16 )
  GT BYTE#0
  ST Output4

  (* Copy bit 5 to output 5 *)
  CAL AND_MASK( Value, BYTE#32 )
  GT BYTE#0
  ST Output5

  (* Copy bit 6 to output 6 *)
  CAL AND_MASK( Value, BYTE#64 )
  GT BYTE#0
  ST Output6

  (* Copy bit 7 to output 7 *)
  CAL AND_MASK( Value, BYTE#128 )
  GT BYTE#0
  ST Output7

END_PROGRAM
Advertisements