Shop OBEX P1 Docs P2 Docs Learn Events
Adc08100 — Parallax Forums

Adc08100

CenlasoftCenlasoft Posts: 265
edited 2013-01-01 17:16 in Propeller 1
'I have an ADC08100 8 bit IC. I used it before with a camera and Viewport. I trying to use it to simply read 8 pins (D0 to D7). I am using a clock of 10 MHZ. The input is a 10K pot with 3.3 v.
'I am not getting any consistent results.

<Code>
{{
Curtis Desselles
adcpot.spin
}}
Con
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000 ' 5MHz Crystal

FreqPin = 8
New_Freq = 20_000_000

Var
long stack1[30],DigOutPut[8]

Obj
PST : "Parallax Serial Terminal"

Pub Main
Initialize 'Start Process
repeat
PST.bin(ina[0..7],8)
PST.NewLine


PUB Initialize
dira[0..7]~ 'Make Pins Output
dira[FreqPin]~~ 'Make pin input
cognew(Synth("A",FreqPin, New_Freq),@stack1) 'Start clock 10 Mhz
'Start serial terminal
PST.start(115200)
PST.Clear
PST.Home


PUB Synth(CTR_AB, Pin, Freq) | s, d, ctr, frq

Freq := Freq #> 0 <# 128_000_000 'limit frequency range

if Freq < 500_000 'if 0 to 499_999 Hz,
ctr := constant(%00100 << 26) '..set NCO mode
s := 1 '..shift = 1
else 'if 500_000 to 128_000_000 Hz,
ctr := constant(%00010 << 26) '..set PLL mode
d := >|((Freq - 1) / 1_000_000) 'determine PLLDIV
s := 4 - d 'determine shift
ctr |= d << 23 'set PLLDIV

frq := fraction(Freq, CLKFREQ, s) 'Compute FRQA/FRQB value
ctr |= Pin 'set PINA to complete CTRA/CTRB value

if CTR_AB == "A"
CTRA := ctr 'set CTRA
FRQA := frq 'set FRQA
DIRA[Pin]~~ 'make pin output

if CTR_AB == "B"
CTRB := ctr 'set CTRB
FRQB := frq 'set FRQB
DIRA[Pin]~~ 'make pin output
repeat
PRI fraction(a, b, shift) : f
if shift > 0 'if shift, pre-shift a or b left
a <<= shift 'to maintain significant bits while
if shift < 0 'insuring proper result
b <<= -shift
repeat 32 'perform long division of a/b
f <<= 1
if a => b
a -= b
f++
a <<= 1
</Code>

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-12-31 19:14
    Cenlasoft wrote: »
    I am using a clock of 10 MHZ.
    Your code says 20MHz. How does this fit together?
  • CenlasoftCenlasoft Posts: 265
    edited 2012-12-31 19:19
    i am sorry, i tried 10 mhz also.
  • lardomlardom Posts: 1,659
    edited 2012-12-31 20:56
    This is a link to a GadgetGangster tutorial. Hope this helps. http://gadgetgangster.com/tutorials/397
  • SteveWoodroughSteveWoodrough Posts: 190
    edited 2012-12-31 21:59
    Hello,
    This is a tricky business. I spent HOURS to get this to work. Every detail must be carfully attended to.


    First question, have you ever had the camera working, through the ADC and VP?

    If not, I'd suggest starting with Hanno's example in Chapter 9 of the Official Guide.

    That is what I used for the project below. There are also some intermediate tests that can be done in VP before going right to the video. I can send you the objects if you like.

    Regards,
    Steve

    http://forums.parallax.com/showthread.php?144788-Line-Follower-with-CCD-Camera-and-Bluetooth-Support&p=1152696#post1152696
  • CenlasoftCenlasoft Posts: 265
    edited 2013-01-01 08:17
    thanks thus far for your responses. i think my problem is the timing. VP is a great product, but i need to just read the output of the adc08100, no camera. thanks, cenlasoft.
  • MicksterMickster Posts: 2,694
    edited 2013-01-01 08:23
    Hello Curtis.
    Sorry for going off-topic but you don't appear to be around here much, lately; could you advise me as to where I might find a low-cost solution for an Eddy Current probe, please?

    Many thanks,

    Mickster
  • CenlasoftCenlasoft Posts: 265
    edited 2013-01-01 08:32
    Glad to hear from you again, i have been in the hospital for several months now, kidney abcess. send me you email and i will send you information and i can send you a probe and instrument for free. i got some made with a grant, thus they are free to my friends and people who would benefit from it.
    thanks, Curtis
  • CenlasoftCenlasoft Posts: 265
    edited 2013-01-01 09:55
    hello, i read the datasheet again and this maybe important "data is acquired at the falling edge of the clock and the digital equivalent of that data is available at the digital outputs 2.5 clock cycles plud overhead later. the output is straight binary". 20 mhz is minimun clock.
  • MicksterMickster Posts: 2,694
    edited 2013-01-01 14:50
    "Several months" in the hospital?(!!!) OMG, very sorry to hear that. That would definitely drive me nuts. I wish you a very speedy and full recovery sir!

    Your offer is very kind and I hope I can reciprocate in some way. I will forward my contact details via a message.

    Kind regards,

    Mickster
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-01-01 17:16
    Two points, one the schematic shows 330 ohm resistor for the output of the mcp3208. Non-issue unless running the ADC for max performance when supply is +5v. The illustrations show 3.3k which the schematic should match. Second, minor regarding the read out "all at once"; channels must be read individually, not at the same time. If a snapshot on all channels at a point in time is required you would have to implement a sample and hold function for each input channel or select a chip with that capability (and increased price).


    FF
    lardom wrote: »
    This is a link to a GadgetGangster tutorial. Hope this helps. http://gadgetgangster.com/tutorials/397
Sign In or Register to comment.