[Help!] Serial Communication
dakkang
Posts: 6
I'm making a MM Director piece which contols BS2 through serial port.
For example, I'm trying to turn on/off LED's by clicking on button in Director Movie.
I've used 'debug' on BS2 to get serial signals to PC(to Director),
but, only to fail in doing the other way around(PC to BS2).
I've tried·'DirectCommunication Xtra' on Director,
and 'SERIN' on BS2....9600 baud rate 8N1...never succeeded.
Can anybody help on this?
Thank you in advance.
For example, I'm trying to turn on/off LED's by clicking on button in Director Movie.
I've used 'debug' on BS2 to get serial signals to PC(to Director),
but, only to fail in doing the other way around(PC to BS2).
I've tried·'DirectCommunication Xtra' on Director,
and 'SERIN' on BS2....9600 baud rate 8N1...never succeeded.
Can anybody help on this?
Thank you in advance.
Comments
It can only do one thing at a time (although quite fast)....so you need to be sure it's not stuck doing something else while you are sending it these commands.· If it's in the middle of serout'ing to the PC and the PC is sending down to the stamp, then the stamp won't catch it all.
Break it down and be sure that you have 2-way comms working,· How about attaching some code and maybe describing how you are interfacing to the stamp (programming port or I/O pins?).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
That was about another project I've already done.
In this project, I'm only sending out serial messages from PC(Director) to BS2.
So, there is no possible problem of 2-way comm, I believe.
Here's the simple code I've written for BS2 side
OUTPUT 10
OUT10 = 1
SerData VAR Byte
again:
OUT10 = 1
SERIN 2\3, 16468, 1000, again, [noparse][[/noparse]DEC SerData]
OUT10 = 0
PAUSE SerData
OUT10 = 1
PAUSE SerData
GOTO again
And, Director's Lingo code ("Device" is the serial comm object)
global Device, R
on mouseUp me
writecomm ( Device, "50" )
writecomm ( Device, return )
end
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Umm...
The code I've attached actually is not working...-_-;
Is there any problem with the code?
Is the code written correctly?
Or is there anything else I have to consider to make the LED blink?
Maybe, I'm not fully getting the commend "SERIN"...or serial comm...T_T
I've searched web for Director-BS2 serial comm with no chance...
I've already done couple of projects to get serial messages from BS2 on Director...
but, this one, Director to BS2, is not working.
I don't think that sending out serial messages from Director is that big deal.
how BS2 is getting the messages is something that I'm not quite sure about...
If you have any clue that I can make this work, please give me.
Thanks.
I've looked through this forum, and I've found that I have to use p16 to communicate thru programming port.
To test on this, i wrote a new code like this.
p9 is rigged with LED.
But, it's sad that it doesn't work.....
Any idea what is wrong with this?
Stamp side
OUTPUT 9
OUT9 = 1
SerData VAR Byte
again:
SERIN 16, 16468, [noparse][[/noparse]WAIT(255), SerData]
HIGH SerData
GOTO again
Lingo Side
(I tried to use another Xtra for serial comm, so it looks a little different from the one above)
global theXtra
on mouseDown me
if theXtra.IsPortOpen() then
theXtra.WriteChar(NumtoChar(255))
theXtra.WriteChar(NumtoChar(9))
end if
end
It might be wise to display the value of SerData via DEBUG, or by some other means, to see what the value is, once it's been input by the Stamp. I'm also curious about the "NumtoChar" function on the Lingo side. It would seem to me you want to be transmitting numeric, and not character data? Admittedly I know nothing about Lingo or the Director.
The other part not seen here are the characteristics of the serial output in terms of baud rate, parity, number of stop bits, etc on the Director side. That can make all the difference between success and failure.
Regards,
Bruce Bates
I've just got things done with serial comm with Director!!!
I might wanna leave all the codes that I've been struggling with whole today.....just for record.
this one is to make a LED blink by clicking on the button on Director piece.
Stamp side
OUTPUT 8
HIGH 8
SerData VAR Byte
again:
HIGH 8
SERIN 16, 16468, [noparse][[/noparse]SerData]
HIGH SerData
PAUSE 200
LOW SerData
PAUSE 200
GOTO again
Director Side (with SerialXtra)
global theXtra
on mouseDown me
if theXtra.IsPortOpen() then
theXtra.WriteChar("8")
repeat while theXtra.CharsAvailable() = 0
end repeat
reply = theXtra.ReadString()
put reply
end if
end
this one is for a servo...random positioning
Stamp side
SerData VAR Word
counter VAR Word
again:
SERIN 16, 16468, [noparse][[/noparse]DEC SerData]
FOR counter = 1 TO 20
PULSOUT 14, SerData
PAUSE 20
NEXT
GOTO again
Director side
global theXtra
on mouseDown me
if theXtra.IsPortOpen() then
tnum = string(random(450)+350)
theXtra.WriteString(tnum)
theXtra.WriteChar("*")
repeat while theXtra.CharsAvailable() = 0
end repeat
reply = theXtra.ReadString()
put reply
end if
end
I was going to recommend you simplify your serin line to at least be able to see if anything is coming in!
you went from:
SERIN 2\3, 16468, 1000, again, [noparse][[/noparse]DEC SerData]
to
SERIN 16, 16468, [noparse][[/noparse]WAIT(255), SerData]
to
SERIN 16, 16468, [noparse][[/noparse]SerData]
with the first line, you might need a level converter to have pin 3 (flow control) tell the PC to send.
the 2nd line, not sure what you are sending from the PC to tell the stamp to go.· An ascii 255 is a space (I thought anyways), is this part of your string coming down from Director?
the 3rd line is the barebones way to at least get things in to play with.
I usually do things like this when testing:
SERIN 16, 16468, [noparse][[/noparse]SerData]
debug ? SerData, CR
this will immediately tell me what I have received.· I might then change it to a debug dec SerData·· depending on what I'm expecting!
anyhow, if you are going to use one of the I/O pins for connecting to an RS232 buss, then be sure you use a 22kohm resistor in series to avoid killing that pin with excessive current!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
You're totally right!
I have to admit that I was a novice on this kind of stuff...
and was even confused with the data types to exchange...
I've tried to read thru all the materials about serial comm...
then I could picture a little what that is...
Anyways, that is the way it goes...
Now, I'm getting into the REAL project!!!
The last comment is also very useful to me.
Thanks a lot again, Steve...and all of you.
I'm loving this forum!!!!!!