Breakdown of Conveyor Code - Paiet/Capstone GitHub Wiki

Here is a breakdown of what the Conveyor-plc.ld does:

The program begins by defining several input and output signals for the PLC:

  • start_button: This is an input signal to start the conveyor motor.
  • stop_button: This is an input signal to stop the conveyor motor.
  • emergency_stop: This is an input signal to stop the conveyor motor in an emergency.
  • conveyor_motor: This is an output signal to control the motor.
  • warning_light: This is an output signal that indicates when the conveyor is not running or when the emergency stop has been activated.

The program also defines two variables for tracking the state of the system:

  • conveyor_running: This is a Boolean (TRUE/FALSE) variable used to track whether the conveyor is currently running.
  • emergency_active: This is a Boolean (TRUE/FALSE) variable used to track whether the emergency stop has been activated.

The main program loop begins with a check for the emergency stop button:

  • If the emergency stop button is pressed, the program sets the emergency_active flag to TRUE and turns off the conveyor motor.
  • If the emergency stop button is not pressed, the program clears the emergency_active flag.

Next, the program checks for the start button:

  • If the start button is pressed and the emergency stop is not active, the program sets the conveyor_running flag to TRUE and turns on the conveyor motor.

The program then checks for the stop button and the emergency stop button:

  • If the stop button is pressed or the emergency stop button is active, the program sets the conveyor_running flag to FALSE and turns off the conveyor motor.

Finally, the program checks the conveyor_running and emergency_active flags:

  • If the conveyor is running and the emergency stop is not active, the program turns off the warning light.
  • If the conveyor is not running or the emergency stop is active, the program turns on the warning light.