adc problems, please help

Started by nicdman00 October 13, 2004

I've seen some messages about it before. If someone could clear this
up it would be just fantastic.
BX24
simply i need to sample voltage from 0-5VDC on 3 adc pins
so I use pins 13,14,15

if the voltage is over a certain amplitude like say 3.5 VDC then
switch state of 3 other pins
so I use pins 5,6,7

so just to say this again the flow of code is like this.
in adc on 13
if the freakin' value returned from ADC is over lets just say over
800
then putpin 5 to 1

same thing for adc pin 14, if over returned value, putpin 6 to 1

same thing for adc pin 15, if over returned value, putpin 7 to 1

easy as that!!
should be no mystery here, right?

well pin 13 is perfectly fine sampling voltage, the returned value
is exactly what I expected it to be. BUT if you apply close to
5VDC..... pins 5,6,and 7 all change state to 1 even with adc pins
14,15 at ground ref. that is first problem!!

now remenber when I said that 13 is working fine with respect to
0VDC being 0 value returned and 5V being 1024 value returned.
Well, adc in pin 14 is more like 0VDC being 300 value returned and
adc pin 15 is more like 0VDC being 600 returned value.
so my question is WTF!!!

I can change up the pins in the flow of code so I look at say adc in
pin 15 first.....
well, same thing happens just backwards.
I've tried delays, just to slow thing down.
I've tried another chip itself and the same thing.
VCC for the chip is ROCK solid.

pins 5,6,and,7 each are connected to non inverting input of op-amps
with a greater than 250 Mohm input Z.

If someone could offer any advice I would consider then the mayor.



> ... so I look at say adc in pin 15 first... well, same thing happens
just backwards...

Sounds like code. Can you post it? Tom
Tom Becker
--... ...--
www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700


nick
can you post the code.
neil

nicdman00 wrote:

>
> I've seen some messages about it before. If someone could clear this
> up it would be just fantastic.
> BX24
> simply i need to sample voltage from 0-5VDC on 3 adc pins
> so I use pins 13,14,15
>
> if the voltage is over a certain amplitude like say 3.5 VDC then
> switch state of 3 other pins
> so I use pins 5,6,7
>
> so just to say this again the flow of code is like this.
> in adc on 13
> if the freakin' value returned from ADC is over lets just say over
> 800
> then putpin 5 to 1
>
> same thing for adc pin 14, if over returned value, putpin 6 to 1
>
> same thing for adc pin 15, if over returned value, putpin 7 to 1
>
> easy as that!!
> should be no mystery here, right?
>
> well pin 13 is perfectly fine sampling voltage, the returned value
> is exactly what I expected it to be. BUT if you apply close to
> 5VDC..... pins 5,6,and 7 all change state to 1 even with adc pins
> 14,15 at ground ref. that is first problem!!
>
> now remenber when I said that 13 is working fine with respect to
> 0VDC being 0 value returned and 5V being 1024 value returned.
> Well, adc in pin 14 is more like 0VDC being 300 value returned and
> adc pin 15 is more like 0VDC being 600 returned value.
> so my question is WTF!!!
>
> I can change up the pins in the flow of code so I look at say adc in
> pin 15 first.....
> well, same thing happens just backwards.
> I've tried delays, just to slow thing down.
> I've tried another chip itself and the same thing.
> VCC for the chip is ROCK solid.
>
> pins 5,6,and,7 each are connected to non inverting input of op-amps
> with a greater than 250 Mohm input Z.
>
> If someone could offer any advice I would consider then the mayor. > *
> <https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG9kvpg8t/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97777186/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS >
>
> *>.






well,home now, code at work.
will have to wait till tommorrow to post code.
really nothing out of ordinary, like I said If I just sample 1 input
and switch one pin It works like a champ.
oh well, I wait till tommorrow.

--- In , Neil Jepsen <njepsen@i...> wrote:

