Shop OBEX P1 Docs P2 Docs Learn Events
Readings from MCP3001 — Parallax Forums

Readings from MCP3001

-GRIMM--GRIMM- Posts: 56
edited 2011-03-31 18:14 in Propeller 1
I am using an MCP3001 with another project and need some help with the results.

I have used some ADC drivers for this chip from the obex, and for all of them i am having a little trouble.

For all the programs, i am getting a value of "450" when the value at the ADC pin is 1.450V

It seems to be removing the first digit from conversions.

This wouldnt be an issue if my ranger were all in 1V, but I need to measure from 0.3 to 2.5 volts.

Anybody run into this before?

Thanks

Comments

  • -GRIMM--GRIMM- Posts: 56
    edited 2011-03-31 17:37
    This is the assembly code im using, borrowed from a member:

    I believe the solution is in the assembly section somewhere, but have no assembly experience.

    [code]
    DAT
    shiftin
    org 0
    ''Set the direction and state of the I/O pins and non-recurring events
    ''
    or dira, OS ''Set OS to output
    or dira, SCL ''Set SCL to output
    or dira, CS ''Set CS to output
    xor outa, SCL ''Set SCL pin high (1)
    xor outa, CS ''Set CS pin high (1)
    ''
    mov wcnt, #0 ''Zero wcnt
    add wcnt, cnt ''Add system counter to wcnt
    add wcnt, #13 ''Add 13 clock delay to wcnt
    waitcnt wcnt, Tsucs ''Pause COG TSucs clocks

    'rdlong ADCtemp,PAR

    ''==========================================================================================
    ''Start of conversion
    :loop1 ''Loop1
  • Jay KickliterJay Kickliter Posts: 446
    edited 2011-03-31 17:41
    Which driver are you using? Normally, the ADC objects return the bit value of the sample. 450 sounds about right. Since that's a 10 bit chip, the range will be 0 to 1023 (2^10-1).

    (1.45/3.3) * 1023 = 443. About what you're getting. (assuming you're using 3.3 V on the chip's Vref pin)
  • -GRIMM--GRIMM- Posts: 56
    edited 2011-03-31 18:14
    Ok that makes sense. Which leads me to another question:

    If the range is 0-1023, does the chip return a value that is the value 0-1023 that corresponds to the point the sensing voltage is at between 0 and Vref (3.3)?

    So that every 1 bit value returned by the adc corresponds to ~0.021v of the sensor?
Sign In or Register to comment.