Final 3D model with TVS diodes added. This is not the most Advanced Hat, but it enables me to use a Raspberry PI With long wiring and motors in the network without too much worries.
I used a little trick on the 3-port Galvanic RSX as I connect to ground through the ground layer on layer 0. If you look at the area marked in green this is part of the ground, but the EDA don’t warn me that this is an iceland isolated from actual ground. I added a connection (in yellow circle) to fix the issue.
Just a reminder that an EDA is only a tool. It might contain snags so it’s up to yourself to actually check what it is doing.
I made a 5 port (3 port RS485 and 2 port CAN) earlier that is great, but I want a version that is galvanic isolated for solutions that require wiring around a house or more hash environments. ADM2582E is a “All-In-One” package for this, so using 3 of these I get a 3-port RS485 will full isolation. This will cost ca 15.- USD more than the plain one due to the more expensive isolation chips, but those bucks are worth it.
The 3D model above is a bit premature, but it gives you an idea of how the Hat will look like. I have also included a snip of the PCB to illustrate the galvanic isolation.
I have not connected the 3 ports to the MCU yet as I basically wanted to see if I could achieve 3 ports with proper spacing. I am actually quite happy with the result. The 4 red areas are ground. As we have isolation it means that each port have it’s own isolated ground completely separate.
Reviewing the design for a home automation system I realise that a PLC rack is not optional as a control system centre. The reason is that we will mainly be interested in central node processing and communication – we will not be interested in more classic PLC controls. Also we need these centrals to be small and hidden. I am thinking more the style of a flat packed PCB card with RS-485 ports, Wifi, GSM/3G/4G and Ethernet in a flat package with battery backup.
The diagram above illustrate the concept. We mount as many distributed centre’s as we need. These communicate with each other using secure Ethernet (wired of wireless) and control their own subnet of actuators and sensors. As these are small and can be hidden they will be easier to integrate into existing homes. Power can be various distributed mains and battery packages.
This an old picture of my universal adapter that basically can be used as is except that it lack GSM option + I would like to have an option to Connect Raspberry PI (3 or Zero W).
One major issue is how to identify units in a network. I used STM32F030F4 on these and I absolutely love this little MCU costing 50 cent in TSSOP20 package, but it lack the serial number that is burned into other STM32 MCU’s. This serial number is crucial as it present a factory set ID allowing me to just plug in sensors expecting them to identify themselves. STM32F042F6 solves this, but cost ca 2.- USD from the sources I use, so I am very tempted to use STM32F103C8 or CB and create a larger PCB so it becomes single sided. The later actually lower cost in production – but, lets see where we land as I update the modules.
I designed this universal motor controller capable on driving DC-, Stepper-, BLDC- and even AC – motors earlier. The design parameters was 12-24V at 15A. This is quite a capable controller, but I did a mistake that limit the controller to 12-20V since I connected the Gate Drivers to the Motor PSU directly. To compensate for this I need to modify the design and implement a separate 12V PSU. As I correct this I also want to consider some additional changes.
I am considering is to replace the RS485 with an isolated RS485 due to the amount of energy involved. The 3rd change is Ethernet on a separate adapter board. Basically I want to copy the modules I use on the Universal Adapter as soon as I have tested them.
I am not sure about Ethernet. Ethernet sound nice due to the functionality, but it is a clumsy, 4-wire 1:1 solution. RS485 is slower, but it is a 2-wire network. It actually makes more sense having dual RS485 to be honest. CAN & Ethernet is easier to deal with using an adapter board- RS485 is considered a lower level of communication than CAN because CAN have protocols like CANopen, J1939 etc. The reality is that if we use RS-X that changes.
What I probably should do at some point is to create a “Ethernet” on top of RS-X by using a dual RS-X connection. But, that is fun for later…
So the modified design will be
- STM32F405RG MCU, 168Mhz, 32bit M4, 1MbFlash, 192KbSRAM
- 4 x separate half bridge drivers, 30V @15A
- Current sensors on all
- BEMF sensors
- PSU Voltage Sensor
- Separate 3.3V supercap to sustain MCU in power dips.
- 3 x hall sensors
- 2 x temperature sensors.
- 1 x resolver
- 2 x end sensors
- 1-2 x RS485
- Adapter board for battery/caps
- Adapter board for CAN/Ethernet/Wifi
- Solenoid driver
- DC Motor driver
- Stepper Motor Driver
- Brushless 3-Phase motor driver
I have worked far to long with 19″ cabinets and things you mount from front, so what I am thinking is a micro-version of a rack system. We box each electronic module with a backbone plug and custom front connectors. We then plug them in, wire using standard wiring (that we probably have to create) in front – no wiring in the back.
These boxes are simple and can easily be printed on a 3D printer. They will also allow us to mount more electronics tighter to address the total size.
A classic PLC uses 2 wires for a 24V pulse signal – we can typically standardize these so that we apply standard, plug & play cables and avoid as much custom wiring as possible. The top front is after all for wiring to equipment, not for internal wiring that is already done in the back-plane. I think this can work, but I need to talk it through with professional automation engineers – luckily I have access to them in numbers.
One drawback I can see straight away is vibration. I was planning to make this so small that it could fit mobile Equipment, but mobile Equipment vibrate a lot. We will need an outer box and holding mechanism that tolerate very high vibration – or more correctly reduce vibration.
PLC (Programmable Logic Controllers) have been around for years. It usually is a modular system of electronic boxes with IO capabilities that can be assembled into a system for automation purposes. PLC have 5 “standard” languages that are not really that much standard. The standards tend to serve as minimum list of features, but as the vendors add much proprietary stuff the PLC applications end up being very proprietary. Plain have a much higher possibility of actually being portable.
A PLC system cost a lot of money, but as making custom electronics and writing code in C/C++ cost more the vendors get away with high pricing on electronics, tools and HMI. Also – the hard fact is that it is not much I can do with a professional PLC that I can’t do better, faster and with less cost using Arduino or Raspberry PI these days.
I have briefly mentioned HMI – I will return to that later. But, my Raspberry PI Hat’s and RS-X modules powered by Plain is an excellent PLC substitute. I do however fancy a more dedicated, modular system that can compete with classic PLC in a smaller space. My Hat’s are great, but it’s limited what I can create on the size of a Hat + the Raspberry PI is often not needed. I want to keep the option to add a RPI module with a Hat, but I want a new system.
Using Ethernet as backbone I would like to create a motherboard that control 4 x IO modules. Using RS-X as bus allows me to use the modules stand-alone or plugged them into a assembled system. Adding more motherboards I can scale up with 4+4+4+ modules as much as I have space. I believe I can do this on very small Space.
The major restriction I have on the Hat’s is connector space. I want to use standard connectors with standard cabling to avoid the need for custom cabling as much as possible. My “PLC” language will obviously be Plain.
What needs to be different from what I have done so far is Galvanic Isolation on all communication to limit the chain reaction if something backfires – because it will!
The added work-load on coding does not worry me because we can re-use things that I am in the process of creating anyway + I think this will be fun. 10 x 10 cm comes to mind as a size factor. It is easy to create modules that are 5 x 10, 10 x 5 or 10 x 10 to be mounted as part of the same system so it gives us freedom. It is also easy to create a 10×10 carrier module for Raspberry PI so a RPI+ Hat’s can become a module. But, I will look for standard, low cost project boxes before I decide on size.
It will be fun if nothing else and thats why I am here in the first place, so lets crack on with an open source, home made, low cost PLC system. My home is an excellent testing ground – assuming it don’t burn to the ground in the process 🙂
This board uses a LQFP48 because I needed more pins and it extended the size to 50 x 15 mm to get everything in. It contains 2 x Stepper Motor Drivers and 2 x end point connections. This can operate 2 x 5-wire or 4-wire stepper motors. I have not decided on MCU yet. I used STM32F103CB on the schematics, but I know that STM32F303Cx can be used and I will check if the same is the case for the M0 series in LQFP48 package. All of these MCU’s are an overkill for what we do here.
I target 28BYJ-48 or similar stepper motors that can operate on < 0.5A current. Having two steppers rather than one is because it often is required to operate two steppers in parallel. I use two ULN2003 drivers mounted back to back on each side, meaning I have 6 spare PWM signals and plenty of spare pins on the MCU. I only need to expand the PCB Space for Connectors to have a full 3-axis driver. This is just an early draft where I focused on size only, so will see where I go next.
The beauty with the RS-X based micro modules is that you can just add on modules by connecting them to the network and locate them as an extension of cabling on the robot or in your house etc. We still need a more intelligent unit like a Raspberry PI in centre, but it expands our scalability to easily build more complex systems.