Open Source MULTIUART Project, Add more UART Serial Ports to your projects


if you're fan of electronics me find annoying on lack of hardware serial ports on modern devices. many modules wifi esp8266 , bluetooth hc-06 available peanuts each require uart based serial peripheral on controller work effectively. in fact huge range of external electronics can added system via serial uart connection: gps, gsm (mobile phone), rfid, rs232, lin, ethernet, zigbee, modbus, dmx, 4d systems graphical lcds name few more.

most modern microcontrollers , devices raspberry pi have @ least 1 serial uart peripheral can lot these devices. , need combine several communications style modules single design. recent project undertook mobile alarm system used bluetooth proximity arm / disarm system, gps track location, accelerometer track movement , gsm based sms messages inform owner item is.

the arduino mega 2560 offers 4 serial uart peripherals if not enough or need more affordable mass production. move different chip may mean rewriting entire code there easier way?

these modern microcontrollers commonly feature peripheral named spi typically lot faster uart based serial peripheral , can used talk multiple devices use of individual chip select signals controller. if controller not have spi peripheral can driven using bit banged software approach using standard i/o pins no major downfalls. using spi interface , design can communicate 4 serial uart peripherals simultaneously.

here open source project create spi 4 uart bridge code name multiuart or spi2uart.
instructables - spi-to-4-x-uart-bridge-multiuart

i have created arduino library drive hardware.
github - multiuart


included in library test program created test multiuart boards using arduino uno , transmitting data pc using serial library.


if you're interested small number of boards available on sale on ebay.

many , enjoy!

so, that's 16-bit pic on board, acting peripheral 8-bit avr?  alrighty then.

quote
if  your  you're  fan...
fixt.

quote
the arduino mega 2560 offers  two  four  serial uart peripherals
fixt.

quote
i have created arduino library
you should find way leverage stream class (which leverages print class).  i suggest grouping class contains array of 4 instances derived stream.  those instances used code or library expects stream (or print)class.  current hardwareserial usage:

code: [select]
class multiuart;

class multiuartport : public stream
{
    uint8_t    id;
    multiuart *group;
    friend class multiuart;

  public:
    // serial port controls
    begin( uint32_t baud ... );
         ...

    // override pure virtual methods of print , stream...
    virtual size_t write( uint8_t c ) { group->transmitbyte( id, c ); return 1; }
    virtual int available() { return group->checkrx( id ); }
         ...
};

class multiuart
{
    multiuartport port[4];
  public:

    multiuart()
      {
        for (uint8_t i=0; i<num_ports; i++) {
          port[i].id = i;
          port.group = this;
        }
      }

    multiuartport& operator []( uint8_t ) { return port[i]; }
      ...
};

multiuart mu;

void setup()
{
  serial.begin( 9600 );
  mu[0].begin( 9600 );
}

void loop()
{
  if (mu[0].available())
    serial.write( mu[0].read() );
}

you should find way rid of 50us delays.  above loop delay 250us each character.  limit baud rate 38400.

i recommend using spi transactions avoid conflicts other spi devices, , perhaps concurrent transfers (reading , writing 1 transaction).

cheers,
/dev


Arduino Forum > Development > Other Software Development > Open Source MULTIUART Project, Add more UART Serial Ports to your projects


arduino

Comments

Popular posts from this blog

Help with Missing Filename Error?

more info - Joomla! Forum - community, help and support

Using phone battery to power a plane.