> nick
> can you post the code.
> neil
>
> nicdman00 wrote:
>
> >
> > I've seen some messages about it before. If someone could clear this
> > up it would be just fantastic.
> > BX24
> > simply i need to sample voltage from 0-5VDC on 3 adc pins
> > so I use pins 13,14,15
> >
> > if the voltage is over a certain amplitude like say 3.5 VDC then
> > switch state of 3 other pins
> > so I use pins 5,6,7
> >
> > so just to say this again the flow of code is like this.
> > in adc on 13
> > if the freakin' value returned from ADC is over lets just say over
> > 800
> > then putpin 5 to 1
> >
> > same thing for adc pin 14, if over returned value, putpin 6 to 1
> >
> > same thing for adc pin 15, if over returned value, putpin 7 to 1
> >
> > easy as that!!
> > should be no mystery here, right?
> >
> > well pin 13 is perfectly fine sampling voltage, the returned value
> > is exactly what I expected it to be. BUT if you apply close to
> > 5VDC..... pins 5,6,and 7 all change state to 1 even with adc pins
> > 14,15 at ground ref. that is first problem!!
> >
> > now remenber when I said that 13 is working fine with respect to
> > 0VDC being 0 value returned and 5V being 1024 value returned.
> > Well, adc in pin 14 is more like 0VDC being 300 value returned and
> > adc pin 15 is more like 0VDC being 600 returned value.
> > so my question is WTF!!!
> >
> > I can change up the pins in the flow of code so I look at say adc in
> > pin 15 first.....
> > well, same thing happens just backwards.
> > I've tried delays, just to slow thing down.
> > I've tried another chip itself and the same thing.
> > VCC for the chip is ROCK solid.
> >
> > pins 5,6,and,7 each are connected to non inverting input of op-amps
> > with a greater than 250 Mohm input Z.
> >
> > If someone could offer any advice I would consider then the mayor.
> >
> >
> >
> >
> >
> > *
> >
<https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG9kvpg8t/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97777186/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>

> >
> >
> >
> >

> > *>.
> >
> >



If the op amp is connected to 5 volts, there is the possibility that the rail
to rail
output may not go to 5 volts, you may have to feed the op amp with 8 volts
and
send the output thru a 4.7 k ohm resistor to the BX24.

That way you will get 0 to 5 volts buffered output.





No, the op amps are supplyed with a dedicated + and - 12 VDC.
Totally separate from the BX's VCC.
--- In , cjgpokny@a... wrote:
> If the op amp is connected to 5 volts, there is the possibility
that the rail
> to rail
> output may not go to 5 volts, you may have to feed the op amp with
8 volts
> and
> send the output thru a 4.7 k ohm resistor to the BX24.
>
> That way you will get 0 to 5 volts buffered output.





posted a new message this morning w/ the code but have not seen it
yet so sorry if it gets posted twice. like I said any help would be
very appreciated.

beginning of code is not posted where vars are dimmed, and a bunch
of comments are.

Call OpenQueue(Com1_in,20) 'initialize uart com1
Call OpenQueue(Com1_out,20)
Call OpenCom(1,19200,Com1_in,Com1_out)

Call PutPin(5,1) 'test routine
Call Delay(0.5)
Call PutPin(5,0)
Call PutPin(6,1) 'test routine
Call Delay(0.5)
Call PutPin(6,0)
Call PutPin(7,1) 'test routine
Call Delay(0.5)
Call PutPin(7,0)
'Call PutPin(12,1) 'test routine
'Call Delay(0.1)
'Call PutPin(12,0)

SKcounter1 = 0
SKcounter2 = 0
SKcounter3 = 0
cyl1 = 0
cyl2 = 0
cyl3 = 0
SKfactor = 1000 '0-1024 range 5 mv resolution
Kfactor = 500
SK_OGC = 200 'timing for superknock light
indicator

GetINs:
'outty = CStr(cyl1)
'call PutqueueSTR(com1_out,outty)
'outty = CStr(cyl2)
'call PutqueueStr(com1_out,outty)
'outty = CStr(cyl3)
'call PutqueueStr(com1_out,outty)

cylinder1:
If (SKcounter1 > 0) Then
SKcounter1 = SKcounter1 - 1
End If
If (SKcounter1 > 0) Then 'means knock on 1
Goto cylinder2
End If
cyl1 = GetADC(14)
Call PutPin(5,0)
If (cyl1 > SKfactor) Then
goto Sknock1
End If
If (cyl1 > Kfactor) Then
goto Knock1
End If
goto cylinder2

Sknock1:
'Call PutQueueStr(Com1_out,"5high")
Call PutPin(5,1)
Call PutPin(12,0)
Call PutPin(12,1)
SKcounter1 = SK_OGC
Goto cylinder2

