Category Archives: extension board

RasPiCommPlus PLC – Automation

PLC Programming GUI

PLC Programming GUI

This is a very short but also very exciting blogpost about our recent work on the RasPiCommPlus.

We just integrated the iec2c compiler by matiec to the RasPiCommPlus. What it does is pretty amazing: It compiles ST (structured text) or IL code (both IEC 61131-3 compliant) used for PLC programming to C code, which we compile and program to the ARM processor. Voila, you now have a real PLC running independently of the Raspberry Pi (you can disconnect the Pi and the PLC keeps running). But we also developed a Linux driver to read PLC variables and change the state of the PLC (start, stop) or read the cycle time.

You can also use Beremiz to generate the ST code if you prefer using the graphical ladder diagram for programming. Debugging with the Beremiz GUI is not yet possible but planned.

Currently, only digital I/Os are working, but we are working on integrating the serial devices too, so you can also send and receive data through the RS-232, RS-485 and the other modules.

The digital I/Os are still accessible through the Linux drivers, even when they are in use by the PLC. This might be different with the serial ports when implemented, but maybe we still use the drivers to monitor/debug serial communication when the module is occupied by the PLC. If the PLC does not use the serial module the kernel driver still works as expected.

We will introduce an option to the build.amesocn.com site to link in PLC code, but building locally on the Pi will also be possible. The driver source (also available through build.amescon.com) will then be combined with the PLC code, compiled and programmed directly from the Pi.

So in places where you used Siemens S7 PLCs or similar you now can use the RasPiCommPlus which is not only more flexible but also cheaper and with the new Raspberry Pi B 2 you have a powerful Linux machine capable of logging machine data to databases or running websites for monitoring or configuration (for example by using the RasPiCommPlus Web API)

RasPiComm+ finalized, Indiegogo campain preparation

It has been some time since the last post about the RasPiComm+, but be assured, we were very busy and have put huge efforts in finalizing the product and I can now proudly say that we are ready for production.

We are launching a Indiegogo campaign mid-November 2014, so please spread the word!

RPC+both sides

So here is an update and/or introduction for those who have not heard about the RasPiComm+ before.

The RasPiComm+ is an extension platform for the Raspberry Pi which offers an arbitrary combination of up to 4 modules. The huge difference to other extension boards out there is not only the flexibility of using exactly the modules you need but also that all modules come with full linux driver support. I’ll do separate posts showing that in detail, including videos.

 RPCP

Connection to the Raspberry Pi

You may have noticed that the header has 2×14 pins which is uncommon. That is easy to explain: The RasPiComm+ is backwards compatible to the Raspberry Pi B, but also supports the EEPROM functionality for the Raspberry Pi B+, so the inner 2 pins are unused on the B version. When you are using the B+ version, the EEPROM of the RasPiComm+ can be accessed from the Raspberry Pi.

So how does it work now?

You just plug in the modules you need (see below for available modules).

The easiest way to install the firmware and drivers is in online (the Raspberry Pi is connected to the Internet). Just run the script “./rpc+setup” and you’re done. You can now access serial devices via /dev/rttyRPC+0 to /dev/rttyRPC+3 depending on the  module slot. I/Os are mapped to /sys/class/gpio just like the GPIOs of the Raspberry Pi are. That means you can reuse software that access the GPIOs of the Raspberry Pi directly. Special interfaces which are not digital pins or serial devices (like for example analog inputs or displays) are mapped in files in the /proc/rpc+/module1-3 folders. See the documentation of your modules to see how to access the resources from the Raspberry Pi. In the next posts I will show you some examples on how to use various modules, from I/Os, serial ports, sending and receiving SMS messages to sending a bitmap to a Sharp Memory LCD.

What does the script do exactly?

  1. First, it checks if there is a base firmware on the RasPiComm+, if not it downloads and installs it
  2. Then it scans all 4 module slots and reads the EEPROM IDs to identify which modules are plugged in
  3. In the next step a request to our buildserver is made to request the firmware configuration for the ARM microcontroller and the CPLD
  4. The firmware is then built by our buildserver and the firmware package is downloaded, the files are stored in a local cache on your Raspberry Pi so you do not need to be online if you wish to reinstall the same configuration again
  5. The script programs the ARM and then the CPLD firmware
  6. Then the corresponding drivers are loaded
  7. Done. You can now access all modules from your Raspberry Pi

 RPCP Setup - New Page

