Adc08100
Cenlasoft
Posts: 265
'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>
'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
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
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
thanks, Curtis
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
FF