Hello everyone,

While many of us are working on the OpenPLC-NEO design, I'm working in parallel on a much simpler design that I want to release first, with the purpose of attracting more hackers to our community. I've seen that many OpenPLC users use the Raspberry Pi board, which is a cheap alternative for automation. However, the RPi itself lacks some important features to be considered a real PLC. First, it is has low-voltage I/Os (3v3) which are not isolated. Second, it does not have any analog inputs or outputs.

Therefore, my idea with this device is to create a base board that has industrial-level protected I/O, including analogs, for the Raspberry Pi Zero, which is the cheapest Raspberry Pi available ($5 in most places). The board will also add Ethernet, which RPi Zero lacks, using the ENC28J60. More details here:

I'm going to provide a modified Raspbian image that will have OpenPLC built-in, so that all you have to do is to download the image to your SD card and you're good to go. If you want to participate in this project, please let me know. I'm in the early stages of creating the schematics, and I'm using Kicad, to keep everything open source as usual.
Quote 0 0
@thiagoralves are you thinking of using this Ethernet module or to use the ENC28J60 chip and build the Ethernet interface.
I think that will be better. we will have more room to go around and fit analog in / out on board + 485 chip. 
Nice idea to provide an image with everything ready out of the box.
Quote 0 0
I'm initially thinking on using the bare-bone chip and build the Ethernet interface on the board. It would be much easier to just attach the module, but I'm concerned about part availability. If the manufacturer of the module decides to change pinout or any tiny little detail about it, the board is doomed. I'm not planning on adding 485 to this board. It will be a simple home automation device with fixed number of inputs and outputs.
Quote 0 0
485 chip will enable us to plug the module directly on I/O modules. If you do not want to be on same type of our I/O box we can make it flat dinrail mounted and plug it into  OPENPLC I/O modules. On top of what is your plan it will be nice addition to have.
Quote 0 0
Expansion (by 485 or any other means) requires major changes in OpenPLC software for it to be user friendly. I want to provide a low cost board based on the RPi Zero with little or no modifications to the current software.

The expansion-enabled PLC device that we will make is the OpenPLC-NEO. If I make OpenPLC-Zero expansible as well, there will be no difference between the two, apart from the fact that one will be driven by a RPi Zero module, and the other will be driven by an H3 quad-core CPU. OpenPLC-Zero is supposed to be a cheap, entry point device.
Quote 0 0
@thiagoralves I think that you should not discard the idea of future expansion.
If there is at least a means to connect an external rs485 interface you can
at least change your mind any time later on. Even if you do not want build
software that is expandable at this moment. Since this is planned as an open
source design, it may be somebody other than you builds this software at a
later time. Or somebody uses the hardware without using openPLC. For example
OpenHAB supports either ModBus TCP or Serial Slaves. While the user could use
ModBus TCP for expansion it would probably more costly to do so. If you do not
want the interface in the BOM for cost reasons make it at least an assembly
option if there is space on the board. Copper is cheap.

Regarding providing a SD-Card image based on stock a raspbian i have some
reservations. I have some experience as a user with PIs used as controller
in machines. If your machine is susceptible to power failures or the user
can simply switch it off at will, you are bound to get a trashed SD-Card
if this happens during a write to the SD-Card. There are modifications
to raspbian that treat the SD-Card as read only that do not have this problem.
But this would also mean that you can not have persistence in such a system
if you do not add additional memory. If you plan to add a RTC chip to the
design you could use one that has some spare memory or use a small I2C flash
for this.

Generally i would say if you do not plan to include such things in the standard
configuration it would be nice if at least the user had an easy upgrade path.
Soldering some unpopulated parts onto a board could be done by almost everyone
that wants it really hard. I have seen enough almost good designs on the net that
missed only some small feature and forced the user to kludge something together
that would only have needed some copper in unused parts of the board. Mostly
the imagination of the developer is different than that of the user.
Quote 0 0
I totally agree with @LeissKG. In every word. Raspberry is very popular device. It is beyound imagination what momentum can give the NEO OPENPLC project.
@Theogoralves you said:
"If I make OpenPLC-Zero expansible as well, there will be no difference between the two, apart from the fact that one will be driven by a RPi Zero module, and the other will be driven by an H3 quad-core CPU. OpenPLC-Zero is supposed to be a cheap, entry point device"
So what? We are building the first one (zero) easily and inexpensive (in human resources, time  and money) fully attached to our PLCNEO bus, in DINrail, in the same box, the community will start doing projects (a lot!) and on top of that we are building the NEO CPU. Take ABB for instance. They have many CPUS
If you are wiling not to follow that direction (Raspberry zero 485 interface with our I/O bus) I think that I have little to offer in that discussion.
Do not see Raspberry zero as a "competitor" to your NEO CPU. Think that the first will make the world to know the second.
You have a grate mind and you accomplished beautiful things with your OPENPLC issue.
Follow the road to success. That is the power of people in open community. And we people love and trust the Raspberry thing to connect with NEO I/O modules
Quote 0 0
@thiagoralves i have some questions about the planned hardware. Do you plan to
make the analog IO isolated? If yes you could use an isolated I2C interface for
this. The drawback would be that you would have to have a isolated power supply
for this. Another question is are you planning for the same form factor as the
OpenPLC Neo or are you planning to use some purchasable standard case
Quote 0 0
I'm planning to make it simple, like just wiring up a PCF8591 on the Pi's I2C bus, which has 4-channel analog in and 1-channel analog out. Obviously this chip works with low voltages, so I might add some circuitry to amplify the range to 0-10V which is very common in industry. Do you have any suggestions in mind?

