Shop OBEX P1 Docs P2 Docs Learn Events
Having some issues with DEBUG and and ADC0831 — Parallax Forums

Having some issues with DEBUG and and ADC0831

Turnbull2112Turnbull2112 Posts: 65
edited 2010-12-27 11:03 in BASIC Stamp
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

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-12-21 09:40
    Hi , it looks to me as though you have one to many RETURN instructions , delete the one just before the instruction DEBUG HOME.

    Apart from that is the screen displaying anything if so what?

    Jeff T.
  • Turnbull2112Turnbull2112 Posts: 65
    edited 2010-12-21 10:01
    That got the Debug working! Thanks. Now I am trying to scale the PSI and PSI2 numbers from the ADC. Currently the multiplier is cnts2mv CON $139C but I am not sure what to use or if I even need to use */. I believe the resolution from the sensor is 0-5Vdc 2.5-102PSI. It's a Freescale Semiconductor MPX5700AP. Here is my tweaked program. Thanks again.

    ' {$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
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-12-21 18:34
    Hi , can you tell us what the value of either result or result2 is when you apply a pressure of ~50psi and then again when you apply a pressure of ~25psi. If its 8 bit I would expect to see ~127 at 50psi and ~64 at 25psi

    Jeff T.
  • Turnbull2112Turnbull2112 Posts: 65
    edited 2010-12-27 11:03
    I will hopefully have that data by the end of the week. Thanks!
Sign In or Register to comment.