Sunday, September 25, 2016

Paint Flow Control Project, Chapter 3.26, Back to the Drawing Board

Happily, our Paint Flow Controllers worked fine in the installation at the painting facility in China. I'm actually not quite sure where the painting facility is but I think it's in Guangzhou in the south of China, fairly close to Hong Kong. It's where UEI (http://www.uei.com/) gets much of the painting done for their remote control units. Anyhow, because of the good results with our controllers, UEI and the Chinese facility are interested in purchasing up to a ten more controllers. Also Vivid Inc (http://www.vividinc.com/) would like two controllers for their own use at their Santa Clara facility.

We don't yet have the go-ahead on manufacturing the additional twelve or so controllers, but they are requesting some design changes, hence, Back to the Drawing Board. The design changes are not extensive, only requiring a change from the enclosure to an L-Shaped bracket since at the China facility, they mount the controller systems inside Hoffman boxes and consequently do not need the full enclosure, just an L bracket design. So I reworked the controller system design, again using Protocase (http://protocase.com/) design software with the aim of having Protocase build the L brackets for us since Protocase has built high quality enclosures for our previous control systems.

Here is my latest L bracket design:



The bracket has cutouts for the 4DSystems 4DCAPE-70T (4DCAPE_70T/) and for the AW Gearmeter (http://aw-lake.com/) MX9000 flow meter display unit, plus the AC ON/OFF switch and the Reset pushbutton. Both these devices have worked well. The Beaglebone Black microcomputer (BBB) plugs onto the 4DCAPE-70T and allows us to make a good Graphical User Interface (GUI) for the users to set the paint flow setpoint and operate the control system software installed in the BBB. Recall that I chose to use the BBB because of its many features including analog and digital I/O and its 1 GHz speed. I programmed the BBB in Python (Python), using tkinter (tkinter) and matplotlib (Matplotlib) to make the GUI.

Thomas Nguyen of Vivid Inc and I had concerns about use of a positive displacement flow meter such as the AW Gearmeter because those flow meters can be plugged up by paint contaminants. Sure enough, there were problems in the Chinese painting facility, resulting mainly from paint getting coagulated because of bends and obstructions in the tubing. Thomas got the tubing straightened out and had filters installed in the tubing to ensure that the paint would be clean and flow freely through the tubing to the paint guns. A further advantage is that the reject rate has greatly been reduced with the cleaner paint. Anyhow, we have been happy with the AW positive displacement gear meters and will continue to use them in the future systems.

Along with the change to the L-Bracket, I decided to change the power supplies to a different package also from Meanwell (Meanwell RS-15), the RS-15 family because of the connections to a barrier strip on the RS units. The Meanwell supplies have worked just fine, allowing a very wide range of AC input power, necessary for the installations in China.

And I am having to correct some design goofs in my Analog interface board. I had the Collector and Emitters of the output transistors turned around, and also I didn't provide enough space for the Phoenix connectors, minor but necessary fixes. The Analog I/O board utilizes outputs from the BBB Pulse-Width-Modulation (PWM) circuitry to provide 0-20 mA current outputs to control the paint pump and a simple interface (a resistor) to the BBB;s Analog-To-Digital-Converter circuitry to measure the current output from the AW Gearmeter display unit. Here's the resulting board layout from Kicad (Kicad):

Analog I/O Board for Paint Flow Control Systems.

As I said, we don't yet have the go-ahead to manufacture more paint flow controllers but hopefully soon.

Wednesday, July 27, 2016

Paint Flow Control Project, Chapter 3.25, The controllers worked in China!

Thomas Nguyen took two of the control systems to a UEI (UEI) painting facility in China and got them to work, and work well! Thomas is my cohort at Vivid Inc. (VividInc) in Santa Clara. Thomas and I have been working on various paint flow control projects since Thomas and I and my friend Gary Johnson (GWJ) developed a paint flow controller in 1991 for K&H Finishing in San Jose.

Since I last reported on our progress, we made a few design changes in the systems, the most obvious being the enclosure for the controllers. Also I revised the controller software considerably to include a Manual mode upon startup of the controller.

We had selected an AW Gear Meters flow meter (AW Gear Meters) and their MX9000 display unit for measuring the paint flow. My first enclosure design did not accommodate the MX9000 and Thomas wanted a revision to the enclosures to include mounting for the MX9000.

So I had Protocase (Protocase) fab some new enclosures that provided mounting for the MX9000.
Protocase provides a very usable design software and I designed the enclosure below. The MX9000 fits in the cutout on the left side of the enclosure and the 4D Systems 4DCAPE-70T Touch-Screen LCD (LCD) fits in the cutout on the right side. Protocase added some welds in the corners, front to back, and fabbed a very sturdy enclosure. They ground down the welds and after painting, the welds don't show.



Below is a photo of the enclosure with the AW Gear Meters MX9000 and the 4DSystems 4DCAPE-70T in place, Thomas Nguyen taking the photo and reflected in the LCD screen. :-)

The Enclosure with an AW Gear Meters MX9000 Flow Meter Display and a 4DSystems 4DCAPE-70T LCD Touch Screen.

Noemi Fortes had installed the LCD's, Beaglebone Black (BBB) micros, power supplies etc in two of the original enclosures and then when Protocase shipped me the larger enclosures, she installed the MX9000's and the remaining LCD's, the BBB's etc in the larger enclosures. Wanting the larger enclosures with the MX9000, Thomas and I moved the parts from the first enclosures to the larger enclosures and Thomas took those two controllers to the UEI painting facility in China while Noemi and I worked on the two other new enclosures.

At Thomas' request, I modified the software quite a bit in order to provide two operating modes: Manual (open-loop control) and Automatic (closed-loop control). Upon startup, the controller is in Manual mode just to get the paint flowing through the system. Then the operator can switch to Auto mode. Below is a photo of the screen in Auto mode with the system in desktop testing. For desktop testing, I connect the output analog control signal back to the input and include a software low-pass filter of the measured signal to simulate the actual paint flow control. On the LCD screen, the green trace is the setpoint, the red trace is the output signal and the blue trace is the "measured" (simulated) paint flow.

The control software uses Fuzzy Logic as I had described in previous posts but is somewhat enhanced using a computed "System Gain" value. The computed System Gain is determined during the initial Manual mode by dividing the paint flow value by the control signal value. Then when the controller is switched to Auto mode, the System Gain value is used to set the starting control output, thereby getting a control output close to the ultimate value that would then be fine-tuned with the Fuzzy Logic algorithm. It's sort of cheating, but a very effective way to kick-start the controller to the best control value on switching to Auto mode. Hmmm, I wonder if it can be patented.

Screenshot of the control software in a test configuration.
Here is a photo of the controller in actual operation at the Vivid Inc facility. The photo is a bit fuzzy (no pun intended) but the controller is operating in Auto mode with a set-point of 800 mL/min and flow reading of 793 mL/min, The MX9000 is reading a flow of 864 mL/min, about 9% higher than the reading on the controller's LCD, probably a calibration error.

Paint Flow Controller in operation at the Vivid Inc facility, Santa Clara, CA.

The controllers work very well in the UEI painting facility but of course there were a couple of problems. The main problem was with the flow meters getting gummed up with chunks of dried or gummy paint. In initial testing at the Vivid Santa Clara facility, we had problems with the paint getting gummy and clumps of the paint drying in the tubing between testing. Thomas frequently had to open up the AW flow meter and clean it out. The AW flow meters are used in automobile painting in U.S. manufacturing plants, so should be good for our use. I figured that the paint in the China facility would be pure and of consistent viscosity, so Thomas wouldn't have any problems getting the controllers operating perfectly but it turned out that because the tubing in the China facility had many right-angle turns that the paint flow would be slowed and the paint would become coagulated, resulting in a clogged-up flow meter. To remedy the problem at the China facility, Thomas insisted that the tubing be re-plumbed, making smooth turns to keep the paint flowing smoothly so as to eliminate the clogging and gumming-up problems. We will see how well that will be accomplished.

Happily, the controllers work well. The Fuzzy Logic software with my System Gain kick-starting feature seems to be ideal. The Chinese operators are able to work with the LCD touch-screen and do necessary adjustments to the MX9000 flow meter display units for their particular paint flow values. And the Beaglebone Black micro with Python plus tkinter and Matplotlib software seems to be perfect for the control system software.