About the case, I don't plan to make it fit on the NEO's case. I might just ask Petri to design a square case for it. I'm designing it to be just a single board with the connectors on the edges, so a square casing with DIN rail mounting on the back should be a good start. However, when I make it available for selling, the case will be optional, so that users that just want the PCB can buy it with the lowest cost.
Quote 0 0
@thiagoralves if you want to make the input compatible to the 10V industry
standard you will need an additional supply voltage that is higher than 10V.
You could use the 24V rail for this but i would prefer some voltage that
is derived from this rail but cleaner for the analog circuitry. A small
linear regulator like an 7812 should be sufficient.
A non isolated I2C is a viable solution, but i have reservations to the PCF8591.
I did not have the best experience with it. It has a fairly low input impedance
and is VERY susceptible to latch up and it has only 8 Bit resolution. The low
input impedance can be handled with an input buffer like an LM358 in an TSSOP
case. This takes not much place on the board. I would prefer something like an
ADS1015 for the AD part and an DAC7574 for the DA part. Both together would not
need much more space than the single PCF8591 in a wide body SO16 case. And
this would give you 4 inputs and 4 outputs with 12 Bit resolution. With two
of each you had the necessary circuitry of an 8 Bit analog module.
Quote 0 0
@thiagoralves i do not know how my writing comes across to you but let me
make something clear since i fear i might sound like i want you to take a
certain way to your project.
This project is your project. I have no problem with you ignoring anything
i write. If i or another person wants features that you did not have
implemented we will have to do it ourselves. At least the project will be
done in an open source PCB design software and most of the work will be
already done.
An 8-bit analog subsystem is still more than other cheap RPI PLCs have at
the moment. The same is true for future expandability over RS485. All
what i wrote about are features that would be nice to have, but in the
end you do the work, and so you determine the feature set of this PLC.
So if you want to use the PCF8591 do it, but be warned if for some reasons
your input becomes slightly outside of your power supply range the chip is
toast. The classic diode clamping circuit that one sees often on the
Internet is often missing the second current limiting resistor after the
clamping diodes. You need something like Figure 1 on this web site.
Quote 0 0
@LeissKG, your input, as the input of all the users on this forum, is extremely valuable to me. As you said, in the end it is always up to me to decide which features I'll add based on my expertise and free time, because for now I'm still the only developer in the project. I don't have much experience with analog circuits, so it kinda pushes me to do the simplest things, just to have something done. I'm thinking about having just a resistor divide circuit to divide the 0-10V input into something like 0-3.3V for the PCF8591. For the analog output I will have to have an op amp to amplify the output to 0-10V. Do you have any sample circuits to help me with that?
Quote 0 0
thiagoralves wrote:

I don't have much experience with analog circuits, so it kinda pushes me to do the simplest things,
just to have something done.

Today i'm more a digital guy rather than analog, but i think i can still manage simple circuits.
thiagoralves wrote:

I'm thinking about having just a resistor divide circuit to divide the 0-10V input into something
like 0-3.3V for the PCF8591.

While a simple resistor divider would work, you would get unpredictable errors caused by the ADC
input resistance. If i remember right the input resistance of the PCF8591 varied between 30K and 50K
which would be parallel to the lower leg of the resistor divider. A voltage follower between divider
and ADC would fix this. But you will still need the input protection circuit since the one the PCF8591
has is only sufficient if you limit the input current enough. This would led to a measurement error.
Any op-amp that works with a single supply works for this. If you want to use the 24V for this the LM358
has 2 op-amps in one case and works up to 32V. IF you use the TSSOP or VSSOp case the required space is
quite small.
A simple 1:3 voltage divider (e.g. 20K + 10K) followed by this buffer should work. This will create a
slightly over voltage near 10V but should not trip the input protection circuit.
thiagoralves wrote:

For the analog output I will have to have an op amp to amplify the output to 0-10V. Do you have any
sample circuits to help me with that?

Here i would use a simple non-inverting amplifier with a 3:1 amplification.
R2=20K and R1=10K would generate a voltage between 0 and slightly under 10V which should be
good enough. This all assumes that you have a 3.3V reference for the PCF8591.

Now to an unrelated question. I do not know if you have already received the files
for the PiXtend V2 from Qube Solutions. If yes, can you say how long it
will approximately take to integrate them into OpenPLC? I have recently
bought this board and would like to use OpenPLC for a small project.
Quote 0 0