===== 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. 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. {{plc:bv17-dac.png}} {{youtube>sIx86EgzULY}} 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. {{plc:mycnc-profiles--32.png}} XML code for setup the buttons to start/stop Software PLC procedure looks like 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