We are expecting that UEI and Vivid Inc. will be ordering more of the controllers in the next year, eleven or twelve, since they are finding that the controllers work well and are expected to greatly reduce defects and be a real money-saver,

Wednesday, June 1, 2016

Paint Flow Control Project, Chapter 3.24, Some tasks completed and more work to do

Good progress but more to do. I showed a list of tasks in my last post and have an additional software task. Thomas wanted some changes to include a Manual mode along with the Automatic mode, the Manual mode to allow the operator to set the controller output irrespective of the measured flow, an open-loop mode. The Automatic mode would be the same as before, allowing the operator to set a flow rate for the paint flow. The Paint Gun ON/OFF would be eliminated since the paint gun has a bypass valve to allow the paint to continue flowing even when the gun is shut off. So this required some not inconsiderable changes in the GUI along with some software changes, but minimal software changes. Here's a photo of the new GUI showing the Manual settings along the top with the Automatic settings below:
The New GUI Screen with Manual and Automatic Modes.
On startup, the mode is Manual and initially I have set the output to the I/P converter for the pump control to 500, that's 500 ml/min assuming the pump output is linear with respect to the I/P converter signal. In retrospect, perhaps I should change the Manual control to a Percentage of maximum value. Anyhow, the operator can "click" on the screen at the MAN and AUTO "buttons" to switch modes and the current mode is shown at the far right in the STATUS label. When the paint system is ready for painting the operator can switch to Automatic mode and operate in Closed-Loop controlling the paint flow rate to the AUTO setpoint. In the photo above, the controller started in the MANUAL mode at the 500 setting and then I switched to AUTO mode wit the setpoint at 1000 ml/min.

In my last post, I showed a list of software and hardware tasks.
The software tasks were:
  1. record data on a USB flash drive plugged into the BBB (completed).
  2. add a Real Time Clock (RTC) module to the BBB (completed).
  3. add software for the RTC (completed).
  4. add an Idle mode to the paint flow control when the paint gun was turned off (deleted).
Then there are the hardware tasks: 
  1. fabricate the Analog I/O boards and get them loaded (board fab completed).
  2. design the hardware system, purchase power supplies and other parts (parts purchased), and
  3. get the hardware installed in the Protocase enclosures to complete the hardware tasks (in work).
Also I needed to purchase or build a Real Time Clock module for the BBB. 


Analog I/O Cape Module:
I designed the Analog I/O Cape using Kicad as I described in a previous post. The design is a pair of Pulse-Width-Modulation (PWM) to 0-20 mA converters for feeding control signals to the I/P pump control Current-To-Pressure converters and a pair of resistors for converting the 4-20 mA current from the flowmeter to a 0-1.5 VDC signal to be measured by the BBB. I ordered the boards from Osh Park (Osh Park) along with breadboards for the Real-Time-Clock, described below. Noemi Fortes is loading the parts on the boards along with assembling the LCD module, BBB, power supplies etc into the Protocase enclosure that I described in a previous post.

Analog I/O Cape.

Real Time Clock (RTC) Cape (Board):
I found a possible RTC board, the (CircuitCo), but unfortunately they're out of stock everywhere. And that board isn't quite perfect, requiring a little rewiring to connect to the second I2L pins on the BBB. But I found a module at Adafruit, the (DS3231), that is probably more accurate than the CircuitCo board. However, the Adafruit module can't be plugged into the BBB, requiring a breadboard module. So I decided to get the Adafruit DS3231 modules and some breadboards from Osh Park (oshpark) along with some boards for the Analog I/O that I had reported on in a previous post. And I got some 46-pin connectors from Major League Electronics (46 Pin Connectors). My completed RTC module isn't beautiful, but I got it running well with the instructions from Adafruit.

Real Time Clock Cape Module.
I mounted the Adafruit DS3231 module upside-down to allow easy access to the battery.

Noemi Fortes is fabricating the controller systems and expects to have two systems completed by June 2. Noemi is an expert EE Fabrication Technologist and ex-coworker at the Lawrence Livermore National Laboratory. When Noemi completes the fabrication, I will check out my Analog I/O design and get the software installed and operational for Thomas Nguyen to test the systems and then take them to the painting facility in China. All that is coming up in my next posts.


