“Industry will target growth through Microsoft’s computational services that deliver incredible optimization. Such optimization would otherwise take centuries to evolve under the traditional proprietary model.”
Table of Contents |
|
PREFACE
In this project, we will demonstrate the use of the Avnet Azure Sphere module for I2C communication, GPIO analog input, OLED Custom Graphic Image Displays, Soft PWM, and cloud based API data retrieval to acquire weather data. We also show how to host the data gathered in the cloud and display it through a custom .Net web app. These exciting capabilities of the Azure Sphere Module will shape the future of industrial optimization. We hope you share our insights as we outline our prediction of the future in our Coke Drum Health Monitoring project below.
INTRODUCTION: PREDICTING THE FUTURE
Years ago, after I felt the world was outgrowing the C programming language and Apple was on the way out, I started teaching myself Java3D to build a chemical plant operator Simulator. I remember the forward in the book talking about the vision of Java being in every appliance. It would unite the world of microwaves, TVs, and cell phones with its bytecode.
Having entered industry a few years before, I was fortunate to see the Chemical, Materials, and Petroleum industries go through three phases of Information Technology: the main frame dumb terminals, the Win95/XP Phase, and now, mobile tech. In the processing plants, I watched the instrumentation and controls go from air (pneumatics), to wires, and now to wireless.
Almost two decades later, we’ve now evolved full circle back to Apple. Due to the concept of a pinchable screen and Bluetooth peripherals, they are winning the PC war - taking computing off the desktop. However, they are still doing so on the back of Microsoft 365, OneDrive Storage, the .Net platform, and Windows Virtualization. Seeing how Microsoft consistently stayed in the game throughout every iteration of tech - and now experiencing the Microsoft Azure Services platform, I can predict the future:
10 Years from Now Microsoft will Run the World
How? Microsoft will infiltrate process control transmitters with the Microsoft Azure chip. And what will run it – ironically, the programming language of C! Talk about full circle! Read on to see how this future will unfold and see a demo project from the year 2030.
THE IMPETUS FOR CHANGE
So what drives change in technology for industry? Growth – which is made of these two things:
- The prospect of increased revenue generation
- The prospect of increased margins
TESLA Growth to ½ Million Units (1)
Many of the greatest companies drive for core values such as strong safety performance, strong business ethics, and stellar environmental stewardship. However, failing these inhibit growth, but do not drive it. That’s because those values concern how humans behave and improvements of those behaviors are driven by people who work successfully in paper or 90’s IT tech.
However, no Shareholder driven company, or private company for that matter, would ignore revenue growth opportunities to attract investors. If a company isn’t growing, it’s dying – so there is truly one mission - to grow. To do that without asset expansion and additional capital investment takes these two things:
- Optimization
- Reliability
For example, a crude unit going down for just one day would mean at least a 1/2 million dollars in revenue loss. Being able to optimize your operation to get extended days and months between major outages provides several million of growth. In turn, optimization and reliability are the primary keys to growth. In turn, they are the impetus for technology change.
THE TECH THAT WILL DRIVE THE GROWTH
What first comes to mind is WiFi and Broadband tech. They are changing the Instrumentation and Controls Industry as fast as the pinch screen did (negatively) for the desktop market. I recently demo’d these technologies in my blog Big Petro Maker Magic that can Save you Millions. That was just a few months ago where I showed the cutting edge 2.4GHz WiFi tech that is entering the industry. This tech will grow over the next 10 years for sure based on the low cost of implementation alone.
Industrial Wireless Transmitter Network by Rosemount (2)
With it, more and more asset owners are trusting the industrial wireless tech even for their safety interlock systems. This is a necessary step to the future, but again, all WiFi tech is doing, is mirroring the control strategies from the days of pneumatic controllers. Sure, it is easier to install and maintain for those hard working people trying to keep the plant running, but it won’t drive growth. As stated before, growth is found through leaps and bounds in reliability and optimization.
So, what technologies will increase revenue and margins and ultimately a company’s growth? It’s the technology that will remove the limitation on automation today. That limitation is – brace yourself - the hard working, local minds you have focused on keeping the plant running. I’m not saying they will be replaced – they just will no longer be the limitation to growth through reliability and optimization improvements.
The technologies that will allow those hard working people to do what they do while reducing Fixed Cost for maintenance and exponentially improving reliability and optimization are these two things:
- Secure Network Communication
- Cloud AI Services
That’s because these technologies deliver optimization and improved reliability that would otherwise take centuries to evolve under the traditional proprietary research model. This is why Microsoft will run the world in 10 years. Industry will target these services above all other strategies. The Microsoft Azure Chip will eliminate all security concerns to do so.
A USE CASE FROM THE YEAR 2030
Now that we are in 2030 (from the perspective of this prediction), we now have Microsoft with AI agreements with the other big data and service companies that have the vision to do so. In this example, SAP’s PM module has been feeding Microsoft’s data warehouse for ten years where AI algorithms categorize asset failure codes across of the world and tie them to data acquired by Microsoft Azure Sphere that is embedded within field instrumentation.
In 2030, Big Oil is still a player, of course. Organic Chemistry provides all kinds of great polymers that are going into recyclable materials as well as fueling our LiPo tech that is powering all our cars, lawn mowers, and hedge trimmers. LiPo batteries are using diamond coke from the residual compound on the bottom of the distilling towers for synthetic graphic.
4 Drum Coker Unit (3)
In the Delayed Coker Units, one such asset that is under constant machine learning and predictive AI in the year 2030 are the Coke Drums themselves which produce all that diamond coke. These vessels are based on WWII technology designed to chemically crack the residual heavy hydrocarbons into smaller carbon chains used in more valued products. It proverbially squeezes the blood out of the turnip at 800F, which makes volume – which is what refineries do – increase volume by separating molecular carbon compounds and cracking them into higher volume molecules that give higher profits.
Coke Drum Being Transported – Note the Size in Reference to the People (4)
The Delayed Coking process is nearly century old, but is still around because of it runs on a simplistic approach. Fill the drum full of heated material. Sparge it. Collect the goods. Optimization and reliability are the game for growth, so let’s dive in to how we are going to do it on these drums with Microsoft Azure.
Delayed Coker Unit’s Coke Drums (5)
First, we need to stay running for as long as possible. Each cycle to fill and collect needs to be as fast as possible. The down side is, these vessels are made of 4 inch thick plate. Taking it up and down 800F in a matter of minutes is tough on metal. It can lead to delaminating the inside corrosion inhibiting liner and/or hairline cracks occurring. To monitor how hard we are running it, we look at the age old mechanical engineering interests: stress and strain.
Strain Gauge Used to Correlate Stress on a Material (6)
Fortunately, in the 1980’s, computer software started taking on Finite Element Analysis (FEA). These are heavy calculations typically by PHDs to predict the stress imposed by temperature changes and variations on materials. FEA uses some pretty cool math to calculate stresses. Even in 2020, computations take days to render results at local engineering firms and cost of $90K a pop. Only a few leaders across the globe consider these one hit studies as a viable approach to optimization.
But now, in 2030, such calculations are possible in near real time by engineering firms that have partnered with Microsoft Machine Learning services. The firms that build Delayed Coking Units provide the services as an optional maintenance agreement.
FEA Stress Heat Map (7)
Process data such as temperature, pressure, and cycle times is recorded at the same time to the cloud. With the data partnerships of the work order system and asset repair history, correlations are made against the strain data and local weather conditions. In turn, maximum optimization of run conditions are derived that will prevent Coke Drum wall cracks, corrosion liner delamination, and disrupted operation. In turn, we have maximum possible reliability and annual product yields.
Coke Drum Internal Cladding Repair by an Automated TIG Machine
Downtime Costing $1/2 Million a Day (8)
PROTOTYPING THE FUTURE
To prototype this prediction of Coke Drum Health Monitoring IoT AI for the year 2030, we’ll use the cloud services of Microsoft Azure. The portal to the cloud services will be the Avnet Microsoft Azure Sphere Starter Kit. We’ll monitor drum cycle time, drum longitudinal strain, drum circumferential strain, and the drum's vertical growth (it can grow over a foot taller during its cycle). To determine cycle time, we’ll simply measure the ambient air change. Since the drum is operating at 800F, a significant increase in ambient temperature is readily measured using the Avnet Azure Sphere Starter Kit. We’ll also record local weather conditions since cold temperatures are when metal can see the most induced stress from thermal shock.
Now, of course, this is a lab experiment, so our simulated coke drum will be a kettle operating up to 100C. But, the cloud will be the actual Microsoft Azure IoT Hub services.
Bill of Materials
Here is the Bill of Materials for the prototype:
Avnet Azure Sphere Starter Kit (1)Avnet Azure Sphere Starter Kit (1)
LM2596 DC to DC Buck Converter 3.0-40V to 1.5-35V Power Supply Step Down Module
TFMini LiDar (1)
3D Printed Case, Custom (1)
GitHub Design Files and Code Repository: https://github.com/RaisingAwesome/CokeDrumAI
AVNET Microsoft Azure Sphere(9)
For the prototype, we made a 3D case with Autodesk Fusion 360. Since our 3D printed case isn’t Class I Div II, we must put it inside a NEMA enclosure to prevent any issues with combustible gases that could leak to the ambient air.
Our Custom 3D Printed Case - Autodesk Fusion 360
To make the most of the Avnet Microsoft Azure Sphere's capabilities with our custom design, we made a small protoboard to connect to the MikroE Click circuits. This allowed us to use some pins for GPIO and also tap into the I2C Bus.
The TFMini, shown below on the right, is used to measure growth of the drum. It simply points to a handrail near the location where we mount our enclosure. As the drum heats up, it will grow upwards and we’ll be able to record that throughout the drum cycle.
DC-DC Buck Converter (left), TFMini Lidar Distance Sensor (Right)
The power available is 24V, the industry standard for field transmitters. So, we use a Buck Converter (above on the left) to step the voltage down to 5Vs to power the card. The card has 3.3V rail to power the other components.
With this setup, we now have the hardware base of our IoT strategy for Coke Drum Health Monitoring.can now program the Avnet Microsoft Azure Sphere using Microsoft Visual Studio.
IoT STRATEGY
The IoT strategy is very straight forward. The Avnet Azure Sphere Module takes the data and securely delivers it to a Microsoft Azure IoT hub. From there a custom web application (see Programming) provides a user interface to the data. In addition, alerts and predictive displays are provided based on Finite Element Analysis calculated from the data and derived from work order data correlations.
ioT Strategy: Measure at the Coker, FEA/Failure Prediction in the Cloud, Provide Web App and Alert Services (3, 10, 11)
THE AZURE CODE
The code for this project is based on the Avnet Azure Sphere Module Out-of-the-Box Demo (12). Rather than paste it all here, I'll just hit on the added code to support this project and provide a link to my GitHub (13) repository for the full working package.
First, I had to update the app-manifest.json to add to the AllowedConnections so that I could it the weather API. In addition, I added the GPIO pins I would use.
app-manifest.json { "SchemaVersion": 1, "Name": "Coke Drum AI V1.0", "ComponentId": "xxxxxx", "EntryPoint": "/bin/app", "CmdArgs": [ "Coke-Drum-AI" ], "Capabilities": { "AllowedConnections": [ "xxxxxxxxxxxxxxxxxxxx", "34.193.179.91", "34.193.12.42", "35.174.96.85", "ec2-52-4-137-27.compute-1.amazonaws.com", "ec2-34-193-12-42.compute-1.amazonaws.com", "ec2-35-174-96-85.compute-1.amazonaws.com", "ec2-52-72-221-205.compute-1.amazonaws.com", "amazonaws.com", "compute-1.amazonaws.com", "52.3.137.27", "52.72.221.205", "iotc-25850c0c-35dd-43de-ab38-4eb5da61a113.azure-devices.net", "darksky.net", "35.174.96.85", "api.darksky.net", "34.193.12.42", "34.193.179.91" ], "Gpio": [ 0, 1, 4, 5, 8, 9, 10, 12, 13, 34, 35, 42 ], "Uart": [], "I2cMaster": [ "ISU2" ], "SpiMaster": [], "WifiConfig": true, }, "ApplicationType": "Default" }
Customizing the Logo
To customize the logo, I found an application LCD Assistant that takes a 128x64 image and converts it to the bytes needed to display it on the OLED.
LCD Assistant Parameters for Code Generation (14)
It easily generated by code for the display.
//------------------------------------------------------------------------------ // File generated by LCD Assistant // http://en.radzio.dxp.pl/bitmap_converter/ //------------------------------------------------------------------------------ const unsigned char avnet [] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0x7C, 0x1F, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x20, 0x70, 0x70, 0x70, 0x70, 0x70, 0xF0, 0xF0, 0xF0, 0x70, 0x00, 0x00, 0xE0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xF0, 0xE0, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xE0, 0xF0, 0x70, 0xF0, 0xF0, 0xE0, 0x00, 0xC0, 0xE0, 0xE0, 0x70, 0x70, 0x70, 0x70, 0xF0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFE, 0x3F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x1F, 0x7F, 0xFE, 0xE0, 0x00, 0xC0, 0xE0, 0xF0, 0xFC, 0xFE, 0xEF, 0xE7, 0xE1, 0xE0, 0x40, 0x00, 0x00, 0x3F, 0x7F, 0xFF, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x1F, 0x3F, 0x7F, 0xFD, 0xEE, 0xEE, 0xE7, 0xE7, 0xF3, 0x73, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF8, 0x7C, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0xFC, 0xFC, 0xFC, 0x1C, 0x1C, 0x1C, 0x1C, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xDF, 0xC7, 0xC1, 0xE0, 0xEF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0x7F, 0x1F, 0x0F, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x03, 0x3F, 0x7F, 0xFE, 0xE0, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x3F, 0x39, 0x38, 0x38, 0x38, 0x38, 0x78, 0xF0, 0xF0, 0xC0, 0x00, 0xF8, 0xFC, 0xFC, 0x38, 0x1C, 0x1C, 0x1C, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x78, 0x3C, 0x1C, 0x1C, 0xFC, 0xFC, 0xF8, 0x00, 0xC0, 0xF0, 0xF8, 0x78, 0x9C, 0x9C, 0xDC, 0xDC, 0xFC, 0xF8, 0x70, 0x00, 0x00, 0xFC, 0xFC, 0xFC, 0x38, 0x3C, 0x1C, 0x7C, 0x7C, 0x78, 0xC0, 0xF0, 0xF8, 0x78, 0x9C, 0x9C, 0xDC, 0xDC, 0xFC, 0xF8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x1E, 0x3E, 0x3C, 0x38, 0x38, 0x38, 0x38, 0x3C, 0x1E, 0x1F, 0x0F, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0x38, 0x38, 0x38, 0x3C, 0x1F, 0x1F, 0x07, 0x00, 0x00, 0x1F, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x1F, 0x00, 0x07, 0x0F, 0x1F, 0x3F, 0x3B, 0x3B, 0x39, 0x39, 0x3C, 0x1C, 0x0C, 0x00, 0x00, 0x1F, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x1F, 0x3F, 0x3B, 0x3B, 0x39, 0x39, 0x3C, 0x1C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
TFMini LIDAR Communication
I2C is a great protocol in that it lets you have multiple devices sharing the same two pins. The Avnet Azure Sphere Module has multiple I2C Buses, but I just needed one for the two I2C devices used: the OLED screen, and the TFMini Lidar detector.
To add it into the Out-of-the-box Demo code, we simply inserted the lines into the initI2c routine. Below is the condensed code for initializing the TFMini and reading the distance detected.
int initI2c(void) { // Begin MT3620 I2C init ... // Initialize TFMini uint8_t my_reset_value = 0x06 ; I2C_DeviceAddress my_TFMini = 0x10; result = I2CMaster_Write(i2cFd, my_TFMini, &my_reset_value, 1); if (result < 0) { Log_Debug("WARNING: TFMini Soft Reset Fail: errno=%d (%s)\n", errno, strerror(errno)); has_TFMini = false; } else { has_TFMini = true; Log_Debug("TFMini Found!\n"); } ... } float readDistance() { //Routine to output the distance to the console if (!has_TFMini) return -1; uint16_t distance = 0; //distance uint16_t strength = 0; // signal strength uint8_t rangeType = 0; //range scale I2C_DeviceAddress myLIDAR = 0x10; uint8_t incoming[7]; //an array of bytes to hold the returned data from the TFMini. uint8_t cmdBuffer[] = { 0x01, 0x02, 7 }; //the bytes to send the request of distance int32_t retVal = I2CMaster_WriteThenRead(i2cFd,myLIDAR,&cmdBuffer[0],3,&incoming[0],7); if (retVal < 0) { Log_Debug("ERROR: seanWriteI2C: errno=%d (%s)\n", errno, strerror(errno)); return -1; } else { Log_Debug("Success: Read Distance!\n"); for (int x = 0; x < 7; x++) { if (x == 0) { //Trigger done if (incoming[x] == 0x00) { Log_Debug("Problem: Distance data not valid-");//for debugging } else if (incoming[x] == 0x01) { Log_Debug("Data valid: "); } } else if (x == 2) distance = incoming[x]; //LSB of the distance value "Dist_L" else if (x == 3) distance |= incoming[x] << 8; //MSB of the distance value "Dist_H" else if (x == 4) strength = incoming[x]; //LSB of signal strength value else if (x == 5) strength |= incoming[x] << 8; //MSB of signal strength value else if (x == 6) rangeType = incoming[x]; //range scale } float the_return = distance / (12 * 2.54); Log_Debug("Distance=%f Feet\n",the_return); return the_return; } return -1; //if we get this far, it failed. }
Accessing a Weather API
To get the current weather, I use the cloud based service DarkSky API (15). I ported code to the Out-of-the-box Demo that takes the API URL string to hit my local weather and collect its JSON response. Here is the base function:
/// <summary> /// Download a web page over HTTPS protocol using cURL. /// </summary> static void PerformWebPageDownload(char the_site[]) { CURL *curlHandle = NULL; CURLcode res = 0; MemoryBlock block = { .data = NULL,.size = 0 }; char *certificatePath = NULL; bool isNetworkingReady = false; if ((Networking_IsNetworkingReady(&isNetworkingReady) < 0) || !isNetworkingReady) { Log_Debug("\nNot doing download because network is not up.\n"); goto exitLabel; } Log_Debug("\n -===- Starting download -===-\n"); // Init the cURL library. if ((res = curl_global_init(CURL_GLOBAL_ALL)) != CURLE_OK) { LogCurlError("curl_global_init", res); goto exitLabel; } if ((curlHandle = curl_easy_init()) == NULL) { Log_Debug("curl_easy_init() failed\n"); goto cleanupLabel; } // Specify URL to download. // Important: any change in the domain name must be reflected in the AllowedConnections // capability in app_manifest.json. if ((res = curl_easy_setopt(curlHandle, CURLOPT_URL, the_site)) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_URL", res); goto cleanupLabel; } // Set output level to verbose. if ((res = curl_easy_setopt(curlHandle, CURLOPT_VERBOSE, 1L)) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_VERBOSE", res); goto cleanupLabel; } // Get the full path to the certificate file used to authenticate the HTTPS server identity. // The DigiCertGlobalRootCA.pem file is the certificate that is used to verify the // server identity. certificatePath = Storage_GetAbsolutePathInImagePackage("certs/DigiCertGlobalRootCA.pem"); if (certificatePath == NULL) { Log_Debug("The certificate path could not be resolved: errno=%d (%s)\n", errno, strerror(errno)); goto cleanupLabel; } // Set the path for the certificate file that cURL uses to validate the server certificate. if ((res = curl_easy_setopt(curlHandle, CURLOPT_CAINFO, certificatePath)) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_CAINFO", res); goto cleanupLabel; } res = curl_easy_setopt(curlHandle, CURLOPT_SSL_VERIFYPEER, false); //don't verify its certificate since it causes problems // Let cURL follow any HTTP 3xx redirects. // Important: any redirection to different domain names requires that domain name to be added to // app_manifest.json. if ((res = curl_easy_setopt(curlHandle, CURLOPT_FOLLOWLOCATION, 1L)) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_FOLLOWLOCATION", res); goto cleanupLabel; } // Set up callback for cURL to use when downloading data. if ((res = curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, StoreDownloadedDataCallback)) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_FOLLOWLOCATION", res); goto cleanupLabel; } // Set the custom parameter of the callback to the memory block. if ((res = curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, (void *)&block)) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_WRITEDATA", res); goto cleanupLabel; } // Specify a user agent. if ((res = curl_easy_setopt(curlHandle, CURLOPT_USERAGENT, "libcurl-agent/1.0")) != CURLE_OK) { LogCurlError("curl_easy_setopt CURLOPT_USERAGENT", res); goto cleanupLabel; } // Perform the download of the web page. if ((res = curl_easy_perform(curlHandle)) != CURLE_OK) { LogCurlError("curl_easy_perform", res); } else { Log_Debug("\n -===- Downloaded content (%zu bytes): -===-\n", block.size); Log_Debug("%s\n", block.data); } char my_data[50000]; memset(my_data,'\0', 50000); strncpy(my_data, block.data, block.size); Log_Debug("My Data: %s\n",my_data); JSON_Value *my_json = json_parse_string("{\"name\":\"\"}"); int the_type = json_value_get_type(my_json); if (json_value_get_type(my_json) != JSONArray) { Log_Debug("JSON not working!\n"); } JSON_Array *my_array = json_value_get_array(my_json); JSON_Object *commit = my_json; Log_Debug("The array: %d", json_array_get_count(my_array)); Log_Debug("Here it is: %s\n", json_object_get_string(my_json, "currently.summary") ); cleanupLabel: // Clean up allocated memory. free(block.data); free(certificatePath); // Clean up sample's cURL resources. curl_easy_cleanup(curlHandle); // Clean up cURL library's resources. curl_global_cleanup(); Log_Debug("\n -===- End of download -===-\n"); exitLabel: return; } //end of https stuff
The integration of all this code is available for download from our GitHub repository at https://github.com/RaisingAwesome/CokeDrumAI
USER WEB INTERFACE
As shown in the section IoT strategy, we desire a web page that will allow the employees at the refinery to see the health assessment provided by the AI. To establish such a web page, its core can be developed in under 5 minutes. Note: this one costs a couple dollars a day regardless of use. So, be sure you are within your free trial if you are experimenting with it. One can also establish a SQL Database to warehouse data to support the drum health assessment calculations.
Below is example code. The CokeAI class is the "money maker" in this example. It would be designed to provide the deep learning calcs and report out the current health assessment:
<%@ Page Title="" Language="VB" MasterPageFile="~/cokedrumAI.master" AutoEventWireup="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.ADO" %> <%@ Import Namespace="System.Data.OleDb" %> <%@ Import Namespace="System.Collections.Generic" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <script runat="server"> Dim CommonRoutines As New Common Dim myCokeAI As New CokeAI Sub Page_Load(Sender As Object, e As EventArgs) drum_report.Text = myCokeAI.GetCurrentHealthReport() drum_visual.Text = myCokeAI.GetCurrentDrumConditionImage() End Sub </script> <main role="main"> <div> <div> <div> <div> <h1>COKE DRUM HEALTH MONITORING PAGE</h1> </div> </div> </div> <div> <div> <div> <a href="https://coke-drum-health-monitoring.azureiotcentral.com/analytics">View Health Trends</a> </div> </div> </div> <div> <div> <div> <asp:label runat="server" ID="drum_visual" /> </div> </div> <div> <div> <asp:label runat="server" ID="drum_report" /> </div> </div> </div> </div> </main> </asp:Content>
The resulting page, viewable on any device, appears as this:
Example Custom Made Azure Web App to Present the Drum Health AI Assessment
The above page is a demo page only as it's not yet 2030 . We don't have our SAP data warehoused with Deep Learning on 10 years of coke drum strain trends correlated to work orders. However, the Azure service strategy is the same today - ready for a company to adopt it to build their future!
By clicking the View Health Trends icon, we can jump over to the Azure Analytics to see the realtime data trending:
Azure Analytics Page Trending in Real Time
LAB DEMONSTRATION
In the field, we would install this module in a Class I Div II enclousre on a beam and power from a local 24V source. Two strain gauges would be installed on the drum at a point of interest.
Rendering of Field Installation
For classroom demonstration, we will simply use a steel pot and boil water while recording the strain and environmental data to the cloud. Let's take a look at the components ready for assembly:
Our Coke Drum Health Monitoring Edge Components
1. Custom 3D Printed Case
2. OLED Display with Custom Graphics
3. Avnet Azure Sphere Module
4. TFMini LIDAR Distance Sensor
5. Resistance Amplifier & Strain Gauge
6. Custom Mikrobus Adapter
Here is our Hookup Guide for this project:
Component Hookup Guide
The Avnet Azure Sphere Starter Kit card comes with two Mikrobus headers. Since we are doing a unique project with the strain gauges, there was not an off-the-shelf component to simply snap in and start using. So, we made component 6, the custom Mikrobus Adapter. This allowed us to connect the TFMini (4) and Resistance Amplifier (5) with a custom cable. We powered it up to see our custom graphic:
Before we began running our code, we first inspected the hardware. We put our very tiny strain gage under a microscope to ensure it didn't have any damage from handling it.
Our Strain Gage Under a Microscope
Since the Azure Sphere ADC accepts 2.5V by default, we rigged up a way to tune our output from the resistance amplifier within 2.5 Volts. We applied 5V to the resistance amplifier and then turned its potentiometer until we were near 2.0 to be on the safe side.
Strain Gauge Output Calibration
Now calibrated and ready to go, we attached our strain gauge.
And finally, we fired up the lab experiment:
Our Lab Experiment
Our Demonstrated Secure IoT AI Framework in Action
PROJECT SUMMARY
The project was a great success in teaching us the Avnet Azure Sphere Module. It also taught us the future of cloud based services for growth companies. We were able to log data through analog GPIO input and I2C communication. We showed how to use sockets to communicate with other Cloud based APIs such as to acquire weather conditions. We also showed how one can make custom graphics and display them on an attached OLED screen. We then demonstrated how to transfer the data logged securely to the cloud where Microsoft hosted our data. Last, we were able to present the data to the end user through an Azure web app. Most importantly, we demonstrated how companies could build custom classes to perform complex calculations and AI on mass amounts of data.
We hope this project demonstrated our prediction that Microsoft will run the world. Their corporate mission statement isn't to run the world, actually, but rather help companies that will:
“to empower every person and every organization on the planet to achieve more."
-Microsoft Corporate Mission Statement
With Big Data meeting Big Oil, optimization can be achieved that would have taken centuries to learn using traditional proprietary means. The ability to perform deep learning on the condition of assets across the globe and providing real time health monitoring will attract companies pursuing growth.
Thanks,
Sean and Connor Miller
Rendering by Sean J. Miller
REFERENCES
[1]Tesla Annual Sales to hit 500000 in 2020: https://insideevs.com/news/323114/tesla-annual-sales-to-hit-500000-in-2020/
[2] In Plant Smart Wireless Solutions: https://www.plantautomation.com/doc/in-plant-smart-wireless-solutions-0001
[3] Wikipedia-Delayed Coker: https://en.wikipedia.org/wiki/Delayed_coker
[4] Fabrication Welding of Coke Drums: Adobe PDF
[5] Hazards of Delayed Coker Unit Operations: https://www.osha.gov/dts/shib/shib082903c_fig1.gif
[6] What you need to know about Strain Gage Measurement Errors: https://willrich.com/need-know-strain-measurement-errors/
[7] Comprehensive Life Assessment of Coke Drum: https://refiningcommunity.com/presentation/comprehensive-life-assessment-of-a-coke-drum/
[8] Weld Overlay for Coker Drum Done Right: https://www.sulzer.com/en/shared/news/2019/06/17/11/36/190618-weld-overlay-for-coker-drum-done-right
[9] Element14.com Azure Sphere Starter Kit Page: https://www.element14.com/community/community/designcenter/azure-sphere-starter-kits?ICID=azure-sphereCH-topbanner
[10] Cloud Image from Sage on Azure: https://www.dynamicsafrica.biz/sage-on-azure/
[11] Tablet clipart from PNGFANs: https://www.pngfans.com/middle-892f1326cfe57c94-ipad-svg.html
[12] Azure Sphere Out of the Box Demo: https://www.element14.com/community/groups/azuresphere/blog/2019/04/24/avnets-azure-sphere-starter-kit-out-of-box-demo-part-1-of-3
[13] Sean J. Miller's Coke Drum AI GitHub Repository: https://github.com/RaisingAwesome/CokeDrumAI
[14] LCD Assistant Software Download Page: http://en.radzio.dxp.pl/bitmap_converter/
[15] Darksky Weather API: https://darksky.net/forecast/38.7681,-90.1125/us12/en
Top Comments