Max186 ADC channel info
Archiver
Posts: 46,084
If anyone can help; I have the data sheet for the 186 and found an
example on the net on how to interface a BS2 to the 186(thanks Shaun
Wilson(tried to email)), but I'm still unclear as to the code for
separating out individual channels.
My application- I wish to take fast readings from 2 to 3 186's and
pass the level info on to another BS2SX.
In Shaun's example he uses "lookup" and a series of numbers to
choose the channel. These numbers don't seem to relate to anything I
can recognize.
Any help appreciated. Here's the code:
'code by Shaun Wilson April 17/99
'This program interfaces a MAX186 8 Channel ADC to the
'Basic Stamp II. The Stamp takes the 12 bit reading of the
'digital reparestion of the analog input into the ADC,
'and displays it on an LCD display.
'email - swilson@b...
'
Variables
Channel var nib 'set channel to 0 for if your using CH0
'1 if your using Ch1 and so on.
Chsel var byte 'channel select
ADCin var word 'ADC reading
X var nib
'
Constants
ClrLCD con 12 'Clear LCD
N9600 con $4054 '9600 baud
LCD con 0 'serial data to LCD display pin 0
cs con 1 'enable or disable A to D converter
serDo con 2 'serial data out p2
serDin con 3 'serial data in p3
serclk con 4 'serial Clock p4
high cs 'disable
pause 500
serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear the screen
serout LCD,N9600,[noparse][[/noparse]"Ready",cr]
main:
low cs 'enable
gosub chkADC
gosub prnt
goto main
chkADC:
channel =0 'set Channel = x, x being a nubmer between 0 to 7
depending on the channel you are using
lookup channel, [noparse][[/noparse]142,
206,158,222,174,238,190,254],chsel 'tell Adc what channel
shiftout serDo, serclk, msbfirst,[noparse][[/noparse]chsel] 'send the
channel data
shiftin serDin, serclk, msbpost ,[noparse][[/noparse]ADCin\12] 'the reading
'the reading
high cs
'disable
Return
Prnt:
serout LCD, N9600, [noparse][[/noparse]"Using Channel ", DEC channel,cr]
serout LCD, N9600, [noparse][[/noparse]dec ADCin dig 3,".", dec ADCin dig 2,
dec ADCin dig 1, dec ADCin dig 0 ,"Volts" ] 'print results
pause 1000
serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear screen
Return
example on the net on how to interface a BS2 to the 186(thanks Shaun
Wilson(tried to email)), but I'm still unclear as to the code for
separating out individual channels.
My application- I wish to take fast readings from 2 to 3 186's and
pass the level info on to another BS2SX.
In Shaun's example he uses "lookup" and a series of numbers to
choose the channel. These numbers don't seem to relate to anything I
can recognize.
Any help appreciated. Here's the code:
'code by Shaun Wilson April 17/99
'This program interfaces a MAX186 8 Channel ADC to the
'Basic Stamp II. The Stamp takes the 12 bit reading of the
'digital reparestion of the analog input into the ADC,
'and displays it on an LCD display.
'email - swilson@b...
'
Variables
Channel var nib 'set channel to 0 for if your using CH0
'1 if your using Ch1 and so on.
Chsel var byte 'channel select
ADCin var word 'ADC reading
X var nib
'
Constants
ClrLCD con 12 'Clear LCD
N9600 con $4054 '9600 baud
LCD con 0 'serial data to LCD display pin 0
cs con 1 'enable or disable A to D converter
serDo con 2 'serial data out p2
serDin con 3 'serial data in p3
serclk con 4 'serial Clock p4
high cs 'disable
pause 500
serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear the screen
serout LCD,N9600,[noparse][[/noparse]"Ready",cr]
main:
low cs 'enable
gosub chkADC
gosub prnt
goto main
chkADC:
channel =0 'set Channel = x, x being a nubmer between 0 to 7
depending on the channel you are using
lookup channel, [noparse][[/noparse]142,
206,158,222,174,238,190,254],chsel 'tell Adc what channel
shiftout serDo, serclk, msbfirst,[noparse][[/noparse]chsel] 'send the
channel data
shiftin serDin, serclk, msbpost ,[noparse][[/noparse]ADCin\12] 'the reading
'the reading
high cs
'disable
Return
Prnt:
serout LCD, N9600, [noparse][[/noparse]"Using Channel ", DEC channel,cr]
serout LCD, N9600, [noparse][[/noparse]dec ADCin dig 3,".", dec ADCin dig 2,
dec ADCin dig 1, dec ADCin dig 0 ,"Volts" ] 'print results
pause 1000
serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear screen
Return
Comments
1. The 'lookup' -- given a channel number from 0 to 7,
the 'lookup' command puts the indexed value into its
'chsel' value. These values are command values to the
ADC, which result in the desired channel being selected
for output on the next SHIFTIN. You'd have to look
at the ADC documentation to see what combination of
command and channel ID each number represents.
2. The 'chsel' value is then sent to the ADC with
SHIFTOUT, to select a particular A-to-D channel
(one of its 8 channels).
3. The value from the selected channel is then
'grabbed' with the SHIFTIN command.
4. If you wanted to use this, you'd probably
call it as:
channel = 0
gosub chkADC ' Note: REMOVE the 'channel = 0' from there.
Data0 = ADCin
channel = 1
gosub chkADC
Data1 = ADCin
. etc .
--- In basicstamps@yahoogroups.com, "iphillipsca" <iphillips@s...>
wrote:
> If anyone can help; I have the data sheet for the 186 and found an
> example on the net on how to interface a BS2 to the 186(thanks
Shaun
> Wilson(tried to email)), but I'm still unclear as to the code for
> separating out individual channels.
> My application- I wish to take fast readings from 2 to 3 186's and
> pass the level info on to another BS2SX.
> In Shaun's example he uses "lookup" and a series of numbers to
> choose the channel. These numbers don't seem to relate to anything
I
> can recognize.
> Any help appreciated. Here's the code:
>
> 'code by Shaun Wilson April 17/99
> 'This program interfaces a MAX186 8 Channel ADC to the
> 'Basic Stamp II. The Stamp takes the 12 bit reading of the
> 'digital reparestion of the analog input into the ADC,
> 'and displays it on an LCD display.
> 'email - swilson@b...
>
> '
Variables
> Channel var nib 'set channel to 0 for if your using
CH0
> '1 if your using Ch1 and so on.
> Chsel var byte 'channel select
> ADCin var word 'ADC reading
> X var nib
>
> '
Constants
> ClrLCD con 12 'Clear LCD
> N9600 con $4054 '9600 baud
> LCD con 0 'serial data to LCD display pin 0
> cs con 1 'enable or disable A to D converter
> serDo con 2 'serial data out p2
> serDin con 3 'serial data in p3
> serclk con 4 'serial Clock p4
>
> high cs 'disable
> pause 500
> serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear the screen
> serout LCD,N9600,[noparse][[/noparse]"Ready",cr]
>
> main:
> low cs 'enable
> gosub chkADC
> gosub prnt
> goto main
>
> chkADC:
> channel =0 'set Channel = x, x being a nubmer between 0 to 7
> depending on the channel you are using
> lookup channel, [noparse][[/noparse]142,
> 206,158,222,174,238,190,254],chsel 'tell Adc what channel
> shiftout serDo, serclk, msbfirst,[noparse][[/noparse]chsel] 'send the
> channel data
> shiftin serDin, serclk, msbpost ,[noparse][[/noparse]ADCin\12] 'the reading
> 'the reading
> high cs
> 'disable
> Return
>
> Prnt:
> serout LCD, N9600, [noparse][[/noparse]"Using Channel ", DEC channel,cr]
> serout LCD, N9600, [noparse][[/noparse]dec ADCin dig 3,".", dec ADCin dig 2,
> dec ADCin dig 1, dec ADCin dig 0 ,"Volts" ] 'print results
> pause 1000
> serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear screen
> Return
A lot easier on the stamp. Anyway, maybe this will help.
'Control byte information
'
'142=10001110 = Start bit (1), channel 0 (000), unipolar (1), Single
ended (1), Int Clock Mode (0)
'206=11001110 = Start bit (1), channel 1 (100), unipolar (1), Single
ended (1), Int Clock Mode (0)
'158=10011110 = Start bit (1), channel 2 (001), unipolar (1), Single
ended (1), Int Clock Mode (0)
'222=11011110 = Start bit (1), channel 3 (101), unipolar (1), Single
ended (1), Int Clock Mode (0)
'174=10101110 = Start bit (1), channel 4 (010), unipolar (1), Single
ended (1), Int Clock Mode (0)
'238=11101110 = Start bit (1), channel 5 (110), unipolar (1), Single
ended (1), Int Clock Mode (0)
'190=10111110 = Start bit (1), channel 6 (011), unipolar (1), Single
ended (1), Int Clock Mode (0)
'254=11111110 = Start bit (1), channel 7 (111), unipolar (1), Single
ended (1), Int Clock Mode (0)
--- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
wrote:
> I'll try:
> 1. The 'lookup' -- given a channel number from 0 to 7,
> the 'lookup' command puts the indexed value into its
> 'chsel' value. These values are command values to the
> ADC, which result in the desired channel being selected
> for output on the next SHIFTIN. You'd have to look
> at the ADC documentation to see what combination of
> command and channel ID each number represents.
>
> 2. The 'chsel' value is then sent to the ADC with
> SHIFTOUT, to select a particular A-to-D channel
> (one of its 8 channels).
>
> 3. The value from the selected channel is then
> 'grabbed' with the SHIFTIN command.
>
> 4. If you wanted to use this, you'd probably
> call it as:
> channel = 0
> gosub chkADC ' Note: REMOVE the 'channel = 0' from there.
> Data0 = ADCin
> channel = 1
> gosub chkADC
> Data1 = ADCin
> . etc .
>
>
> --- In basicstamps@yahoogroups.com, "iphillipsca" <iphillips@s...>
> wrote:
> > If anyone can help; I have the data sheet for the 186 and found
an
> > example on the net on how to interface a BS2 to the 186(thanks
> Shaun
> > Wilson(tried to email)), but I'm still unclear as to the code for
> > separating out individual channels.
> > My application- I wish to take fast readings from 2 to 3 186's
and
> > pass the level info on to another BS2SX.
> > In Shaun's example he uses "lookup" and a series of numbers to
> > choose the channel. These numbers don't seem to relate to
anything
> I
> > can recognize.
> > Any help appreciated. Here's the code:
> >
> > 'code by Shaun Wilson April 17/99
> > 'This program interfaces a MAX186 8 Channel ADC to the
> > 'Basic Stamp II. The Stamp takes the 12 bit reading of the
> > 'digital reparestion of the analog input into the ADC,
> > 'and displays it on an LCD display.
> > 'email - swilson@b...
> >
> > '
Variables
> > Channel var nib 'set channel to 0 for if your using
> CH0
> > '1 if your using Ch1 and so on.
> > Chsel var byte 'channel select
> > ADCin var word 'ADC reading
> > X var nib
> >
> > '
Constants
> > ClrLCD con 12 'Clear LCD
> > N9600 con $4054 '9600 baud
> > LCD con 0 'serial data to LCD display pin 0
> > cs con 1 'enable or disable A to D converter
> > serDo con 2 'serial data out p2
> > serDin con 3 'serial data in p3
> > serclk con 4 'serial Clock p4
> >
> > high cs 'disable
> > pause 500
> > serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear the screen
> > serout LCD,N9600,[noparse][[/noparse]"Ready",cr]
> >
> > main:
> > low cs 'enable
> > gosub chkADC
> > gosub prnt
> > goto main
> >
> > chkADC:
> > channel =0 'set Channel = x, x being a nubmer between 0 to 7
> > depending on the channel you are using
> > lookup channel, [noparse][[/noparse]142,
> > 206,158,222,174,238,190,254],chsel 'tell Adc what channel
> > shiftout serDo, serclk, msbfirst,[noparse][[/noparse]chsel] 'send the
> > channel data
> > shiftin serDin, serclk, msbpost ,[noparse][[/noparse]ADCin\12] 'the reading
> > 'the reading
> > high cs
> > 'disable
> > Return
> >
> > Prnt:
> > serout LCD, N9600, [noparse][[/noparse]"Using Channel ", DEC channel,cr]
> > serout LCD, N9600, [noparse][[/noparse]dec ADCin dig 3,".", dec ADCin dig 2,
> > dec ADCin dig 1, dec ADCin dig 0 ,"Volts" ] 'print results
> > pause 1000
> > serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear screen
> > Return
Thanks again!
Ian
Original Message
From: walter woodrow [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ApK4xic87B_7EIvA4GKzG003GskWopgYpfKKATNmiqbhZR3AxfLUmEKUfWNS_dylGKh12ytemlP5Yq7bOg]oopicwow@y...[/url
Sent: May 28, 2003 2:01 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: Max186 ADC channel info
I have used the same max186 chip on the basic stamp and on the oopic.
A lot easier on the stamp. Anyway, maybe this will help.
'Control byte information
'
'142=10001110 = Start bit (1), channel 0 (000), unipolar (1), Single
ended (1), Int Clock Mode (0)
'206=11001110 = Start bit (1), channel 1 (100), unipolar (1), Single
ended (1), Int Clock Mode (0)
'158=10011110 = Start bit (1), channel 2 (001), unipolar (1), Single
ended (1), Int Clock Mode (0)
'222=11011110 = Start bit (1), channel 3 (101), unipolar (1), Single
ended (1), Int Clock Mode (0)
'174=10101110 = Start bit (1), channel 4 (010), unipolar (1), Single
ended (1), Int Clock Mode (0)
'238=11101110 = Start bit (1), channel 5 (110), unipolar (1), Single
ended (1), Int Clock Mode (0)
'190=10111110 = Start bit (1), channel 6 (011), unipolar (1), Single
ended (1), Int Clock Mode (0)
'254=11111110 = Start bit (1), channel 7 (111), unipolar (1), Single
ended (1), Int Clock Mode (0)
--- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
wrote:
> I'll try:
> 1. The 'lookup' -- given a channel number from 0 to 7,
> the 'lookup' command puts the indexed value into its
> 'chsel' value. These values are command values to the
> ADC, which result in the desired channel being selected
> for output on the next SHIFTIN. You'd have to look
> at the ADC documentation to see what combination of
> command and channel ID each number represents.
>
> 2. The 'chsel' value is then sent to the ADC with
> SHIFTOUT, to select a particular A-to-D channel
> (one of its 8 channels).
>
> 3. The value from the selected channel is then
> 'grabbed' with the SHIFTIN command.
>
> 4. If you wanted to use this, you'd probably
> call it as:
> channel = 0
> gosub chkADC ' Note: REMOVE the 'channel = 0' from there.
> Data0 = ADCin
> channel = 1
> gosub chkADC
> Data1 = ADCin
> . etc .
>
>
> --- In basicstamps@yahoogroups.com, "iphillipsca" <iphillips@s...>
> wrote:
> > If anyone can help; I have the data sheet for the 186 and found
an
> > example on the net on how to interface a BS2 to the 186(thanks
> Shaun
> > Wilson(tried to email)), but I'm still unclear as to the code for
> > separating out individual channels.
> > My application- I wish to take fast readings from 2 to 3 186's
and
> > pass the level info on to another BS2SX.
> > In Shaun's example he uses "lookup" and a series of numbers to
> > choose the channel. These numbers don't seem to relate to
anything
> I
> > can recognize.
> > Any help appreciated. Here's the code:
> >
> > 'code by Shaun Wilson April 17/99
> > 'This program interfaces a MAX186 8 Channel ADC to the
> > 'Basic Stamp II. The Stamp takes the 12 bit reading of the
> > 'digital reparestion of the analog input into the ADC,
> > 'and displays it on an LCD display.
> > 'email - swilson@b...
> >
> > '
Variables
> > Channel var nib 'set channel to 0 for if your using
> CH0
> > '1 if your using Ch1 and so on.
> > Chsel var byte 'channel select
> > ADCin var word 'ADC reading
> > X var nib
> >
> > '
Constants
> > ClrLCD con 12 'Clear LCD
> > N9600 con $4054 '9600 baud
> > LCD con 0 'serial data to LCD display pin 0
> > cs con 1 'enable or disable A to D converter
> > serDo con 2 'serial data out p2
> > serDin con 3 'serial data in p3
> > serclk con 4 'serial Clock p4
> >
> > high cs 'disable
> > pause 500
> > serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear the screen
> > serout LCD,N9600,[noparse][[/noparse]"Ready",cr]
> >
> > main:
> > low cs 'enable
> > gosub chkADC
> > gosub prnt
> > goto main
> >
> > chkADC:
> > channel =0 'set Channel = x, x being a nubmer between 0 to 7
> > depending on the channel you are using
> > lookup channel, [noparse][[/noparse]142,
> > 206,158,222,174,238,190,254],chsel 'tell Adc what channel
> > shiftout serDo, serclk, msbfirst,[noparse][[/noparse]chsel] 'send the
> > channel data
> > shiftin serDin, serclk, msbpost ,[noparse][[/noparse]ADCin\12] 'the reading
> > 'the reading
> > high cs
> > 'disable
> > Return
> >
> > Prnt:
> > serout LCD, N9600, [noparse][[/noparse]"Using Channel ", DEC channel,cr]
> > serout LCD, N9600, [noparse][[/noparse]dec ADCin dig 3,".", dec ADCin dig 2,
> > dec ADCin dig 1, dec ADCin dig 0 ,"Volts" ] 'print results
> > pause 1000
> > serout LCD,N9600,[noparse][[/noparse]ClrLCD] 'clear screen
> > Return
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/