I have the following system:
As a master, I have an Arduino UNO Chip, more specifically an Atmel MEGA328P. The important thing is that this microcontroller has only one hardware Serial port, and that port is used to communicate with a WiFi adapter.
The problem I'm facing with is that I want to receive data from a Compass and a GPS modules. Booth send data via Serial protocol. The 328p Chip have only one serial which is busy!
I can't use SoftwareSerial as I don't want any delay on master board! I can't also use Arduino Mega2560 which have 3 Serial ports as its sizes are too big.
So there are are my approaches:
- Using MCP4725 I2C DAC for Compass, but what we do with GPS?
- Using and intermediate Arduino UNO Chip? On that chip I could use Software serial but how to transfer data to MASTER using only digital and analogic pins? Maybe using 10 pins to implement a parallel transfer?
- Perhaps there is possible to convert Compass and GPS data to analogic then transfer to MASTER?
Anyway, what possibilities would I have to play around?
-
1That was a lot of design restrictions. You might want to look at an I2C/SPI to UART bridge; nxp.com/products/interface-and-connectivity/…Mikael Patel– Mikael Patel2016年08月11日 10:53:07 +00:00Commented Aug 11, 2016 at 10:53
-
Maybe you should consider stepping away from Arduino boards and exploring the plethora of more capable boards that are out there - most of which can be programmed with the Arduino IDE using the Arduino API.Majenko– Majenko2016年08月11日 11:06:26 +00:00Commented Aug 11, 2016 at 11:06
-
You chose the wrong part. Lots of ARM Cortex parts have 3 UARTs, some of them have Arduino ports.Chris Stratton– Chris Stratton2016年08月11日 13:29:52 +00:00Commented Aug 11, 2016 at 13:29
-
@ChrisStratton Only 3? I'm used to working with chips that have 6 UARTs... ;)Majenko– Majenko2016年08月11日 15:49:00 +00:00Commented Aug 11, 2016 at 15:49
-
1@Majenko : Can you guys provide some links please? It would be very usefully :)caffeine– caffeine2016年08月13日 13:36:06 +00:00Commented Aug 13, 2016 at 13:36
2 Answers 2
This answer summarizes the possibilities:
1) HardwareSerial
is always best. You are using that for WiFi.
2) AltSoftSerial
is the best software serial library, but it requires pins 8 & 9. Very efficient and non-blocking! Strongly recommended for the GPS connection.
3) NeoSWSerial
is next best, but it supports only 9600, 19200 and 38400. It is non-blocking on receive, so it could be used for the GPS connection.
4) SoftwareSerial
is the worst. :P Not suitable for the GPS connection, as you have discovered.
I'll also mention my GPS library, NeoGPS. It is smaller and faster than other libraries, and there are examples that show how to make it run during the RX character interrupt, saving even more time. It can also be configured for just the messages and fields that you actually use, saving RAM, program space and execution time.
I think softserials are working based pinchange interrupt. This wont make you any significant delay i hop.Or you should go gps or wifi modules with SPI or IIC interface.
-
SoftwareSerial uses PCINT to start reception. During reception it blocks all other operations. That causes significant delays, especially at lower baud rates.Majenko– Majenko2016年08月11日 11:14:43 +00:00Commented Aug 11, 2016 at 11:14