User Tools

Site Tools

Translations of this page:

Sidebar

MyCNC Shop

MyCNC website

myCNC Price List

plc:button_to_toggle_select_output_pin_with_indication

Add a Button to toggle output pin with indication

  • Need to add a button on main screen of Tomas2 profile instead of “CV” button.
  • The button should toggle output #6
  • The button should have built-in LED indicator to show current Output Pin state.

The button code in cnc-screen.xml will look as

  <gitem where="work-toolbar" type="xbutton" height="60" 
  image="outputs/transistor-off" action="soft-plc-run:__TR"  
  xattr="2;38;20;20;led;green;round" address="outputs" number="6"/>
  • where=“work-toolbar” - Widget name to put the button
  • type=“xbutton” - Type for button with buil-in LED indicator
  • height=“60” - Size for button. It's supposed square button if No “width” attribute given
  • image=“outputs/transistor-off” - Skin image for the button
  • xattr=“2;38;20;20;led;green;round” - Built-in Led indicator type, color, position and size
  • address=“outputs” number=“6”- Address (inputs or outputs) and pin number to show state

Software PLC procedure source code to toggle output pin will be as follow

main()
{
 
  a=portget (0x406); //read current state of output #6
 
  if (a==0) {portset(6);} 
  else {portclr(6);};
  exit(99);
 
};

To add Software PLC procedure -

  • Go to Software PLC tab
  • Press + (Add) button and enter PLC procedure name
  • Fill the procedure source code
  • Press 2 buttons on the right - Build All and Save to save sourece code and build PLC binary file

plc/button_to_toggle_select_output_pin_with_indication.txt · Last modified: 2017/12/06 13:49 by es

Translations of this page: