Shop OBEX P1 Docs P2 Docs Learn Events
Problem with Propeller BOE ADC — Parallax Forums

Problem with Propeller BOE ADC

rubergdrubergd Posts: 11
edited 2012-06-11 10:20 in Propeller 1
Hi, Folks,

I just received my first Propeller BOE and was trying out the new onboard ADC function. I downloaded the spin code folder for Section 5 - Measure Voltage from http://learn.parallax.com/node/103 and ran "Simple ADC Test.spin", which measures the voltage on the wiper of a pot hooked across 5V and displays the ADC count on the PST. The code returns "-1" instead of the expected ADC count. I checked the wiper voltage of the pot with a DVM, and it's there. The default input channel was 0 for the code. I changed the code to monitor channels 1 and 2, all with the same result. All support objects are in the same folder. The -1 is returned by the "In" method of "PropBOE ADC.spin". The best I can tell, it looks to be generated when expected data is not received from the ADC chip.

Any ideas? The relevant code is posted below. The complete code archive is attached.

Thanks in advance!

....Don


Here is "Simple ADC Test.spin":
[FONT=Times New Roman]OBJ

  system : "Propeller Board of Education"              ' PropBOE configuration tools
  pst    : "Parallax Serial Terminal Plus"             ' Terminal communication tools
  adc    : "PropBOE ADC"                               ' A/D Converter on PropBOE
  time   : "Timing"                                    ' Timing convenience methods

VAR

  long ad                                              ' Stores A/D conversion Result

PUB Go                                                 ' Program starts here

  system.Clock(80_000_000)                             ' Propeller system clock -> 80 MHz
  
  repeat                                               ' Main loop
    ad := adc.In(0)                                    ' Get AD0 analog to digitla conversion
    Display                                            ' Call Display method (below)
    time.Pause(50)                                     ' Delay for 50 ms

PUB Display
''Display Method
''Sends cursor home, then displays ad=value and clears
''to right of value.

  pst.Home                                              ' Home position on screen
  pst.Str(String("ad="))                                ' Display AD=
  pst.Dec(ad)                                           ' Display analog/digital measurement
  pst.ClearEnd                                          ' Clear to the right of the value
    [/FONT]



Here is In() from "PropBOE ADC.spin":

[FONT=Times New Roman]PUB In(channel) : adcval | pointer, acks, chan
{{Measure input voltage at one of the Propeller Board
of Education's analog inputs: A0, A1, A2 are sockets
below the breadboard, and A3 is connected to an
amplified microphone output.

Parameter: channel use 0, 1, 2, or 3 for A0, A1, A2,
                   or A3}}
  ifnot configured
    i2c.Init(29, 28, 0_0011)
    
  ifnot cog  
    pointer := |< (channel + 4)
    acks := i2c.poll(0)
    acks += i2c.ByteOut(pointer)
    acks += i2c.poll(1)
    adcval := i2c.ByteIn(0)
    chan := adcval>>4
    adcval &= 11
    adcval <<= 8  
    adcval += i2c.ByteIn(1)
    adcval >>= 2
    if acks <> 0 or chan <> channel
      adcval := -1
  else
    repeat until not lockset(lockID)
    adcVal := adc[channel]
    lockclr(lockID)[/FONT]

Comments

  • rubergdrubergd Posts: 11
    edited 2012-06-11 09:04
    Spoke with Tech Support. ADC chip is not communicating. I am getting the board replaced.
  • rubergdrubergd Posts: 11
    edited 2012-06-11 10:20
    I decided to give it one more shot before sending the board back........and I found the problem!

    I went to the datasheet for the onboard AD7993 ADC chip and noticed that there were two versions of the chip, 7993-0 and 7993-1. Each version had its own I2C address (for the AS pin tied to VSS, the way the BOE is wired).‘

    'Just for the heck of it, I replaced the default %010_0011 address (which is for version 7993-1) in PropBOE ADC.spin with the version 7993-0 address (%010_0001) and everything started working!

    Tech support has been notified and will be passing this info on to the PTB's.

    ...Don

Sign In or Register to comment.