Tuesday, May 17, 2016

Paint Flow Control Project, Chapter 3.23, Good Progress

Proudly wearing my Berkeley sweatshirt
with my wife Heide's painting in the background.
The funding really did come through from Vivid Inc (VividInc) of Santa Clara and Universal Electronics (UEI) down in Santa Ana. Vivid needs a paint flow controller at their coating and painting facility and UEI needs paint flow controllers for their overseas manufacturing facilities. Initially they want only four systems. If these work out for them, they will need a few more, maybe about eleven more. So there's not a big need for our systems to be sure, but the controllers should be big cost savers as the conductive paint is quite expensive and they want to use just enough paint for the RF shielding.

The paint flow control system comprises the controller, a flowmeter to measure the paint flow rate, a paint pump, a paint gun and a robot to steer the paint gun and turn it on and off. The flowmeter outputs a 4-20 mA current for the flow rate and the pump is controlled by an I/P converter, requiring a 4-20 mA current. I helped to choose the flowmeter and the I/P converter for the systems.

As I have been saying in previous posts, for the controller and User interface we decided to use a Beaglebone Black (BBB) single-board-computer (SBC) along with a 4D Systems (4D) touch-screen LCD, the 4DCAPE-70T (4DCAPE_70T). I used commercial SBC's for previous projects with K&H Finishing in San Jose and Enclosures Engineering of Fremont and recently had designed my own SBC with analog I/O, Ethernet and Serial Communication capability but Vivid and UEI wanted a commercial board for this project, preferring not to manufacture a board. So I had planned on using a BL2600 SBC from Digi International (BL2600) for the control and a notebook PC to communicate with the BL2600 and provide a GUI for the operator. However Thomas Nguyen, my cohort at Vivid, suggested using a touch-screen LCD panel instead of the PC in order to simplify the system for the User. I searched and found the BBB and the 4D Systems 4DCAPE, figuring that I could do the whole job with those two widgets and thereby greatly simplifying the control system. The BBB has an onboard Analog-To-Digital Converter (ADC) for measuring the current from a paint flowmeter and has a Pulse-Width_modulation output for providing a control signal to control the pump speed. It does need some interface circuitry to convert the 4-20 mA current from the flowmeter to voltage, a resistor, and an operational amplifier and transistors to convert the PWM output signal to a 4-20 mA current to control the pump. So I got to design a little board for those purposes, using Kicad (Kicad), a freebie CAD software package. Kicad has its idiosyncrasies as all CAD programs do, I suppose, but I have found it to be usable and the Kicad user group is quite helpful for beginners (Kicad Users).

I had been working on a simulation of the system using Python (Python) and decided to continue using Python in the BBB for the control code and also for the GUI. I like using Python since it's a faster development process, not requiring the usual compile and link and do over and over until you get it right. Python is an interpreter so the programs run slower than a C or C++ or C# program but the slower speed is not a problem with the paint flow controller since the process is very slow. In order to produce a GUI for the operator, I used Tkinter. That has been something of a problem, giving me fits with a Tkinter error that I mentioned in the last post.  However, my code can be run by connecting a keyboard to the BBB thru its USB interface and starting the code with "sudo python myProg.py." But certainly that's not adequate. I can't require the users to have to type in a command to get myProg.py up and running since those guys or gals are in a manufacturing environment and probably in Asia. They would like a simple button to press. If possible, it would be nice for myProg.py to start up on booting the BBB.

So I set about finding ways to start my Python code with a button press or touching a "button" on the 4DCAPE screen. I found that there are three ways to do that:

  1. systemd
  2. cron
  3. icon on desktop, Debian or other Linux.
Lots of info on systemd and cron is available with an Internet search, so I won't repeat it. I tried and tried to get either of them to start up my SimB.py Python program but wasn't able to do so. I think the problem is the Tkinter error that I mentioned above. However, with the help from a post by Cyril Laury in this askubuntu post (Icon StartupDesktop Icon), I was able to put an Icon on the Debian desktop and have it call a bash script to start my program. Here are the scripts.

