Andrei IRL
Senior Member
Hello everyone.
I have been working on a project which is almost completed now.
However, i have came across an issue that i am not able to resolve after many days of troubleshooting.
The project is build on 14M2 chip with AD623 INAMP and a half bridge load cell.
Within the MAIN program loop i am continuously monitoring ADC on PIN C.4
When a certain threshold is met the program jumps to FIRE subprogram.
It turns a couple of things ON and OFF and then program continues to another subprogram called WAITQS1.
The WAITQS1 subprogram start by reading ADC value on the same pin C.4.
Then this value is being compared to another value.
The really strange thing is, READADC10 within the MAIN program and READADC10 within the WAITQS1 subprogram read different value even though the weight n the load cell is remaining the same.
I have been doing some testing and looking at the ADC values from both MAIN and Subprogram and the ADC value from the Subprogram is always returning around 200 more.
So if ADC reading from the MAIN program is 550, straight after the ADC reading from WAITQS1 subprogram will return 700-750 value.
So if the pressure is still being applied on the load cell and ADC reading is below 500 then the program should just loop within WAITQS1, but for some reason ADC reurns value greater then 500 and the program returns to the MAIN, then the main loop reads the ADC to be below 600 and the program goes to FIRE and then WAITQS1 and then ADC within WAITQS1 reads a high value and the circle continuities.
Any idea what might be causing that?
Why ADC reading from two different routines would return different value when the input to ADC remains constant.
I have literally tried everything i could.
Thanks very much in advance.,
I have been working on a project which is almost completed now.
However, i have came across an issue that i am not able to resolve after many days of troubleshooting.
The project is build on 14M2 chip with AD623 INAMP and a half bridge load cell.
Within the MAIN program loop i am continuously monitoring ADC on PIN C.4
When a certain threshold is met the program jumps to FIRE subprogram.
It turns a couple of things ON and OFF and then program continues to another subprogram called WAITQS1.
The WAITQS1 subprogram start by reading ADC value on the same pin C.4.
Then this value is being compared to another value.
The really strange thing is, READADC10 within the MAIN program and READADC10 within the WAITQS1 subprogram read different value even though the weight n the load cell is remaining the same.
I have been doing some testing and looking at the ADC values from both MAIN and Subprogram and the ADC value from the Subprogram is always returning around 200 more.
So if ADC reading from the MAIN program is 550, straight after the ADC reading from WAITQS1 subprogram will return 700-750 value.
So if the pressure is still being applied on the load cell and ADC reading is below 500 then the program should just loop within WAITQS1, but for some reason ADC reurns value greater then 500 and the program returns to the MAIN, then the main loop reads the ADC to be below 600 and the program goes to FIRE and then WAITQS1 and then ADC within WAITQS1 reads a high value and the circle continuities.
Any idea what might be causing that?
Why ADC reading from two different routines would return different value when the input to ADC remains constant.
I have literally tried everything i could.
Thanks very much in advance.,
Code:
;Program rev.1.3; Date 16-Nov-2017
;PICAXE14M2
#picaxe 14m2
setfreq m8 ` Running at 8Mhz, all pause values are x2 times
symbol greenled=B.1 `GREEN LED
symbol redled=B.2 'RED LED
symbol RELAY1=C.0
symbol RELAY2=C.1
symbol old_adc=w3
symbol new_adc=w9
main: high greenled
low redled
readadc10 C.4,new_adc 'w4-b8/b9 - strain gauge running
sertxd("NEW_ADC reading at MAIN is ",#new_adc,13,10)
#terminal 9600
if new_adc<600 then gosub fire
goto main
fire: high relay1
high relay2
high redled
low greenled
pause 200
low relay1
low redled
pause 40
low relay2
waitqs1: readadc10 C.4, new_adc
sertxd("NEW_ADC reading at waitqs is ",#new_adc,13,10)
select case new_adc
case < 500 goto waitqs1
endselect
return