Dear All,
I have a device which has only 1 I/Os and 1 Rx/Tx (Serial). I am thinking to use Arduino to expand this device I/Os and Rx/Tx. Anyone did this before?
I search for information online but mostly are talking about how to expand I/Os of Arduino. I am trying to look for information on expanding external device I/Os using Arduino.
Attached is a block diagram of my idea.
If you have information on how to do this, please share the link.
Based on your reply, it seems like it can be done.
May I know any reference for the codes so that arduino can process the data from External Devices and forward the data to the Rx/Tx to Device on the left?
Dear PaulRB,
Thanks for the link but it is not helpful. Is my information provided not clear?
I have drawn out the diagram in the attachment. I think it would be quite clear what is the XY problem I would like to ask.
For IOs
I am thinking to use Arduino to process the data from IOs external devices. Arduino process the data and send it back to the main device on the left.
For Rx/Tx
I am also thinking to use Arduino to process data from external devices and Arduino send the data back to main device using the Rx/Tx line.
The aim is to expand the Device on the left 1 IOs to 8 IOs and 1 Rx/Tx to 3 Rx/Tx.
No your requirements are not clear at all. You are failing to explain them in anything that amounts to sufficient detaile for anything but an arm waving explanation.
You do not say what processing you need to do.
I/O expansion is simple there are many chips that will do that, and many more articles telling you how to use them but you seem to think they do not apply to want you want to do. Why is this? Explain please.
Serial ports are much more difficult because they require more complex chips and most of them come only in surface mount packages which are hard for a beginner to manage. The also contain FIFO buffers ( look it up ) and you need to know how long a FIFO you need for your application.
What is the device in the left and how is it going to indicate to the Arduino what expanded I/O it should use?
Why do you think you need a device on the right at all?
Dear Grumpy_Mike,
Thanks for the reply. Sorry for not writing out the details:
Detail as follows:
For IOs
I am thinking to use Arduino to process the data from IOs external devices. Arduino process the data and send it back to the main device on the left. We will be connecting to digital sensors like door sensors etc.
For Rx/Tx
I am also thinking to use Arduino to process data from external devices and Arduino send the data back to main device using the Rx/Tx line. We will be connecting this to weighing sensors, RFID etc.
We want to do so because we are thinking to let the Arduino to process the data.
Example:
Data from Door Sensor will arrive at Arduino then Arduino will send it to the IO of main device. If there are multiple sensors, Arduino need to do the sending timing and also how to identify what data belongs to which sensors and send them properly to IO of main device (on the left)
For Rx/Tx, we are thinking to do the same thing. Dat from weighing sensors/RFID, will go into Arduino and Arduino will do the data identification (For example: Weighing sensor data start with 10, RFID data start will 01 and so on) and send it properly to the Rx/Tx of main device (on the left).
This way, we could use only 1 IO and 1 Rx/Tx from main device and can use Arduino to connect to a lot of external devices.
Thanks but you have not answered how the device on the left signals to the Arduino what I/O it wants to use. I am assuming you have some control over the program for the device on the left.
"May I know any reference for the codes so that arduino can process the data from External Devices and forward the data to the Rx/Tx to Device on the left?"
Sounds like you need to develop a protocol that both sides will understand.
"1. Data from Door Sensor will arrive at Arduino then Arduino will send it to the IO of main device. If there are multiple sensors, Arduino need to do the sending timing and also how to identify what data belongs to which sensors and send them properly to IO of main device (on the left)"
That could be the start. Perhaps the message the Arduino sends is a shortened version of:
"Pin #, state (high or low), time" sent whenever the door sensor is opened (high detected on the pin) or closed (low detected).
Similar for the other sensors. Maybe add a 4th part to indicate the sensor type, and the sensor types could have different quantities of bytes sent with them. Maybe 4 bytes for a weight if a float value is to be used.
CrossRoads:
"May I know any reference for the codes so that arduino can process the data from External Devices and forward the data to the Rx/Tx to Device on the left?"
Sounds like you need to develop a protocol that both sides will understand.
"1. Data from Door Sensor will arrive at Arduino then Arduino will send it to the IO of main device. If there are multiple sensors, Arduino need to do the sending timing and also how to identify what data belongs to which sensors and send them properly to IO of main device (on the left)"
That could be the start. Perhaps the message the Arduino sends is a shortened version of:
"Pin #, state (high or low), time" sent whenever the door sensor is opened (high detected on the pin) or closed (low detected).
Similar for the other sensors. Maybe add a 4th part to indicate the sensor type, and the sensor types could have different quantities of bytes sent with them. Maybe 4 bytes for a weight if a float value is to be used.
Dear CrossRoads,
Thanks a lot for your explanation. Do you know any websites/forum topics I can refer to to write a simple protocol for testing?
Dear Grumpy_Mike,
We have control over the device on the left. The device it self have 1 I/O which is connected to SOS button which will pull down to ground when pressed.
Now we are planning to expand this I/O so that it can be connected to more external devices such as door sensor, sos button, light sensors and so on.
We have control over the device on the left. The device it self have 1 I/O which is connected to SOS button which will pull down to ground when pressed.
OK thanks that makes things more clear.
So there is no need for anything for the device on the right. All that can be done with the Arduino if you pick the right one. You could use a Mega or one of the Teensy range of boards, but these is no need to expand the outputs. These two boards have more than one serial port and lots of I/O
Grumpy_Mike:
OK thanks that makes things more clear.
So there is no need for anything for the device on the right. All that can be done with the Arduino if you pick the right one. You could use a Mega or one of the Teensy range of boards, but these is no need to expand the outputs. These two boards have more than one serial port and lots of I/O
Dear Grumpy_Mike,
Ok thanks. If I am using Arduino Mega2560, it has a lot of IOs and 4 Rx/Tx. So, all I need to do is to connect like the block diagram and the need to write some timing protocol for device on the left and Arduino to communicate properly right?
Appreciate if you could share some info on howto write the protocol.
Not sure about timing. I would use the serial port to do all the communicating. You would send it commands structured in a specific way or protocol.
One common approach is to send the data in packets. A packet consists of a start byte followed by how many bytes are in the package, then the bytes and finally a end of package byte. This is suited to ASCII / text messages so the start and end bytes can be unprintable characters.
The packets could say / mean send this message to serial port 3, or set output 6 to the logic state of the input pin.
For an example look at the Firmata system that does the same sort of thing. The code is in the IDE.
Grumpy_Mike:
Not sure about timing. I would use the serial port to do all the communicating. You would send it commands structured in a specific way or protocol.
One common approach is to send the data in packets. A packet consists of a start byte followed by how many bytes are in the package, then the bytes and finally a end of package byte. This is suited to ASCII / text messages so the start and end bytes can be unprintable characters.
The packets could say / mean send this message to serial port 3, or set output 6 to the logic state of the input pin.
For an example look at the Firmata system that does the same sort of thing. The code is in the IDE.
Dear Grumpy_Mike,
Thanks for the information. I will look at the Firmata system to find out more. Thanks a lot.