Shop OBEX P1 Docs P2 Docs Learn Events
combne serout commands — Parallax Forums

combne serout commands

guydbguydb Posts: 29
edited 2006-01-20 16:32 in BASIC Stamp
hi,
I'm having a weird problem:
I want to send MIDI out (using pin 14) and send strings to a serial LCD display (using pin 7). both operations use SEROUT.
Now comes the weird thing (at least to me): separately everything works (I can send MIDI or send strings to the LCD display), but as soon as I combine both things in one program the LCD goes blank once the first MIDI command is being sent, and it stays blank, whatever I send to it, while MIDI continues to function???
any suggestions about what goes wrong?
thanks,µGuy

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-19 13:47
    How about U/L'ing your program?
  • guydbguydb Posts: 29
    edited 2006-01-19 13:51
    ooops, probably sound stupid: what is U/Ling?
  • guydbguydb Posts: 29
    edited 2006-01-19 14:09
    ok, uploading.
    here is the simple test version (the actual thing is way too long, while this reproduces the problem:

    ' {$STAMP BS2sx}

    z VAR Byte
    x VAR Byte

    N9600 CON $40F0
    j CON 254
    CLR CON 1
    LINE2 CON 192
    L1_C7 CON 135


    FOR x = 1 TO 127
    z=z+1
    SEROUT 7, n9600, [noparse][[/noparse]j,CLR]
    SEROUT 7, n9600, [noparse][[/noparse]j,CLR]
    PAUSE 10
    SEROUT 7, n9600, [noparse][[/noparse]"last number"]
    SEROUT 7, n9600, [noparse][[/noparse]j,LINE2]
    SEROUT 7, n9600, [noparse][[/noparse]DEC z]


    SEROUT 15,60,[noparse][[/noparse]177,23,z]


    PAUSE 1000
    NEXT

    END


    run it like this and nothing will show up on the screen, remove the SEROUT 15 line and the LCD will nicely display figures from 1 to 127
  • guydbguydb Posts: 29
    edited 2006-01-19 15:00
    been trying more things...adding a 5 second pause right before the serout to the LCD shows the figure on the screen, until the other serout comes up...it's still not what I wanted (I would like the screen to stay§ on until it is being cleared in the program) but it's better than nothing.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-19 16:26
    It looks like you're using a SEETRON display -- and when using it a 9600 baud you need to put a 2 ms PAUSE after a you issue a clear instruction; you have two in a row before the PAUSE. Why the other SEROUT would affect this one way or the other makes absolutely no sense to me. I've used multiple serial devices on different pins many times.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • guydbguydb Posts: 29
    edited 2006-01-19 16:43
    not sure , it's a parallax serial display...but it's working now with the pause I added, except that it goes off as soon as I send the other serout
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-19 17:25
    What is the specific model number of your LCD?· And... did you copy-and-paste that code fragment into the forum, or did you type it in.· Is it possible you actually have the same pin number for the two SEROUTs in your program?

    You might consider using our template as a starting place and following our "Elements of PBASIC Style" guidelines.· One of my big no-no's is using "magic numbers" (embedded numeric values) in code (except for with PAUSE which is unambiguous).· I've taken your program and applied it to our template; give this a try and see if it clears the air.· Note that I've used a bit of a trick with the LCD -- I've inserted a 3 millisecond delay (pacing) between every byte; this will not be noticed by humans and eliminate the need to put PAUSE instructions after the LCD commands that require a bit of a delay before the next character arrives.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • guydbguydb Posts: 29
    edited 2006-01-19 18:30
    thank you,
    I just did copy paste...I don't have twice the same pin number in the program.
    I tried with your example and it's just the same problem: nothing shows on the LCD display unless I disable the serout line for the MIDI output...it is very puzzling, especially as both commands work separately...
    just had an idea: I ran the program but disconnected the midi output cable...and now the display works, while sending (tho
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-19 18:51
    Guy -

    It may be a grounding problem. Is there a solid ground between the MIDI device and the Stamp, either through the serial cable, or elsewhere? If not, you may need to supply one.

    Regards,

    Bruce Bates
  • guydbguydb Posts: 29
    edited 2006-01-19 19:21
    yes, there's the midi ground running between the stamp and the MIDI device (tried it with several devices)
    thanks
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-19 20:59
    Do you have 220-ohm resistor between your MIDI output pin and the MIDI connector? If no, this is the problem -- you're swamping the supply.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • guydbguydb Posts: 29
    edited 2006-01-20 06:59
    yes, I have them...
    I guess I'll work with it like this (need it tomorrow) and will do some thinking and make a new board from scratch when I'm back...it might be an electrical problem (nothing else makes sense)...
    thanks,
    guy
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-20 16:32
    If you can replace the SEROUT to the MIDI port with a DEBUG statement and get everything to work, I'd say your problem is electrical. Use this DEBUG line:

    DEBUG DEC3 midiCmd, " ", DEC3 midiDat1, " ", DEC3 midiDat2, CR

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.