Shop OBEX P1 Docs P2 Docs Learn Events
shiftin/shiftout interfaces — Parallax Forums

shiftin/shiftout interfaces

ArchiverArchiver Posts: 46,084
edited 2003-07-08 19:06 in General Discussion
Hey Everyone,

I posted something similar to this last week but I guess nobody
knows an answer or just missed it. I was hoping that someone would
have some advice this time because it seems like this problem could
occur with many types of shiftin/shiftout interfaces. I've connected
a playstation2 controller to my basic stamp2sx. I've wired up all the
pins correctly, and I'm supplying regulated +5V from a power source
seperate from the basic stamp (grounds of the basic stamp and
controller are connected though). I changed the pin #s in the code
below (program1 from playstation.zip from nuts and volts:
http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
to fit my hook ups. When I run the code though, I get the same data
whether the controller is powered or not, just 255s and 1s varying
with all 0s occasionally. Also my stamp seems to get pretty hot
whenever I'm testing the interface. any ideas of what the problem
might be? Thanks a lot! I appreciate it! Code below:

' I/O Assignment and TRIS:

clk con 7
att con 9
dat con 5
cmd con 6

'*********************************************************************
*******************
' Variables:

index var byte
char var byte

'*********************************************************************
*******************
'this code simply reads in the commands from the playstation
controller joysticks and buttons
'and displays them via debug.
main:

low att '
select the PSX controller

shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
and "send data"
shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
this byte, it
'starts up the controller

'shiftin dat, clk, 3, [noparse][[/noparse]char]
'shiftin dat, clk, 3, [noparse][[/noparse]char]

shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
left switches
debug cr,"Buttons:
",cr
debug bin char, " " ' debug
window binary format

shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
right switches
debug bin char, " " ' debug
window binary format


'the above block shifted in the on/off (111011011) status of all the
switches
debug cr, "Right joy:
L/R "
shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
left / right
debug dec char, " " ' debug
window decimal format

debug cr, "Right joy:
U/D "
shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
down
debug dec char, " " ' debug
window decimal format

debug cr, "Left joy:
L/R "
shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
left / right
debug dec char, " " ' debug
window decimal format

debug cr, "Left joy:
U/D "
shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
down
debug dec char, CR ' debug
window dec format and return
pause 1000
'the block above gets decimal values representing analog X/Y joystick
positions

high att
'stops transmissions

goto main

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-07-07 17:21
    Did you miss the line in the "Program 2.bs2" that says:

    read_PS2 'A trade off was made between software and hardware.
    ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    ' ' without additional pauses. To do this, the clock signal
    ' ' must be inverted. A transistor or other sutable inverter
    ' ' is required for this code.

    It sounds like driver contention -- ie you're trying to
    drive the line while someone else tries to drive the
    line. You should have a 220 ohm resistor in series with
    your data and clock pins to prevent damage in these
    circumstances.

    --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > Hey Everyone,
    >
    > I posted something similar to this last week but I guess nobody
    > knows an answer or just missed it. I was hoping that someone would
    > have some advice this time because it seems like this problem could
    > occur with many types of shiftin/shiftout interfaces. I've
    connected
    > a playstation2 controller to my basic stamp2sx. I've wired up all
    the
    > pins correctly, and I'm supplying regulated +5V from a power source
    > seperate from the basic stamp (grounds of the basic stamp and
    > controller are connected though). I changed the pin #s in the code
    > below (program1 from playstation.zip from nuts and volts:
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > to fit my hook ups. When I run the code though, I get the same data
    > whether the controller is powered or not, just 255s and 1s varying
    > with all 0s occasionally. Also my stamp seems to get pretty hot
    > whenever I'm testing the interface. any ideas of what the problem
    > might be? Thanks a lot! I appreciate it! Code below:
    >
    > ' I/O Assignment and TRIS:
    >
    > clk con 7
    > att con 9
    > dat con 5
    > cmd con 6
    >
    > '*******************************************************************
    **
    > *******************
    > ' Variables:
    >
    > index var byte
    > char var byte
    >
    > '*******************************************************************
    **
    > *******************
    > 'this code simply reads in the commands from the playstation
    > controller joysticks and buttons
    > 'and displays them via debug.
    > main:
    >
    > low att '
    > select the PSX controller
    >
    > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > and "send data"
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > this byte, it
    > 'starts up the controller
    >
    > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    >
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > left switches
    > debug cr,"Buttons:
    ",cr
    > debug bin char, " " ' debug
    > window binary format
    >
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > right switches
    > debug bin char, " " ' debug
    > window binary format
    >
    >
    > 'the above block shifted in the on/off (111011011) status of all
    the
    > switches
    > debug cr, "Right joy:
    L/R "
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > left / right
    > debug dec char, " " ' debug
    > window decimal format
    >
    > debug cr, "Right joy:
    U/D "
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > down
    > debug dec char, " " ' debug
    > window decimal format
    >
    > debug cr, "Left joy:
    L/R "
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > left / right
    > debug dec char, " " ' debug
    > window decimal format
    >
    > debug cr, "Left joy:
    U/D "
    > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > down
    > debug dec char, CR ' debug
    > window dec format and return
    > pause 1000
    > 'the block above gets decimal values representing analog X/Y
    joystick
    > positions
    >
    > high att
    > 'stops transmissions
    >
    > goto main
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-07 18:04
    it didn't mention that inversion was necessary in the program1
    file... I didn't get that issue of nuts and volts, did anyone else
    read that article and have any advice? Do I need inversion for the
    program1 code too?

    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > Did you miss the line in the "Program 2.bs2" that says:
    >
    > read_PS2 'A trade off was made between software and hardware.
    > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > ' ' without additional pauses. To do this, the clock
    signal
    > ' ' must be inverted. A transistor or other sutable
    inverter
    > ' ' is required for this code.
    >
    > It sounds like driver contention -- ie you're trying to
    > drive the line while someone else tries to drive the
    > line. You should have a 220 ohm resistor in series with
    > your data and clock pins to prevent damage in these
    > circumstances.
    >
    > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > Hey Everyone,
    > >
    > > I posted something similar to this last week but I guess nobody
    > > knows an answer or just missed it. I was hoping that someone
    would
    > > have some advice this time because it seems like this problem
    could
    > > occur with many types of shiftin/shiftout interfaces. I've
    > connected
    > > a playstation2 controller to my basic stamp2sx. I've wired up all
    > the
    > > pins correctly, and I'm supplying regulated +5V from a power
    source
    > > seperate from the basic stamp (grounds of the basic stamp and
    > > controller are connected though). I changed the pin #s in the
    code
    > > below (program1 from playstation.zip from nuts and volts:
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > to fit my hook ups. When I run the code though, I get the same
    data
    > > whether the controller is powered or not, just 255s and 1s
    varying
    > > with all 0s occasionally. Also my stamp seems to get pretty hot
    > > whenever I'm testing the interface. any ideas of what the problem
    > > might be? Thanks a lot! I appreciate it! Code below:
    > >
    > > ' I/O Assignment and TRIS:
    > >
    > > clk con 7
    > > att con 9
    > > dat con 5
    > > cmd con 6
    > >
    >
    > '*******************************************************************
    > **
    > > *******************
    > > ' Variables:
    > >
    > > index var byte
    > > char var byte
    > >
    >
    > '*******************************************************************
    > **
    > > *******************
    > > 'this code simply reads in the commands from the playstation
    > > controller joysticks and buttons
    > > 'and displays them via debug.
    > > main:
    > >
    > > low att '
    > > select the PSX controller
    > >
    > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > > and "send data"
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > > this byte, it
    > > 'starts up the controller
    > >
    > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > >
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > > left switches
    > > debug cr,"Buttons:
    ",cr
    > > debug bin char, " " ' debug
    > > window binary format
    > >
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > > right switches
    > > debug bin char, " " ' debug
    > > window binary format
    > >
    > >
    > > 'the above block shifted in the on/off (111011011) status of all
    > the
    > > switches
    > > debug cr, "Right joy:
    L/R "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > > left / right
    > > debug dec char, " " ' debug
    > > window decimal format
    > >
    > > debug cr, "Right joy:
    U/D "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > > down
    > > debug dec char, " " ' debug
    > > window decimal format
    > >
    > > debug cr, "Left joy:
    L/R "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > > left / right
    > > debug dec char, " " ' debug
    > > window decimal format
    > >
    > > debug cr, "Left joy:
    U/D "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > > down
    > > debug dec char, CR ' debug
    > > window dec format and return
    > > pause 1000
    > > 'the block above gets decimal values representing analog X/Y
    > joystick
    > > positions
    > >
    > > high att
    > > 'stops transmissions
    > >
    > > goto main
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-07 19:05
    Yes, the PSX requires an inverted clock signal; it also requires the
    data line to be pulled up. I will put my version of the schematic in
    the files folder for those that didn't get the magazine. I've included
    series resistors to protect the BASIC Stamp from a possible failure of
    the PSX controller.

    One note: Because of the way the PSX controller samples the data line,
    it will cause Bit7 of the last data byte (which is the up/down axis of
    the left analog joystick) to be set if you use SHIFTIN. If you manually
    shift the data into the Stamp (as I will show you how in my N&V column
    -- so stay tuned) you can deal with this and get the full range of the
    left joystick. Manually shifting is much slower than SHIFTIN, so that's
    something you have to account for. If you're not using the Analog PSX
    controllers, this is a non-issue and SHIFTIN works perfectly.

    -- Jon Williams
    -- Parallax


    Original Message
    From: Sam [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ZbhqOxYJ5Hbc9iBTjoSpPDrHJF4jm0dCOHYYrZiQisR4TfrTHRZHll4qYXKaGtvuFqMWeK9zCdvPmS7t]hard-on@t...[/url
    Sent: Monday, July 07, 2003 12:04 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces


    it didn't mention that inversion was necessary in the program1
    file... I didn't get that issue of nuts and volts, did anyone else
    read that article and have any advice? Do I need inversion for the
    program1 code too?

    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > Did you miss the line in the "Program 2.bs2" that says:
    >
    > read_PS2 'A trade off was made between software and hardware.
    > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > ' ' without additional pauses. To do this, the clock
    signal
    > ' ' must be inverted. A transistor or other sutable
    inverter
    > ' ' is required for this code.
    >
    > It sounds like driver contention -- ie you're trying to
    > drive the line while someone else tries to drive the
    > line. You should have a 220 ohm resistor in series with
    > your data and clock pins to prevent damage in these
    > circumstances.
    >
    > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > Hey Everyone,
    > >
    > > I posted something similar to this last week but I guess nobody
    > > knows an answer or just missed it. I was hoping that someone
    would
    > > have some advice this time because it seems like this problem
    could
    > > occur with many types of shiftin/shiftout interfaces. I've
    > connected
    > > a playstation2 controller to my basic stamp2sx. I've wired up all
    > the
    > > pins correctly, and I'm supplying regulated +5V from a power
    source
    > > seperate from the basic stamp (grounds of the basic stamp and
    > > controller are connected though). I changed the pin #s in the
    code
    > > below (program1 from playstation.zip from nuts and volts:
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > to fit my hook ups. When I run the code though, I get the same
    data
    > > whether the controller is powered or not, just 255s and 1s
    varying
    > > with all 0s occasionally. Also my stamp seems to get pretty hot
    > > whenever I'm testing the interface. any ideas of what the problem
    > > might be? Thanks a lot! I appreciate it! Code below:
    > >
    > > ' I/O Assignment and TRIS:
    > >
    > > clk con 7
    > > att con 9
    > > dat con 5
    > > cmd con 6
    > >
    >
    > '*******************************************************************
    > **
    > > *******************
    > > ' Variables:
    > >
    > > index var byte
    > > char var byte
    > >
    >
    > '*******************************************************************
    > **
    > > *******************
    > > 'this code simply reads in the commands from the playstation
    > > controller joysticks and buttons
    > > 'and displays them via debug.
    > > main:
    > >
    > > low att '
    > > select the PSX controller
    > >
    > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > > and "send data"
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > > this byte, it
    > > 'starts up the controller
    > >
    > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > >
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > > left switches
    > > debug cr,"Buttons:
    ",cr
    > > debug bin char, " " ' debug
    > > window binary format
    > >
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > > right switches
    > > debug bin char, " " ' debug
    > > window binary format
    > >
    > >
    > > 'the above block shifted in the on/off (111011011) status of all
    > the
    > > switches
    > > debug cr, "Right joy:
    L/R "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > > left / right
    > > debug dec char, " " ' debug
    > > window decimal format
    > >
    > > debug cr, "Right joy:
    U/D "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > > down
    > > debug dec char, " " ' debug
    > > window decimal format
    > >
    > > debug cr, "Left joy:
    L/R "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > > left / right
    > > debug dec char, " " ' debug
    > > window decimal format
    > >
    > > debug cr, "Left joy:
    U/D "
    > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > > down
    > > debug dec char, CR ' debug
    > > window dec format and return
    > > pause 1000
    > > 'the block above gets decimal values representing analog X/Y
    > joystick
    > > positions
    > >
    > > high att
    > > 'stops transmissions
    > >
    > > goto main


    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/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-07 21:11
    do I have to buy a logic inverter chip? or will you describe another
    way of doing it in your schematic when you post it? thanks

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Yes, the PSX requires an inverted clock signal; it also requires the
    > data line to be pulled up. I will put my version of the schematic
    in
    > the files folder for those that didn't get the magazine. I've
    included
    > series resistors to protect the BASIC Stamp from a possible failure
    of
    > the PSX controller.
    >
    > One note: Because of the way the PSX controller samples the data
    line,
    > it will cause Bit7 of the last data byte (which is the up/down axis
    of
    > the left analog joystick) to be set if you use SHIFTIN. If you
    manually
    > shift the data into the Stamp (as I will show you how in my N&V
    column
    > -- so stay tuned) you can deal with this and get the full range of
    the
    > left joystick. Manually shifting is much slower than SHIFTIN, so
    that's
    > something you have to account for. If you're not using the Analog
    PSX
    > controllers, this is a non-issue and SHIFTIN works perfectly.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: Sam [noparse][[/noparse]mailto:hard-on@t...]
    > Sent: Monday, July 07, 2003 12:04 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces
    >
    >
    > it didn't mention that inversion was necessary in the program1
    > file... I didn't get that issue of nuts and volts, did anyone else
    > read that article and have any advice? Do I need inversion for the
    > program1 code too?
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    > wrote:
    > > Did you miss the line in the "Program 2.bs2" that says:
    > >
    > > read_PS2 'A trade off was made between software and hardware.
    > > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > > ' ' without additional pauses. To do this, the clock
    > signal
    > > ' ' must be inverted. A transistor or other sutable
    > inverter
    > > ' ' is required for this code.
    > >
    > > It sounds like driver contention -- ie you're trying to
    > > drive the line while someone else tries to drive the
    > > line. You should have a 220 ohm resistor in series with
    > > your data and clock pins to prevent damage in these
    > > circumstances.
    > >
    > > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > > Hey Everyone,
    > > >
    > > > I posted something similar to this last week but I guess
    nobody
    > > > knows an answer or just missed it. I was hoping that someone
    > would
    > > > have some advice this time because it seems like this problem
    > could
    > > > occur with many types of shiftin/shiftout interfaces. I've
    > > connected
    > > > a playstation2 controller to my basic stamp2sx. I've wired up
    all
    > > the
    > > > pins correctly, and I'm supplying regulated +5V from a power
    > source
    > > > seperate from the basic stamp (grounds of the basic stamp and
    > > > controller are connected though). I changed the pin #s in the
    > code
    > > > below (program1 from playstation.zip from nuts and volts:
    > > >
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > > to fit my hook ups. When I run the code though, I get the same
    > data
    > > > whether the controller is powered or not, just 255s and 1s
    > varying
    > > > with all 0s occasionally. Also my stamp seems to get pretty hot
    > > > whenever I'm testing the interface. any ideas of what the
    problem
    > > > might be? Thanks a lot! I appreciate it! Code below:
    > > >
    > > > ' I/O Assignment and TRIS:
    > > >
    > > > clk con 7
    > > > att con 9
    > > > dat con 5
    > > > cmd con 6
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > ' Variables:
    > > >
    > > > index var byte
    > > > char var byte
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > 'this code simply reads in the commands from the playstation
    > > > controller joysticks and buttons
    > > > 'and displays them via debug.
    > > > main:
    > > >
    > > > low att '
    > > > select the PSX controller
    > > >
    > > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > > > and "send data"
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > > > this byte, it
    > > > 'starts up the controller
    > > >
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > > > left switches
    > > > debug cr,"Buttons:
    ",cr
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > > > right switches
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > >
    > > > 'the above block shifted in the on/off (111011011) status of all
    > > the
    > > > switches
    > > > debug cr, "Right joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Right joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > > > down
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > > > down
    > > > debug dec char, CR ' debug
    > > > window dec format and return
    > > > pause 1000
    > > > 'the block above gets decimal values representing analog X/Y
    > > joystick
    > > > positions
    > > >
    > > > high att
    > > > 'stops transmissions
    > > >
    > > > goto main
    >
    >
    > 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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-07 21:21
    The schematic is posted. It uses a common NPN transistor and a few
    resistors that you can pick-up from Radio Shack. About the only thing
    you can't find is the PSX socket (I didn't want to hack my joystick). I
    cut a socket from an inexpensive PSX extender cable.

    There are a couple of useful web sites on PSX interfacing:

    http://laurent.saintmarcel.free.fr/psx/
    http://www.geocities.co.jp/Playtown/2004/psx/ps_eng.txt


    -- Jon Williams
    -- Parallax




    Original Message
    From: Sam [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=GTjiDH_DvwOG2Zlq2eGrg769DoJy4d1nFHZ-TJ3QyjVtxbxb6HkVpAfEIWRHfOc8q98mXpgCnQbFYw]hard-on@t...[/url
    Sent: Monday, July 07, 2003 3:11 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces


    do I have to buy a logic inverter chip? or will you describe another
    way of doing it in your schematic when you post it? thanks

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Yes, the PSX requires an inverted clock signal; it also requires the
    > data line to be pulled up. I will put my version of the schematic
    in
    > the files folder for those that didn't get the magazine. I've
    included
    > series resistors to protect the BASIC Stamp from a possible failure
    of
    > the PSX controller.
    >
    > One note: Because of the way the PSX controller samples the data
    line,
    > it will cause Bit7 of the last data byte (which is the up/down axis
    of
    > the left analog joystick) to be set if you use SHIFTIN. If you
    manually
    > shift the data into the Stamp (as I will show you how in my N&V
    column
    > -- so stay tuned) you can deal with this and get the full range of
    the
    > left joystick. Manually shifting is much slower than SHIFTIN, so
    that's
    > something you have to account for. If you're not using the Analog
    PSX
    > controllers, this is a non-issue and SHIFTIN works perfectly.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: Sam [noparse][[/noparse]mailto:hard-on@t...]
    > Sent: Monday, July 07, 2003 12:04 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces
    >
    >
    > it didn't mention that inversion was necessary in the program1
    > file... I didn't get that issue of nuts and volts, did anyone else
    > read that article and have any advice? Do I need inversion for the
    > program1 code too?
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    > wrote:
    > > Did you miss the line in the "Program 2.bs2" that says:
    > >
    > > read_PS2 'A trade off was made between software and hardware.
    > > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > > ' ' without additional pauses. To do this, the clock
    > signal
    > > ' ' must be inverted. A transistor or other sutable
    > inverter
    > > ' ' is required for this code.
    > >
    > > It sounds like driver contention -- ie you're trying to drive the
    > > line while someone else tries to drive the line. You should have a
    > > 220 ohm resistor in series with your data and clock pins to prevent
    > > damage in these circumstances.
    > >
    > > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > > Hey Everyone,
    > > >
    > > > I posted something similar to this last week but I guess
    nobody
    > > > knows an answer or just missed it. I was hoping that someone
    > would
    > > > have some advice this time because it seems like this problem
    > could
    > > > occur with many types of shiftin/shiftout interfaces. I've
    > > connected
    > > > a playstation2 controller to my basic stamp2sx. I've wired up
    all
    > > the
    > > > pins correctly, and I'm supplying regulated +5V from a power
    > source
    > > > seperate from the basic stamp (grounds of the basic stamp and
    > > > controller are connected though). I changed the pin #s in the
    > code
    > > > below (program1 from playstation.zip from nuts and volts:
    > > >
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > > to fit my hook ups. When I run the code though, I get the same
    > data
    > > > whether the controller is powered or not, just 255s and 1s
    > varying
    > > > with all 0s occasionally. Also my stamp seems to get pretty hot
    > > > whenever I'm testing the interface. any ideas of what the
    problem
    > > > might be? Thanks a lot! I appreciate it! Code below:
    > > >
    > > > ' I/O Assignment and TRIS:
    > > >
    > > > clk con 7
    > > > att con 9
    > > > dat con 5
    > > > cmd con 6
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > ' Variables:
    > > >
    > > > index var byte
    > > > char var byte
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > 'this code simply reads in the commands from the playstation
    > > > controller joysticks and buttons 'and displays them via debug.
    > > > main:
    > > >
    > > > low att '
    > > > select the PSX controller
    > > >
    > > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > > > and "send data"
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > > > this byte, it
    > > > 'starts up the controller
    > > >
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > > > left switches
    > > > debug cr,"Buttons:
    ",cr
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > > > right switches
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > >
    > > > 'the above block shifted in the on/off (111011011) status of all
    > > the
    > > > switches
    > > > debug cr, "Right joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Right joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > > > down
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > > > down
    > > > debug dec char, CR ' debug
    > > > window dec format and return
    > > > pause 1000
    > > > 'the block above gets decimal values representing analog X/Y
    > > joystick
    > > > positions
    > > >
    > > > high att
    > > > 'stops transmissions
    > > >
    > > > goto main
    >
    >
    > 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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...


    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/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-08 00:07
    I hooked up everything as shown in your diagram (in which I'm
    assuming you deliberately didn't hook up the ack line). I no longer
    have the value fluctuation that I mentioned before (readings of 255/1
    and 0 over the data line). Now it's only and always 0 values for
    button presses and for the joysticks. Whatever I press doesn't do
    anything. Using a logic probe, I can see that the clock is indeed
    inverted (high with low pulses), and on the data and command and att
    lines, I detect pulses everytime that the bs2sx is taking a reading
    from the controller (I have a 'pause 500' after collecting each full
    string of data, including all button presses). I'm using a wall-wart
    to power the controller now (was using a 9V battery before), thinking
    that the current might have been too low, but that didn't change
    anything; there is a 5V regulator between the wall-wart and the
    controller. I'm using an 'obsolete' 2n222A npn transister instead of
    the one you mentioned because I owned one already. Any suggestions?
    The code I'm using was posted in my post several messages up from
    here.

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Yes, the PSX requires an inverted clock signal; it also requires the
    > data line to be pulled up. I will put my version of the schematic
    in
    > the files folder for those that didn't get the magazine. I've
    included
    > series resistors to protect the BASIC Stamp from a possible failure
    of
    > the PSX controller.
    >
    > One note: Because of the way the PSX controller samples the data
    line,
    > it will cause Bit7 of the last data byte (which is the up/down axis
    of
    > the left analog joystick) to be set if you use SHIFTIN. If you
    manually
    > shift the data into the Stamp (as I will show you how in my N&V
    column
    > -- so stay tuned) you can deal with this and get the full range of
    the
    > left joystick. Manually shifting is much slower than SHIFTIN, so
    that's
    > something you have to account for. If you're not using the Analog
    PSX
    > controllers, this is a non-issue and SHIFTIN works perfectly.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: Sam [noparse][[/noparse]mailto:hard-on@t...]
    > Sent: Monday, July 07, 2003 12:04 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces
    >
    >
    > it didn't mention that inversion was necessary in the program1
    > file... I didn't get that issue of nuts and volts, did anyone else
    > read that article and have any advice? Do I need inversion for the
    > program1 code too?
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    > wrote:
    > > Did you miss the line in the "Program 2.bs2" that says:
    > >
    > > read_PS2 'A trade off was made between software and hardware.
    > > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > > ' ' without additional pauses. To do this, the clock
    > signal
    > > ' ' must be inverted. A transistor or other sutable
    > inverter
    > > ' ' is required for this code.
    > >
    > > It sounds like driver contention -- ie you're trying to
    > > drive the line while someone else tries to drive the
    > > line. You should have a 220 ohm resistor in series with
    > > your data and clock pins to prevent damage in these
    > > circumstances.
    > >
    > > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > > Hey Everyone,
    > > >
    > > > I posted something similar to this last week but I guess
    nobody
    > > > knows an answer or just missed it. I was hoping that someone
    > would
    > > > have some advice this time because it seems like this problem
    > could
    > > > occur with many types of shiftin/shiftout interfaces. I've
    > > connected
    > > > a playstation2 controller to my basic stamp2sx. I've wired up
    all
    > > the
    > > > pins correctly, and I'm supplying regulated +5V from a power
    > source
    > > > seperate from the basic stamp (grounds of the basic stamp and
    > > > controller are connected though). I changed the pin #s in the
    > code
    > > > below (program1 from playstation.zip from nuts and volts:
    > > >
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > > to fit my hook ups. When I run the code though, I get the same
    > data
    > > > whether the controller is powered or not, just 255s and 1s
    > varying
    > > > with all 0s occasionally. Also my stamp seems to get pretty hot
    > > > whenever I'm testing the interface. any ideas of what the
    problem
    > > > might be? Thanks a lot! I appreciate it! Code below:
    > > >
    > > > ' I/O Assignment and TRIS:
    > > >
    > > > clk con 7
    > > > att con 9
    > > > dat con 5
    > > > cmd con 6
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > ' Variables:
    > > >
    > > > index var byte
    > > > char var byte
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > 'this code simply reads in the commands from the playstation
    > > > controller joysticks and buttons
    > > > 'and displays them via debug.
    > > > main:
    > > >
    > > > low att '
    > > > select the PSX controller
    > > >
    > > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > > > and "send data"
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > > > this byte, it
    > > > 'starts up the controller
    > > >
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > > > left switches
    > > > debug cr,"Buttons:
    ",cr
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > > > right switches
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > >
    > > > 'the above block shifted in the on/off (111011011) status of all
    > > the
    > > > switches
    > > > debug cr, "Right joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Right joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > > > down
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > > > down
    > > > debug dec char, CR ' debug
    > > > window dec format and return
    > > > pause 1000
    > > > 'the block above gets decimal values representing analog X/Y
    > > joystick
    > > > positions
    > > >
    > > > high att
    > > > 'stops transmissions
    > > >
    > > > goto main
    >
    >
    > 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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-08 01:18
    If you're sure your circuit is good, you may have a bad controller. I
    know that the circuit does work as I've used it with a Sony controller,
    as well as a Radio Shack clone. And any NPN will do; it's not critical.

    The Ack signal from the controller is very short and is only used by the
    PlayStation to detect the presence of a controller on the port. We can
    use the datastream to do this and save a pin.

    My only suggestion would be to double-check your interface and
    connections to the Stamp. And I've used the code you posted -- it's
    messy, but does work with a properly-functioning interface.

    -- Jon Williams
    -- Parallax


    Original Message
    From: Sam [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=XVrUsS_7TuDJUDYsFw0Qq3r7FnfrO00tvR14vkdyRSj3vz1KTbZamu1u2jw2Em6j7u5-ILiZHmubUrv3wLA]hard-on@t...[/url
    Sent: Monday, July 07, 2003 6:08 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces



    I hooked up everything as shown in your diagram (in which I'm
    assuming you deliberately didn't hook up the ack line). I no longer
    have the value fluctuation that I mentioned before (readings of 255/1
    and 0 over the data line). Now it's only and always 0 values for
    button presses and for the joysticks. Whatever I press doesn't do
    anything. Using a logic probe, I can see that the clock is indeed
    inverted (high with low pulses), and on the data and command and att
    lines, I detect pulses everytime that the bs2sx is taking a reading
    from the controller (I have a 'pause 500' after collecting each full
    string of data, including all button presses). I'm using a wall-wart
    to power the controller now (was using a 9V battery before), thinking
    that the current might have been too low, but that didn't change
    anything; there is a 5V regulator between the wall-wart and the
    controller. I'm using an 'obsolete' 2n222A npn transister instead of
    the one you mentioned because I owned one already. Any suggestions?
    The code I'm using was posted in my post several messages up from
    here.

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Yes, the PSX requires an inverted clock signal; it also requires the
    > data line to be pulled up. I will put my version of the schematic
    in
    > the files folder for those that didn't get the magazine. I've
    included
    > series resistors to protect the BASIC Stamp from a possible failure
    of
    > the PSX controller.
    >
    > One note: Because of the way the PSX controller samples the data
    line,
    > it will cause Bit7 of the last data byte (which is the up/down axis
    of
    > the left analog joystick) to be set if you use SHIFTIN. If you
    manually
    > shift the data into the Stamp (as I will show you how in my N&V
    column
    > -- so stay tuned) you can deal with this and get the full range of
    the
    > left joystick. Manually shifting is much slower than SHIFTIN, so
    that's
    > something you have to account for. If you're not using the Analog
    PSX
    > controllers, this is a non-issue and SHIFTIN works perfectly.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: Sam [noparse][[/noparse]mailto:hard-on@t...]
    > Sent: Monday, July 07, 2003 12:04 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces
    >
    >
    > it didn't mention that inversion was necessary in the program1
    > file... I didn't get that issue of nuts and volts, did anyone else
    > read that article and have any advice? Do I need inversion for the
    > program1 code too?
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    > wrote:
    > > Did you miss the line in the "Program 2.bs2" that says:
    > >
    > > read_PS2 'A trade off was made between software and hardware.
    > > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > > ' ' without additional pauses. To do this, the clock
    > signal
    > > ' ' must be inverted. A transistor or other sutable
    > inverter
    > > ' ' is required for this code.
    > >
    > > It sounds like driver contention -- ie you're trying to drive the
    > > line while someone else tries to drive the line. You should have a
    > > 220 ohm resistor in series with your data and clock pins to prevent
    > > damage in these circumstances.
    > >
    > > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > > Hey Everyone,
    > > >
    > > > I posted something similar to this last week but I guess
    nobody
    > > > knows an answer or just missed it. I was hoping that someone
    > would
    > > > have some advice this time because it seems like this problem
    > could
    > > > occur with many types of shiftin/shiftout interfaces. I've
    > > connected
    > > > a playstation2 controller to my basic stamp2sx. I've wired up
    all
    > > the
    > > > pins correctly, and I'm supplying regulated +5V from a power
    > source
    > > > seperate from the basic stamp (grounds of the basic stamp and
    > > > controller are connected though). I changed the pin #s in the
    > code
    > > > below (program1 from playstation.zip from nuts and volts:
    > > >
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > > to fit my hook ups. When I run the code though, I get the same
    > data
    > > > whether the controller is powered or not, just 255s and 1s
    > varying
    > > > with all 0s occasionally. Also my stamp seems to get pretty hot
    > > > whenever I'm testing the interface. any ideas of what the
    problem
    > > > might be? Thanks a lot! I appreciate it! Code below:
    > > >
    > > > ' I/O Assignment and TRIS:
    > > >
    > > > clk con 7
    > > > att con 9
    > > > dat con 5
    > > > cmd con 6
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > ' Variables:
    > > >
    > > > index var byte
    > > > char var byte
    > > >
    > >
    >
    > '*******************************************************************
    > > **
    > > > *******************
    > > > 'this code simply reads in the commands from the playstation
    > > > controller joysticks and buttons 'and displays them via debug.
    > > > main:
    > > >
    > > > low att '
    > > > select the PSX controller
    > > >
    > > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get ready"
    > > > and "send data"
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then discard
    > > > this byte, it
    > > > 'starts up the controller
    > > >
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 1st "digital" byte -
    > > > left switches
    > > > debug cr,"Buttons:
    ",cr
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' 2nd "digital" byte -
    > > > right switches
    > > > debug bin char, " " ' debug
    > > > window binary format
    > > >
    > > >
    > > > 'the above block shifted in the on/off (111011011) status of all
    > > the
    > > > switches
    > > > debug cr, "Right joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Right joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right joystick up /
    > > > down
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    L/R "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick
    > > > left / right
    > > > debug dec char, " " ' debug
    > > > window decimal format
    > > >
    > > > debug cr, "Left joy:
    U/D "
    > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left joystick up /
    > > > down
    > > > debug dec char, CR ' debug
    > > > window dec format and return
    > > > pause 1000
    > > > 'the block above gets decimal values representing analog X/Y
    > > joystick
    > > > positions
    > > >
    > > > high att
    > > > 'stops transmissions
    > > >
    > > > goto main
    >
    >
    > 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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...


    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/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-08 19:06
    Got it all working. turned out to be a combination of things. Had
    clock and data lines switched when hooked up to the bs2sx pins, and
    also, used a real sony controller, instead of the 'cypher games'
    controller I was testing with before. the cypher games controller did
    not work with the circuit and code. I think the cypher games
    controller has a higher current draw or something, it's analog led
    would not turn on when the button was pressed, while the sony
    controller led would. I'm confused because the joysticks on the sony
    controller were working nicely, giving different values depending on
    their position, but I wasn't using an analog to digital converter at
    all... I'm assuming these values are just innacurate random numbers
    that arise when the stamp tries to analyze analog voltages as
    digital, so I'm going to put an adc on the data line to try to fix
    this. Thank you very much for your patience and help!

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > If you're sure your circuit is good, you may have a bad
    controller. I
    > know that the circuit does work as I've used it with a Sony
    controller,
    > as well as a Radio Shack clone. And any NPN will do; it's not
    critical.
    >
    > The Ack signal from the controller is very short and is only used
    by the
    > PlayStation to detect the presence of a controller on the port. We
    can
    > use the datastream to do this and save a pin.
    >
    > My only suggestion would be to double-check your interface and
    > connections to the Stamp. And I've used the code you posted -- it's
    > messy, but does work with a properly-functioning interface.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: Sam [noparse][[/noparse]mailto:hard-on@t...]
    > Sent: Monday, July 07, 2003 6:08 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces
    >
    >
    >
    > I hooked up everything as shown in your diagram (in which I'm
    > assuming you deliberately didn't hook up the ack line). I no longer
    > have the value fluctuation that I mentioned before (readings of
    255/1
    > and 0 over the data line). Now it's only and always 0 values for
    > button presses and for the joysticks. Whatever I press doesn't do
    > anything. Using a logic probe, I can see that the clock is indeed
    > inverted (high with low pulses), and on the data and command and
    att
    > lines, I detect pulses everytime that the bs2sx is taking a reading
    > from the controller (I have a 'pause 500' after collecting each
    full
    > string of data, including all button presses). I'm using a wall-
    wart
    > to power the controller now (was using a 9V battery before),
    thinking
    > that the current might have been too low, but that didn't change
    > anything; there is a 5V regulator between the wall-wart and the
    > controller. I'm using an 'obsolete' 2n222A npn transister instead
    of
    > the one you mentioned because I owned one already. Any suggestions?
    > The code I'm using was posted in my post several messages up from
    > here.
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    > wrote:
    > > Yes, the PSX requires an inverted clock signal; it also requires
    the
    > > data line to be pulled up. I will put my version of the schematic
    > in
    > > the files folder for those that didn't get the magazine. I've
    > included
    > > series resistors to protect the BASIC Stamp from a possible
    failure
    > of
    > > the PSX controller.
    > >
    > > One note: Because of the way the PSX controller samples the data
    > line,
    > > it will cause Bit7 of the last data byte (which is the up/down
    axis
    > of
    > > the left analog joystick) to be set if you use SHIFTIN. If you
    > manually
    > > shift the data into the Stamp (as I will show you how in my N&V
    > column
    > > -- so stay tuned) you can deal with this and get the full range of
    > the
    > > left joystick. Manually shifting is much slower than SHIFTIN, so
    > that's
    > > something you have to account for. If you're not using the Analog
    > PSX
    > > controllers, this is a non-issue and SHIFTIN works perfectly.
    > >
    > > -- Jon Williams
    > > -- Parallax
    > >
    > >
    > >
    Original Message
    > > From: Sam [noparse][[/noparse]mailto:hard-on@t...]
    > > Sent: Monday, July 07, 2003 12:04 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] Re: shiftin/shiftout interfaces
    > >
    > >
    > > it didn't mention that inversion was necessary in the program1
    > > file... I didn't get that issue of nuts and volts, did anyone
    else
    > > read that article and have any advice? Do I need inversion for
    the
    > > program1 code too?
    > >
    > > --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    > > wrote:
    > > > Did you miss the line in the "Program 2.bs2" that says:
    > > >
    > > > read_PS2 'A trade off was made between software and hardware.
    > > > ' ' It is desirable to use the SHIFTIN and SHIFTOUT cammands
    > > > ' ' without additional pauses. To do this, the clock
    > > signal
    > > > ' ' must be inverted. A transistor or other sutable
    > > inverter
    > > > ' ' is required for this code.
    > > >
    > > > It sounds like driver contention -- ie you're trying to drive
    the
    > > > line while someone else tries to drive the line. You should
    have a
    > > > 220 ohm resistor in series with your data and clock pins to
    prevent
    > > > damage in these circumstances.
    > > >
    > > > --- In basicstamps@yahoogroups.com, "Sam" <hard-on@t...> wrote:
    > > > > Hey Everyone,
    > > > >
    > > > > I posted something similar to this last week but I guess
    > nobody
    > > > > knows an answer or just missed it. I was hoping that someone
    > > would
    > > > > have some advice this time because it seems like this problem
    > > could
    > > > > occur with many types of shiftin/shiftout interfaces. I've
    > > > connected
    > > > > a playstation2 controller to my basic stamp2sx. I've wired up
    > all
    > > > the
    > > > > pins correctly, and I'm supplying regulated +5V from a power
    > > source
    > > > > seperate from the basic stamp (grounds of the basic stamp and
    > > > > controller are connected though). I changed the pin #s in the
    > > code
    > > > > below (program1 from playstation.zip from nuts and volts:
    > > > >
    > > >
    > >
    >
    http://www.nutsvolts.com/toc_Pages/TOC_Related_Info/Playstation.htm)
    > > > > to fit my hook ups. When I run the code though, I get the same
    > > data
    > > > > whether the controller is powered or not, just 255s and 1s
    > > varying
    > > > > with all 0s occasionally. Also my stamp seems to get pretty
    hot
    > > > > whenever I'm testing the interface. any ideas of what the
    > problem
    > > > > might be? Thanks a lot! I appreciate it! Code below:
    > > > >
    > > > > ' I/O Assignment and TRIS:
    > > > >
    > > > > clk con 7
    > > > > att con 9
    > > > > dat con 5
    > > > > cmd con 6
    > > > >
    > > >
    > >
    >
    > '*******************************************************************
    > > > **
    > > > > *******************
    > > > > ' Variables:
    > > > >
    > > > > index var byte
    > > > > char var byte
    > > > >
    > > >
    > >
    >
    > '*******************************************************************
    > > > **
    > > > > *******************
    > > > > 'this code simply reads in the commands from the playstation
    > > > > controller joysticks and buttons 'and displays them via debug.
    > > > > main:
    > > > >
    > > > > low att
    '
    > > > > select the PSX controller
    > > > >
    > > > > shiftout cmd,clk, LSBFIRST,[noparse][[/noparse]$01,$42] ' send "get
    ready"
    > > > > and "send data"
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' read then
    discard
    > > > > this byte, it
    > > > > 'starts up the controller
    > > > >
    > > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > > > 'shiftin dat, clk, 3, [noparse][[/noparse]char]
    > > > >
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] '
    1st "digital" byte -
    > > > > left switches
    > > > > debug cr,"Buttons:
    ",cr
    > > > > debug bin char, " " '
    debug
    > > > > window binary format
    > > > >
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] '
    2nd "digital" byte -
    > > > > right switches
    > > > > debug bin char, " " '
    debug
    > > > > window binary format
    > > > >
    > > > >
    > > > > 'the above block shifted in the on/off (111011011) status of
    all
    > > > the
    > > > > switches
    > > > > debug cr, "Right joy:
    L/R "
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right
    joystick
    > > > > left / right
    > > > > debug dec char, " " '
    debug
    > > > > window decimal format
    > > > >
    > > > > debug cr, "Right joy:
    U/D "
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' right
    joystick up /
    > > > > down
    > > > > debug dec char, " " '
    debug
    > > > > window decimal format
    > > > >
    > > > > debug cr, "Left joy:
    L/R "
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left
    joystick
    > > > > left / right
    > > > > debug dec char, " " '
    debug
    > > > > window decimal format
    > > > >
    > > > > debug cr, "Left joy:
    U/D "
    > > > > shiftin dat, clk, 3, [noparse][[/noparse]char] ' left
    joystick up /
    > > > > down
    > > > > debug dec char, CR '
    debug
    > > > > window dec format and return
    > > > > pause 1000
    > > > > 'the block above gets decimal values representing analog X/Y
    > > > joystick
    > > > > positions
    > > > >
    > > > > high att
    > > > > 'stops transmissions
    > > > >
    > > > > goto main
    > >
    > >
    > > 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/
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p...
    >
    >
    > 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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
Sign In or Register to comment.