Category Archives: Raspberry PI Hat’s

Open PLC System

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 🙂

Raspberry PI Hat’s

I have so far designed 3 Hat’s that I have produced, and a few others in draft versions. Looking at my older picktures I seem to have uploaded 3D models, but not so many Pictures of the actual Boards – probably lost some Pictures on the old blog – I will fix that.

This is just a summary.

32 x Servo/IO

16 x Servo/IO in stacked position

STM32F105RB or STM32F103RB

Raspberry PI 2/3 + Zero

I also planned a GPIO Hat, but froze the plan because this is capable of being used for that purpose.

The 3D model is the updated Version that I have not ordered yet. The difference is mechanical changes and added protection Logic.

8 x Dc Motor + 8 x IO (end stop)

STM32F105RB or STM32F103RB

Raspberry PI 2/3 + Zero

I received the PCB’s some time ago, but have not assembled it yet. Think I finally have received all parts.

 

 

5 port Com Hat

3 x RS485

2 x CAN HS

STM32F105RB only

I have uploaded Pictures of this hat assembled, but they are on the old blog system. Build two Versions of this Board and need to do a revision due to minor mechanical issues.

I have shown 3D models of other Hat’s that still are work in progress – including some for Zero. I initially froze the Zero Hat’s because my full size Hat’s can also be used for Zero. With the new Zero W it actually is more attractive to use Zero for Wifi connection, so I might update some of my old Zero designs.

I have loads of design ideas I would like to work on, but I am a bit short of time.

32 x Servo/IO Hat

32xIOHat

New 3D model showing the right angle connectors and the updated “Servo” that now is renamed to 32 x IO Hat. I have done some mechanical changes and added a lot of protection electronics. As mentioned earlier this is my test ground for the VM and each channel have multiple capabilities – hence the “IO” rather than Servo.

  • 32 channel Servo Controller
  • 32 channel digital in
  • 32 channel digital out
  • 32 channel low resolution PWM
  • 2 channel analogue out
  • 12 channel analogue in
  • or any combination of the above

I have three Hat’s that will stack nicely

  • 16/32 channel IO (shown here)
  • 8x H-Bridge + 8 x IO
  • 5 port RS-485/CAN

I do in addition have the 7 x Stepper, but I am not happy with the connectors on that one. The 28BYJ-48 stepper motors comes with a 5-pin connector that is nice and exist as right-angle, but I can only manage 3 of these in stacked position – To be honest I am considering ditching this Hat design.

As we move forward I will add more hat’s and more distributed sensors and controllers to allow larger and more complex systems to be created. I want to create a few robots + I want to automate my home for the fun of it. But, all of this is worthless without an easier way to apply Distributed logic so I will continue to dig into the PLAIN concept for now.

32xServo Hat Revision 1.1

32xservehat_1_1Not very exiting, but it has taken me most of the day. This is the revision 1.1 of the 32xServo Hat. Just for the record – the red lanes are actually ground plane so it will all be covered with GND – I just switched it off for the picture.

  • Added optional TVS diode on PSU for better protection.
  • Added 100uF and 100nF capacitor on PSU for spike cutting.
  • Adjusted pin header positions to better fit 3×4 headers.
  • Adjusted the lower 16 channels as they where a bit close to the bottom edge.
  • Added TVS on all 32 channels for protection of the MCU.
  • Changed all LED’s to 0603 package.
  • Added weak pull-up on nRESET.

32xservehat_1_13d

The lower 16 channels can use 3×4 right angle connectors allowing the Hat to be used in a stack. I finally found a good price on 3×4 right angle down to ca 10 cent each – still looking. You can still use classic 2.54 Pitch pin headers that is even cheaper.

Revision 1.0 is actually ok to go, so I will try putting this into production & sales since a lot of people have asked for it. It will be exiting to see what assembly prices I can achieve. PCB & Components are probably ca 10.- USD all together.

32 x Servo Controller Logic

servo_arduino_style

The illustration above shows ruffly how servo logic will come out if you bit bang directly. Some of the Arduino libraries does this. As each servo uses up to 50ms on a pulse you can in theory service 20 servos in a second. The limitation here is that you bit-bang one channel at the time in sequence.

servo_basicpi_style

This second illustration shows how we want it to be with all 32 servos operating in parallel. This way we have a much higher capacity and avoid latency between servo operations.

To achieve this we need to use a table with 32 channels and accurate timing for then we switch on, length of pulse and then we switch off. Switching off is an issue because we need to do it with some accuracy. Our RTOS is perfect for this type of jobs and will achieve 0.1 ms accuracy without any problem.

The 32 x Servo Hat uses 32 pins that can be used for multiple purposes.

  1. Servo
  2. Digital output
  3. Digital input
  4. Analogue input
  5. Analogue output

The servo interface is (1) signal pin, (2) Voltage pin and (3) Ground pin.

As the user set a servo value in Raspberry PI using the easyIPC libraries that value is transferred to the 32 x Servo hat, the value is inserted into the 32 channel entry and the pulse will be corrected to represent the new value. The total time latency should be very low, but up to 100ms from a value is set in RPI and the output is corrected must be expected. I will return on actual latency timing later.

Stepper Hat

rpistepperhat

This is the first draft of a 7 x Stepper Motor Hat. It target uni- or bi-polar steppers up to 500mA per phase like the 28BYJ-48. It also have 7 x end-point connectors. Using the ULN2003 as driver it also provide generic PWM and digital ports that can be used as such. The PSU is external and can be up to 50V. The MCU is powered separately from RPI.

32 x Servo hat

rpi-32xservo-hat

This Hat takes advantage of the many pins on a LQPF64 to output a 32 channel servo Hat. 32 channels is a bit of an overkill for most, but the channels can be used for output, digital input and some for analogue input as well. A separate PSU connector for the servo’s must be provided.

The only drawback with this board is that it needs to be on top of a stack due to the Connectors. This was designed some time ago, but I have been holding these Boards back a bit.