PDA

View Full Version : combne serout commands



guydb
01-19-2006, 08:30 PM
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

PJ Allen
01-19-2006, 08:47 PM
How about U/L'ing your program?

guydb
01-19-2006, 08:51 PM
ooops, probably sound stupid: what is U/Ling?

guydb
01-19-2006, 09:09 PM
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, [j,CLR]
SEROUT 7, n9600, [j,CLR]
PAUSE 10
SEROUT 7, n9600, ["last number"]
SEROUT 7, n9600, [j,LINE2]
SEROUT 7, n9600, [DEC z]


SEROUT 15,60,[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

guydb
01-19-2006, 10:00 PM
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 Williams
01-19-2006, 11:26 PM
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

guydb
01-19-2006, 11:43 PM
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 Williams
01-20-2006, 12:25 AM
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

guydb
01-20-2006, 01:30 AM
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çugh to nowhere) the MIDI command...???????
I start to wonder whether this could be a capacitance problerm?

Bruce Bates
01-20-2006, 01:51 AM
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

guydb
01-20-2006, 02:21 AM
yes, there's the midi ground running between the stamp and the MIDI device (tried it with several devices)
thanks

Jon Williams
01-20-2006, 03:59 AM
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

guydb
01-20-2006, 01:59 PM
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 Williams
01-20-2006, 11:32 PM
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