Knock1:
Call PutPin(5,1)
'Call PutPin(5,0)
goto cylinder2 cylinder2:

If (SKcounter2 > 0) Then
SKcounter2 = SKcounter2 - 1
End If
If (SKcounter2 > 0) Then 'means knock on 2
Goto cylinder3
End If
cyl2 = GetADC(16)
Call PutPin(6,0)
If (cyl2 > SKfactor) Then
goto Sknock2
End If
If (cyl2 > Kfactor) Then
goto Knock2
End If
goto cylinder3

Sknock2:
'Call PutQueueStr(Com1_out,"6high")
Call PutPin(6,1)
Call PutPin(12,0)
Call PutPin(12,1)
SKcounter2 = SK_OGC
Goto cylinder3

Knock2:
Call PutPin(6,1)
'Call PutPin(6,0)
goto cylinder3 cylinder3:
If (SKcounter3 > 0) Then
SKcounter3 = SKcounter3 - 1
End If
If (SKcounter3 > 0) Then 'means knock on 3
Goto GetINs
End If
cyl3 = GetADC(18)
Call PutPin(7,0)
If (cyl3 > SKfactor) Then
goto Sknock3
End If
If (cyl3 > Kfactor) Then
goto Knock3
End If
goto GetINs

Sknock3:
'Call PutQueueStr(Com1_out,"7high")
Call PutPin(7,1)
Call PutPin(12,0)
Call PutPin(12,1)
SKcounter3 = SK_OGC
Goto GetIns

Knock3:
Call PutPin(7,1)
'Call PutPin(7,0)
goto GetINs End Sub
--- In , "nicdman00" <nicdman00@y...> wrote:
>
> No, the op amps are supplyed with a dedicated + and - 12 VDC.
> Totally separate from the BX's VCC. >
> --- In , cjgpokny@a... wrote:
> > If the op amp is connected to 5 volts, there is the possibility
> that the rail
> > to rail
> > output may not go to 5 volts, you may have to feed the op amp
with
> 8 volts
> > and
> > send the output thru a 4.7 k ohm resistor to the BX24.
> >
> > That way you will get 0 to 5 volts buffered output.
> >
> >
> >
> >
> >




Nick
Where is your main loop? Does the code you posted run
continuously? Because if it does, the peice of code:

If (SKcounter1 > 0) Then
SKcounter1 = SKcounter1 - 1
End If

wiill simply result in SKcounter1 being set to zero. Perhaps this is
intentional. Its hard to tell with half the code missing.

You could compress your code a little eg The following code could be
re-written

If (SKcounter1 > 0) Then
SKcounter1 = SKcounter1 - 1
End If
If (SKcounter1 > 0) Then 'means knock on 1
Goto cylinder2
End If

Re write as:

If (SKcounter1 > 0) Then
SKcounter1 = SKcounter1 - 1
Goto cylinder2
End If

However, even this is not good code. You should avoid goto if possible
as it makes the code hard to follow and it ends up like a rats nest. For
example change "cylinder2" to a subroutine and call it when you want
to use it.
Something like this: main
do
if something.
call subroutine 1
end if
if something else
call subroutine 2
end if
if something else
call sub 3
end if

loop

end sub
'************************
subroutine 1
end sub

subroutine 2
end sub
subroutine 3
end sub
'****************************

This layout is much easier to follow.
Also, where are your comments?
I'm sure your probelm is in the code, not in faulty hardware.

neil

If (SKcounter1 > 0) Then
SKcounter1 = SKcounter1 - 1
Goto cylinder2
End If nicdman00 wrote:

