SDK Variables

From Mach3Wiki
Jump to: navigation, search

Following is a list of brief explanations of the contents of the ENGINE block variable in the Mach3 SDK.

The Engine-> variable contains all the variables used to communicate with the Ring0 driver which does all the work with Printer ports. In addition, this block of variables is used for simulation modes, and to create a standard point of reference even for non-printer port modes such as the G100 operating mode. When no driver is loaded, the program applies various algorithms to this data to create a runtime simulation of the printer port running. This Block then may be considered as a very important one in Mach3, and is responsible for a great deal of its Driver functionallity.

First, we have some structures, (All this information can be found in the "Engine.h" file, but this Wiki entry will attempt to better document them. Users are invited to add annotations to qualify their use, or point out limitations to their use as they are discovered.

This structure is used for all output signals. Not only printer port, but ModIO and G100, just with different port numbers typically.

NOTE: The structures are also documented (in a different fashion and slightly differently) in Engine.h. This page is older than the Engine.h page.

struct OutputInfo
       bool active;            // Is this output Active (Enabled) or Not?
       char OutPin;            // What Pin? Any number from 0 -255
       char OutPort;           // What port, again any number from 0 - 255, BUT the
                               // printer driver will ignore any inappropriate to the
                               // printer port.
       bool Negated;           // Low Active or High Active. Expectation of the voltage
                               // level to trigger the following boolean..
       bool Activated;         // True when the voltage level equals the above setting.

// input signal structure
struct  InputInfo
      bool  Active;            // signal active?
      char  InPin;             // which Pin
      char  InPort;            // which Port
      bool  Negated;
      int   ReqState;          // Required State on Activation (Not used at present., 
                               // may be used by a PlugIn at will.
      bool  Activated;         // Set by the pinter driver (Or ModIO, or G100) 
                               // to indicate an input is seen matching conditions. 
      bool  Emulated;          // If True, then the emulation key will trigger an
                               // Activated condition..
      int   EmulationKey;
// encoder inputs
// Following is set by G100, or printer port, as well as ModIO sections 
// to set condition for the encoder. 
// Only the printer drivers will use anything other than count[0] which is total encoder
// count.
struct Encoder
      bool Active;             // is the encoder turned on?
      int  APin;               // A Pin designations
      int  BPin;               // B Pin designations
      int  APort;              // A Pin Ports
      int  BPort;              // B Pin Ports
      bool LastStateA;
      bool LastStateB;         // storage for the last known state
      int  Count[2];           // Index counts for each encoder
      int  Memory[16];         // Unused. Free for plugins.
      int  ActiveMemory;
      int  Color;              // Unusaed. May be used by Plugins.
// axis information structure, 7 axis, 7th is spindle..
struct AxisInfo
      int  Index;              // Current Count
      int  MasterIndex;
      char StepPin;           // Pin for step pulse
      char DirPin;            // Pin for Direction Pulse
      char StepPort;          // Port # for step
      char DirPort;           // Port # for Direction
      bool StepNegate;        // low active step?
      bool DirNegate;         // low active Direction?
      int  CurVelocity;       // Current Velocity
      int  MaxVelocity;       // Current Max Velocity (jogging )
      int   MasterVelocity;   // Master Velocity...Maximum Velocity in all circumstances.
      int   Acceleration;     // Acceleration
      bool  AtSpeed;          // At Speed Currently
      bool  Acc;              // Accelerating?
      bool  Dec;              // Decelerating?
      bool  Enable;           // Axis Enabled?
      bool  Jogging;          // Jogging On?
      int   JoggDir;          // Direction of Jog;
      bool  Homing;           // is this a homing jog?
      bool  DeRef;            // Dereferanceing Move? (move off switch)
      int   Memory[6];        // 6 memory variables, unused. May be used for plugins..
      int   ActiveMemory;     //index for memories. Unused. 
      int   Color;
      int   TripCount;
      int   DepthCount;
      bool  Probing;
      bool  Slave;
      int   SlaveAxis;
struct TrajPoint
      int Points[6];
      int Command;
      int ID;
      char shifter[6];
struct TrajBuffer{
      TrajPoint Trajectories[0x1000];
      int   TrajIndex;	             // Trajectory buffer current Index
      int   TrajHead;		     // Trajectory buffer Fill point
      int   uSecStep;               // clock count for step signal
      int   uSecDir;                // clock count for pre-raising the direction bit;
      double LastCommandPos[6];     // End position as of last movement. 
      bool  Configured;             // Engine is now configured. 
      bool  Busy;                   // Not used. 
      bool  Idle;                   // Not used. 
      bool  Emergency;              // Emergency Condition..this is not not use.
      bool  Jogging;                // One of the axis is jogging..
      bool  IncrementalJog;         // Incremental Jog..
      bool  Sync;                   // If set to true, the system will resync 
                                    // the planner and the interpeter positions.
      bool  Port1On;
      bool  Port2On;
      bool  Tuning;
      bool  ReconfigHotKeys;        // Unused.
      short Port1Address;
      short Port2Address;

      AxisInfo   Axis[7];           // axis information
      InputInfo  InSigs[nSigs];     // input signals
      OutputInfo OutSigs[nSigsOut]; // output signals
      Encoder    Encoders[7];       // encoder inputs
      int        LastCubics[6];     // Used by the printer port for position
                                    // calculations vs printer port pins.

// WatchDogs
      int   WDInt0;                 // internal watchdog.
      int   WDInt8;                 // second internal watchdog.
      int   WD2Way;                 // application to Driver watchdog, 
                                    // bi directionally used. 
      int   StartClocks;            //timing checking var's..
      int   EndClocks;
      bool  ReadClocks;
      bool  Sampleing;              // Sampleing flag
      bool  CubicDrain;             // cubicDrain flag. Sets cubics to zero;
      bool  EStop;                  // Estop condition in effect.
// software limits
       int   XLimitPos,YLimitPos,ZLimitPos,ALimitPos,BLimitPos,CLimitPos;
       int   XLimitNeg,YLimitNeg,ZLimitNeg,ALimitNeg,BLimitNeg,CLimitNeg;
       int   StatHolders[6];
       int   StatLast[6];
       bool  StatBusy;             // engine busy doign statistics for oscilliscope 
                                   // readings.. DO not use.. Internal.
       int   StatCount;
       bool  SyncError;            // Do not use.
       int   DwellTime;            // If set, the system will delay all movement
                                   // and processing by this amount of tick.
                                   // (G04Pxxx) sets this.
       int   CurrentUnits;         // mm's or inches..
       bool  Directions[7];        // Reverses Motor directions 
       bool  Safe;
// G-Code vars
       int   State;                // STOP, PAUSE, RUN....
       bool  NoTime;
       int   DisplayLine;
       int   CurrentLineExec;
       bool  Loaded;
       int   SpindleCW;
       int   SpindleCCW;
       bool  Jpg;
       double oSpinSeconds;
       bool  SpinDelayReq;
       int   Flood;
       int   Mist;
       bool  Hpgl;
       bool  NoSpindle;
       bool  NoFlood;
       bool  Pro;
       bool  Dxf;
       bool  Referenced[ 6 ];
       bool  HomeSpeed[ 6 ];
       unsigned long  TargetTime;
       int   BackCounts[ 6 ];
       int   BackSpeeds[ 6 ];
       bool  BackState[6];
       bool  BackLast[6];
       bool  BackOn; 
       bool  AutoZero[6];
       double ToolChangePos[6];
       int   LastState;
       int   LookAhead;
       int   Year;
       int   LastExec;
       int   DROUpdate;
       bool  WatchDogOn;
       bool  LimitsOff;
       bool  Simulate;
       int   Month;
       int   KeyAction;
       bool  JoyOn;
       unsigned __int64   WaitCondition;
       int   EStopReason;
       bool  PWM;
       int   PWMFreq;
       int   Day;
       int   oCurrentPulley;                //remove this
       int   oldMaxSpeeds[4];               //and this. .
       int   m_SetExec;
       bool  AutoHome;
       int   templookahead;
       bool  Homing;
       char  CircData[201];
       bool  CircLoaded;
       bool  DROMaster;
       int   SoftLimitsHi[6];
       int   SoftLimitsLo[6];
       bool  SoftDir[3];
       bool  SoftLimitEnable;
       bool  SoftLimitTriggered;
       bool  HotStart;
       bool  LCD;
       int   OverRide;
       bool  Follow;
       int   NewWindow;
       bool  Deselect;
       bool  DeSelectClick;
       bool  SelectClick;
       int   PWMBaseFrequency;
       int   PulseCount;
       int   THCCorrection;
       int   THCMaxCor;
       int   THCMinCor;
       bool  THCOn;
       int   THCAdder;
       bool  THCZero;
       int   PPS;
       int   RefCounts[6];
       int   CurrentSpindleCount;
       int   IntsPerRotation;
       bool  SpinDec;
       bool  SpinAcc;
       long  WorstCase;
       int   VerifyChecks[6];
       int   Verifys[6];
       int   THCDev;
       int   Debounce;
       bool  WaitForTrigger;
       int   nTrigger;
       int   PumpTime;
       int   MaxSpinCounts;
       bool  Threading;
       int   NormSpinCounts;
       int   SpinCorrection;
       int   SpinAdder;
       int   SpinDebounce;
       int   SPIDataPin;
       int   SPIClockPin;
       int   DataOutPort;
       int   DataOutByte;
       bool  DataOutDone;
       int   DataInPort;
       int   DataInByte;
       bool  DataInDone;
       bool  LaserTrigger;
       int   Counter;
       bool  SPIOn;
       int   SPIDataOut;
       int   SPIDataIn;
       bool  SPIDone;
       bool  SPIhidata;
       bool  OffLine;
       int   SpinStability;
       char  BitTest;
       int   CurRate;
       int   PlungeLimit; 
       bool  NoPlunge;                 //THC No plunge control
       bool  SpindleStable;
       short nSlots;
       bool  LaserMode;
       bool  MaxNCMode;
       int   MaxNCLag;
       bool  SlowMode;
       bool  MaxNC10;
       bool  Port2Input;
       bool  ChargeAlwaysOn;
       bool  RaiseLower;
       unsigned int   RawInputs;
       bool  HalfPulse;
       bool     Shuttle;
       int   ShuttleCurVel;  // Current Velocity
       int   ShuttleMaxVel;  // Current Max Velocity (jogging )
       int   ShuttleAccel;
       int   LaserX;
       int   LaserY;
       int   LaserZ;
       int   LaserXOff;
       int   LaserYOff;
       int   LaserZOff;
       bool  HoldInput1;
       int   Pierce;
struct  TimeData{
       int Time[32000];