Web Firmware configuratorbuildserver

You do not need to use the automated script. You can also select the modules manually and download the firmware. This also enables you to download the sourcecode for the firmware.

If you install the Unity 3d plugin (http://unity3d.com/webplayer) you can see a beautiful 3d visualization of your configuration.

We are currently also working on a case generator. When it is ready you can also auto-generate a STL file used by 3d printers with exactly the openings you need for your selected modules. You can then print it on your 3d printer or send the file to a company offering 3d printing as a service like www.shapeways.com

The modules

We already have QK0A0099quite some modules available for the start, and we are currently testing a lot more.

Modules available:

  • 8 Input (5-35V)
  • 8 Output (5-35V)
  • 8 Analog Input (12 bit)
  • 4 Relays
  • RS-485/RS-485-4 wire/RS-422
  • GPS
  • GSM
  • Profibus
  • Sharp Memory Display

Modules we work on:

  • 1-Wire
  • 16 Isolated I/Os (24V)
  • Stepper Motor
  • CAN
  • KNX
  • 6LoWPAN
  • 433MHz
  • 868MHz
  • 9-Axis MEMS (3 axis gyro, accelerometer and magnetometer)

Each module has an EEPROM to identify itself. The installer uses this to request the correct firmware. There is also user-space available on the EEPROM, you can store data like counter values if you want to.

More posts are coming. In the next one I’ll quickly show you some simple scenarios how to use modules and how easy it is to script functionality.

Another post will I’ll do more in-depth explanation on how the RasPiComm+ works internally and why we made certain design decisions.

After that I will do a post on how easy you can hack the RasPiComm+ and compile your own firmware code based on the boilerplate code, to run it standalone (without the Raspberry Pi) for example or do ultra-fast switching logic with the CPLD without CPU intervention or implement additional functionality on the ARM processor with the GNU C compiler.

RasPiComm+

Here is a quick update on the RasPiComm+ status. We are currently working hard on the Raspberry Pi drivers and hope to get the RasPiComm+ out there in Q3.

RasPiComm Plus

RasPiComm Plus mounted on Raspberry Pi with GSM and 16 isolated I/O extensions

The board itself is a 56x74mm 4-layer board, most components are mounted on the bottom. The top-side only features 4 edge-board connectors for the modules, power LEDs and two JTAG debugging/programming headers for the Cortex M3/M4F and the Altera MAX V CLPD.

We currently have 6 RasPiComm+ modules which we are testing:

RasPiComm+Extensions

CAN bus, RS-485, 8 inputs and 8 outputs RasPiComm+ extension boards

  • 8 Input (with adjustable reference voltage, can be jumpered to 5V or 24V or fed from outside)
  • 8 Outputs (5V or 24V or fed from outside)
  • GSM module
  • RS-485 (two RS-485 on one board)
  • CAN (two CAN bus ports on one board, you’ll need the ARM Cortex-M4 option to use both simultaneously)
  • 16 isolated I/O (using th iC Haus iC-JX)

The firmware of the Cortex M3/M4F (both can be populated) will provide a bridge from the extension boards to the Raspberry Pi and interface with the drivers. The ARM microcontroller can be programmed from the Raspberry Pi for power users. It will come with a fully functional firmware and does not need to be changed though. If you want do do realtime or high relieability stuff you can do this by programming the ARM microcontroller.

The CPLD is also programmable via the Raspberry Pi, so changing configurations for different extension modules is easy.

RasPiComm+ bottom side

RasPiComm+ bottom side

The big metal box on the bottom side is an isolated DC/DC converter. This will be optional and powers both the RasPiComm+ and the Raspberry Pi from a 24V power supply. The battery holder is for the real-time clock backup battery for which we will also add driver support, so that the Raspberry Pi can get the current date and time.

The driver is very elegant I think. You can dynamically load and unload driver modules and they create an interface (for example /dev/ttyRPC0) to the specified module in case the module is a serial module (this applies to the GSM, RS-485 and the CAN module). This is already working quite well, we successfully sent SMS messages from the Raspberry Pi.

For the I/O modules we are looking into a driver interface similar to the Raspberry Pi GPIOs, but this is still work in progress, if you have suggestions what the best way is to implement I/Os leave a message 🙂

I will post separate articles about the RPCP extension boards to explain them in detail.

And if you have any other ideas how to make the RasPiComm+ even better let me know!

RasPiComm API

The RasPiComm API is here!

Martin did all the hard work and now it’s online: https://github.com/amescon/raspicomm

Check out the readme.md for instructions on how to install and use it. There is also a Demo-Tool where you can test the basic functions of the board.

We also added a deamon which you can use to forward RS485 communication via TCP/IP. We used it to make an Andoid App to control a stepper motor. Videos will follow soon!

RasPiComm Update

RasPiComm v3

I want to give you a short update about the status of the RasPiComm project.

We already have ordered parts for the first production batch of 1.000 RasPiComms. We expect all parts to arrive in 4 weeks, so the RasPiComm will be available in approximately 6 weeks.

RS-Components!
We are also had a conversation with RS-Components. We are very confident that they will add the RasPiComm to their product lineup! So if everything works out the RasPiComm will be available worldwide!

Raspberry Pi with RasPiComm

Raspberry Pi with RasPiComm

The RasPiComm will most probably get a distinctive subsite on Designspark.

I made some changes to the final board, most of them are minor layout changes.

I2C
The pull-ups for the I2C were removed since they are already present on the Raspberry Pi. I still have to check how the I2C pull-ups are with the RasPi rev2.

ESD Protection
I also made an important change to the RS-232 and RS-485 ports. I added TVS-diodes for protection which is a massive improvement in terms of stability.

Here are the specs of the ESD-protection:

RS-232 port:

  • 300 watts peak pulse power (tp = 8/20µs)
  • ‹40 watts peak pulse power (tp = 10/1000µs)
  • ‹Transient protection for data and power lines to
    • IEC 61000-4-2 (ESD) ±15kV (air), ±8kV (contact)
    • IEC 61000-4-4 (EFT) 40A (5/50ns)
    • IEC 61000-4-5 (Lightning) 12A (1.2/50µs)

RS-485 port:

  • 400 watts peak pulse power (tp = 8/20µs)
  • ‹Transient protection for asymmetrical data lines to
    • IEC 61000-4-2 (ESD) ±15kV (air), ±8kV (contact)
    • IEC 61000-4-4 (EFT) 40A (5/50ns)
    • IEC 61000-4-5 (Lightning) 12A (8/20µs)

RasPiComm v3 almost ready

RasPiComm v3 missing headers

RasPiComm v3 missing headers

I assembled RasPiComm v3 and it all works. This should be the design for production. Sadly the new connectors for the RS-485 and RS-232 ports still need 2 (!) more weeks to deliver, I ordered them 2 weeks ago. I only have the 2-pin pluggable power header yet, and only one half (the pluggable screw-terminal also takes another 2 weeks). So the picture to the right is still missing the pluggable headers, but you get the idea of the new design.

I had to make room for the new (big) pluggable headers, so the outputs are now on 2mm pitch headers (not polulated). SPI and input are also 2mm pitch headers and also not polulated. If you need the inputs, outputs or SPI you just need to solder the headers. I think most useres wont need them, and if you do it is easy to retrofit.

I2C Header

RasPiComm OLED

Raspberry Pi with RasPiComm OLED

I changed the I2C header from through-hole to SMD, simply because the battery holder is now below this header to avoid collision with the S2 header of the Raspberry Pi. This will probably be a male connector on the production board.

Production
I know, what you are really interested in is the availability. Well, I already got the quote for the first batch, way off my initial calculation, but they screwed up the material costs. They now have my BOM and I’m waiting for another quote. So I’m still on it and hoping that I can place the order in one or two weeks.

RasPiComm vs Gertboard

After the availability announcement of the Gertboard, a couple of days after my first post about the RasPiComm, questions arose on some blogs whether the RasPiComm is an alternative to the Gertboard or not.

So here is the answer: It is not!

The gertboard, especially the first YouTube video about it, has been around for a while. Gert van Loo is the father of this platform. These two boards have very few in common. The Gertboard is an easy-to-assemble board with a lot of features. It comes as a self-assembly kit, it is perfect for educational purposes. All you need is a soldering iron and a little bit of time and you can learn a lot and have fun!

The RasPiComm, as its name indicates, is specialized more on serial communication. It comes fully assembled, and it’s optimized for minimum space requirement. The highlight of the RasPiComm is its RS485 connector.  There are already lots of boards with relays, (stepper-)motor control and all the stuff you can imagine which can be connected via RS485. The advantage is that you can use long cables (only 2 wires needed) to control these boards (4000ft or 1200m are allowed with RS485!) and that you can connect up to 256 boards to the RasPiComm.

Here is a feature comparison chart:

Gertboard RasPiComm
Self-assembly kit assembled
Connected to RPi with flat-cable Piggyback board (no cable needed)
12x buffered I/O 5x unbuffered Inputs
3x push buttons 5x pushbuttons (4-way joystick with center-push)
6x open collector drivers (50V, 0.5A) 2x open collector drivers (5V, 0.2A)
48V, 4A motor controller
28-pin dual in line ATmega microcontroller
2-channel 8/10/12 bit Digital to Analogue converter
2-channel 10 bit Analogue to Digital converter
2-channel 8/10/12 bit Digital to Analogue converter
SPI connector to ATMega SPI connector to Raspberry Pi
I2C connector
Real-time clock (RTC)
RS-232
RS-485

I think the comparison chart shows pretty well that these two boards have totally different foci. So go ahead and buy both 🙂

RasPiComm v3

I want to give you a short update about the RasPiComm progress. You’ll find the schematics of v3 below.

I reworked the whole board and rerouted it all. I tried to implement as much feature requests as I could while preserving the footprint.

I also decided to start working on a RasPiComm Plus board. It will be bigger and better! But it will not play in the same league pricewise.

But first things first, here are the changes I made:

  • Moved the backup battery out of the way. Now it does not collide with the DSI (S2) plug on the Raspberry Pi.
  • 5V tolerant inputs
  • pluggable terminals for power, RS232 and RS485
  • supressor diodes for the outputs. You can now directly connect relays to the outputs
  • output is now a pinheader. The RasPiComm focus is on serial communication. Sacrifice I had to made to get the pluggable terminal headers in.
  • Extra 2 pin header for 5V fan. In case you want active cooling on the Raspberry Pi
  • Changed the through-hole joystick to a SMD variant. That resolves a little issue with the aluminum capacitor of the Raspberry Pi. No need for a tape or PCB support below to prevent accidental joystick activation
  • Extra tantal capacitor for external 5V power supply through the power header
  • SPI header

Shipment: Since my first post about the RasPiComm about 1 week ago I got a lot of positive feedback, so I really want to push v3 to production soon. Please give me a little time for finding the right partner for that. Eben Upton (Director of the Raspberry Pi foundation) is helping me to get this to Element14 (Farnell), this would be my preferred partner. Thanks Eben for your support! But as they are very busy with the Gertboard right now I don’t know about the timeframe yet. So I am working on it!

And thank you all for all the nice comments on my first blogpost about this! You all keep this going!

Downloads (Creative Commons Attribution-ShareAlike License)

RaspiComm_v3_schematics

 

RasPiComm – Hardware

Thank you for all the views and responses on my original RasPiComm blogpost!

Here I want to explain the RasPiComm hardware. The software part will follow next week.
At the end of the post you will find the schematics of the RasPiComm version 1 and version 2.

If you are not interested in the RasPiComm hardware, take a look at the original RasPiComm blogpost!

Now, let’s start!

Version 1 vs. Version 2

RasPiComm version 1

RasPiComm version 1 with populated RS-485 driver

As I mentioned in the first blogpost about the RasPiComm, I did two versions of the board. The first version had either one serial port OR an RS-232 port. I used the /dev/ttyAMA0 (TX on GPIO header pin 8 and RX on pin 10. You could either solder the MAX3232 for RS-232 or the MAX3483 for the RS-485 port. But there was another disadvantage: I used the GPIO1 (pin 12 on the GPIO header) for switching between receive and send mode.
Just a short explanation why you need to switch between send and receive mode: Unlike RS-422, RS-485 is an unidirectional bus system. That means that you use the same wires for sending and receiving data, so you cannot send and receive at the same time. Usually you always stay in ‘receive’ mode. If you want to send data you switch to the send mode and return to receive mode immediately after sending your data. The timing is critical here, I will explain that later. There are chips out there which support “auto-direction” from Maxim. I have not yet worked with them, I’ll probably will have a look at them in the future.
Another thing that changed is that version 1 had a SPI header. I removed them simply because the wiring of the SPI tracks would not have been optimal (they are not optimal yet but way better this way).

Changing to RS-485 via SPI

RasPiComm to Rasberry Pi Connector

So the disadvantage of version 1 is obvious: You could either have RS-232 or RS-485, not both. There was another problem. Switching the GPIO line for changing between receive and transmit was suprisingly slow. Not exactly because the GPIO switching is too slow but because it is not so easy to find out when the last byte was transmitted completely to switch back from send mode to receive mode. You can check if the /dev/ttyAMA0 send-buffer is empty using tcdrain(). Sadly this function blocks too long, we lose valuable miliseconds after sending until we can switch to receive mode and receive data. That means that all data that is sent by a RS-485 client before switching back is lost.
To overcome this limitation, and the problem that I can only use either RS-232 or RS-485 I dropped the MAX3483 and used the MAX3140 in version 2. This chip has an SPI-UART and RS-485 controller in one chip.
The interrupt line of the MAX3140 is connected to GPIO0 (pin 11).

RS-232
The RS-232 connector is driven by a MAX3232, I will probably replace it with another, cheaper version for the production board. Only TX and RX are connected, sadly the Raspberry Pi does not bring both CTS and RTS to the GPIO header, so hardware handshake is not supported. But this is not used often anyways.

I2C Connector
If you look closely at the I2C connector in the schematics you will see that this are actually two I2C connectors. It is a 2×4 header, and unlike all other headers row 1 and row 2 are not identical. I did that for a simple practical reason. I use this header mainly to connect I2C displays. There are two common pin layouts:

  • 5V, GND, SDA and SCL
  • 5V, GND, SCL and SDA

So I did both of them. With that little trick you can connect both types directly to the board using either row 1 or row 2.

Inputs
All 5 inputs are pulled-down to GND. They are all 3.3V inputs with an 1k resistor to the Raspberry Pi.

Outputs
Both outputs are open-collector outputs and switched with a BC847 transistor.

Power connector (3.3V, GND, 5V)
The 5V line can be used to supply 5V if you do not use the USB plug or use it as 5V ouput if the Raspberry Pi is connected via USB.
The RasPiComm generates its own 3.3V from 5V, the 3.3V line is connected to this output (200mA combined maximum rating).

RTC with backup battery

RasPiComm bottom

RasPiComm bottom

The backup battery on the bottom side of the PCB is a CR2032 cell. It should power the DS1307 for approximately 10 years. Currently there is a small problem with the battery holder on the bottom – it collides with the S2 socket (DSI). The RasPiComm v2 still can be connected to the Pi, but you cannot push it all the way down (it’s only 1mm). For testing I removed the S2-connector from my Raspberry Pi board. For the production version the PCB will get 5mm wider (did it without changing PCB size!) the battery socket is moved out of the way. It won’t change the footprint of the Raspberry Pi, the 5mm go torwards the video connector. That also means that the battery is slightly moved over the processor. This should not raise any temperature problems, neither for heat dissipation nor for the battery since the operational temperature range for the CR2032 cell is -20 to + 70 degrees Celsius (-4°F to +158°F).

Downloads (Creative Commons Attribution-ShareAlike License)

RasPiComm v1 schematics

RasPiComm v1 schematics

RasPiComm v2 schematics

RasPiComm v2 schematics

Arduino/Netduino GSM Shield

 

Versatile Arduino/Netduino GSM shield

I needed a way to send SMS messages from a Netduino board, so I first tried the SM5100B shield. It worked somehow but it was not very stable and I did not like the hardware design. It also lacked some features. So I decided to build my own. Here is what I did (if you already used Arduino/Netduino the nomenclature below will be familiar, if not read a little bit about Arduino or Netduino, its a really nice microcontroller platform):

I wired both serial ports (so you can open a data connection and still send AT commands through the other line), A2 and A3 are used for ignition and hard reset of the gsm module and D12 and D13 are used for the ring indicator (signals events) and power indicator. These two lines are optional so I added an smd jumper pad which is connected and can be cut easily. the same is for the second serial interface.

I also added a battery holder for backing up the RTC in the module, so you do not lose the time stored in the module. Also very handy.
The SIM card holder is a push-lock and is on the bottom of the PCB facing to the side with the usb and power connector, so when a housing is used you can cut a slot into the housing and change the sim-card without opening it.

The USB port can be used to configure the GSM board, but this is optional. All settings can be made through the RS232 interface.

%d bloggers like this: