User panel component for start / feed hold / stop

More
08 Mar 2023 12:34 #266113 by TOLP2
Created a small component for the user panel on my EMCO5-to-become. The machine has a small user panel with three buttons with indicator lights. The three buttons are labelled:
  • start: should start the GCode if any is loaded;
  • pause / feed-hold: when active, it pauses the current program. When paused, one can step through the program by pressing the start button;
  • stop: stops any program currently active.
The indicator lights should show whether:
  • button/mode is enabled: on;
  • button/mode is active: blinking (e.g. the start button is blinking when a program is running);
  • button/mode is disabled: off.
The above is certainly possible with a HAL file and loads of and and or ports and I have seen an example on this forum (cannot find it now though). In my opinion it clutters the HAL-file and is not really readable, so instead I created a component so the behavior can be nicely defined in a states.

Maybe someone finds it useful for their machine. 

File Attachment:

File Name: emco5_userpanel.comp
File Size:4 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
08 Mar 2023 13:19 #266115 by TOLP2
An example on how to use this component:
loadrt emco5_userpanel count=1
loadrt pwmgen output_type=type0

addf emco5_userpanel.0             servo-thread
addf pwmgen.make-pulses            servo-thread
addf pwmgen.update                 servo-thread

# Status from halui
net is-idle          emco5-userpanel.0.is-idle           <= halui.program.is-idle
net is-paused        emco5-userpanel.0.is-paused         <= halui.program.is-paused
net is-running       emco5-userpanel.0.is-running        <= halui.program.is-running
# Status whether program is loaded
net is-gcode-loaded  emco5-userpanel.0.is-gcode-loaded   <= gmoccapy.program.length
# Connect the buttons
net is-start-pressed emco5-userpanel.0.is-start-pressed  <= EMCO5.gpio.start_button.in
net is-pause-pressed emco5-userpanel.0.is-pause-pressed  <= EMCO5.gpio.pause_button.in
net is-stop-pressed  emco5-userpanel.0.is-stop-pressed   <= EMCO5.gpio.stop_button.in
# Export the actions to the halui
net pause            emco5-userpanel.0.pause             => halui.program.pause
net resume           emco5-userpanel.0.resume            => halui.program.resume
net run              emco5-userpanel.0.run               => halui.program.run
net step             emco5-userpanel.0.step              => halui.program.step
net stop             emco5-userpanel.0.stop              => halui.program.stop
# Connect the status LEDs
net start-status-LED emco5-userpanel.0.start-status-LED  => EMCO5.gpio.start-LED.out
net pause-status-LED emco5-userpanel.0.pause-status-LED  => EMCO5.gpio.pause-LED.out
net stop-status-LED  emco5-userpanel.0.stop-status-LED   => EMCO5.gpio.stop-LED.out
# Signals for disabled (OFF/FALSE), enabled (ON/TRUE) and active (BLINKING -> PWM) buttons. 
setp emco5-userpanel.0.status-disabled FALSE
setp emco5-userpanel.0.status-enabled  TRUE
# - create blinking signal and connect to the active signal
setp pwmgen.0.enable   TRUE
setp pwmgen.0.value    0.5
setp pwmgen.0.scale    1.0
setp pwmgen.0.pwm-freq 1.0
net status-active    emco5-userpanel.0.status-active     <= pwmgen.0.pwm 
The following user(s) said Thank You: rodw

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum