Serial Communication from master to slave....

Greetings and Salutations,

I am a hobby experienced programmer, and I am told that is is possible to do serial communication between 2 or more Arduino's, using the hardware method, external of the Arduino.
Would this be a wise move to experiment with? Is it even possible with serial comm's between them, coordinating actions sent out by the master, with only an acknowledge signal that the slave got the message as sent? All I would need is a return signal, acknowledging the data was transferred successfully.
I was wondering if it would be possible for other purposes, leading to AI learning, between the controllers.

Does this sound like a viable place to start? I do not have to have the slaves execute anything other than the monitoring software, looking for the ID code of the slave to be recognized, and there would only be one function for the slave, and that is execute the contained code after the slave acknowledges the date was received, then returning to monitor the serial com line, for another command selection from the master.
In shorter words, it is looking for it's ID code to be transmitted, and when it see's it, it executes the code it has on board. This way, the master can send out multliple codes per cycle, on the same command line. This will not need high speed signals, so timing shouldn't be an issue.

I was thinking, hardware minimal from the master.74hct595, or a 74LS595, as a receiver from the master in serial, changing it to parallel output, running it through simple comparative hardware(8 bit), then use that output, and a DIP switch selecting the 8 bit binary code, which allows each slave to have unique addresses, to execute its commands, and send a signal back saying it is completed. One byte acknowledge, or better yet, pull one single line, briefly low, after program completes it executed code, and wait for the next request to be received....etc...

Is this a good possible way to achieve my experiment? I am open for comment, and any questions you may have.

What say you, Arduino Kings? Can you help me out a bit?

Thank you, and have a cracker jack of a day!!

using the hardware method, external of the Arduino.

I'm not quite sure what you mean by that.

Is it even possible with serial comm's between them, coordinating actions sent out by the master, with only an acknowledge signal that the slave got the message as sent? All I would need is a return signal, acknowledging the data was transferred successfully.

Yes.

I do not have to have the slaves execute anything other than the monitoring software, looking for the ID code of the slave to be recognized, and there would only be one function for the slave, and that is execute the contained code after the slave acknowledges the date was received, then returning to monitor the serial com line, for another command selection from the master.
In shorter words, it is looking for it's ID code to be transmitted, and when it see's it, it executes the code it has on board. This way, the master can send out multliple codes per cycle, on the same command line. This will not need high speed signals, so timing shouldn't be an issue.

You might want to consider that the slave might be busy and should return a NAK if it's still busy with the previous request.

I was thinking, hardware minimal from the master.74hct595, or a 74LS595, as a receiver from the master in serial, changing it to parallel output, running it through simple comparative hardware(8 bit), then use that output, and a DIP switch selecting the 8 bit binary code, which allows each slave to have unique addresses, to execute its commands, and send a signal back saying it is completed. One byte acknowledge,

For the ID recognisition, don't use 74HCT/74LS devices; they are basically not compatible with CMOS. Use 74HC devices.
Not sure why you want to use shift registers (unless you need to save on pins); you can connect the dip-switch directly to the pins of an Arduino. The comparison can be done in software.

or better yet, pull one single line, briefly low, after program completes it executed code, and wait for the next request to be received....etc...

I would not pull it low briefly; keep it low while the slave is busy processing so the master knows not to send anything. Disadvantage is that you need an input per slave.

====

Consider the use of RS485; it's designed for single master / multiple slaves.

It's a nice exercise for AI; but standard Arduinos are very slow so you possibly need a million of them :wink:

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

The examples will obviously work if the HardwareSerial connections (plus GND) are connected between the two Arduinos. However you would need to disconnect from Rx and Tx when uploading to an Uno or Nano so using SoftwareSerial to create an extra serial connection would be useful. It also means that you can use the standard Serial connection for debug messages to the PC. A Mega has 3 spare HardwareSerial ports so it would be a better choice if you want serial communication between Arduinos.

…R

Hello, everyone!

I want to remain clear with my ideas. I don't like to get in a hurry, so that I can explain my idea much better, without leaving too much out when doing so.

I have a diagram, in pdf format. I am not sure, and I am still looking at where I can, or IF I can upload it so you can look at it.
I do see the need for the slaves to respond with a byte of data, where each bit shows that it,(the slave), followed the command and show the response/status from the slave.

Example:

When transmitting data, it is a DIP selectable address that when the proper 8 bit code is received, and compared to the byte received, it sends a single signal output to the other Arduino, allowing it to run it program, upon completion, will send a one byte output, serially to the master, or command Arduino, acknowledging the result of the operation. A FEW of these bits in the byte, will be used to tell the master, what LED’s to light, or turn off on the control panel, show a number on display, so that the Master knows the status of the slave. Speed isn’t an issue. Accuracy should be tight, and is important.
So, I will assume I need to use a software serial communication because of the simplicity of this method, would make the best choice. I will delve in to that option, as it looks like the best way to work it, and keep it as simple as possible, without compromising properly operating.
Please let me know what and how I upload this PDF file, so you can see my block diagram of this experiment.

Thanks for your help!!! It is appreciated!!

"Please let me know what and how I upload this PDF file, so you can see my block diagram of this experiment."

Use the "reply"n option and at the bottom right is the option to add attachments.

AHHH! I see, said the blind man…
Thank you!! I have it attached.

This is a rough diagram, but, I hope it will show my project idea in a bitmore data and detail.

Thanks!!

SERIAL COM BLOCK DIAGRAM.pdf (14.1 KB)

Phandangle:
When transmitting data, it is a DIP selectable address that when the proper 8 bit code is received, and compared to the byte received, it sends a single signal output to the other Arduino

Using the code I mentioned in Reply #3 I am implementing a system very like that to control a model railway. The Master (a Mega) sends a message to the slave boards (using Atmega 328s on stripboard). Each slave board has a few jumpers that are used to set its address (A to H) and if the message is not addressed to a slave it ignores it. If it is addressed to the slave it immediately responds to the master to confirm that it has received the message. All the slave boards have identical hardware and software.

...R

It will be much easier for everyone if you post your diagram as a JPG or PNG image as you can then display it in your Post. See this Simple Image Posting Guide

From a quick look a your PDF, there is no need for a clock signal with serial data.

...R

Indeed I saw that, Robin, and thank you. I will convert to a jpg, and upload it soon!

I just want to be sure I follow the path that makes it successful, and you are actually right on, about the dispatch panel, so that I can have 1 master panel, and I already have a signal system, using Arduino’s 'en masse'. I have already built the signals, and wrote the software, and they WORK!! JUST like to real ones do! Now, I am working on making it a bit easier to run the system, without having to be at every control O.S.
Obviously, you are a Rail fan, and I am also. Thank you. Do you mind if I pick your mind every now and then? I will be using the Atmega Chips, not Arduino boards. I use them for research and design.

I cannot see why this wouldn't work. I see you feel the same. Each signal has its own controller. in a roundabout sort of way. All it needs is a command signal telling it to read the forward block status, the rear block, traffic direction for THAT rail line,(EB or WB).
The only thing I want to return, is a byte, that tells the master to set the signal LED's or reset them, because the signal was cleared, and then knocked down. The master needs to control the panel, with a small byte giving it the complete information to set the proper LED's.
I have used a single ATTiny85, as a Servo controller for each crossover, and multi-crossover Controlled points
On my layout, I use servos for point control, and small micro switches, to tell the master that the switch is in the proper position, and then it sets the proper signal. I want to be able to have the byte sent back in acknowledgement, and the resulting actions that happen as it is knocked down. OS Detector Status, traffic direction,(Left bound/Right bound). Next block and rear block status, and display data for the dispatch operator.
I will have no need to use a programming interface, because they will be preprogrammed for operations.

I hope that make it clearer. I was told by a fellow railroader to be careful talking about Model Railroads here, so they said to be a bit cryptic. I just didn’t want to upset anyone’s apple cart, and not get any help, because someone doesn’t have an open mind on what is a hobby, or a toy. I can say mine are very expensive trains, and are not toys…. DCC is also an option to be interfaced with, and I have a simple plan for that too.

Thanks again, and PLEASE feel free to give me any advice anytime. I really do appreciate your clairvoyance, and straight forward attitude…. It is refreshing….

Phandangle...

I was considering using software serial coms. That’s why I had the clock signal. I am open to other means, but, I have my fears for using the serial interface, for such a simple transmission. Speed is not of paramount need, but, it would so fast, you wouldn’t know or see any difference.

Here is the jpg. I hope I sized it right…

P

AND.... I was thinking of making the communications synchronous, because of using software serial use.

P

Phandangle:
I was considering using software serial coms. That’s why I had the clock signal.

