User Tools

Site Tools


plc:controller_peripherals_test_-_bv17

Controller Peripherals test BV17

We use Software PLC procedure BV17 to test control board peripherals - binary outputs, DACs, PWM. The procedure is a good example of how to get access to PWM, DACs and binary output registers from Software PLC.

__BV17.plc
main()
{
//exit(99);
 
a=0; n=0;
 
  do
  {
  c=0;
  do {
  c++;
  if (c&1){ portset(n);}else { portclr(n);};
 
  p1+=100;
  if (p1>4096) {p1=0;};
 
  gvarset(0x1010000,p1);//set to PWM1 value p1
  gvarset(0x1010001,p1);//set to PWM2 value p1
  gvarset(0x1010002,p1);//set to PWM3 value p1
  gvarset(0x1010003,p1);//set to PWM4 value p1
 
  gvarset(0x1010010,p1); //dac
 
  }while(c<6);
 
n++;
if (n>15){n=0;};
 
}while(1);
 
};

The procedure sequentially ping outputs (triple blink), and increase PWMs and DAC registers in loop.

Name of the test procedure was BV17 for early releases. This function is loaded and started automatically with starting the myCNC software. To disable peripherals test you need to enable the first line “exit(99);” (remove comments).

main()
{
  exit(99);
  ....
  ....

In this case, the procedure will be finished immediately without touching any peripherals.
Need to save changes, rebuild sources - press 2 buttons on the right of the PLC Builder screen - to apply the changes.

All the Software PLC procedures are loaded and started automatically with starting myCNC software except procedures started with (double underline). In later releases, we renamed the procedure from “BV17” to “__BV17” to remove an issue with automatical enter to test peripherals mode.

To start/stop peripherals test we use on-screen buttons “1” and “0” on diagnose widget. However, any other button anywhere on the GUI can be configured to do the same.

XML code for setup the buttons to start/stop Software PLC procedure looks like

  <gitem where="system-buttons" height="80" 
    action="soft-plc-run:__BV17/0" 
    image="alphabet/alphabet-1" 
    type="button"/>
  <gitem where="system-buttons" height="80" 
    action="soft-plc-stop:__BV17/0" 
    image="alphabet/alphabet-0" 
    type="button"/>

Action attribute “soft-plc-run:__BV17/0” is used to Start Software PLC procedure Action attribute “soft-plc-stop:__BV17/0” is used to Stop Software PLC procedure

plc/controller_peripherals_test_-_bv17.txt · Last modified: 2018/07/20 14:11 by skirillov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki