Monday, March 10, 2014

Input, Output, and Indirect - Oh My!

This will be a little confusing, but if you try to take in small bytes, and just ignore some of the details, you should get through it.

NOTE: anything in parenthesis is an example value, replace with a value needed for your project.

  1. Define a variable in your IEC program. A floating point (SP), not retained, Input.
  2. Create (if not already) an IO channel, Float, Input (i.e., #1)
  3. Modify the Parameters of the selected Input(#1) of the channel to 255.253.1 i.e., Indirect
  4. Map the IO channel to the IEC variable (SP)
  5. Set the global variable NUMREGISTERS to  (1).
Now you have several different registers defined in you program.
VariableNameValueParameter
ISaGRAF VariableSP13.57User:9012
IO channeltx.ySP255.253.1
Totalflow Register91.9.1813.57
Indirect91.253.17.4.1
IO/AI17.4.113.57

Warning: Do not use Get/Set (DINIT, REAL, STRING, UDINT) in the main loop. Only use them for on demand read /writes.  They are CPU intense and 100x slower than the I/O method. (updated 4/21/2014)