ls7166 or ls7266 (got source code?)
hi,
i am looking at the ls7166 and/or ls7266 chips
for interfacing with a usdigital rotary encoder.
Anybody have some source code specifically for
the basic stamp?
Feel free to email it to me if you have it.
Thanks
i am looking at the ls7166 and/or ls7266 chips
for interfacing with a usdigital rotary encoder.
Anybody have some source code specifically for
the basic stamp?
Feel free to email it to me if you have it.
Thanks
Comments
http://robots.unl.edu/classes/498/lab/lab6/lab6_f99.pdf
and since others in the group have also looked for it, i
figured that i'd post a link to it..
thanks.
poscart@y...
--- In basicstamps@y..., "poscart" <poscart@y...> wrote:
> hi,
>
> i am looking at the ls7166 and/or ls7266 chips
> for interfacing with a usdigital rotary encoder.
>
> Anybody have some source code specifically for
> the basic stamp?
>
> Feel free to email it to me if you have it.
>
> Thanks
the code listed below but the read position keeps changing. Di you
get this to work? do I need to add pullup or pul downs ont the data
line to clean them up. any help would be appreciated
--- In basicstamps@y..., "poscart" <poscart@y...> wrote:
>
> I, after much searching, found some code for the ls7166...
>
> http://robots.unl.edu/classes/498/lab/lab6/lab6_f99.pdf
>
> and since others in the group have also looked for it, i
> figured that i'd post a link to it..
>
> thanks.
> poscart@y...
>
>
>
> --- In basicstamps@y..., "poscart" <poscart@y...> wrote:
> > hi,
> >
> > i am looking at the ls7166 and/or ls7266 chips
> > for interfacing with a usdigital rotary encoder.
> >
> > Anybody have some source code specifically for
> > the basic stamp?
> >
> > Feel free to email it to me if you have it.
> >
> > Thanks
BS2 LS7266
P12 13 C/D-
P11 16 RD-
P10 14 WR-
P9 17 X-/Y
P8 15 CS-
P7 11 D7
P6 10 D6
P5 9 D5
P4 8 D4
P3 7 D3
P2 6 D2
P1 5 D1
P0 4 D0
READ_ENCODER:
'Reset Byte Pointer and xfer count to Output Latch for X or Y
'On entry XY is set to indicate if X or Y encoder is to be read
'XY = 0 = read X
'XY = 2 = read Y
DIRL = $FF 'bus is output
OUT12 = 1 'control mode
OUTL = $11
OUTC = $8 | XY 'RD=1, WR=0, X=?, CS=0
OUTC = $D | XY 'RD=1, WR=1, X=?, CS=1
'Read encoder
DIRL = $00 'bus is input
OUT12 = 0 'data mode
OUTC = $4 | XY 'RD=0, WR=1, X=?, CS=0
ENC_COUNT.LOWBYTE = INL 'read ls byte of encoder
OUTC = $C | XY 'RD=1, WR=1, X=?, CS=0
OUTC = $4 | XY 'RD=0, WR=1, X=?, CS=0
ENC_COUNT.HIGHBYTE = INL 'read mid byte of encoder
OUTC = $C | XY 'RD=1, WR=1, X=?, CS=0
OUTC = $4 | XY 'RD=0, WR=1, X=?, CS=0
ENC_DATA = INL 'read high byte of encoder
OUTC = $D 'RD=1, WR=1, X=0, CS=1
RETURN
Dennis
In a message dated 6/19/2002 5:27:12 PM Central Daylight Time,
basicstamps@yahoogroups.com writes:
> Date: Wed, 19 Jun 2002 19:11:06 -0000
> From: "sadlpx" <porter.sadler@s...>
> Subject: Re: ls7166 or ls7266 (got source code?)
>
> I to am trying to get the BS2 to interface witht the ls7166. I tried
> the code listed below but the read position keeps changing. Di you
> get this to work? do I need to add pullup or pul downs ont the data
> line to clean them up. any help would be appreciated
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]
My code is essentially the same except for three things:
1 No "or" with xy (I'm using the 7166),
2 You bring CS high before first read then back low
3 Your setup string for read is $11, mine was $01.
Still cannot make it read (all zeros with encoder attached). RD and WR are
pulled up with 10k, seems to work better that way.
No pull-ups or down on the data lines (do you use that or think that would
help).
It must be in my setup (initialize routine). Should not be this hard.
Thanks in advance for the help.
See code below.
'***************************************************************************
***
CS CON 15
READ_PIN CON 14
WRITE_PIN CON 13
CNTRL CON 12
POS0 VAR BYTE
POS1 VAR BYTE
POS2 VAR BYTE
POSITION VAR WORD
OUTPUT CNTRL
HIGH WRITE_PIN
HIGH READ_PIN
'*************************MAIN PROGRAM*********************************
LOW CS
GOSUB INITILIZE
AGAIN:
GOSUB READ_POSITION
PAUSE 2000
GOTO AGAIN
'*************************INITIALIZE LS7166****************************
INITILIZE
LOW CS
HIGH CNTRL
HIGH READ_PIN
HIGH WRITE_PIN
DIRL = %11111111 ' SET LOW ORDER BITS
(P0-P7) TO OUTPUTS
OUTL = %00110101 ' LOW CONTROL BYTES
WITH $35
GOSUB EXECUTE_WRITE ' WRITE PULSE
DEBUG cls, "MASTER CONTROL REGISTER: ", BIN INL, CR
OUTL = %01001000
DEBUG "INPUT CONTROL REGISTER: ", BIN INL, CR
GOSUB EXECUTE_WRITE
OUTL = %10000000
DEBUG "OUTPUT CONTROL REGISTER: ", BIN INL, CR
GOSUB EXECUTE_WRITE
OUTL = %11000011 ' SET FOR 4X
DEBUG "QUADRATURE CONTROL REGISTER: ", BIN INL, CR
GOSUB EXECUTE_WRITE
PAUSE 50
RETURN
'*************************READ COUNTER********************************
READ_POSITION:
DIRL = %11111111
HIGH CNTRL
OUTL = $11
GOSUB EXECUTE_WRITE
DIRL = %00000000
LOW CNTRL
LOW READ_PIN
POS0 = INL
PAUSE 1
HIGH READ_PIN
PAUSE 1
LOW READ_PIN
POS1 = INL
PAUSE 1
HIGH READ_PIN
PAUSE 1
LOW READ_PIN
POS2 = INL
PAUSE 1
HIGH READ_PIN
HIGH CNTRL
DEBUG "p2: ", HEX2 pos2," "
DEBUG "p1: ", HEX2 pos1," "
DEBUG "p0: ", HEX2 pos0," "
POSITION.LOWBYTE = POS0
POSITION.HIGHBYTE = POS1
DEBUG "POSITION: ", DEC POSITION, CR
RETURN
'*************************WRTIE PULSE********************************
EXECUTE_WRITE:
LOW WRITE_PIN
PAUSE 1
HIGH WRITE_PIN
RETURN
Original Message
From: borgmandl@c... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Y5fc1py30g9V3gMfFCpAD_E_n1OPkJs0cJWx9YBvxerIDYx2bamUb9txmz9wiC1nobeqVL22]borgmandl@c...[/url
Sent: Thursday, June 20, 2002 1:39 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: ls7166 or ls7266 (got source code?)
The following works with BS2 connected as:
BS2 LS7266
P12 13 C/D-
P11 16 RD-
P10 14 WR-
P9 17 X-/Y
P8 15 CS-
P7 11 D7
P6 10 D6
P5 9 D5
P4 8 D4
P3 7 D3
P2 6 D2
P1 5 D1
P0 4 D0
READ_ENCODER:
'Reset Byte Pointer and xfer count to Output Latch for X or Y
'On entry XY is set to indicate if X or Y encoder is to be read
'XY = 0 = read X
'XY = 2 = read Y
DIRL = $FF 'bus is output
OUT12 = 1 'control mode
OUTL = $11
OUTC = $8 | XY 'RD=1, WR=0, X=?, CS=0
OUTC = $D | XY 'RD=1, WR=1, X=?, CS=1
'Read encoder
DIRL = $00 'bus is input
OUT12 = 0 'data mode
OUTC = $4 | XY 'RD=0, WR=1, X=?, CS=0
ENC_COUNT.LOWBYTE = INL 'read ls byte of encoder
OUTC = $C | XY 'RD=1, WR=1, X=?, CS=0
OUTC = $4 | XY 'RD=0, WR=1, X=?, CS=0
ENC_COUNT.HIGHBYTE = INL 'read mid byte of encoder
OUTC = $C | XY 'RD=1, WR=1, X=?, CS=0
OUTC = $4 | XY 'RD=0, WR=1, X=?, CS=0
ENC_DATA = INL 'read high byte of encoder
OUTC = $D 'RD=1, WR=1, X=0, CS=1
RETURN
Dennis
In a message dated 6/19/2002 5:27:12 PM Central Daylight Time,
basicstamps@yahoogroups.com writes:
> Date: Wed, 19 Jun 2002 19:11:06 -0000
> From: "sadlpx" <porter.sadler@s...>
> Subject: Re: ls7166 or ls7266 (got source code?)
>
> I to am trying to get the BS2 to interface witht the ls7166. I tried
> the code listed below but the read position keeps changing. Di you
> get this to work? do I need to add pullup or pul downs ont the data
> line to clean them up. any help would be appreciated
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]
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/
[noparse][[/noparse]Non-text portions of this message have been removed]
transferring the counter to the output latch. Instead of $11, $13
when you prepare to read. Bit-1 of the MCR transfers the count
to the output latch, in effect freezing the count in a stable way
so it can be read.
Also, I don't use pull-ups or downs anywhere on the bus or on
any of the controls that are tied to the BS2.
Your setup looks ok, but it's a little different than the 7266, so
I may have missed something.
Hope this helps,
Dennis
In a message dated 6/20/2002 1:16:41 PM Central Daylight Time,
basicstamps@yahoogroups.com writes:
> Date: Thu, 20 Jun 2002 10:41:33 -0400
> From: Sadler Porter <porter.sadler@s...>
> Subject: RE: Re: ls7166 or ls7266 (got source code?)
>
> Dennis thanks for your reply.
>
> My code is essentially the same except for three things:
> 1 No "or" with xy (I'm using the 7166),
> 2 You bring CS high before first read then back low
> 3 Your setup string for read is $11, mine was $01.
> Still cannot make it read (all zeros with encoder attached). RD and WR are
> pulled up with 10k, seems to work better that way.
> No pull-ups or down on the data lines (do you use that or think that would
> help).
>
> It must be in my setup (initialize routine). Should not be this hard.
> Thanks in advance for the help.
> See code below.
>
>
> '***************************************************************************
> ***
>
> CS CON 15
> READ_PIN CON 14
> WRITE_PIN CON 13
> CNTRL CON 12
>
> POS0 VAR BYTE
> POS1 VAR BYTE
> POS2 VAR BYTE
> POSITION VAR WORD
>
> OUTPUT CNTRL
> HIGH WRITE_PIN
> HIGH READ_PIN
>
> '*************************MAIN PROGRAM*********************************
> LOW CS
> GOSUB INITILIZE
> AGAIN:
> GOSUB READ_POSITION
> PAUSE 2000
> GOTO AGAIN
>
>
> '*************************INITIALIZE LS7166****************************
> INITILIZE
> LOW CS
> HIGH CNTRL
> HIGH READ_PIN
> HIGH WRITE_PIN
>
> DIRL = %11111111 ' SET LOW ORDER BITS
> (P0-P7) TO OUTPUTS
> OUTL = %00110101 ' LOW CONTROL BYTES
> WITH $35
> GOSUB EXECUTE_WRITE ' WRITE PULSE
> DEBUG cls, "MASTER CONTROL REGISTER: ", BIN INL, CR
>
> OUTL = %01001000
> DEBUG "INPUT CONTROL REGISTER: ", BIN INL, CR
> GOSUB EXECUTE_WRITE
>
> OUTL = %10000000
> DEBUG "OUTPUT CONTROL REGISTER: ", BIN INL, CR
> GOSUB EXECUTE_WRITE
>
> OUTL = %11000011 ' SET FOR 4X
> DEBUG "QUADRATURE CONTROL REGISTER: ", BIN INL, CR
> GOSUB EXECUTE_WRITE
> PAUSE 50
> RETURN
>
>
>
> '*************************READ COUNTER********************************
> READ_POSITION:
> DIRL = %11111111
> HIGH CNTRL
> OUTL = $11
>
> GOSUB EXECUTE_WRITE
> DIRL = %00000000
>
> LOW CNTRL
>
> LOW READ_PIN
> POS0 = INL
> PAUSE 1
> HIGH READ_PIN
> PAUSE 1
> LOW READ_PIN
> POS1 = INL
> PAUSE 1
> HIGH READ_PIN
> PAUSE 1
> LOW READ_PIN
> POS2 = INL
> PAUSE 1
> HIGH READ_PIN
>
> HIGH CNTRL
> DEBUG "p2: ", HEX2 pos2," "
> DEBUG "p1: ", HEX2 pos1," "
> DEBUG "p0: ", HEX2 pos0," "
> POSITION.LOWBYTE = POS0
> POSITION.HIGHBYTE = POS1
> DEBUG "POSITION: ", DEC POSITION, CR
> RETURN
>
>
> '*************************WRTIE PULSE********************************
> EXECUTE_WRITE:
> LOW WRITE_PIN
> PAUSE 1
> HIGH WRITE_PIN
> RETURN
>
[noparse][[/noparse]Non-text portions of this message have been removed]