Which should be the perfect protocol and why?

Guys,
I need to develop a project where there will be multiple subsystems. I recently found initializing GSM is a bit time consuming as it needs to be registered and bla bla bla... No issues. Thus say GSM will be under a sub-section independently operated. But as it will receive SMS and also may initiate SMS and also may need to call/receive calls, it I planned to communicate with a master device. Basically there will be a CPU (m2560) that will control 3 to 4 subsections. GSM is one, and other will be for display (yes, as there will be TFT for only display, not for command, and let a processor handle it, as it will receive string, WHAT TO BE PRINTED OUT.) And the same way, there will be a motor controller with sensors for motor controlling job.

So, all of them will get command from the CPU and start tasking individually. And will report to the CPU their staatus. CPU will then send the data to display or stop if necessary. Like Motor is asked to be turned ON and while motor is turning ON (say not at full RPM) but SMS came to shut off and hence CPU will also notify the motor controller to shut off.

Now, I can see in here all of them as master and slave in nature. And they all can communicate randomly. In a scenerio, there must be handshaking and hence I'm a bit confused, which approach should I take. Any ideas?? Also pleasee say your reasonings.

Thanks in advance...
Mishu~

A CAN bus might be a solution.

So there must be one master in your proposal? Some slaves are write-only (display) but most will have data to give to the master when requested?

How far apart are these devices? I2C works for short distances up to 1m or so. SPI can work pretty well up to a few meters. RS232 works up to 100m but only if within the same building. RS485 can go kilometers.

These days, wireless radios are cheaper than buying 10m of cable. Have you considered one of the mesh network radios such as the NRF24 or Xbee?

MorganS:
So there must be one master in your proposal? Some slaves are write-only (display) but most will have data to give to the master when requested?

How far apart are these devices? I2C works for short distances up to 1m or so. SPI can work pretty well up to a few meters. RS232 works up to 100m but only if within the same building. RS485 can go kilometers.

These days, wireless radios are cheaper than buying 10m of cable. Have you considered one of the mesh network radios such as the NRF24 or Xbee?

It will be within the board or max, a board beside. Basically there will be a large Motherboard with different subsections.

as said, there will be actually kinda multi master. Consider the following:

A separate configuration window (CLI/GUI) will be used to config the system (aka main CPU). Like allowed mobile number, etc. This will also make the master decisions and notify the subsystems about it. Thus this CPU will hold all the configuration of the whole system.

