• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

adaptiman.com

Ruminations from David Sean Sweeney

  • Blog
  • Twitter
  • Facebook
  • LinkedIn
  • GitHub
  • Mail

Communication Issues

Brewery Design, Brewing · November 6, 2016

The Sweeney Brewery v3 has lots of electrical controls. I have six 2-way electric ball valves – three for tun control and three for gas control, and two 3-way valves for various fluid routing processes. I also have a new Omega CN7500 (more on that later),  and the system pump.

Controlling everything, I have an RPi v2. The first problem was how to control all of the devices. the RPi offers support for multiple communication protocols including one-wire, RS232, RS485, and lots of others. After flirting with one-wire, I settled on RS485 for several reasons. First, the Omega could communicate with either RS232 or RS485. I had to design the controllers for the electric ball valves from scratch, so that wasn’t a limiting factor. RS485 can also support up to 32 devices per communications port. Also, RS485 can communicate over long distances. These all added up to a design decision to use RS485.

There’s lots of information on using RS485 with RPi – most of it poorly written, erroneous, or just plain wrong. I went down the road of trying to get the RPi to control RS485 directly but soon gave that up because of voltage conversions.  Then I found a neat little RPi shield that takes care of the voltage shifting for you. This was the solution that would allow me to control both the Omega PID and an array of relays that could control the mechanical controls.

And so I set out to configure the RPi to communicate to the serial devices. This was NOT easy. I installed a minimal Raspbian image (September 2016, Kernel 4.4) and updated all packages. I setup SSH and a USB wireless dongle to communicate with my house network so I could work on the RPi headless. I then added the following additional packages using apt-get:

  1. vim
  2. git-core
  3. python-pip
  4. wiringpi
  5. python-serial

This package should be installed with pip:

  1. minimalmodbus (has a custom driver for the Omega CN7500!!)

The setup instructions for the LinkSprite shield are old (2013) and inaccurate. They detail the following tasks which have to be modified on the new systemd enabled Raspbian image.

  1. Install library dependencies (detailed above)
  2. Disable use of the serial port as a TTY. Use raspi-config to do this. Run sudo raspi-config and check if it has the option interfacing-options -> serial. If it has, set it to disabled and you’re done.
  3. Set the serial GPIO flags to ALT0:
    gpio readall
    gpio mode 15 ALT0; gpio mode 16 ALT0
    gpio readall

    You should now see pins 15 and 16 set to ALT0.

  4. Disable the login messages on the serial port. This is tricky because the instructions assume an old version of unix that uses SystemV (i.e., edit /etc/inittab). The newest version of Raspbian uses systemd, which doesn’t have /etc/inittab. The correct way to do this under systemd is to run:
    sudo systemctl mask serial-getty@ttyAMA0.service

After I took these steps, I was able to communicate to the Omega controller via a simple python script that extended the custom Omega CN7500 driver for python. Here’s the simple script which returns the current process temp from the controller:

#!/usr/bin/env python
import omegacn7500
instrument = omegacn7500.OmegaCN7500('/dev/ttyAMA0', 2) # port name, slave address
print instrument.get_pv() # print temperature

And so, I made my first successful RS485 communication. More to follow.

RPi3 Update

Well, it turns out that the steps to enable the RS485 on the RPi3 are different. I found an article that deals with much of the subtlety of this. Because of the addition of bluetooth on the RPi3, /dev/ttyAMA0 is reserved for that, and so the procedure is slightly different. In the following steps, we will move bluetooth from the high-performance /dev/ttyAMA0 interface to the lower performing /dev/ttyS0.

 

 

 

Facebooktwitterredditpinterestlinkedinmail

Filed Under: Brewery Design, Brewing Tagged With: MinimalModbus, Raspberry Pi, RS485, WiringPi

adaptiman

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

What interests me…

  • Brewery Design
  • Brewing
  • Cognition
  • Community
  • Family
  • Higher Ed
  • Higher Ed IT
  • Hiking
  • Politics
  • Project Management
  • Scouting
  • Student Affairs IT
  • Uncategorized

Recent Posts

  • Differentiating Yourself
  • Hitchen’s Razor
  • The Future of Work
  • Educational Marketing
  • Tradition! Tradition!

Recent Comments

  • adaptiman on Yummy!
  • Denise Guidry Stackhouse on Doris Mae Sweeney, 1944-2016
  • Mark W. Altman on Technology Implementation in Student Affairs

Hiking

  • AT Conservancy
  • Lone Star Hiking Trail
  • National Outdoor Leadership School
  • NWES
  • Tarptent

Student Affairs IT

  • Dr. Ed Cabellon
  • EDUCAUSE SA Constituent Group
  • Eric Stoller
  • Joe Sabado
  • NASPA Technology KC
  • Paul Schantz

Copyright © 2021 · Maker Pro on Genesis Framework · WordPress · Log in