SoftwareSerial is fully compatible with HardwareSerial and does not need a clock signal. The only “problem” with SoftwareSerial is that it only works at low baud rates - 9600 definitely, 38400 maybe.

The only thing I want to return, is a byte, that tells the master to set the signal LED’s or reset them, because the signal was cleared, and then knocked down. The master needs to control the panel, with a small byte giving it the complete information to set the proper LED’s.

All bytes are the same size :slight_smile:

IMHO, while using each bit in a byte to provide different information is technically efficient it can make programs difficult to debug. My preference is to send human readable data (i.e. characters) unless the performance actually requires the use of binary data.

…R

Hmmm.... 9600 baud would be just fine as a speed. This isn't going to be something we need to worry about high speed. By the time you lift your finger off the code button, it will have completed the operation, and only one code button will be pushed at a time, setting the route.

I am sure you know reason for the 8-bit option, is so that it can read the status of the Control point, and reset the signal LED, and Associated LED's on the track block plan. The Master has to reset the LED's for the SWITCH, when knocking down a signal, and status of the OS block, so as to know when it is blocked/occupied.

These are the dispatch panel display being set by the master, after the status is read from the slave C.P.(control point)

SWITCH "N", SET/CLEAR LEFT BOUND, SET/CLEAR RIGHT BOUND LED's, along with the RED LED, when the signal is knocked down, as the consist enters the OS. BLOCK OCCUPANCY DETECTORS ARE PROCESSED THROUGH A DIFFERENT CONTROLLER, ALREADY DEVELOPED AND RUNNING ON MY SIGNAL SYSTEM DEVELOPMENT. Shoot, sorry about the caps, it stuck and I didn't notice it... lol!!! My block detectors have several outputs(O.C.), to drive a train tracking option, where it will show the location of the train in the block, as it passes over, and through each individual occupancy detector. They can also be used to trigger grade crossing signals, and other track side accessories you may want to. I made them Open collector, so it could sink LED current, if the user wanted to go that direction too.

I have my concerns, but, I think that those will be minimal, after the hardware is hooked up, and some experimental test code is examined, and tested. These tested and proven program bl sections, can be added to the main sketch one at a time, and then tested each step through. I am just trying to organize my brain, so as to take it slow, and start out with simple, commented code, and test it and see. I'm in no hurry. I am still in the track sub base installation, so it will be a while before I am ready to have anything operational. Although, I am going to build a test track, so that everything can be tested upon reaching the final phase of the experiment.

It would be the same format for each control point to send as status, but, it should probably send 2 bytes, first for Control point ID, then the status byte. This will give me all I need to finish making the prototype setup and test bed. I am just going to have to learn more about the coding for command and status, so it works together. I am sure there is a way to do it.

The idea you mentioned about sending a character, instead of the headache of bit selection and usage is correct. it is a pain to do, but, I'd rather limit that option.

I used to do things similar when I was working at Cat, had machining systems, that were all controlled by the master computer CNC. Now, I know it is a bit different, but, it is the same method that I would try to implement. This is my goal.

I will certainly need more questions answered when I start it up. So, I really appreciate the fact that you know where my destination is with this project.

I Look forward to your response. Have a great FRIDAY!!! lol!!! Boy, I am glad every day is Friday for me!!!

P

For the future ...

There is a lot of stuff in your Reply #12 that I don't understand because I am not familiar with your model train system. When writing your next Reply please keep in mind that we only know what you tell us so you need to give a lot more detail if we are to understand the ideas in terms of their implementation in Arduino code. Also, I am not very familiar with North American railroad jargon.

Examples of the messages that you are planning to send and what they mean would also help.

...R

Thanks, Robin. I am happy to put together some diagrams and picture/drawings. I may not get back to you until tomorrow, or late tonight.

You make a great point!

P

Hey Robin, check out the attched PDF file. It will give you and example of what is being implemented, to make the model system operate like the prototype. I have already developed the software, and tested it, and it works. I was just going to implement a bit more a little more of a way to save on hardware, and clutter. Besides, why not?? It would make running op sessions, a great deal more realistic!!

P.

Control Train Components - CTCPARTS.pdf (799 KB)

Phandangle:
Hey Robin, check out the attched PDF file

I'm sure you are a very nice guy but I don't fancy studying 26 pages of a PDF. Sorry. Call me lazy.

...R