transmitter help
Hello. So I'm trying to transmit data from my bs2 to a ground station using the serout command. I'm using 1200 baud. I've been going through the manual for pbasic and as near as I can tell·my serout command should look something like this.
··· SEROUT 15,17197,[noparse][[/noparse]"W004B"]
··· SEROUT 15,17197,[noparse][[/noparse]"W014E"]
··· SEROUT 15,17197,[noparse][[/noparse]"W0234"]
··· SEROUT 15,17197,[noparse][[/noparse]"W034A"]
··· SEROUT 15,17197,[noparse][[/noparse]"W0546"]
··· SEROUT 15,17197,[noparse][[/noparse],DEC ABS xTilt,DegSym, CLREOL, 13]
··· SEROUT 15,17197,[noparse][[/noparse]DEC ABS yTilt,DegSym, CLREOL, 13]
··· SEROUT 15,17197,[noparse][[/noparse]DEC (ABS xmG / 1000), ".", DEC3 (ABS xmg), " g",13]
But I'm·not getting anything to transmit. I am also wondering what is meant by inverted, and how do I know if it applys to what I'm working on. Thanks for all the help.
···
··· SEROUT 15,17197,[noparse][[/noparse]"W004B"]
··· SEROUT 15,17197,[noparse][[/noparse]"W014E"]
··· SEROUT 15,17197,[noparse][[/noparse]"W0234"]
··· SEROUT 15,17197,[noparse][[/noparse]"W034A"]
··· SEROUT 15,17197,[noparse][[/noparse]"W0546"]
··· SEROUT 15,17197,[noparse][[/noparse],DEC ABS xTilt,DegSym, CLREOL, 13]
··· SEROUT 15,17197,[noparse][[/noparse]DEC ABS yTilt,DegSym, CLREOL, 13]
··· SEROUT 15,17197,[noparse][[/noparse]DEC (ABS xmG / 1000), ".", DEC3 (ABS xmg), " g",13]
But I'm·not getting anything to transmit. I am also wondering what is meant by inverted, and how do I know if it applys to what I'm working on. Thanks for all the help.
···
Comments
Regarding the true vs. inverted question, attached is Inverted.jpg. That's what you'll see monitoring P15 with the Parallax USB oscilloscope when the command SEROUT 15, 17197, [noparse][[/noparse]"W"] is executed. At the left of the screen, the signal is in its (low) resting state. Moving to the right, there is a 1/1200 second high signal, which is called the "start bit", and it signals the beginning of a byte transmission. The next eight 1/1200 second data bits are inverted, so a low signal indicates a binary-1, and a high signal indicates a binary-0. The first three 1/1200 second time slices to the right of the start bit are all low, so they are binary-1s. Next comes the following 1/1200 second signals: high, low, high, low, high, which correspond to binary-01010. This is followed by low resting state again. Since serial communication transmits least significant bit first, the message is actually: %01010111, which when converted to decimal is the number 87, which is the ASCII code for "W".
Also attached is True.jpg, which shows what's plotted by the Parallax USB Oscilloscope while monitoring SEROUT 15, 813, [noparse][[/noparse]"W"]. The difference between true and inverted signals is that everything that was high in inverted serial messages is now low, and visa-versa. So, now resting state is high, the start bit is low, binary-1s are high, and binary-0s are low.
Note: After each byte, there is a resting state of at least one 1/1200 seconds. It's referred to as the stop bit, and it's the minimum time before the next start bit can be sent assuming you are using 1200 bps, no parity, one stop bit.· If you are using 1200 bps, no parity, two stop bits, there would be a minimum of 2/1200 second resting state before the next·start bit.
Post Edited (Andy Lindsay (Parallax)) : 11/26/2005 9:05:59 AM GMT
You're set up for 1200, 8, N, 1, inverted which should let you talk to a 'standard' rs232 device like a computer.
Two quick checks: Make sure the receiving device signal ground is tied to the stamp's ground ( 0v).
The wire from pin 15 on the stamp will go to pin 2 or 3 on the receiving device, depending on whether it is set as a DTE or DCE, Try both.
Finally, your receiving device may need handshaking pins jumpered in order for it to process incoming data. Most likely a jumper from pin 4 to pin 5 on the receiving unit will take care of that.
As always, "Serial Port Complete", by Jan Axelson is THE reference for serial work.
http://www.camiresearch.com/Data_Com_Basics/RS232_standard.html
There are lots more pages like this out there - find one that works well for you a a reference.
Even with this information, use caution before making the electrical connection. Whenever I connect BASIC Stamp I/O pin to a serial port, I put a 22 k resistor in series even if I'm transmitting to the serial port. In the event of a wiring mistake, I won't end up with a dead I/O pin (or maybe even a dead BASIC Stamp).
Another thing I do is use a voltmeter to check the serial port pins before making any connections. For example, if I know I'm working with a DCE device with a DB9 port, after consulting that web site, I expect pin 3 to be the receiver, pin 2 to be the transmitter, and pin 5 to be the signal ground. So, with the device's serial port disconnected, I'll power it up and use a voltmeter to test the voltages. After connecting COM/GND to pin 5, I'll connect the voltmeter's positive lead to pin 2, which should be the transmitter. If the voltage is a negative value (-7 V, -9 V, -12 V, etc), that verifies that it's a transmitting pin. Next, I'll try pin 3. I expect to see either zero volts on pin 3, or some voltmeters displays won't settle down because the pin is an input and appears to be "floating". That pretty much verifies that it's an input.·
There are also RS232 driver chips you can use to protect your BASIC Stamp I/O pins. The MAX232 is a common one.
<corrected>
The PC's serial port is DTE, and when you program your BASIC Stamp, you are using a straight through cable to the port on the BASIC Stamp's carrier board, which similar to DCE in that it receives serial messages on pin 3 and sends on pin 2.· In the BASIC Stamp, these signals are coupled so that whatever the BASIC Stamp receives on pin 3 is echoed on pin 2.·
<corrected>
A null modem cable can be used connect the Board of Education to some other devices that are otherwise designed to be connected to a PC's serial port; however, the Board of Education's DB9 connector does not support all the signal lines a DCE device like a modem uses.· On the Board of Education, the DCE ready and CTS pins are tied together,·so hardware flow control is not an option.··So long as the other device only·needs only to use its transmit and/or receive lines (pins 2 and 3), a null modem cable is a quick way to make the connection.· SERIN and SEROUT commands can then use 16 for·their Pin arguments to communicate using the BASIC Stamp's SIN and SOUT pins.· The SIN pin·is connected to·pin 3 on the Board of Education's DB9 connector,·and the SOUT pin is connected to pin 2.· Vss is connected to pin 5.·
One final note, stamptrol's suggestion about making sure Vss is connected to the device's signal ground bears repeating. That's probably the most common mistake we see when connecting a microcontroller to a serial port.
Post Edited (Andy Lindsay (Parallax)) : 11/26/2005 10:15:53 PM GMT
for the ground station. Can these two communicate and if so do I have to do something two the atmel chip or can it be adjusted for in my bs2p code.
The "unknown transmitter" part doesn't sound very promising. How do you know which pin to connect to Vss and which pin to connect to P15 with this unknown transmitter? How do you know whether it transmits a frequency and format that the base station is capable of demodulating?
Without the documentation for the RF units, and the base station, it's hard to know whether or not it will work. The BASIC Stamp 2p is certainly capable of transmitting at 1200 bps, but there are a lot of things that have to be working right:
- The BASIC Stamp has to be correctly wired to the transmitter
- The transmitter and receiver have to correctly relay the serial data the BASIC Stamp is sending to the microcontroller in the base station
- The BASIC Stamp 2p has to be sending the data in the format the microcontroller on the base station expects to receive. If that's 1200 8N1 and the other two conditions are covered, then it should work.
SEROUT 15, 2063, [noparse][[/noparse]"S", "Testing 123...", 13]
SEROUT 15, 18447, [noparse][[/noparse]"S", "Testing 123...", 13]
DEBUG output should appear on pin port 16 (aka SOUT), on the BS-2 Stamps. Are you sure you have identified pin port 3 correctly, and correctly specified it in your SEROUT command? Pin port 3 is physical pin 8 on the BS-2 and BS-2SX.
Regards,
Bruce Bates