paintflow.desktop
[Desktop Entry]
Version=1.0
Exec=sudo /home/debian/Desktop/startcontrol.sh
Name=Paint
Comment=Start up SimB.py
Encoding=UTF-8
Terminal=false

Type=Application

startcontrol.sh:
#!/home/bash
#sudo /bin/bash clock_init.sh
sudo /usr/bin/python2.7 /home/debian/Desktop/SimB.py

Many thanks to Cyril Laury.

My next software tasks were:

  1. record data on a USB flash drive plugged into the BBB,
  2. add a Real Time Clock (RTC) module to the BBB,
  3. add software for the RTC,
  4. add an Idle mode to the paint flow control when the paint gun was turned off.
Then there are the hardware tasks: 
  1. fabricate the Analog I/O boards and get them loaded,
  2. design the hardware system, purchase power supplies and other parts, and
  3. get the hardware installed in the Protocase enclosures to complete the hardware tasks.
So I still have much to do and will report on those tasks in future posts.
So, that's all for now and back to work.
John

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.

Wednesday, January 27, 2016

Paint Flow Control Project, Chapter 3.21, Check is in the Mail!

Thomas Nguyen, my cohort at Vivid Inc., tells me that they are expecting a check from UEI for Thomas and me to provide them four control systems comprising the Beaglebone Black (BBB), the 4D Systems Touch-Screen LCD and my Fuzzy-Logic-based control software. I believe that one controller will be used by Vivid Inc in their Santa Clara facility and that UEI plans to install three of the controllers in their painting facility in China. I understand that UEI will order an additional eleven systems if the first four work satisfactorily in their China facility.

I provided a list of the components, an Agreement for the development effort and a Software Licensing Agreement to UEI and Vivid and am expecting that they will authorize me to go ahead with the project.

Accordingly, I am elated that the project will be going ahead. I had done considerable work with the Fuzzy Logic algorithm and the simulation code that I reported in previous posts. And now I need to complete a few more tasks:
  1. Produce an interface board for the BBB to interface with the flow meter and the pump control,
  2. Redesign the enclosure to accommodate the BBB and the LCD Touch-Screen,
  3. Complete the Fuzzy Logic closed-loop software.
