Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleRevision Info

This page currently corresponds to the Ns=91 revision of the MCode.

Note
titleMotors with PCDS MCode Loaded

Any motors with standard PCDS MCode loaded should be purged and reset with the FD command before being loaded with pulse picker MCode. This avoids any interference between variables and code labels.

 

Global Variable Declarations

...

  • Wiki Markup
    *Se* \- Pulse Picker mode \[Se\]lect. Refer to Mode List for a complete list of Se modes.
  • Sd - Status indicator register. Used for debugging. Refer to Status List for a complete list of statuses.
  • Wiki Markup
    *Sw* \- \[Sw\]eep distance. Number of motor steps to equal 11.25 degrees of motion.
  • Sr - Encoder sweep distance. Number of encoder steps to equal 11.25 degrees of motion.
  • Wiki Markup
    *Dr* \- Encoder \[Dr\]ift, or the difference between the encoder count the predicted encoder position.
  • Wiki Markup
    *Dl* \- Encoder \[D\]rift \[L\]imit, Ud or Ld flags will be raised if encoder drift \[Dr\] exceeds this limit. This can be changed by the user, but is reset to 23 encoder ticks (roughly 0.5deg) if the motor is power-cycled.
  • P0 - Center (open) position, in motor steps.
  • P1 - Positive closed position, in motor steps, nominally P0+Sw. (Repurposed from standard MCode program.)
  • P2 - Negative closed position, in motor steps, nominally P0-Sw.
  • N0 - Center (open) position, in encoder counts.
  • N1 - Positive closed position, in encoder counts, nominally N0+Sr.
  • N2 - Negative closed position, in encoder counts, nominally N0-Sr.
  • Ec - Error checking flag. (0=OFF, 1=ON)
  • Ns - Pulse Picker MCode version. (Repurposed from standard MCode program.)
  • Hb - Heartbeat counter, incremented approx. every 100ms.
  • Cs - Encoder counter shadow register (=C2)
  • Ud - Drift violation counter, incremented at each + limit drift violation
  • Ld - Drift violation counter, incremented at each - limit drift violation
  • Df - Motor position flag (see interpretation below)
  • Mo - Experimentally-determined magic offset, in motor steps, that is the distance between the negative side of the homing index mark and P1. This number will be negative so that it feeds directly into an MR command. This has no initializer and depends on being correctly set by the engineer!

Program 1

Initialization (LB SU)