>
> posted a new message this morning w/ the code but have not seen it
> yet so sorry if it gets posted twice. like I said any help would be
> very appreciated.
>
> beginning of code is not posted where vars are dimmed, and a bunch
> of comments are.
>
> Call OpenQueue(Com1_in,20) 'initialize uart com1
> Call OpenQueue(Com1_out,20)
> Call OpenCom(1,19200,Com1_in,Com1_out)
>
> Call PutPin(5,1) 'test routine
> Call Delay(0.5)
> Call PutPin(5,0)
> Call PutPin(6,1) 'test routine
> Call Delay(0.5)
> Call PutPin(6,0)
> Call PutPin(7,1) 'test routine
> Call Delay(0.5)
> Call PutPin(7,0)
> 'Call PutPin(12,1) 'test routine
> 'Call Delay(0.1)
> 'Call PutPin(12,0)
>
> SKcounter1 = 0
> SKcounter2 = 0
> SKcounter3 = 0
> cyl1 = 0
> cyl2 = 0
> cyl3 = 0
> SKfactor = 1000 '0-1024 range 5 mv resolution
> Kfactor = 500
> SK_OGC = 200 'timing for superknock light
> indicator
>
> GetINs:
> 'outty = CStr(cyl1)
> 'call PutqueueSTR(com1_out,outty)
> 'outty = CStr(cyl2)
> 'call PutqueueStr(com1_out,outty)
> 'outty = CStr(cyl3)
> 'call PutqueueStr(com1_out,outty)
>
> cylinder1:
> If (SKcounter1 > 0) Then
> SKcounter1 = SKcounter1 - 1
> End If
> If (SKcounter1 > 0) Then 'means knock on 1
> Goto cylinder2
> End If
> cyl1 = GetADC(14)
> Call PutPin(5,0)
> If (cyl1 > SKfactor) Then
> goto Sknock1
> End If
> If (cyl1 > Kfactor) Then
> goto Knock1
> End If
> goto cylinder2
>
> Sknock1:
> 'Call PutQueueStr(Com1_out,"5high")
> Call PutPin(5,1)
> Call PutPin(12,0)
> Call PutPin(12,1)
> SKcounter1 = SK_OGC
> Goto cylinder2
>
> Knock1:
> Call PutPin(5,1)
> 'Call PutPin(5,0)
> goto cylinder2 > cylinder2:
>
> If (SKcounter2 > 0) Then
> SKcounter2 = SKcounter2 - 1
> End If
> If (SKcounter2 > 0) Then 'means knock on 2
> Goto cylinder3
> End If
> cyl2 = GetADC(16)
> Call PutPin(6,0)
> If (cyl2 > SKfactor) Then
> goto Sknock2
> End If
> If (cyl2 > Kfactor) Then
> goto Knock2
> End If
> goto cylinder3
>
> Sknock2:
> 'Call PutQueueStr(Com1_out,"6high")
> Call PutPin(6,1)
> Call PutPin(12,0)
> Call PutPin(12,1)
> SKcounter2 = SK_OGC
> Goto cylinder3
>
> Knock2:
> Call PutPin(6,1)
> 'Call PutPin(6,0)
> goto cylinder3 > cylinder3:
> If (SKcounter3 > 0) Then
> SKcounter3 = SKcounter3 - 1
> End If
> If (SKcounter3 > 0) Then 'means knock on 3
> Goto GetINs
> End If
> cyl3 = GetADC(18)
> Call PutPin(7,0)
> If (cyl3 > SKfactor) Then
> goto Sknock3
> End If
> If (cyl3 > Kfactor) Then
> goto Knock3
> End If
> goto GetINs
>
> Sknock3:
> 'Call PutQueueStr(Com1_out,"7high")
> Call PutPin(7,1)
> Call PutPin(12,0)
> Call PutPin(12,1)
> SKcounter3 = SK_OGC
> Goto GetIns
>
> Knock3:
> Call PutPin(7,1)
> 'Call PutPin(7,0)
> goto GetINs > End Sub >
> --- In , "nicdman00" <nicdman00@y...> wrote:
> >
> > No, the op amps are supplyed with a dedicated + and - 12 VDC.
> > Totally separate from the BX's VCC.
> >
> >
> >
> > --- In , cjgpokny@a... wrote:
> > > If the op amp is connected to 5 volts, there is the possibility
> > that the rail
> > > to rail
> > > output may not go to 5 volts, you may have to feed the op amp
> with
> > 8 volts
> > > and
> > > send the output thru a 4.7 k ohm resistor to the BX24.
> > >
> > > That way you will get 0 to 5 volts buffered output.
> > >
> > >
> > >
> > >
> > >
>
> *
> <https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG98rqvgk/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97865324/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS >
>
> *>.







The main loop begins with GetIns: this is the ONLY loop

