I an electrical engineer for high current and high voltage, but my passion and hoby is electronics.
At my work i maintenance machines, computers, …
When they have a problem at one specific machine and when they call me to find and fix the problem, i immidiately get a headache. The machine (whole production line) is still working on STEP5 siemens plc.
I can access to progam, but when problem appear lets say because of some broken wire in some moving part of machine, the error is to quick for visulisation to show it, but machine stops without any alarm, and then you dont know what is first, the chicken or egg.
I have an idea to make a table with machine tloris drawings, and i will put the led diodes to the place of sensor, switches, actuators, motors…. But there is the problem. I have 20 sensors here, another 20 sensors 20 meters away, and so on.
My idea is to connect those 20 sensors to 4N25 (or simmilar, because of 24V machine operating voltage) and all the signals to maybe MAX7219 to arduino.
Together there will be maybe 5 arduinos and each arduino will have around 20 sensors.
LED pano will have another master arduino and 100 or more leds connected to it. I think the easyest way to connect 100 or more leds to signle arduino would be to buy leds with build in chip with i2c communication.
Question 1: What would be the best way to connect 20, 30, .. sensors to one arduino?
Question 2: Is there posibility to somehow connect 24V sensors, without using 4N25 optocoupler?
Question 2: Can i connect 5 arduinot to 1 via WIFI moduls?
Robi26:
Question 1: What would be the best way to connect 20, 30, .. sensors to one Arduino?
Some would say - use a Mega 2560.
I don't find them terribly attractive, though the enhanced version looks more interesting.
I suggest using expanders:
I have another reason for recommending these, as below.
Robi26:
Question 2: Is there possibility to somehow connect 24V sensors, without using 4N25 optocoupler?
Not really, because they will be connected to different pieces of equipment which likely will not share the same ground connection.
Robi26:
Question 2: Can i connect 5 Arduino to 1 via WIFI modules?
Once you refer to WiFi, it is best to drop the conventional Arduino altogether and use an ESP8266 such as the WeMOS D1 Mini. This does all your processing as well as the WiFi connection.
And when you use this with the expanders I cited, you have as much I/O as you want. No need for a Mega.
If you have one per piece of equipment, you may not need the opto-isolators. And note - 4N25s are obsolete.
But I will not guarantee how well WiFi will work in the industrial environment. And it must not ever be used for any purpose safety-related. (OH&S)
Robi26:
Why WeMOS? I see it has much higher frequency and build in WiFi. Is there any other difference which is more good for this project?
That is the difference. The ESP8266 is your WiFi platform in one neat and compact module, like a smaller version of the Nano which is the Arduino version you use for practical projects such as you cite. I consider the UNO the "toy" or "demonstrator" version.
Now the WeMOS D1 Mini has a reasonable number of available I/O pins, and it has an on-board regulator for the 3.3 V; you power it from a 5 V supply. And it has the USB interface.
If you only ever wanted 4 I/O pins and provide a regulator, the tiny ESP-01 will suffice - I use them with the little USB adapter board which again includes a regulator and tends to make the total cost similar to the D1 Mini.
The point is - the ESP8266 is the complete processor; it is not an add-on to an Arduino. You can use the same expansion modules you might with an Arduino to achieve the necessary result. When you program it, you combine the I/O stuff with the WiFi stuff.
Robi26:
Do you have any suggestion what to use for ger 5 or 3V signals from 24V if not 4N25?
As long as you are certain the grounds are the same in any given area, you can use simple resistive voltage dividers to drop a 24 V level to 3.3 V (or 5 V). It is when the grounds are different that you need the opto-couplers. Later version have better performance than the 4N25 and you can get four opto-couplers in one pack.
No component values or IC part numbers.
You don't wire up an opto isolator like that.
Are those sensors digital or analogue? Opto isolators like that only work with digital signals.
To optically isolate and analogue gignal you need a dual output isolator and an op amp.
Robi26:
I already started to design circuit board. I will post updates after I receive PCB and other material from eBay.
You refer to "designing" a PCB but you do not have a working and fully tested circuit yet. What PCB are you getting from eBay? Are you going to etch it yourself?
A resistor between the 5 V supply and ground is going to do nothing at all useful
For 24 V, figuring on 5 mA to the opto-coupler, a 4k7 resistor in series would be appropriate (dissipates about 120 mW). The CTR minimum of 50% means you expect the output transistor to switch at least 2.5 mA. You connect the opto-coupler output transistors collector to Arduino inputs, emitter to ground and use pinMode of INPUT_PULLUP to provide a pull-up of about 100 µA. This works just fine but the opto-couplers should be mounted on the same PCB as the Arduino.
Ah! Wait - you are using a PCF8575! No problem; it has inherent (i.e., it is already there you do not need to do anything to enable it) pull-up functionality virtually identical (100 µA) to the INPUT_PULLUP on the Arduino so exactly the same thing applies. Collector to PCF8575, emitter to ground, opto-couplers mounted adjacent to the PCF8575.
What is the "optional resistor, for some other project" about?
I already ordered few two sided boards from china for other projects. I tried to etch myself, with uv foil and with toner transfer, but the results ar 90% good.
You do not show anything in your receive side of the opto isolator and what ever it is you can't affect the signal going to PCF8575 input because you have connected it to 5V.
Do you think you are really at the stage of getting a PCB made?
I made another drawing for explain better the situation (attached photo).
I will connect arduino to the wires which go to siemens plc inputs/outputs. There is 24V level. Betwean arduino and siemens i want to put optocoupler, for not to disturb the plc. As Paul_B say, resistor 4,7k will be ok in optocoupler input side to get 5mA.
Since PCF8575 have internal pull-up on inputs, do i need to put resistors on every input or not? Maybe 10kOhm to GND?
You appear to have not grasped the concept of pull-ups and pull-downs.
The opto-coupler collector connects to the PCF8575, the opto-coupler emitter connects to the PCF8575 ground, no other component is required. The opto-couplers will be mounted adjacent to the PCF8575 to minimise the length of these connections.