The BBB will need an interface board to output a 4-20 mA current for controlling the paint pump and for inputting the 4-20 mA current from the flow meter. I had gotten started designing the board using Kicad (http://kicad-pcb.org/) and need to finish up the design, then go on to manufacturing the board. It's a simple Voltage-to-Current circuit using an LM324 opamp and some transistors to produce the 4-20 mA current from the BBB's Pulse-Width-Modulation (PWM) output. The input current from the flow meter requires only a resistor to produce 0 to 1.8 VDC to be measured by the BBB's Analog-To-Digital Converter (ADC). I had made a similar Voltage-to-Current converter circuit for my Microchip paint flow controller board a few years ago and so will use a similar circuit for the BBB.

Here's a partial circuit schematic:
Voltage to Current Converter Schematic (partial)
and the layout:
Voltage to Current Converter Board Layout.

Previously we were planning on using a Digi International BL2600 Single-Board-Computer (SBC) for controlling the paint flow and a PC with a GUI to communicate with the BL2600 to establish the paint flow set-point and other parameters. I designed an enclosure for the BL2600 using the software from Protocase (http://www.protocase.com/). However, Thomas suggested eliminating the PC and instead use a Touch-Screen LCD attached to the BL2600. It didn't seem practicable to attach a Touch-Screen LCD to the BL2600 and then I hit upon the idea of using a low-cost SBC such as an Arduino or a Raspberry PI or a Beaglebone Black board with a 7" LCD Touch-Screen. I selected the Beaglebone Black (BBB) since it is more powerful than the others and has more on-board analog I/O with its Analog-To-Digital Converter (ADC) that I can use to measure the current from the flow meter and its Pulse-Width-Modulation outputs that I can use to produce a 4-20 mA current to control the paint pump motor. Consequently I will need to redesign the enclosure to accommodate the BBB and the 4D Systems LCD Touch-Screen. My original enclosure design is shown below. I got a quote from Protocase for a few boxes but of course I'll have to get new quote for the new enclosure design for the BBB and 4D Systems LCD. Fortunately the Protocase design software is quick and easy to use. I haven't yet purchased any enclosures from Protocase but I am fully expecting their products to be first-class.

Protocase Enclosure for Digi BL2600 SBC.
The BBB can run Linux operating systems. I installed an updated Debian Linux OS, the Python interpreter along with MatPlotLib etc as I mentioned in my previous post. My Fuzzy Logic simulation code ran just fine with only a few mods to the code to comply with the Python 2.7 version. I did have to resize the screen code to make it fit. The result is shown in the crude photo below, taken in my office/lab with the BBB and the LCD sitting in the 4D Systems cardboard box on my desk.

Fuzzy Logic Simulation Code Running on Beaglebone Black with Attached 4D Systems 7" Touch-Screen LCD.
Now to get on with the project for UEI and Vivid Inc.

Monday, October 26, 2015

Paint Flow Control Project, Chapter 3.20, Getting Started With the Beaglebone and the 4D Systems LCD

With one of Heide's paintings in the background.
In the last post, I said I was proposing to Vivid Inc and UEI that I use the Beaglebone Black (BBB) and a 4D Systems 7" LCD touchscreen to do the paint flow control and also handle the Monitoring, Supervisory and GUI (MS&GUI) tasks. I had originally planned to use a Digi International BL2600 Single Board Computer to do the control and have it communicate by Ethernet to a PC which would do the MS&GUI part of the system. However, Thomas Nguyen suggested using a touchscreen LCD panel instead of a PC. Recognizing that it is a great idea to get rid of the PC, I then realized that the BBB had sufficient on-board hardware and was sufficiently fast to do the whole job of controlling the paint flow and the MS&GUI. Then I found the 4D Systems 7" touchscreen LCD panel that would accommodate the BBB.

So plunging ahead, I purchased a BBB from Amazon. It included a 5V power supply, a USB cable and a small plastic box. The unit soon arrived and I got going with the Getting Started info at (BBB Getting Started), first connecting the BBB to my PC thru the USB cable. The BBB came with an Angstrom Linux operating system in the onboard flash memory but the Getting Started instructions recommended updating the OS. But which OS to use: Debian, Ubuntu ...? After checking around, I read somewhere that the Debian distribution was easiest to use and decided to use it. I figured that I could switch to the Ubuntu or some other Linux distribution if the Debian didn't work out.

In order to upgrade the Linux OS, a 4GB or larger microSD card is needed and the Debian distribution is loaded onto the microSD, then the microSD is plugged into the BBB and the OS is "flashed" to the onboard flash memory. The Debian distribution can be downloaded from (Linux Downloads) to a PC and the image loaded into the microSC card per the instructions. I wasn't really sure I needed to upgrade the OS from the Angstom version to the Debian, so held off for a day or so but then decided to go ahead and replace the Angstrom OS with the Debian OS because I wanted to install Matplotlib and Numpy, and figured that I should get the latest versions from the Debian distribution, Again following the Getting Started instructions, I "flashed" the Debian into the onboard flash memory. Python etc come with the Linux distribution but require an installation operation to take it from the already flashed onboard memory to a working area in the flash memory. At least, I believe this is the way it works. I hadn't realized that Python was included in the distribution and the whole process seemed somewhat mysterious. I installed Python, Matplotlib and Numpy according to the instructions on the Matplotlib website (Installing Matplotlib) using the "sudo apt-get install Python" sort of instructions.

Fortunately all this went very smoothly and I then had an updated BBB with the Debian Linux distribution including Python, Numpy and Matplotlib.

My next step was to try to run my Python Fuzzy Logic simulation code that I described in previous posts. I had borrowed a couple of books from the local library, Getting Started by Matt Richardson and the BeagleBone For Dummies book by Rui Santos et al. These books had guided me in getting the BBB running over Ethernet and also would be helpful in getting my code running on the BBB from the Debian desktop.

I had expected there would be problems running my code on the BBB since it would be calling Matplotlib instructions to make the GUI and at this point I had no display attached to the BBB but I figured I'd give it a try to see what happened. And I hadn't thought of it before, but I wrote my Python code for Python 3.4 and I had imported Styles in my code. Then when I ran my code, it first gave me some errors related to Styles. Only then I discovered that the Debian Python was version 2.7, and Styles was not available for 2.7. And when I checked some more, I found that the Debian Python 3.4 did not include Matplotlib. So I was a bit concerned that I might have a lot of problems running my code in the Debian Python 2.7. Fortunately I didn't really need the Styles features and was able to simply comment out the Styles commands. Then happily my Python simulation program ran all the way thru until the Python interpreter output an error relating to the display since it found no display to write the GUI. That is, no real errors resulting from the Debian Python 2.7. At the time, I really didn't understand the display error message, but wasn't overly concerned since I had expected some sort of errors relating to the absence of the display.

I had been planning on buying a 4D Systems LCD display panel, but cautiously wanted to hold off on the purchase until I could verify that the BBB was operating correctly and since the BBB has a micro HDMI connector, I decided to try connecting the BBB to our Samsung 40" LCD TV set. However, I needed a cable for the micro HDMI to the Samsung's standard size HDMI connector and so made a couple of trips to Fry's Electronics in nearby Concord, Calif, two trips because the first trip I mistakenly bought a miniHDMI to HDMI cable not realizing that there are two types of tiny HDMI connectors!

Anyhow, when I finally got the correct microHDMI cable and connected the BBB up to our Samsung LCD TV, the OS gave some errors that looked troublesome but then displayed the happy Beagle in the lower right hand corner of the screen. I didn't see any way to run the Linux Terminal, and since I was tired from my two runs up to Fry's, I almost decided to pack it in for the night but then referred to the Dummies book, that said "hey Dummy, just resize the TV screen" and lo and behold the tiny icons showed up for the Accessories, File Manager etcetera. Then using commands from the Dummies book, I was able to execute the "sudo su" command and then the "Python MyCode.py" command and my GUI showed up on the TV screen, shown below, and I was able to get my code going and simulating the Fuzzy Logic control by clicking the Enable button on the GUI.

BBB Debian Desktop Showing the GUI from my Fuzzy Logic Simulation Code.

I was elated and relieved at the same time that the BBB could run my simulation code even though I had written it for Python 3.4 and the Debian distribution uses version 2.7. Actually I could get 3.4 from the distribution but Matplotlib wasn't available on the Debian 3 distribution, so I was stuck with 2.7.

Talking with Thomas about it, he said he would get Vivid to purchase the 4D Systems LCD panel or I could go ahead and get it, to be reimbursed by Vivid later. So straightaway (well, the next day) I ordered the LCD panel from Mouser, getting a little better price than from Amazon, and the panel was delivered by US Priority mail in just two days.

So then I set about connecting the 4D Systems LCD panel to the BBB, a thirty-second process as I was very careful to connect it properly. Using the 5V power supply, the BBB booted up and quickly showed the happy Beagle on the lower right hand corner of the screen and also the tiny icons showed on the lower left corner that allowed me to start my Python code. Again, and anticlimatically, my code started running right away, doing it's thing to simulate the Paint Flow Control. However, as you can see below, my GUI was too large for the screen and will have to be resized. Not a big deal and something that I will do later. Notice the blue lines. Those are simply marks on the plastic covering made by the QC folks at 4D Systems.

Fuzzy Logic Simulation Code Running on BBB with 4D Systems Touchscreen LCD.

So all looks well so far for using the BBB and 4D Systems 4DCAPE-70T LCD Touchscreen panel, at least as far as the GUI and computing the Fuzzy Logic Look-Up-Tables for the Paint Flow Control System. However, I will have to design an add-on board for the BBB, called a CAPE, that will convert the PWM output signals to a 4-20 mA current for the paint pump and also to convert the 4-20 mA current from the flowmeter to a 1.8 VDC signal to be digitized by the BBB's Analog-To-Digital Converter.

With the use of the BBB to do the whole control system including the MS&GUI, the development job will be significantly simpler for me to complete. I had been expecting to have to program the Digi BL2600 for the control tasks and a PC for the MS&GUI task, plus program the Ethernet communication between the PC and the BL2600. So the job will be simpler and I believe it will also be more robust and reliable.

However, a minor detail  ;-) that I hadn't yet mentioned in this post: I don't yet have an agreement to complete the job! Hopefully soon.