pcdshub / lcls-twincat-motion

TwinCAT 3 Motion Control Utilities - PLC Motion Library for all PCDS Applications
https://pcdshub.github.io/lcls-twincat-motion
Other
35 stars 20 forks source link

Unknown Race Condition/State Machine Deadlock in States Motion #197

Closed ZLLentz closed 1 year ago

ZLLentz commented 1 year ago

Current Behavior

TMO's AL1K4 and LI1K4 ended up in a bad state deadlock where they could not move.

There are two function blocks I'd like to point out here.

First: https://github.com/pcdshub/lcls-twincat-motion/blob/master/lcls-twincat-motion/Library/POUs/Motion/States/FB_StatesInputHandler.TcPOU Where:

Second: https://github.com/pcdshub/lcls-twincat-motion/blob/master/lcls-twincat-motion/Library/POUs/Motion/FB_MotionRequest.TcPOU Where:

The problems are:

This is recoverable with an online write to bExecMove := FALSE

Expected Behavior

States should always move when asked, if possible and safe.

Context / environment

lcls-twincat-motion 4.0.1 lcls-twincat-common-components 3.0.1

Steps to Reproduce (for bugs)

Unknown

Suggested Solution

  1. Understand how we get into this state deadlock and prevent it
  2. Add an escape hatch to escape the deadlock- perhaps we can adjust some things when the FB errors are cleared?
ZLLentz commented 1 year ago

Some further thinking: the path to this bad state must begin when a move is requested, since at startup none of the execute booleans are TRUE.

ZLLentz commented 1 year ago

Update: this is caused by the following sequence:

  1. We get an error
  2. We ask for another move during an error without clearing the error first

And then the states function block becomes permanently stuck

The solution should involve one or more of:

  1. Reset more variables on epics user reset
  2. Reject moves when in an error state