__header__

Digital IO Erik

The Digital IO Erik is a ladder logic engine.  It allows you to run boolean equations using the digital IO. 

Using Erik

The Digital IO Erik property page (accessed through the icon in the ROT) allows you to enter equations that give you control of logic over your Digital IOs.



Type your equation into the large text area.  When you have finished you will need to save what you have written so that it can be accessed by the system.  Erik is saved in a basic .txt format.  If you already have saved expressions on the system you can also load them through this window.
The "Time" button will display the time in milliseconds that it takes to run the current expression.  You will get a more accurate estimate if you compile the expression first.

The "Compile" button converts all of your code into Erik's native format.  It also checks for syntax errors in the text.  While you do not need to compile before you save and run it is always a good idea to do so to make sure you have typed everything correctly.

The Erik Viewer

The Erik expressions can be viewed in the Erik Viewer window.  This window can be enabled in the Windows Configuration by selecting IOErikView.  The IOs that are currently active or on will display in green, and the IOs that are currently inactive or off will display in red.

Understanding the Erik Code

Erik has its own set of expressions that it uses to create equations.  In the following expressions Aux1, Aux2 and Aux3 are sample IO.

AND ("&" or "." can be substituted for AND - i.e. aux1 = aux2 and aux3 can be written aux1 = aux2 . aux3)

Example:
Aux1 = Aux2 AND Aux3

Explanation:
In this case Aux1 will be on when both Aux2 and Aux3 are on.

OR ("|" or "+" can be substituted for OR)

Example:
Aux1 = Aux2 OR Aux3

Explanation:
Aux1 will be on when either Aux2 or Aux3 are on.

NOT ("~" or "/" can be substituted for NOT)

Example 1:
Aux1 = NOT Aux2

Explanation:
Aux1 will be on when Aux2 is off.

Example 2:
Aux1 = Aux2 OR NOT Aux3

Explanation:
Aux1 will be on either when Aux2 is on or Aux3 is off.

RISING (TURNEDON can be substituted for RISING)
FALLING (TURNEDOFF can be substituted for FALLING)

Example 1:
Aux1 = RISING (Aux2)

Explanation:
Aux1 will turn on for the one cycle when Aux2 is turning on.  In either RISING or FALLING Aux1 will only stay on for 1 cycle.  If FALLING were substituted for RISING Aux1 would turn on for the one cycle when Aux2 is turning off.

Example 1:
Aux1 = RISING (1, Aux2)
Aux1 = RISING (1,(Aux2 AND Aux3))


here the default state on start up is on


DELAYON
DELAYOFF

Example:
Aux1 = DELAYON (300, Aux2)

Explanation:
Aux1 will turn on 300 milliseconds after Aux2 is turned on.  If Aux2 is not turned on for 300 milliseconds then Aux1 will not turn on at all.  Once Aux1 is on it is linked to Aux2 so that it will stay on as long as Aux2 is on and turn off when Aux2 turns off.
If DELAYOFF is substituted for DELAYON then Aux1 will turn off 300 milliseconds after Aux2 is turned off.  When Aux2 is on Aux1 will be on as well, but when Aux2 is turned off Aux1 will only turn off after 300 milliseconds.  If Aux2 is not off for 300 milliseconds then Aux1 will not turn off.

SECTION (IF can be substituted for SECTION)
END (END is needed to complete theequation)

Example:
SECTION  NOT (Aux1)
  Aux2 = Aux3 OR Aux4
   Aux3 = NOT Aux4
END

Explanation:
If Aux1 is off... then
Aux2 will be on when either Aux3 or Aux4 is on and
Aux3 will be on whenever Aux4 is off

Note sections can be nested

SECTION RESET
END

Example:
SECTION Aux4
  SECTION RISING Aux5
    Aux6 = ON
  END
END

SECTION RESET Aux4
  SECTION RISING Aux5
    Aux7 = ON
  END
END
Explanation:
If Aux5 is on before Aux 4 in the SECTION RESET Aux7 will be on when AUX4 goes.IE the RISING state is reset

