Shop OBEX P1 Docs P2 Docs Learn Events
communication with other microprocessors — Parallax Forums

communication with other microprocessors

qiuqiuaaaqiuqiuaaa Posts: 37
edited 2012-03-26 02:06 in BASIC Stamp
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

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-03-14 20:25
    To transfer the data from the "Arcuino" to the Stamp, connect "D1" to a Stamp pin set up for SERIN using a "True" baudmode. Hedge your bets with a 1K resistor (between D1 and SERIN pin of choice.) Don't forget to connect the grounds together. They should be configured to send/receive using the same baud rate.
    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.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-03-16 20:09
    q,
    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.
  • qiuqiuaaaqiuqiuaaa Posts: 37
    edited 2012-03-18 18:39
    Thank you! I am still working on the program of Arduino. If I have any progress I will tell you.
    PJ Allen wrote: »
    q,
    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.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-03-19 17:38
    OK
    I have something that I worked out.
    If you get stuck, shout out and we can compare notes.
  • qiuqiuaaaqiuqiuaaa Posts: 37
    edited 2012-03-20 19:18
    I found that the serial pin(Sout and Sin) had been connected to USB port, because I use "Board of Education". How do I use these pins...? maybe a stupid question ...
    PJ Allen wrote: »
    To transfer the data from the "Arcuino" to the Stamp, connect "D1" to a Stamp pin set up for SERIN using a "True" baudmode. Hedge your bets with a 1K resistor (between D1 and SERIN pin of choice.) Don't forget to connect the grounds together. They should be configured to send/receive using the same baud rate.
    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-03-20 19:43
    It's not a stupid question.

    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.
  • qiuqiuaaaqiuqiuaaa Posts: 37
    edited 2012-03-21 21:40
    Thank you so much! It seems to be hard for me, since they still can not communicate with each other. I need more work
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-03-22 05:46
    How about posting what you have so far?
    And then we could have a meaningful conversation.
  • qiuqiuaaaqiuqiuaaa Posts: 37
    edited 2012-03-22 22:43
    ' {$STAMP BS2px}
    ' {$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 )
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-03-23 05:40
    qiuqiuaaa wrote: »
    ' {$STAMP BS2px}
    ' {$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.]
  • qiuqiuaaaqiuqiuaaa Posts: 37
    edited 2012-03-26 02:06
    Thank you so much. That's really funny... I changed 5 to 1, and it works ( at least it can receive something). I will study to transfer the useful imformation.
Sign In or Register to comment.