If Stamp P14 transmits (SEROUT) and P15 receives (SERIN),
then for the javelin use:
static Uart·stampTX = new Uart(Uart.dirTransmit,CPU.pin15,Uart.dontInvert,Uart.speed2400,Uart.stop1);
static Uart·stampRX = new Uart(Uart.dirReceive,CPU.pin14,Uart.dontInvert,Uart.speed2400,Uart.stop1);
You then use to receive
if (stampRX.byteAvailable()) { · int c = stampRX.receiveByte(); · //do something
}
and for transmit
int data = someByte;
stampTX.sendByte(data);
stampTX.sendString("just some text");
It is always a good idea to put in a protection resistor:
StampP15 o----[noparse][[/noparse]1k]----o JavelinP15
StampP14 o----[noparse][[/noparse]1k]----o JavelinP14
StampGND o
o JavelinGND
For the stamp BS1 I think you must use T2400 (true mode)
Lookup the correct BS2 value for 2400 baud (different values
for different models basic stamp).
For the BS2, BS2e and BS2pe, the value for truemode 2400 baud is 396
regards peter
Post Edited (Peter Verkaik) : 6/23/2009 11:12:27 PM GMT
I too am trying this today. I was wondering if pin 16 for the stamp and the javelin (which naturally connects to the serial connection on the board of education) has embedded hardware that can handle inverted. If you look at the board of education schematic, there is no dissipating resistor to handle the 12 V from a serial connection from a computer.
For the basic stamps, pin16 means either pin SOUT (for serout) or pin SIN (for serin).
Those pins need the pc com port signal levels. If you connected a MAX232 TTL->RS232
chip to a javelin I/O pin and use Uart.Invert then you should be a able to
communicate with a basic stamp via its SIN and SOUT pins. But note that
everything sent from the javelin will be echoed back to the javelin so your
javelin code must filter these echoes out.
Its much simpler to use a BS I/O pin instead.
I've had different problems with this configuration, trying to send stuff from the Stamp to the Javelin and back.
This works fine: SEROUT JTx, N2400, [noparse][[/noparse]"an"]
But this does not work: SEROUT JTx, N2400, [noparse][[/noparse]"a","n"]
Neither does this: SEROUT JTx, N2400, [noparse][[/noparse]"a",SomeVariable]
Also, stampRX.byteAvailable() always returns True, if I send something or not, so I have to check if stampRX.receiveByte() actually contains something.
Receiving data in the stamp seems to be no problem when I use sendString(). When I use sendByte() I get garbage.
Comments
If Stamp P14 transmits (SEROUT) and P15 receives (SERIN),
then for the javelin use:
static Uart·stampTX = new Uart(Uart.dirTransmit,CPU.pin15,Uart.dontInvert,Uart.speed2400,Uart.stop1);
static Uart·stampRX = new Uart(Uart.dirReceive,CPU.pin14,Uart.dontInvert,Uart.speed2400,Uart.stop1);
You then use to receive
if (stampRX.byteAvailable()) {
· int c = stampRX.receiveByte();
· //do something
}
and for transmit
int data = someByte;
stampTX.sendByte(data);
stampTX.sendString("just some text");
regards peter
When I run this code on Javelin:
if (stampRX.byteAvailable()) {
int c = stampRX.receiveByte();
I get a zero "0" immediately even if no wires are connected.
Should I use non-inverted when I send from the Stamp (since you wrote non-inverted above for the Javelin)?
I tried this:
SEROUT JavelinPinOut, N2400 + Inverted, [noparse][[/noparse]SomeByte]
Will this work without flow-control?
What about the wiring? Should I use a resistor on the Tx and Rx line?
Both computers are connected to the same power source.
StampP15 o----[noparse][[/noparse]1k]----o JavelinP15
StampP14 o----[noparse][[/noparse]1k]----o JavelinP14
StampGND o
o JavelinGND
For the stamp BS1 I think you must use T2400 (true mode)
Lookup the correct BS2 value for 2400 baud (different values
for different models basic stamp).
For the BS2, BS2e and BS2pe, the value for truemode 2400 baud is 396
regards peter
Post Edited (Peter Verkaik) : 6/23/2009 11:12:27 PM GMT
It works!!! (lol)
I think it was the inverted vs. non-inverted things I mixed up.
I had some problems with sendByte (couldnt get any result on the stamp), but when I switched to sendString it all works fine.
Thanks a lot Peter!!
Those pins need the pc com port signal levels. If you connected a MAX232 TTL->RS232
chip to a javelin I/O pin and use Uart.Invert then you should be a able to
communicate with a basic stamp via its SIN and SOUT pins. But note that
everything sent from the javelin will be echoed back to the javelin so your
javelin code must filter these echoes out.
Its much simpler to use a BS I/O pin instead.
regards peter
This works fine: SEROUT JTx, N2400, [noparse][[/noparse]"an"]
But this does not work: SEROUT JTx, N2400, [noparse][[/noparse]"a","n"]
Neither does this: SEROUT JTx, N2400, [noparse][[/noparse]"a",SomeVariable]
Also, stampRX.byteAvailable() always returns True, if I send something or not, so I have to check if stampRX.receiveByte() actually contains something.
Receiving data in the stamp seems to be no problem when I use sendString(). When I use sendByte() I get garbage.
(ignore the second BS2 in the schematic)