Having some issues with DEBUG and and ADC0831
Turnbull2112
Posts: 65
I'm trying to read two ADC0831's that are connected to two gas pressure sensors.
Here are my problems.
1. The DEBUG terminal isn't working very well, I'm not seeing the ADC values or voltages. I'm not very sharp with the DEBUG programming so I know what I have isn't correct. Any guidance would be appreciated. I am trying to see both the ADC values and the scaled pressures from both ADC's.
2. The math to determine the pressure scaling for the DEBUG terminal. The pressure ranges are 2.5-102psi and the output from the sensor is 0-5v. I assume this means 20.5psi/V??
Here is my program so far, any help/guidance would be greatly appreciated.
Regards,
' {$STAMP BS2}
' {$PBASIC 2.5}
'ADC8031
cs PIN 0
clock PIN 1
datain PIN 2
cs2 PIN 3
clock2 PIN 4
datain2 PIN 5
cnts2mv CON $139C
result VAR Byte
mVolts VAR Word
result2 VAR Byte
mVolts2 VAR Word
reset:
DEBUG CLS,
"ADC....",CR
"ADC2...",CR
main:
DO
GOSUB read_0831
mVolts = result */ cnts2mv
GOSUB read_0831_2
RETURN
DEBUG HOME,
CRSRXY, 9, 0, DEC result, CLREOL
CRSRXY, 9, 1, DEC result2, CLREOL
PAUSE 100
LOOP
subroutine
read_0831:
LOW cs
SHIFTIN datain, clock, MSBPOST, [result\9]
HIGH cs
RETURN
read_0831_2:
LOW cs2
SHIFTIN datain2, clock2, MSBPOST, [result2\9]
HIGH cs2
RETURN
Here are my problems.
1. The DEBUG terminal isn't working very well, I'm not seeing the ADC values or voltages. I'm not very sharp with the DEBUG programming so I know what I have isn't correct. Any guidance would be appreciated. I am trying to see both the ADC values and the scaled pressures from both ADC's.
2. The math to determine the pressure scaling for the DEBUG terminal. The pressure ranges are 2.5-102psi and the output from the sensor is 0-5v. I assume this means 20.5psi/V??
Here is my program so far, any help/guidance would be greatly appreciated.
Regards,
' {$STAMP BS2}
' {$PBASIC 2.5}
'ADC8031
cs PIN 0
clock PIN 1
datain PIN 2
cs2 PIN 3
clock2 PIN 4
datain2 PIN 5
cnts2mv CON $139C
result VAR Byte
mVolts VAR Word
result2 VAR Byte
mVolts2 VAR Word
reset:
DEBUG CLS,
"ADC....",CR
"ADC2...",CR
main:
DO
GOSUB read_0831
mVolts = result */ cnts2mv
GOSUB read_0831_2
RETURN
DEBUG HOME,
CRSRXY, 9, 0, DEC result, CLREOL
CRSRXY, 9, 1, DEC result2, CLREOL
PAUSE 100
LOOP
subroutine
read_0831:
LOW cs
SHIFTIN datain, clock, MSBPOST, [result\9]
HIGH cs
RETURN
read_0831_2:
LOW cs2
SHIFTIN datain2, clock2, MSBPOST, [result2\9]
HIGH cs2
RETURN
Comments
Apart from that is the screen displaying anything if so what?
Jeff T.
' {$STAMP BS2}
' {$PBASIC 2.5}
'ADC8031
cs PIN 0
clock PIN 1
datain PIN 2
cs2 PIN 3
clock2 PIN 4
datain2 PIN 5
cnts2mv CON $139C
result VAR Byte
mVolts VAR Word
result2 VAR Byte
mVolts2 VAR Word
reset:
DEBUG CLS,
"ADC....",CR,
"PSI....",CR,
"ADC2...",CR,
"PSI2...",CR
main:
DO
GOSUB read_0831
mVolts = result */cnts2mv
GOSUB read_0831_2
mVolts2 = result2 */cnts2mv
DEBUG HOME,
CRSRXY, 9, 0, DEC result, CLREOL,
CRSRXY, 9, 1, DEC mVolts, CLREOL,
CRSRXY, 9, 2, DEC result2, CLREOL,
CRSRXY, 9, 3, DEC mVolts2, CLREOL
PAUSE 100
LOOP
subroutine:
read_0831:
LOW cs
SHIFTIN datain, clock, MSBPOST, [result\9]
HIGH cs
RETURN
read_0831_2:
LOW cs2
SHIFTIN datain2, clock2, MSBPOST, [result2\9]
HIGH cs2
RETURN
Jeff T.