Code:

  • If Se<>0, we are likely experiencing a hard reset. In that case:
    • Signal state change to 80 (Hard Reset Initialization)
    • Set Ve (MCode version) to 3 and Pu (Power-Up flag) to 0.
    • Set EL ( EL (Encoder lines) to 4096, giving 4096 lines * 4 steps/line = 16384 steps/rev
    • Set MS (Microsteps) to 8, giving 8 uSteps/step * 200 step/rev = 1600 uSteps/rev
    • Set EE (Encoder enabled) to 0, forcing open-loop step mode. Closed-loop mode is too slow because of a 1kHz loop rate.
    • Set S3 (I/O 3 settings) to 16,0,1. This is used for encoder power - sourcing output, active low.
    • Set O3 (Output 3) to 1, turning the encoder on.
    • Set S4 (I/O 4 settings) to 16,0,0. This is used for fan power - sinking power, active low.
    • Set O4 (Output 4) to 1, turning the fan on.
    • Set S13 (I/O 13 settings) to 60,0,0. This is used for input signaling, and makes it available to the input capture trip (interrupt)
    • Set FC (Filter Capture) to 9. This sets a debounce filter on input 13 with a 12.9usec delay time.
    • Set HT (Hold Time) to 5, setting the hold current delay time to 5ms.
    • Set RC (Run Current) to 100, making 100% of current available for movement.
    • Set HC (Holding Current) to 5.
    • Set NE (Numeric Enable) to 0, to prevent errant communications as being interpreted as movement commands.Set Pu (Power-Up Flag) to 0 to prevent IOC from locking itself.
    • Set Sw (Sweep Distance) to 50 steps.
    • Set Sr (Encoder Sweep Distance) to 512 counts.
    • Reset Dr (Drift) to 0.
    • Reset Dl (Drift limit) to 23.
    • Reset P0 (Open position) to 0.
    • Reset P1 (Positive closed position) to P0+Sw = 512.
    • Reset P2 (Negative closed position) to P0-Sw = -512.
    • Reset N0 (Open encoder position) to 0.
    • Reset N1 (Positive closed encoder position) to N0+Sr.
    • Reset N2 (Negative closed encoder position) to N0-Sr.
    • Pre-load shadow register Cs=C2 (this doesn't actually do anything and may be eliminated in a future revision)
    • Set Ec=1 to turn error checking on.
    • Reset drift violation flags counters Ud and Ld to 0.
    • Reset Df to 99 (current slit position is unknown)
  • For both hard and soft resets, we do the following
    • Signal state change to 81 (Soft Reset Initialization)
    • Disable any trips (TE=0)
    • Hold for 100ms to let things stabilize.
    • Reset Hb (heartbeat) to 0.
    • Set Se (Mode Select) to 0
    • Goto Mode Select Loop

Mode Select Loop

...

(LB Za)

  • Mode Select Loop START (forever):
    • Signal state change to 0 (Mode Select)
    • If Se=1, branch to Mode 1: One-Shot
    • If Se=2, branch to Mode 2: Flip-Flop
    • If Se=3, branch to Mode 3: Burst
    • If Se=4, branch to Mode 4: Fast Open
    • If Se=5, branch to Mode 5: Fast Close
    • If Se=7, branch to Mode 7: Home
    • Increment heartbeat
    • Hold for 100ms
  • Mode Select Loop END

Mode 1: One-Shot (LB Z1)

  • Signal state change to 10 (One-Shot Init)
  • Load One-Shot speeds (CL V1)
  • Specify One-Shot ISR (J1) to run on Input Trip
  • Move the shutter to the nearest closed position (CL X5)
  • If the shutter is in the negative closed position:
    • Specify One-Shot ISR 2 (J2) to run on Input Trip
  • Else
    • Specify One-Shot ISR 1 (J1) to run on Input Trip
  • EndIf
  • Arm Arm Input Trip (TE=TE|4)
  • Signal state change to 11 (One-Shot Loop)
  • One-Shot Loop START (forever):
    • Increment heartbeat
    • Hold for 100ms
    • If user sets the soft reset (Se=0)
      • Branch to Fast Close (Mode 5)
    • EndIfIf movement is complete (Sd=90) Signal state change to 12 (
  • One-Shot Complete)
  • EndIf
  • One-Shot Loop Loop END

NOTE: Once in the one-shot loop, you must set Se=0 to get back to Mode Select.

One-Shot ISR 1 (

...

P1 to P2 move) (LB J1)

  • Move (MA) to negative closed position P2
  • If error checking is enabled (Ec=1)
    • Calculate , check drift at previous , negative closed position (call X9)Hold until movement completeposition P1: Dr=N1-Cs
    • If drift is at or beyond limit (Dr>=Dl)
      • Increment the lower drift violation counter Ld
    • EndIf
  • EndIf
  • Hold until movement is complete
  • Copy current encoder count (C2) to shadow register Cs
  • Set Df=1, indicating current position is positive -1 to signal at negative closed positionElse (any other position but P1
  • Return

One-Shot ISR 2 (P2 to P1 move) (LB J2)

  • Move (MA) to positive closed position P1
  • If error checking is enabled (Ec=1)
    • Calculate , check drift at previous , positive closed position (call X8)
    • Hold until movement complete
    • Set Df=-1, indicating current position is negative closed position
    EndIf
    • position P2: Dr=Cs-N2
    • If drift is at or beyond limit (Dr>=Dl)
      • Increment the upper drift violation counter Ud
    • EndIf
  • EndIf
  • Hold until movement is complete
  • Copy current encoder count (C2) to shadow register CsSignal state change to 90 (Toggle movement complete)
  • Set Df=1 to signal at positive closed position
  • Return

Mode 2: Flip-Flop

  • Signal state change to 20 (Flip-Flop Init)
  • Load Flip-Flop speeds (V2)
  • Specify Flip-Flop ISR (J2) to run on Input Trip
  • Arm Input Trip (TE=TE|4)
  • Signal state change to 21 (Flip-Flop Loop)
  • Flip-Flop Loop START (forever):
    • Increment heartbeat
    • Hold for 100ms
    • If user sets the soft reset (Se=0)
      • Branch to Fast Close (Mode 5)
    • EndIf
    • If at least one movement is complete (Sd=90)
      • Signal state change to 22 (Flip-Flop Loop Active)
    • EndIf
  • Flip-Flop Loop END

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2a73787144f5fbd0-b20d2473-44e841ad-b32fb773-66c39d484b0c2563005e9461"><ac:plain-text-body><![CDATA[

Var

Value [step/s(^2)]

[deg/s(^2)]

[rev/s(^2)]

]]></ac:plain-text-body></ac:structured-macro>

VI

5300

1192.5

3.3125

VM

10000

2250

6.25

A

1875000

421880

1171.9

D

1875000

421880

1171.9

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0ed65edea1b4a0fc-4f0fa1ec-43ff494d-a99e8453-b649b7efaeed12df9c20e285"><ac:plain-text-body><![CDATA[

Var

Value [step/s(^2)]

[deg/s(^2)]

[rev/s(^2)]

]]></ac:plain-text-body></ac:structured-macro>

VI

7500

1687.5

3.3125

VM

10000

2250

4.6875

A

1875000

421880

1171.9

D

1875000

421880

1171.9

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="51217c7307b2f556-6f8cd42c-45d149e7-8f49a3ce-e8dcbb2f7729db8422dd9b10"><ac:plain-text-body><![CDATA[

Var

Value [step/s(^2)]

[deg/s(^2)]

[rev/s(^2)]

]]></ac:plain-text-body></ac:structured-macro>

VI

7500

1687.5

3.3125

VM

10000

2250

4.6875

A

1875000

421880

1171.9

D

1875000

421880

1171.9

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="67982bc4f8156e12-b3cee824-40b64ba2-9f63a5c2-b0f979b50c7f123b6a0ae3e8"><ac:plain-text-body><![CDATA[

Var

Value [step/s(^2)]

[deg/s(^2)]

[rev/s(^2)]

]]></ac:plain-text-body></ac:structured-macro>

VI

640

144

0.4

VM

2560

576

1.6

A

640

144

0.4

D

640

144

0.4

...