Shop OBEX P1 Docs P2 Docs Learn Events
Serout - pin 16 — Parallax Forums

Serout - pin 16

ArchiverArchiver Posts: 46,084
edited 2002-06-20 01:09 in General Discussion
Hi, I just made a project where a BS2 should send a MIDI-code to a
sampler/keyboard.

the command in the code is this :
"serout 7, 32780, [noparse][[/noparse] $90, $25, $7F]" (here pin7 is the output-pin)

it works fine if I use PIN 0 .. PIN 15 as the output-pin to send
this command. The sampler/keyboard responds correctly to the MIDI
code it gets.

The problem is that all my PINs are used for other function and I
need to use the serial port. The manual says to use pin 16 in the
command. so when I use this piece of code :
"serout 16, 32780, [noparse][[/noparse] $90, $25, $7F]"
nothing happens!! the keyboard does not respond....
What is the difference between pin 16 and all the others?

PS I hook up the keyboard after the progam is downloaded into the
BS2.
- step1) download the program
- step2) disconnect the power from the BS2
- step3) disconnect the computer from the BS2
- step4) hook up the keyboard
- step5) power up the BS2

I hope someone can help me out!
Thanks!

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 16:52
    Try
    serout 16, 12, [noparse][[/noparse] $90, $25, $7F]
    The P16 serial port hardware automatically inverts the signal. P0--P15 do not.
    You have 31250 baud if that is a BS2. Right?

    -- Tracy


    >Hi, I just made a project where a BS2 should send a MIDI-code to a
    >sampler/keyboard.
    >
    >the command in the code is this :
    >"serout 7, 32780, [noparse][[/noparse] $90, $25, $7F]" (here pin7 is the output-pin)
    >
    >it works fine if I use PIN 0 .. PIN 15 as the output-pin to send
    >this command. The sampler/keyboard responds correctly to the MIDI
    >code it gets.
    >
    >The problem is that all my PINs are used for other function and I
    >need to use the serial port. The manual says to use pin 16 in the
    >command. so when I use this piece of code :
    >"serout 16, 32780, [noparse][[/noparse] $90, $25, $7F]"
    >nothing happens!! the keyboard does not respond....
    >What is the difference between pin 16 and all the others?
    >
    >PS I hook up the keyboard after the progam is downloaded into the
    >BS2.
    >- step1) download the program
    >- step2) disconnect the power from the BS2
    >- step3) disconnect the computer from the BS2
    >- step4) hook up the keyboard
    >- step5) power up the BS2
    >
    >I hope someone can help me out!
    >Thanks!
    >
    >
    >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/
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 18:13
    Yes, the baudrate is 31250 baud. I tried your suggestion but it
    didn't work. then I saw that the parameter to invert everything was
    wrong.
    Instead of "serout 16, 12, [noparse][[/noparse] $90, $25, $7F]", I figured out it had
    to be "serout 16, 32780, [noparse][[/noparse] $90, $25, $7F] to have 31250 baud
    inverted.

    But still it does not work....

    Thanks anyway!





    --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > Try
    > serout 16, 12, [noparse][[/noparse] $90, $25, $7F]
    > The P16 serial port hardware automatically inverts the signal. P0-
    -P15 do not.
    > You have 31250 baud if that is a BS2. Right?
    >
    > -- Tracy
    >
    >
    > >Hi, I just made a project where a BS2 should send a MIDI-code to a
    > >sampler/keyboard.
    > >
    > >the command in the code is this :
    > >"serout 7, 32780, [noparse][[/noparse] $90, $25, $7F]" (here pin7 is the output-pin)
    > >
    > >it works fine if I use PIN 0 .. PIN 15 as the output-pin to send
    > >this command. The sampler/keyboard responds correctly to the MIDI
    > >code it gets.
    > >
    > >The problem is that all my PINs are used for other function and I
    > >need to use the serial port. The manual says to use pin 16 in the
    > >command. so when I use this piece of code :
    > >"serout 16, 32780, [noparse][[/noparse] $90, $25, $7F]"
    > >nothing happens!! the keyboard does not respond....
    > >What is the difference between pin 16 and all the others?
    > >
    > >PS I hook up the keyboard after the progam is downloaded into the
    > >BS2.
    > >- step1) download the program
    > >- step2) disconnect the power from the BS2
    > >- step3) disconnect the computer from the BS2
    > >- step4) hook up the keyboard
    > >- step5) power up the BS2
    > >
    > >I hope someone can help me out!
    > >Thanks!
    > >
    > >
    > >To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@y...
    > >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/
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 19:47
    --- dirkxp <dirk.van.hecke@v...> wrote:
    > Hi, I just made a project where a BS2 should send a
    > MIDI-code to a
    > sampler/keyboard.
    > The problem is that all my PINs are used for other
    > function and I
    > need to use the serial port. The manual says to use
    > pin 16 in the

    According to the BS2 manual, regardless of the
    baudmode setting, the data is inverted and driven
    through the dedicated serial port (tpin=16). Could
    this be your problem?

    Chris



    __________________________________________________
    Do You Yahoo!?
    Yahoo! - Official partner of 2002 FIFA World Cup
    http://fifaworldcup.yahoo.com
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 21:14
    As Chris pointed out, the P16 SEROUT is inverted no matter which way
    set it, "12" or "32780" does not make a difference. But the fact
    that "32780" does work for you on P0 means that inverted is the
    correct polarity.

    Another take: Maybe there is a problem with the voltage levels or
    speed. The P16 serial port steals power from the receive line, so if
    you are not using that line, there is no power to steal and the
    response is sluggish. Connect a resistor (~2 kohm) from your
    transmit line (pin 1 on the IC) to ground. That should speed it up
    and give it a solid low level.

    -- Tracy


    >Yes, the baudrate is 31250 baud. I tried your suggestion but it
    >didn't work. then I saw that the parameter to invert everything was
    >wrong.
    >Instead of "serout 16, 12, [noparse][[/noparse] $90, $25, $7F]", I figured out it had
    >to be "serout 16, 32780, [noparse][[/noparse] $90, $25, $7F] to have 31250 baud
    >inverted.
    >
    >But still it does not work....
    >
    >Thanks anyway!
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 22:24
    Hi!

    "32780" on P0 works, but this means (according to the manual) "Open
    Output", It doesn't have anything to do with normal or inverted
    mode....

    I think the first thing I will try is your option with the 2K
    pull-down resistor... I will let you know how this works out

    thanks a lot!
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-20 01:09
    >Hi!
    >
    >"32780" on P0 works, but this means (according to the manual) "Open
    >Output", It doesn't have anything to do with normal or inverted
    >mode....
    >
    >I think the first thing I will try is your option with the 2K
    >pull-down resistor... I will let you know how this works out
    >
    >thanks a lot!

    Oh, right, open mode, not inverted! I didn't look at it carefully
    enough. That being true, the P16 serial output won't work without a
    bit of external hardware to reinvert the signal.

    The open bausdmode with 32780 from P0 to P15 will rest at a high
    level (given a pullup resistor), and it will go active low to send
    the start bit and other logical "0" bits.

    P16 always rests low. Here is a simple transistor open mode inverter circuit:

    N-mosfet 2N7000
    |
    midi
    ||
    P16 ---o--||---o
    common
    | |
    `-/\/\--o
    5k |
    Vss

    -- Tracy
Sign In or Register to comment.