Const Device = CB405 '******************************************************************** Opencom 1,115200,3,80,80 'Open COM1 for MODBUS communication. Set Modbus 1,1,1 'Mode=RTU, Slave Adress=1, Return Adress=1 '******************************************************************** '******************************************************************** '*** Set P5, P6 & P7 as inputs to LADDER Usepin 5,In Usepin 6,In Usepin 7,In '*** Set P33, P34 & P34 as outputs from LADDER Usepin 33,Out Usepin 34,Out Usepin 35,Out '*** Set P16 / AD0 as input Input 16 '*** Turn ON Ladder execution Set Ladder On 'Must be done to enable PLC ladder. '*** Loop BASIC Do '*** Get value from AD Channel 0 and store in LADDER data-register D10 '*** use the _ before the PLC register name and number to acces it from BASIC _D(10) = Adin(0) Loop