Microcontroller question

Discussion in 'General Electronics Chat' started by entropy01, Apr 6, 2011.

  1. entropy01

    Thread Starter New Member

    Apr 6, 2011
    Please forgive the beginner nature of this question but...

    I am trying to conceptualize a project that involves two micro controllers communicating with each other serially. One micro is gathering data (buttons and such) and sending it along, the other micro is processing the data and occasionally sending it back.

    My trouble comes at the part where the micros have to know what is being communicated to them. I figure that this would be possible with a multi-byte packet, one byte including a reference to and instruction, and the rest of the bytes being the data associated with that instruction. But if this method is used, wouldn't the micro stop listening for further instructions so it can break off and process the data before a new one is received? Or are micros capable of multi-threading?

    Or am I thinking too high level and missing concepts of low level electronics...
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    The serial communication is quite slow compared to the MCU instruction speed. And the MCU UART itself is an autonome unit. It does not need any attention from the MCU core to send/receive data. It will also be double buffered (input/output). So you do not have to read in the moment a byte is received, in order to receive the next. You can also set up the MCU to generate interrupts on UART events. Hence you can avoid polling the UART all the time. However depending on the program. This may be the result
    Last edited: Apr 6, 2011
  3. entropy01

    Thread Starter New Member

    Apr 6, 2011
    I see, where would I find how many chocolates can be on the belt at one time?
  4. debjit625

    Well-Known Member

    Apr 17, 2010
    May be you can use something like I2C protocol,make one mcu as master and another slave.

    Good luck
  5. entropy01

    Thread Starter New Member

    Apr 6, 2011
    Actually I was planning on switching over to 485 once I get it working as I will be adding more nodes. I'm trying to develop a message queue format and handle the interactions between a node and the central MCU.
  6. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    I did something similar many years ago using addressed devices over a differential line. I created a packetized format with address recognition. I then went on to other things, and years latter dove into USB, where upon I realized that much of the format had similar aspects.

    Moral of the story, pick a protocol that exists within your physical transmission needs, and adopt it's format. You'll have definative guidelines to help reduce the ' how should I', and you'll have potential oppportunity to employ devices/concepts already proven.
  7. HallMark


    Apr 3, 2011
    Yes, RS- 485 is very good option and reliable for long distance communication.