Played with "Pauses", and am thinking the CUSTFUN should execute top to bottom, stopping at the "Pause". Unpaused several times to eliminate startup values. Here is a part of the CustFun, which is executed 0.1second:
SETIO OUT_41
CLRIO OUT_44
CtrPV[2] = 6
IF CtrPV[1] = 1
CLRIO OUT_42
CLRIO OUT_43
X = ADC(1)
X = ADC(1)
X = ADC(1)
X = ADC(1)
DM[3991] = ADC(1)
DM[3988] = DM[3991] * 3863/100000
ENDIF
IF CtrPV[1] = 2
'Set A0
SETIO OUT_42
'Set A1
CLRIO OUT_43
X = ADC(1)
X = ADC(1)
Y = ADC(1)
Z = ADC(1)
DM[3992] = ADC(1)
DM[3989] = DM[3992] *120/3150
IF DM[3989] > 10
SETLCD 4,1, STR$(DM[3989]) + " *********"
PAUSE
ENDIF
ENDIF
previously when CtrPV[1] = 1, ADC(1) = 3500, and is OK.
For this case the CtrPV[1] = 2, and ADC(1) should be near zero, and X, Y, Z, and DM[3989] are all around 3500. With the PLC Paused, measuring voltages with a volt meter, The Out_41 to Out_44 are as expected and ADC(1) input is zero. Have experimented with long delay loops (For I = 1 to 50000) and as seen here added dummy ADC()'s. The addresses are to a DG408 analog multiplex chip. The inputs are large lead acid batteries and 120 volt transformed to 9vac, rectified and resistor voltage divided to under 5 VDC. This worked for several weeks and quit working maybe about the time TRILOGI 6.1 came out, when I was working on other issues. The individual small program worked fine. Was there any changes in the code generated between 5.3 and 6.1 for these functions?