Sunday, March 27, 2016

Paint Flow Control Project, Chapter 3.22, Project is Funded!

Thomas Nguyen of Vivid Inc. (VividInc) tells me that we finally have the funding. For the past couple of months I have been working feverishly to get the Paint Flow Control System operational, revising the enclosure design, the analog circuit board design and the Python software for the closed-loop control of the paint flow. My work isn't completed but I do have a Python simulation program operating on a Beaglebone Black processor board with a GUI on a 4D Systems 4DCAPE LCD.

I understand from Thomas that parts are being ordered, including the Beaglebone Black processor board, the 4D Systems 4DCAPE LCD, the enclosure described below and power supplies.

Originally, the design consisted of a Digi Inc BL2600 Single Board Computer (BL2600) to control the paint flow and a PC programmed in Microsoft C# for the GUI and to set the control system parameters. However, Thomas suggested eliminating the PC and instead using a touch-screen LCD connected to the BL2600, particularly to make a simpler and more user-friendly system. Researching the possibilities, I found the 4D Systems 4DCAPE-70T 7" Touch-Screen LCD (4DCAPE-70T) that would accommodate a Beaglebone Black (BBB) processor board (BBB). Since the BBB had analog I/O circuitry on its processor chip, I decided to use the BBB and the 4DCAPE-70T to provide the GUI and the paint flow control system, thereby eliminating the BL2600 and the PC. However, the BBB does not output a 4-20 mA current required by the pump controller and also its Analog-To-Digital-Converter (ADC) measures voltage rather than directly measure current. The BBB has a Pulse-Width-Modulation (PWM) digital output that can be low-pass analog filtered to make a D.C. voltage and that voltage can be converted to the required 4-20 mA current by a simple voltage-to-current circuit.

As with the previous design, I planned to use an aluminum enclosure from Protocase (Protocase) to house the electronics but the enclosure design would have to be modified to accommodate the 4DCAPE. Fortunately Protocase provides an easy-to-use software package for designing enclosures and I made the design below, showing the rear and top panels, with the large cutout for the 4DCAPE-70T LCD screen.

Enclosure for Beaglebone Black and 4D Systems 4DCAPE-70T.

Next I updated the design of the add-on analog interface board using Kicad (Kicad). The BBB add-on boards are called Capes. The board layout is shown below. The design modification was to add a CMOS analog switch IC to protect the BBB circuitry for when the BBB is not yet powered up as it can be damaged by external input voltages before it is powered up and stabilized.

Analog CAPE for Beaglebone Black.

The circuit board design converts the BBB PWM output signal to a 4-20 mA output current for controlling the paint pump and also converts the 4-20 mA current from the flow meter to a voltage to be measured by the BBB's ADC. Boards are yet to be ordered. I plan to load the parts on them myself.

Then for the past month or so, I have been revising my Python simulation code for the BBB to provide a means for entering the flow set-point by use of the touch panel and also to incorporate the PWM and ADC code. It has been quite an arduous task since I had considerable trouble with both an error message cropping up with Tkinter and with the PWM and ADC code for the analog I/O. Tkinter (Tkinter) provides the capability for making a GUI, allowing me to include buttons and text boxes plus a graph showing the flow set-point and actual (simulated) flow value. The error message showing up is:

_tkinter.TclError: no display name and no $DISPLAY environment variable

I searched for answers and found some suggestions but none of them worked for me until I found a suggestion on the Beagleboard.org user Forum. User Steve Plant had the same problem and was able to work around it by connecting a mouse and keyboard to the BBB, then going to the terminal program on the BBB and running the Python by typing: "sudo python myPythonProgram.py." I'm running the Debian 3.8.13 distribution on the BBB. I had tried this by using putty.exe (putty.exe) to connect to the BBB and typing the above command but I still got the Tkinter error message. Putty is an SSH program to communicate with the BBB from a PC. Following Steve's suggestion, I did connect a keyboard and mouse to the BBB and using the Debian terminal program, I was able to get my program up and running. Hooray! That was a big relief. 


I also had been having trouble getting the PWM and ADC functions to operate, apparently getting a conflict between the code and the 4DCAPE use of the I/O pins. Fortunately I was able to get the PyBBIO functions (PyBBIO) to operate satisfactorily and get the PWM output to work and also the BBB ADC to measure a voltage. I had wired up a simple R-C low-pass filter on a BBB breadboard, the output of the filter going to the analog inputs AIN4 and AIN5. When I ran my simulation code, I could monitor the filtered PWM signal on my oscilloscope and see it follow the output commands. Another Hooray! Here is a recent photo of the screen showing my simulation code running.The buttons for adjusting the flow set-point are at the upper left corner. The photo shows the flow rate set-point at 2000 ml/min and the simulated response of the controller with an assumed pump and flow-meter time constant of 1 second and sample rate of 0.25 seconds. 

There is more work to be done with the simulation and possibly modifications to use actual mechanical push-buttons on the bottom edge of 4DCAPE instead of the screen buttons as I am concerned that repeated poking at the screen will wear it out. Also, I will be getting the analog I/O Cape boards etched and I will load the parts. And I have more work to convert the simulation code to a real close-loop control system, so plenty to keep me busy for the next couple of months at least.

GUI for Simulation Code on BBB and 4DCAPE.

1 comment:

  1. Great blog! I really love how it is easy on my eyes and the information are well written. I am wondering how I might be notified whenever a new post has been made.
    Paddle Wheel Flow Meter

    ReplyDelete