yes like I said it is spagheti code right now. there is no reason for
me to clog up this message with dimmed variables and I do not want to
post what is written in the beginning, it has nothing to do with
anything, just a bunch of text with no program flow. and It is very
hard for someone to understand what I am doing here without taking the
time to go line to line. forget the software counters they work fine,
better than fine, and yes they are meant to be just like they are. It
is the offset I see on the ADC's. why would the offsets be even
increments from ADC to ADC.
like I said the first adc in this case is pin 14, (I changed it from
13)is fine...the next will have an offset so that 0VDC reads returns
300, the next at 0VDC will return a value of 600... This is a small
program, and I have had to try to change everything in attempt to
debug the ADC prob. it can easily be cleaned up once this is working.
actually it should be easy to follow because no matter what; the flow
just goes down, it doesnt jump all over the place at all.
simply there are 3 rountines cylinder1: cylinder2: and cylinder3:
They all do the same thing. just differant adc inputs and switch
differant pin thats all. Thanks for the input anyway.
--- In , Neil Jepsen <njepsen@i...> wrote:
> Nick
> Where is your main loop? Does the code you posted run
> continuously? Because if it does, the peice of code:
>
> If (SKcounter1 > 0) Then
> SKcounter1 = SKcounter1 - 1
> End If
>
> wiill simply result in SKcounter1 being set to zero. Perhaps this is
> intentional. Its hard to tell with half the code missing.
>
> You could compress your code a little eg The following code could be
> re-written
>
> If (SKcounter1 > 0) Then
> SKcounter1 = SKcounter1 - 1
> End If
> If (SKcounter1 > 0) Then 'means knock on 1
> Goto cylinder2
> End If
>
> Re write as:
>
> If (SKcounter1 > 0) Then
> SKcounter1 = SKcounter1 - 1
> Goto cylinder2
> End If
>
> However, even this is not good code. You should avoid goto if possible
> as it makes the code hard to follow and it ends up like a rats nest.
For
> example change "cylinder2" to a subroutine and call it when you want
> to use it.
> Something like this: > main
> do
> if something.
> call subroutine 1
> end if
> if something else
> call subroutine 2
> end if
> if something else
> call sub 3
> end if
>
> loop
>
> end sub
> '************************
> subroutine 1
> end sub
>
> subroutine 2
> end sub
> subroutine 3
> end sub
> '****************************
>
> This layout is much easier to follow.
> Also, where are your comments?
> I'm sure your probelm is in the code, not in faulty hardware.
>
> neil >
>
> If (SKcounter1 > 0) Then
> SKcounter1 = SKcounter1 - 1
> Goto cylinder2
> End If > nicdman00 wrote:
>
> >
> > posted a new message this morning w/ the code but have not seen it
> > yet so sorry if it gets posted twice. like I said any help would be
> > very appreciated.
> >
> > beginning of code is not posted where vars are dimmed, and a bunch
> > of comments are.
> >
> > Call OpenQueue(Com1_in,20) 'initialize uart com1
> > Call OpenQueue(Com1_out,20)
> > Call OpenCom(1,19200,Com1_in,Com1_out)
> >
> > Call PutPin(5,1) 'test routine
> > Call Delay(0.5)
> > Call PutPin(5,0)
> > Call PutPin(6,1) 'test routine
> > Call Delay(0.5)
> > Call PutPin(6,0)
> > Call PutPin(7,1) 'test routine
> > Call Delay(0.5)
> > Call PutPin(7,0)
> > 'Call PutPin(12,1) 'test routine
> > 'Call Delay(0.1)
> > 'Call PutPin(12,0)
> >
> > SKcounter1 = 0
> > SKcounter2 = 0
> > SKcounter3 = 0
> > cyl1 = 0
> > cyl2 = 0
> > cyl3 = 0
> > SKfactor = 1000 '0-1024 range 5 mv resolution
> > Kfactor = 500
> > SK_OGC = 200 'timing for superknock light
> > indicator
> >
> > GetINs:
> > 'outty = CStr(cyl1)
> > 'call PutqueueSTR(com1_out,outty)
> > 'outty = CStr(cyl2)
> > 'call PutqueueStr(com1_out,outty)
> > 'outty = CStr(cyl3)
> > 'call PutqueueStr(com1_out,outty)
> >
> > cylinder1:
> > If (SKcounter1 > 0) Then
> > SKcounter1 = SKcounter1 - 1
> > End If
> > If (SKcounter1 > 0) Then 'means knock on 1
> > Goto cylinder2
> > End If
> > cyl1 = GetADC(14)
> > Call PutPin(5,0)
> > If (cyl1 > SKfactor) Then
> > goto Sknock1
> > End If
> > If (cyl1 > Kfactor) Then
> > goto Knock1
> > End If
> > goto cylinder2
> >
> > Sknock1:
> > 'Call PutQueueStr(Com1_out,"5high")
> > Call PutPin(5,1)
> > Call PutPin(12,0)
> > Call PutPin(12,1)
> > SKcounter1 = SK_OGC
> > Goto cylinder2
> >
> > Knock1:
> > Call PutPin(5,1)
> > 'Call PutPin(5,0)
> > goto cylinder2
> >
> >
> > cylinder2:
> >
> > If (SKcounter2 > 0) Then
> > SKcounter2 = SKcounter2 - 1
> > End If
> > If (SKcounter2 > 0) Then 'means knock on 2
> > Goto cylinder3
> > End If
> > cyl2 = GetADC(16)
> > Call PutPin(6,0)
> > If (cyl2 > SKfactor) Then
> > goto Sknock2
> > End If
> > If (cyl2 > Kfactor) Then
> > goto Knock2
> > End If
> > goto cylinder3
> >
> > Sknock2:
> > 'Call PutQueueStr(Com1_out,"6high")
> > Call PutPin(6,1)
> > Call PutPin(12,0)
> > Call PutPin(12,1)
> > SKcounter2 = SK_OGC
> > Goto cylinder3
> >
> > Knock2:
> > Call PutPin(6,1)
> > 'Call PutPin(6,0)
> > goto cylinder3
> >
> >
> > cylinder3:
> > If (SKcounter3 > 0) Then
> > SKcounter3 = SKcounter3 - 1
> > End If
> > If (SKcounter3 > 0) Then 'means knock on 3
> > Goto GetINs
> > End If
> > cyl3 = GetADC(18)
> > Call PutPin(7,0)
> > If (cyl3 > SKfactor) Then
> > goto Sknock3
> > End If
> > If (cyl3 > Kfactor) Then
> > goto Knock3
> > End If
> > goto GetINs
> >
> > Sknock3:
> > 'Call PutQueueStr(Com1_out,"7high")
> > Call PutPin(7,1)
> > Call PutPin(12,0)
> > Call PutPin(12,1)
> > SKcounter3 = SK_OGC
> > Goto GetIns
> >
> > Knock3:
> > Call PutPin(7,1)
> > 'Call PutPin(7,0)
> > goto GetINs
> >
> >
> > End Sub
> >
> >
> >
> > --- In , "nicdman00" <nicdman00@y...> wrote:
> > >
> > > No, the op amps are supplyed with a dedicated + and - 12 VDC.
> > > Totally separate from the BX's VCC.
> > >
> > >
> > >
> > > --- In , cjgpokny@a... wrote:
> > > > If the op amp is connected to 5 volts, there is the possibility
> > > that the rail
> > > > to rail
> > > > output may not go to 5 volts, you may have to feed the op amp
> > with
> > > 8 volts
> > > > and
> > > > send the output thru a 4.7 k ohm resistor to the BX24.
> > > >
> > > > That way you will get 0 to 5 volts buffered output.
> > > >
> > > >
> > > >
> > > >
> > > >
> >
> >
> >
> >
> > *
> >
<https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG98rqvgk/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97865324/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>

> >
> >
> >
> >

> > *>.
> >
> >




Do any of the other pins from 13 - 20 source current to anywhere?

nicdman00 wrote:

>
>
> The main loop begins with GetIns: this is the ONLY loop
>
> yes like I said it is spagheti code right now. there is no reason for
> me to clog up this message with dimmed variables and I do not want to
> post what is written in the beginning, it has nothing to do with
> anything, just a bunch of text with no program flow. and It is very
> hard for someone to understand what I am doing here without taking the
> time to go line to line. forget the software counters they work fine,
> better than fine, and yes they are meant to be just like they are. It
> is the offset I see on the ADC's. why would the offsets be even
> increments from ADC to ADC.
> like I said the first adc in this case is pin 14, (I changed it from
> 13)is fine...the next will have an offset so that 0VDC reads returns
> 300, the next at 0VDC will return a value of 600... This is a small
> program, and I have had to try to change everything in attempt to
> debug the ADC prob. it can easily be cleaned up once this is working.
> actually it should be easy to follow because no matter what; the flow
> just goes down, it doesnt jump all over the place at all.
> simply there are 3 rountines cylinder1: cylinder2: and cylinder3:
> They all do the same thing. just differant adc inputs and switch
> differant pin thats all. Thanks for the input anyway. >
> --- In , Neil Jepsen <njepsen@i...> wrote:
> > Nick
> > Where is your main loop? Does the code you posted run
> > continuously? Because if it does, the peice of code:
> >
> > If (SKcounter1 > 0) Then
> > SKcounter1 = SKcounter1 - 1
> > End If
> >
> > wiill simply result in SKcounter1 being set to zero. Perhaps this is
> > intentional. Its hard to tell with half the code missing.
> >
> > You could compress your code a little eg The following code could be
> > re-written
> >
> > If (SKcounter1 > 0) Then
> > SKcounter1 = SKcounter1 - 1
> > End If
> > If (SKcounter1 > 0) Then 'means knock on 1
> > Goto cylinder2
> > End If
> >
> > Re write as:
> >
> > If (SKcounter1 > 0) Then
> > SKcounter1 = SKcounter1 - 1
> > Goto cylinder2
> > End If
> >
> > However, even this is not good code. You should avoid goto if possible
> > as it makes the code hard to follow and it ends up like a rats nest.
> For
> > example change "cylinder2" to a subroutine and call it when you want
> > to use it.
> > Something like this:
> >
> >
> > main
> > do
> > if something.
> > call subroutine 1
> > end if
> > if something else
> > call subroutine 2
> > end if
> > if something else
> > call sub 3
> > end if
> >
> > loop
> >
> > end sub
> > '************************
> > subroutine 1
> > end sub
> >
> > subroutine 2
> > end sub
> > subroutine 3
> > end sub
> > '****************************
> >
> > This layout is much easier to follow.
> > Also, where are your comments?
> > I'm sure your probelm is in the code, not in faulty hardware.
> >
> > neil
> >
> >
> >
> >
> > If (SKcounter1 > 0) Then
> > SKcounter1 = SKcounter1 - 1
> > Goto cylinder2
> > End If
> >
> >
> >
> >
> >
> > nicdman00 wrote:
> >
> > >
> > > posted a new message this morning w/ the code but have not seen it
> > > yet so sorry if it gets posted twice. like I said any help would be
> > > very appreciated.
> > >
> > > beginning of code is not posted where vars are dimmed, and a bunch
> > > of comments are.
> > >
> > > Call OpenQueue(Com1_in,20) 'initialize uart com1
> > > Call OpenQueue(Com1_out,20)
> > > Call OpenCom(1,19200,Com1_in,Com1_out)
> > >
> > > Call PutPin(5,1) 'test routine
> > > Call Delay(0.5)
> > > Call PutPin(5,0)
> > > Call PutPin(6,1) 'test routine
> > > Call Delay(0.5)
> > > Call PutPin(6,0)
> > > Call PutPin(7,1) 'test routine
> > > Call Delay(0.5)
> > > Call PutPin(7,0)
> > > 'Call PutPin(12,1) 'test routine
> > > 'Call Delay(0.1)
> > > 'Call PutPin(12,0)
> > >
> > > SKcounter1 = 0
> > > SKcounter2 = 0
> > > SKcounter3 = 0
> > > cyl1 = 0
> > > cyl2 = 0
> > > cyl3 = 0
> > > SKfactor = 1000 '0-1024 range 5 mv resolution
> > > Kfactor = 500
> > > SK_OGC = 200 'timing for superknock light
> > > indicator
> > >
> > > GetINs:
> > > 'outty = CStr(cyl1)
> > > 'call PutqueueSTR(com1_out,outty)
> > > 'outty = CStr(cyl2)
> > > 'call PutqueueStr(com1_out,outty)
> > > 'outty = CStr(cyl3)
> > > 'call PutqueueStr(com1_out,outty)
> > >
> > > cylinder1:
> > > If (SKcounter1 > 0) Then
> > > SKcounter1 = SKcounter1 - 1
> > > End If
> > > If (SKcounter1 > 0) Then 'means knock on 1
> > > Goto cylinder2
> > > End If
> > > cyl1 = GetADC(14)
> > > Call PutPin(5,0)
> > > If (cyl1 > SKfactor) Then
> > > goto Sknock1
> > > End If
> > > If (cyl1 > Kfactor) Then
> > > goto Knock1
> > > End If
> > > goto cylinder2
> > >
> > > Sknock1:
> > > 'Call PutQueueStr(Com1_out,"5high")
> > > Call PutPin(5,1)
> > > Call PutPin(12,0)
> > > Call PutPin(12,1)
> > > SKcounter1 = SK_OGC
> > > Goto cylinder2
> > >
> > > Knock1:
> > > Call PutPin(5,1)
> > > 'Call PutPin(5,0)
> > > goto cylinder2
> > >
> > >
> > > cylinder2:
> > >
> > > If (SKcounter2 > 0) Then
> > > SKcounter2 = SKcounter2 - 1
> > > End If
> > > If (SKcounter2 > 0) Then 'means knock on 2
> > > Goto cylinder3
> > > End If
> > > cyl2 = GetADC(16)
> > > Call PutPin(6,0)
> > > If (cyl2 > SKfactor) Then
> > > goto Sknock2
> > > End If
> > > If (cyl2 > Kfactor) Then
> > > goto Knock2
> > > End If
> > > goto cylinder3
> > >
> > > Sknock2:
> > > 'Call PutQueueStr(Com1_out,"6high")
> > > Call PutPin(6,1)
> > > Call PutPin(12,0)
> > > Call PutPin(12,1)
> > > SKcounter2 = SK_OGC
> > > Goto cylinder3
> > >
> > > Knock2:
> > > Call PutPin(6,1)
> > > 'Call PutPin(6,0)
> > > goto cylinder3
> > >
> > >
> > > cylinder3:
> > > If (SKcounter3 > 0) Then
> > > SKcounter3 = SKcounter3 - 1
> > > End If
> > > If (SKcounter3 > 0) Then 'means knock on 3
> > > Goto GetINs
> > > End If
> > > cyl3 = GetADC(18)
> > > Call PutPin(7,0)
> > > If (cyl3 > SKfactor) Then
> > > goto Sknock3
> > > End If
> > > If (cyl3 > Kfactor) Then
> > > goto Knock3
> > > End If
> > > goto GetINs
> > >
> > > Sknock3:
> > > 'Call PutQueueStr(Com1_out,"7high")
> > > Call PutPin(7,1)
> > > Call PutPin(12,0)
> > > Call PutPin(12,1)
> > > SKcounter3 = SK_OGC
> > > Goto GetIns
> > >
> > > Knock3:
> > > Call PutPin(7,1)
> > > 'Call PutPin(7,0)
> > > goto GetINs
> > >
> > >
> > > End Sub
> > >
> > >
> > >
> > > --- In , "nicdman00" <nicdman00@y...> wrote:
> > > >
> > > > No, the op amps are supplyed with a dedicated + and - 12 VDC.
> > > > Totally separate from the BX's VCC.
> > > >
> > > >
> > > >
> > > > --- In , cjgpokny@a... wrote:
> > > > > If the op amp is connected to 5 volts, there is the possibility
> > > > that the rail
> > > > > to rail
> > > > > output may not go to 5 volts, you may have to feed the op amp
> > > with
> > > > 8 volts
> > > > > and
> > > > > send the output thru a 4.7 k ohm resistor to the BX24.
> > > > >
> > > > > That way you will get 0 to 5 volts buffered output.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
> > >
> > > *
> > >
> <https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG98rqvgk/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97865324/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS
> <https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>>" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG98rqvgk/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97865324/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>>
>
> > >
> > >
> > >
> > >
>
> > > *>.
> > >
> > >
>
> *
> <https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS" target="_blank" rel="nofollow">http://us.ard.yahoo.com/SIG94a243j/M15388.5497957.6576270.3001176/D=groups/S06554205:HM/EXP97883506/A#72354/R=0/SIGid813k2/*https://www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS >
>
> *>.