communication with other microprocessors
qiuqiuaaa
Posts: 37
I have an Arcuino processor to obtain some information from sensors, and I want to transfer the information to my Basic Stamp. After checking the manual, I only found the Serial communication between PC and BS2. How do I it between two microprocessors. I have no idea...
Comments
Then you need to decide if you're going to transmit the data as ASCII characters or as bytes and plan accordingly.
Maybe that's "sketchy", but now you have an idea.
I worked out a couple of test programmes: a BS2 data receiver, and the open-source development platform filling an array with analogRead results (in lieu of "sensor data") and then dumping that out.
The BS2 couldn't keep up at 9600, but it does good at 4800.
Let me know how you're progressing.
I have something that I worked out.
If you get stuck, shout out and we can compare notes.
The Stamp is designed with a serial port (Sin/Sout) that is normally used for downloading programs and for debugging (DEBUG / DEBUGIN). The Stamp module has an RS232-like interface for this port and, on the USB Board of Education, there's a built-in USB to RS232 adapter for this port. This port is limited in how else it can be used. The Baud is normally fixed at 9600 for most Stamp models and any data sent from the USB side is echoed back to the USB side, so it's really half duplex. This is an artifact of how the RS232-like interface works. You can also use the SEROUT and SERIN statements with this port which is treated like I/O pin 16 in those statements.
In any event, this port, while it can be used more generally, is really intended for communicating with an attached PC. If you want to communicate with another microcontroller, you would normally use a pair of the normal I/O pins with the SERIN and SEROUT statements the way it's described in the Stamp Manual and the Stamp Editor's help files.
And then we could have a meaningful conversation.
' {$PBASIC 2.5}
serData VAR Byte
noSerialData:
DEBUG "Hello "
SERIN 5, 17197,10000,noSerialData,[serData]
DEBUG ? serData
This is my test code. I don't know if there is some problem with it, but it received nothing. (BS2px is used, Baud rate 4800. I connect P0 to TX1 on Arduino,and Vss to Ground on Arduino )
That's interesting. You are connecting your TX (output device) to P0, but you're using SERIN 5.
"Hello" is 5 bytes, but serData is only one byte. You need to make that an array big enough to hold the incoming data in (serData VAR [5]) and then take a look at the STR formatter.
[I don't have PBASIC Help with me, right now, but make sure that you're using the baudmode for 8N1 True.]