How many is max numbers of serial IMU (serial Protocol using Tx, Rx 3.3V ,Gnd for each sensor) sensors can be connected to Ardiuno Mega 2560? I know that there is only 4 serial ports but is there any idea to conntect up to six serial sensor to it?
you can use SoftwareSerial, just check on which pins it works on Mega. and you have to switch between multiple SoftwareSerials with the listen() function
Using any software serial can be something you regret, using it twice more than doubles your chances of that. I believe there are hardware serial port expanders but I don't know anything about them. Another option might be to use two Megas with three sensors on each. One of those might be a ProMega sharing a shield with some terminal blocks etc. The Mega Pro is 15 pins wide, so I doubt it would fit on all Mega proto boards, but an adapted standard perf board should be fine.
If you take that path, it looks like you might be better off powering the plain Mega off the Pro, as I believe the latter has more sophisticated regulators etc.
I would think that that depends on the sensors which you did not mention. If there is a command/reply protocol involved, you can use multiplexers.
- Select a sensor on multiplexer.
- Send command
- Get reply
- Back to (1)
As i remember It works only on the same pins as Hardware Serial ports. That is, the Softserial does not increase the number of ports on the Mega, it supported only for compatibility.
I want to use serial IMU sensors ( serial Protocol using Tx, Rx 3.3V ,Gnd for each sensor) , Also, do the multiplexers permit to read 6 serial imu sensors at the same time? @sterretje
You remember incorrectly; if that was true, it would be totally useless to have SoftwareSerial.
No. With 4 hardware serial ports each has its own internal software buffer that's filled using interrupts which feels like it's running in parallel. With the multiplexer, you will share one port.
Hi @m-a-m
Using SoftwareSerial on the Mega is by far the easiest option and the path of least resistance.
The Arduino Due also officially has 4 hardware serial ports, but actually has a 5th one as well.
The only other boards that I can think of that can possibly (at a glance) meet your requirement for 6 serial ports, is something either like Adafruit's Grand Central M4, but it's currently difficult to find due to the current chip shortage:
or perhaps PJRC's Teensy 4.1/4.0: Teensy® 4.1
Not all pins on the Mega and Mega 2560 boards support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69)
It is simply not practical to do so.
Tell us what you really want to do, i.e. the Big Picture. Serial UART sensors are often a poor choice.
I am using the IMU sensor which Razor firmware is installed on it and which is connected serialy to Mega 2560 to measure the acceleration but I need 6 IMU sensors to attach it on the same structure but in different locations and I need the sensors readings in same time..
The readings that I have got from one serial IMU sensoris very good..
No, you don't. In fact, it is not even possible, because it takes time to collect each individual sample, one at a time, and you are sending the data elsewhere, which also takes time.
Time stamp each sensor reading and use post processing to analyze the data.
The problem is that I need the responses at the same time.. Each response has a specific meaning..
Bummer.
Indeed, you seem to have put yourself in a very difficult situation. It is time to sit down and actually think the project through.
Since the Arduino can do only one thing at a time:
How long does it take to collect and analyze one sample of data?
How often do you need to do that?
How many different samples need to be collected "at the same time"?
Define the actual meaning of "at the same time". Would six samples collected during 1 second be considered "at the same time"?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.