CMP

compare numeric parameters

eg CMP( A,5) returns true is a = 5
eg CMP( A = 5) returns true is a = 5
eg CMP( A > 5) returns true is a > 5

comparisons include

= > < >= <=


SIMPLE SHIFT REGISTER

 the following is an example using 6 outout IO to create a 6 bit shift register

SECTION RISING(RESET)
    Bit6.OFF = ON
    Bit5.OFF = ON
    Bit4.OFF = ON
    Bit3.OFF = ON
    Bit2.OFF = ON
    Bit1.OFF = ON
END

SECTION RISING(Shift)
    Bit6 = Bit5
    Bit5 = Bit4
    Bit4 = Bit3
    Bit3 = Bit2
    Bit2 = Bit1
    Bit1 = newValue
END

IOSHIFTREGISTER

SECTION RISING(RESET)
    IOSequencer = OFF
    IOSequencer = OFF
    IOSequencer = OFF
    IOSequencer = OFF    ; As many times as there are bits
END

SECTION RISING(Shift)
    IOSequencer = newBitValue
END

to use the data
    Reject = IOSequencer

from within the code the IOShiftRegister is also a IVariant as long so it can be read and written to ???

   

Simple Latching

Example:
Aux1.ON = RISING(Aux2)

Here Aux1 is set only then the conditon is true. Is is not reset when Aux2 goes off.

To turn Aux1 off a similar statement can be set later in the program

Aux1.OFF = RISING(Aux3)

Running Programs with Erik

While programs do not function precisely the same way as IO, they can be run using Erik.  Programs can be linked into Erik by typing the name of the program.

Setting a program equal to an IO will cause the program to run continuously while the IO is on.

Example:
Main = F2

This will cause the program Main to run continuously while F2 is pressed.  Programs can be run using the NOT command as well, so "Main = NOT F2" will cause the program Main to run continuously as long as F2 is not pressed.

The RISING and FALLING commands work as well.  

Example:
Main = RISING F2

This will cause the program Main to run once when the F2 button is pressed.  The FALLING command, conversely, would cause the Main program to run once when the F2 button is released.

Setting a program.ON equal to an IO will cause the statement to trun only when the condtition is true

Example:
Main.ON = RISING(F2)



While programs can be run using Erik, programs cannot be setup in Erik to trigger IO when these porgram are  not is async mode.

For example:
Aux1 = Main

This program will not cause AUX1 to turn on when the Main program is running.

Parameters with Erik

Parameters can be defined inside  Erik by goitn to the Parameters Property Page.
Theses Parameters can be assigned an manipulated inside the Erik Logic

Maths with Erik

Example
 Param1 = Param2 * 3 + Param2

The maths above is carried out and assigned to parameter 2.
For more help on these maths options see Possible Expressions

String Assignment with Erik

Example
 Param1 = "Hello there"

Protocol - SMEMA

consider a conveyor
on entry we have an output MCReady
on entry we recieve an input PAIn  (Part Available Inbound)

on exit we have an output PAOut (Part Available Out)
on exit we have an input NxtMCReady (Next Machine ready)

we have two inputs to detect the part ProxIn and ProxOut
we have an output that conveys

FOR TTS the logic could be

MCReady = ((NOT Incycle) AND  (NOT ProxIn) AND (NOT PAOut) AND (NOT Error)) OR (MCReady AND PAIn)
PAOut = ProxOut OR (PAOut and NxtMCready)
Convey = InCycle or NxtMCReady OR PAIn
InCycle.On = RISING(ProxIn)
InCycle.Off = RISING(ProxOut)
InCycle.Off = RISING(Tmr)
Tmr.On = RISING(ProxIn)
Tmr.Off = RISING(ProxOut)
SECTION RISING(Tmr)
    msgError =" Time Out error"
    Error = ON
END


FOR PICK AND PLACE modify
Convey = InCycle
InCycle.On = ProxIn AND NOT PAIn