Each subsystem (like GSM controller) will be independent (like if GSM momdule is bootup, or no power, then the subsystem controller will issue bootup. Hence subsystem controller will send it's master (parent/CPU) the notification that GSM is down (so master will not issue any SMS outgoing if any). Once GSM module is registered and ready to operate, the subsystem controller will notify the CPU that GSM is ready. Hence GSM part will be dealt by the main program afterwards.

Now, if a SMS comes, GSM controller will send the SMS to main CPU in a formatted way so the content and sender info can be stripped. And if it is allowed from config, then main CPU will issue next order to the another subsystem say Motor controller. And that subsystem will independently work and report back on status to main CPU.

See, thus it's like a multi master type (in my eyes). Consider it like a multi task and each task has a different sub controller.

No way for wireless. All will be in board or max, board to board.

ard_newbie:
A CAN bus might be a solution.

I was thinking of the same but the thing is, consider it like a inter motherboard with bios, RAM, bla bla bla... I mean several subsystem will make a interconnected network inside the board. So hardware design is an issue also here.

Also, I cant rely on all the available sheilds as the device have to be really robust. My last experience with shields is worse than ever...

Ideas????

aq_mishu:
See, thus it's like a multi master type (in my eyes). Consider it like a multi task and each task has a different sub controller.

People often come to the Forum with a concept in their head that is far more complex than it needs to be - usually because there is insufficient definition of what actually needs to be done.

I don't immediately see why the scope outlined in your Original Post can't be handled by a single Arduino Mega.

On the other hand you say

consider it like a inter motherboard with bios, RAM, bla bla bla... I mean several subsystem will make a interconnected network inside the board.

and that makes me wonder if what you really need is a RaspberryPi or a cheap laptop.

"Motherboard". "bios" and "RAM" (in that context) are not what an Arduino is intended for.

...R

NO NO... RAM was just for an analogy.

Like a system, that needs to be run independently using the subsystem.

As said, the main arduino CPU I want to be free from extra codes and to be more busy with processing, not on graphics display. But as I need graphics display, a separate m2560 as a gpu can handle that easily.

the same way, gsm module needs some time to init and also some time to finish other tasks. Like deleting a sms for sim800c takes 5 sec as per the reference manual. I dont want to keep it waiting for 5 sec untill finish. Send the command of delete SMS to controller subsection and keep going, as subsection will do that and will notify to main CPU.

Multitasking Simultaneously is a need here. I know RPi can do that... even a panel PC (as it mus be stable and RPi is good ony if your SD card is good) can do that. But for pricing issues, i have selected arduino and also for stability.

Again saying, RAM and etc is just as an analogy. Basically there will be a seperate subsystems to do the works independently. One is display (like i2c displays, and probably i will actually use that). Other one is SD card via SPI. These 2 are one way... always slave. But for GSM and also for motor controlling issues, there needs both way communication and they MUST run independently with decisions from main CPU.

The brigadier will pass order and make calls, but battalion commanders will work independently based on the wish of the brigadier.

aq_mishu:
Again saying, RAM and etc is just as an analogy.

This just reinforces my suspicion that if you write down exactly what you really want to do (no analogies, and no brigadiers) you will find that it is very much simpler than what is currently in your head.

But for pricing issues, i have selected arduino and also for stability.

Unless you plan to make these things in commercial quantities the value of the extra time taken to implement it on an Arduino (or, especially on multiple Arduinos) will far out weigh any small saving in hardware cost.

The biggest risk to stability will be your program, whatever platform you use.

...R

hahahahaahah

OK, basically I wanted the GSM to be fully independent, because that's how i can leave the delay(5000) away from the main CPU.

Next, display is just for fancy branding issue... so let it be separate from main CPU again...

Motor controlling can be done with main CPU though there will be lots of sensors.

I have been thinking to go like this:

Display via i2c [sub system]
SD card writing of log entries via SPI [under direct main CPU]
Ethernet (if any) will be by SPI [under direct main CPU]
GSM will be either Serial (hardware or software that is the question) or any other method including i2c [sub system]
Motor to be controlled via main CPU.

What you guys say??

(The purpose is to let the CPU to focus on events instantly ASAP instead of getting blockd by the delay(xxx) ffor that GSM.

Mishu~

and I forgot, there will be an RTC too, but i2c and will be slave only. [except the time setting as init]

aq_mishu:
OK, basically I wanted the GSM to be fully independent, because that's how i can leave the delay(5000) away from the main CPU.

Why would you use delay(5000) ?

You can manage timing without blocking using millis() as illustrated in Several Things at a Time

Edit to insert the correct link above. The following link was wrong - sorry for any confusion (senior moment :wink: )
Serial Input Basics

...R

the startup process of GSM is full of delay i found... and later too...

ok, so are you telling me to use the smartdelay()?? I'm not sure... need to study more on feasibility.

aq_mishu:
ok, so are you telling me to use the smartdelay()?? I'm not sure... need to study more on feasibility.

Humble apologies. I included the wrong link in Reply #9. I have now corrected it.

I don't know what you mean by smartdelay() but it will probably be irrelevant when you study the correct link.

...R

Imagine what happens if the main CPU sends a command to the GSM one during that delay(5000). It can't respond or even take a note of what was said so that it can do it later.

You have to design the system to work without delays. So you can do all of that on one Arduino and it will be much simpler than trying to get five to talk to each other.

MorganS:
Imagine what happens if the main CPU sends a command to the GSM one during that delay(5000). It can't respond or even take a note of what was said so that it can do it later.

You have to design the system to work without delays. So you can do all of that on one Arduino and it will be much simpler than trying to get five to talk to each other.

Right!!That delay(5000) [for example] will cause the whole thing to clog and it will eventually the biggest pitfall.

I think It's rather going to the other way, as you and others said... and also else I will require a ACK mechanism after each command sent and that means still the same multitasking and then what's wrong to use the single one??

Now,
from the link Demonstration code for several things at the same time - Project Guidance - Arduino Forum

The millis() have a limit... overflow... what will happen after that?? I mean as my device will run for a long long time and eventually millis() will get an overflow. any ideas??

Mishu~

It starts again from zero. If you do the arithmetic properly then it is no issue at all.

Use unsigned long and subtract times to get an interval. Look for Nick Gammon's tutorial on millis.

aq_mishu:
what will happen after that??

In the example code you will see that all the time tests use subtraction and if you do that the maths works correctly even when the millis() overflows - one of the nice quirks of integer maths.

...R