Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat...

51
IN DEGREE PROJECT TECHNOLOGY, FIRST CYCLE, 15 CREDITS , STOCKHOLM SWEDEN 2019 Electrification of valve system MATHIAS NORDQVIST OLLE SVENSSON KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT

Transcript of Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat...

Page 1: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

IN DEGREE PROJECT TECHNOLOGY,FIRST CYCLE, 15 CREDITS

, STOCKHOLM SWEDEN 2019

Electrification of valve system

MATHIAS NORDQVIST

OLLE SVENSSON

KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT

Page 2: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Electrification of valve system

MATHIAS NORDQVISTOLLE SVENSSON

Bachelor’s Thesis at ITMSupervisor: Nihad SubasicExaminer: Nihad Subasic

TRITA-ITM-EX 2019:20

Page 3: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Abstract

This report is going to investigate the possibility to save en-ergy by converting a valve opening mechanism in a wastedisposal system from a pneumatic system to an electricsystem. To power the system, which mainly consists of anelectric actuator and a valve control module, a solar panelsystem was designed. The valve system was controlled bythe lightweight messaging protocol MQTT.

To be able to choose an electric actuator the needed forcewas measured and data regarding maximal stroke was takenfrom the data sheet of the existing setup.

For developing an optimal solar panel system a programwas written in Google Spreadsheet. The program takesinput regarding power, cycles, solar panel system specifi-cations and environmental factors. The output from theprogram is energy consumption for the system, specifica-tion for solar charger, solar panel setup and charge data.

The result was that the solar panel system needed to con-sists of four 12 V VRLA batteries with a capacity of 90 Aheach and four solar panels with a rated power of 300 Weach. The solar charger must be able to handle 900 W andprovide an output current of 25,5 A to fulfil the demands.

The new electric actuator will consume four times less en-ergy than the old pneumatic actuator. Most of the energysavings are consequences of reduced energy consumption atidle of the system.

A demonstarator was built to test the system.

KeywordsMechatronics, Actuator, Solar system, MQTT, Valve con-trol

Page 4: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

ReferatElkonvertering av ventilsystem

Den har rapporten kommer att undersoka mojlighten attspara energi geom att konvertera ett ventiloppningsmekanismi ett avfallshanteringssystem fran ett pneumatiskt systemtill ett elektriskt system. For att driva systemet, som framstbestar av en elektrisk aktuator och en ventil styrenhet, skaett solcellssystem designas. Ventilsystemet ska styras medhjalp lattviktsmeddelandeprotokollet MQTT.

For att kunna valja en aktuator mattes den behovda kraf-ten och data angaende maximal slaglangd togs fran datab-ladet pa den nuvarande konstruktionen.

For att utveckla ett optimalt solcellssystem skrevs ett pro-gram i Google Kalkylark. Programmet anvander energi,cykler, solcellssystem och miljofaktorer som indata. Somutdata ges energiforbrukning hos systemet, specifikation forsolcellsregulator, solpaneler och laddningsdata.

Resultatet var att det solcellssystem som behovs besta avfyra 12 V VRLA batterier med en kapacitet pa 90 Ah varoch fyra solpaneler med en nominell effekt pa 300 W var-dera. Solcellssregulatorn behover kunna hantera 900 W ochgenerera en strom pa 25,5 A.

Den nya elektriska aktuatorn kommer forbruka fyra gangersa lite energi jamfort med den gamla pneumatiska aktua-torn. Den storsta delen av energibesparingarna ar en kon-sekvens av minskad energiforbrukning av systemet i vila.

En prototyp byggdes for att testa systemet.

NyckelordMekatronik, Aktuator, Solcellssystem, MQTT, Ventilstyr-ning

Page 5: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Acknowledgements

We would like to thank everyone who helped us through this project starting withour Envac AB supervisor Niklas Forestier, who have helped us through this projectwith tips and ideas. We would also like to thank our contact at SKF Motion Tech-nologies Hakan Jesperson, for the support with the assignment to find an actuatorwhich would work in this project. We also like to thank the assistants Kayla Kearns,Staffan Qvarnstrom and Seshagopalan Thorapalli Muralidharan for all the help withdeveloping the final demonstrator. A big thanks to Bjorn Finer for helping us setup static IP-addresses.

Last but not least we would like to thank all the other students, assistants andother people who have helped us through this project. Without them, this wouldn’tbe possible.

Olle Svensson and Mathias NordqvistStockholm, May 2019

Page 6: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

List of Abbreviations

AC Alternating CurrentDC Direct CurrentGPIO General-Purpose Input/OutputHDMI High-Definition Multimedia InterfaceLED Light Emitting DiodeLAN Local Area NetworkMono-Si MonocrystallineMOSFET Metal oxide semiconductor field effect transistorMPP Maximum Power PointMPPT Maximum Power Point TrackingMQTT Message Queuing Telemetry TransportPCB Printed Circuit BoardPoly-Si PolycrystallinePWM Pulse-width ModulationRAM Random Access MemoryRPM Revolutions Per MinuteSMHI Swedish Meteorological and Hydrological InstituteSSR Solid State RelayTCP/IP Transmission Control Protocol/Internet ProtocolUSB Universal Serial BusVAC Voltage Alternating CurrentVCM Valve Control ModuleVDC Voltage Direct CurrentVRLA Valve-regulated Lead-acid

Page 7: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Contents

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Theory 52.1 Actuator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1.1 Electric actuator . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.2 Pneumatic actuator . . . . . . . . . . . . . . . . . . . . . . . 6

2.2 Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 Batteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4 Solar panel system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.4.1 Solar panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4.2 Solar charger . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.5 Voltage divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Demonstrator 123.1 Problem formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.3 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.3.1 Test rig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.2 Valve control module . . . . . . . . . . . . . . . . . . . . . . . 133.3.3 Actuator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.3.4 Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.3.5 Batteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.3.6 Solar panel system . . . . . . . . . . . . . . . . . . . . . . . . 153.3.7 Raspberry Pi 3B+ . . . . . . . . . . . . . . . . . . . . . . . . 153.3.8 PCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.4 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.4.1 MQTT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.4.2 JSP flow chart . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Page 8: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

4 Calculations and result 194.1 Pneumatic system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.2 Electric system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5 Discussion and conclusions 215.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

6 Recommendations and future work 23

Bibliography 24

Appendices 26

A Circuitry 27A.1 PCB schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27A.2 PCB board layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27A.3 Complete circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . 28

B Software code 29B.1 Python valve opening code . . . . . . . . . . . . . . . . . . . . . . . 29B.2 Solar system calculator . . . . . . . . . . . . . . . . . . . . . . . . . . 33

C Datasheets 37C.1 Festo actuator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38C.2 Victron Battery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39C.3 SoliTek solar panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40C.4 Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Page 9: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

List of Figures

1.1 The pneumatic waste disposal system [2]. . . . . . . . . . . . . . . . . . 11.2 Existing setup [2]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.1 SKF linear actuator [5]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 SKF rolled ball screw [5]. . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Pneumatic actuator captured with OnePlus 6. . . . . . . . . . . . . . . 72.4 Global irradiance per month for Stockholm from SMHI data made in

Microsoft Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.5 Voltage divider schematic made with Autodesk eagle v. 9.3.2. . . . . . . 11

3.1 Test rig, captured with OnePlus 6. . . . . . . . . . . . . . . . . . . . . . 133.2 VCM, captured with OnePlus 6. . . . . . . . . . . . . . . . . . . . . . . 143.3 Schematic visualization of MQTT, drwan in Microsoft PowerPoint. . . . 16

A.1 Schematic for the PCB made in Autodesk eagle v.9.3.2. . . . . . . . . . 27A.2 Board layout for the PCB made in Autodesk eagle v.9.3.2. . . . . . . . . 27A.3 Complete circuit diagram made in Autodesk eagle v.9.3.2. . . . . . . . . 28

Page 10: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Chapter 1

Introduction

1.1 BackgroundClimate change is one of the biggest challenges in today’s modern society. There areseveral predictions of what the world might look like if we do not lower our energyconsumption rate drastically. What most of the predictions have in common arethat the world will go through a radical change if nothing is done. A report fromIPCC, an intergovernmental body of the United Nations, states that if the planetis warmed over 1,5oC over pre-industrial level the effects on the planet will be longterm. This includes higher risks for natural disasters and rising sea level [1].

This project will investigate the possibility to reduce energy use in a pneumaticwaste disposal system. The waste disposal system uses a low pressure to transportgarbage from local waste bins, up to 2 km to a central disposal station through apipe system. A schematic figure of the system can be seen in Figure 1.1. A valve,which can be seen in Figure 1.2, separates the local waste bin from the pipe system.The local waste bins garbage level is monitored by a control system, which throughoptic sensors can decide when to open the valve emptying the trash into the pipesystem.

Figure 1.1. The pneumatic waste disposal system [2].

1

Page 11: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 1. INTRODUCTION

Presently the system consists of a valve with linkage connected to a pneumatic ac-tuator, which is driven by compressed air coming from the disposal central. It iscontrolled by an electrical control system called a Valve control module, VCM. TheVCM is fed by 48VAC, from the same source as the compressed air. The existingsetup can be seen in Figure 1.2.

Figure 1.2. Existing setup [2].

The goal is to be able to power the new electric actuator and the VCM in a morepro-environmental way. Another motivation for going electrics is less maintenanceand easier installation which leads to reduced costs over time. From SKFs High-performance actuator catalogue (p.17) it can be seen that pneumatic systems onlyoutputs 8% of the power, where the electrical equivalent outputs 80% [3].

Solar panels accompanied by batteries are intended for this project. If this is foundto be possible, an actual implementation will take place in Hammarby Sjostad,Stockholm, Sweden.

2

Page 12: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 1. INTRODUCTION

1.2 PurposeThe purpose of this report is to investigate if it is possible to implement an electricactuation system over the existing pneumatic one and if so, see if it can be poweredusing solar panels and batteries. The research questions to be answered are as fol-lows:

”What will the advantages be in terms of needed power over the existing setup?”

”How should the solar system be designed to be able to supply the system energyall year around?”

1.3 ScopeThis project was made in collaboration with a company, Envac. Their scope wasgiven in two parts:

• Replace a pneumatic actuator with an electrical actuator

• Use solar power for the actuator and the control equipment

The electric source available at the existing setup was an electric feed to the controlsystem which was 48VAC. In case the solar panels would not be able to power thesystem, this must be considered.

There are a lot of different electric motors. The motors relevant for this projectare DC motors as the motor is supposed to be driven from a solar panel system inan effective way. Using a DC motor will exclude the need for expensive inverters.

The project will not investigate how the VCM will be driven, only if it is possi-ble to power the control module using solar panels and batteries. This report is alsolimited to investigate the possibility to supply only one actuator and one controlsystem.

1.4 MethodBy measuring the most limiting parameters the minimal force to operate the valveand opening time, an optimal actuator could be chosen. The surrounding environ-ment also had to be considered, e.g. temperature and moisture.

With data from the actuator and data from Envac regarding opening and clos-ing cycles, the power consumption for the system could be calculated. From this,the number of batteries and solar panels was calculated.

3

Page 13: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 1. INTRODUCTION

By using a test rig the actuator and the control system was implemented to beable to make sure the new system works. The communication system was basedaround a Raspberry Pi microcontroller and the MQTT [4] protocol was used forcommunication between the VCM and a computer.

4

Page 14: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Chapter 2

Theory

2.1 Actuator

2.1.1 Electric actuatorAn actuator is a mechanical component which transfers a torque in an electricalmotor to an axial force in a push tube. The linear actuator consists of mainly threeparts which determine its performance, a motor, a gear and a push tube. A modelcan be seen in Figure 2.1.

Figure 2.1. SKF linear actuator [5].

.

5

Page 15: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 2. THEORY

There are two types of DC motors, brushed DC motor and brushless DC motor.The brushed DC motor is simpler and cheaper compared to the brushless DC motor.The brushed DC motor has brushes that are eventually worn out. The brushlessDC motor has no brushes, hence the name and therefore have better reliability andlongevity.

The push tube is the part on the actuator which performs the work. It is connectedto a nut seen in Figure 2.1 as 4. The nut is put on a screw which is connected tothe motor seen as 3 in 2.1. When the motor is rotating the screw will make the nutpush the push tube. There are several different types of nut and screw, where theball screw is the most common and used one [3]. This can be seen in Figure 2.2.

Figure 2.2. SKF rolled ball screw [5].

.

2.1.2 Pneumatic actuatorThe current pneumatic actuator is a Festo DSBC-100-250-PPSA-N3 and can beseen in Figure 2.3. The actuator uses compressed air to force a piston to move.The air is transported in the blue tubes that can be seen in Figure 2.3. One tubeis to open the valve and one tube is for closing the valve. The working pressure forthe actuator is 6 bar, but it can handle up to 12 bar [6]. This actuator consumes26,6-litre air each cycle [7].

A screw compressor is used to compress the air and a normal specific power forthat type of compressor is 6045 W/m3/min [8]. The energy to compress air is givenby the following formula

E = Es · a · n60 · 1000 [Wh], (2.1)

where Es was the specific energy for the compressor, a the air consumption of theactuators and n number och cycles.

6

Page 16: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 2. THEORY

Figure 2.3. Pneumatic actuator captured with OnePlus 6.

2.2 RelayA relay is used to control a high power circuit with a separate lower power circuit.It acts like an electric switch that is turned on when the lower powered circuit isturned on. Different types of relays exist. The most commonly used relay consists ofan electromagnet that mechanically operates a switch and is called a contact relay.Two variants of contact relays are latching and non-latching. The latching variantneeds one pulse on the low power circuit to move the contact in one direction andanother redirected pulse to move it back. The latching relays will not return to asafe off state upon power loss on the low power circuit. These types can have eitherone or two coils. The none latching has one low power circuit and is spring loaded

7

Page 17: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 2. THEORY

so when no power is supplied on the low power circuit the high power circuit isturned off. This is good in applications where power is lost on the low power circuitthe switch must return to an off state.

Solid-state-relay, SSR is another type of relay and uses no mechanically movingparts which makes it. Instead, it uses a photo-sensitive MOSFET which is acti-vated by an LED and is more robust and has longer longevity than mechanicalrelays. SSRs can also switch on and off faster than then contact relays and requireless current for turning on [9].

2.3 BatteriesThe properties that need to be considered in this project is maximum power out-put, energy capacity, number of cycles before degradation starts, volume, cost andif it is temperature sensitive. There are different types of batteries one of whichlithium-ion is one of the more famous types today, due to its high specific energy,small volume and high cycle number. But these batteries are expensive and doesnot allow for low-temperature charging. They should not be charged at all below0C and preferably not below 5C [10].

Another common type is a valve-regulated lead-acid, VRLA, battery or more com-monly referred to as gel-battery. These types of lead-acid batteries have lower spe-cific energy, are larger in volume and a lower number of total cycles than lithium-ion.The advantage, however, is that it can be charge in sub-zero environments and ischeaper than lithium-ion batteries.

When discharging a VRLA battery the effective capacity that can be taken outis changed with the temperature and the discharging current. The capacity willdecrease as the temperature gets lower and with higher discharge current. Thebattery’s number of charge and discharge cycles is dependent on how deep it isdischarged. If the discharge is low the number of cycles is higher [11].

2.4 Solar panel system

2.4.1 Solar panelsCurrently the most widely used panels are monocrystalline solar, mono-Si, panelsand polycrystalline solar panels, poly-Si. Mono-Si has higher efficiency [12] and alonger life span but is more expensive than poly-Si.Solar panels rated power are tested at 1000 W/m2 and 25C [13]. In Sweden, theaverage is 950 kWh/m2 per year [14], but the solar irradiance varies much over theyear. The worst case scenario will be the winter season because the solar irradianceis lower, which can be seen in Figure 2.4. The data is obtained from SMHI web

8

Page 18: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 2. THEORY

page and is averaged over the data period 1983 to 2014 [15].

Regarding the optimal tilt angle, βopt for the solar panel, one rule of thumb is

βopt = θ ± 15, (2.2)

where θ is the locations latitude and the plus and minus signs is for summer andwinter respectively [16].

Figure 2.4. Global irradiance per month for Stockholm from SMHI data made inMicrosoft Excel.

2.4.2 Solar chargerTo be able to charge the batteries a regulator is needed to maintain stable outputvoltage from the solar panels to the batteries. There are different technologies forregulating solar panels power output. The two main types are pulse width modu-lated, PWM, controller or maximum power point tracking, MPPT, controller. Ofthese two the MPPT has higher efficiency. According to Victron Energy [17], PWMcontroller had a 19% lower power output than the MPPT controller at 25C.

The idea with an MPPT controller is that there exists a unique point on the voltage-power curve of the solar cells, where the total system (including solar panel set, reg-ulator, etc.) operates at its maximum efficiency. This is called the maximum powerpoint, MPP. The exact point is not known but can be found with calculation orsearch models and with MPPT techniques be kept there to produce the maximumpower output [18]. This is achieved by variate the load on the solar cells to keep theefficiency at the peak all the time, which is good when the sunlight is not consistent.

9

Page 19: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 2. THEORY

Unlike the MPPT which is a DC-DC transformer, the PWM controller is not. It isa switch which connects the panels to the batteries and when closed will charge thebatteries. The PWM controller will switch on and off at different rates to maintainthe desired charging voltage. When the desired voltage on the batteries is reachedit will start to connect and disconnect the panels to prevent overcharging.

2.5 Voltage dividerMost of the microcontrollers available at the market today are not able to managehigh voltage on its analogue input. This report is going to investigate the possibilityto save energy by converting a valve opening mechanism in a waste disposal systemfrom a pneumatic system to an electric system. To power the system, which mainlyconsists of an electric actuator and a valve control module, a solar panel system wasdesigned. The valve system was controlled by the lightweight messaging protocolMQTT.

To be able to choose an electric actuator the needed force was measured and dataregarding maximal stroke was taken from the data sheet of the existing setup.

For developing an optimal solar panel system a program was written in GoogleSpreadsheet. The program takes input regarding power, cycles, solar panel systemspecifications and environmental factors. The output from the program is energyconsumption for the system, specification for solar charger, solar panel setup andcharge data.

The result was that the solar panel system needed to consists of four 12 V VRLAbatteries with a capacity of 90 Ah each and four solar panels with a rated powerof 300 W each. The solar charger must be able to handle 900 W and provide anoutput current of 25,5 A to fulfill the demands.

The new electric actuator will consume four times less energy than the old pneu-matic actuator. Most of the energy savings are consequences of reduced energyconsumption at idle of the system.One way to solve this is by using a voltage divider that consists of two resistorsin series, which can be seen in Figure 2.5. By knowing from Kirchoff’s voltage lawthat the sum of all voltage potentials in a closed loop must be zero. The formulafor the voltage divider becomes

Vout = R2R1 +R2

Vin. (2.3)

10

Page 20: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 2. THEORY

Figure 2.5. Voltage divider schematic made with Autodesk eagle v. 9.3.2.

11

Page 21: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Chapter 3

Demonstrator

3.1 Problem formulationTo be able to make sure the actuator actually can be implemented a real size testrig was set up in the lab. The actuator was driven by batteries which were chargedby the solar system and if needed battery chargers connected to the main AC outletwas used.

3.2 ComponentsIt was requested by Envac that all the components should be made for industrialuse. The goal was to buy as many components as possible, to be able to easilyreproduce the product.

3.3 HardwareThe electric actuator was mounted on the test rig using an adapter made by Envacso that the new actuator would fit on the existing construction. Two 24 VDC relayswere connected to the actuator via 2.5 mm2 cables. The relays were supplied powerfrom two 12 V Victron VRLA batteries connected in series to provide 24 VDC. Therelays’ switch signal was supplied from the valve control module, VCM, which wasprovided by Envac. For charging the batteries the solar panel was connected to thesolar charge controller, which in turn was connected to the batteries. A completecircuit diagram for the test rig can be found in Appendix A.2. A Raspberry Pi 3B+was used as a broker.

12

Page 22: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 3. DEMONSTRATOR

3.3.1 Test rigThe test rig, seen in Figure 3.1, consists of a DVF2 dn 500 flap valve provided byEnvac. An adapter produced by Envac is mounted on the flap valve to be able toinstall the new electric actuator.

Figure 3.1. Test rig, captured with OnePlus 6.

3.3.2 Valve control moduleThe valve control module, VCM, is a microcomputer developed for Envac’s needs.It is powered by 48 VDC or 48 VAC. It is possible to connect the module to theinternet via an Ethernet port. Two Molex connectors give the VCM 28 digitalinputs, 24 digital outputs and 7 analogue inputs. The VCM can be seen in Figure3.2

13

Page 23: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 3. DEMONSTRATOR

Figure 3.2. VCM, captured with OnePlus 6.

3.3.3 ActuatorThe actuator is a CAHB-22E, from SKF with a 24 VDC brushed DC motor. Itis a linear actuator and its stroke is 200 mm. The rated force is 3500 N and amaximal force of 4900 N which it can provide for a short period of time. The ratedcurrent is 11 A, maximal 25,5 A and its rated speed is 37 mm/s. Its duty cycle ismaximal 20% and the minimum temperature is −40C [19]. The unit comes withover-temperature protection and mechanical overload protection.

The minimal force needed for closing the valve was measured to 2,2 kN by En-vac and they specified a safety factor of two which gave the minimal required forceof 4,4 kN. The low DC voltage made it possible to get an affordable and spaceefficient system. This actuator was slower than the original pneumatic actuator butwas still considered fast enough.

14

Page 24: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 3. DEMONSTRATOR

3.3.4 RelayThe relays that were used were two 24 V automotive non-latching mechanical relayswhich can handle a current of 50 A. The coil resistance was 255 Ω. Datasheet canbe found in Appendix C.3. These relays were chosen because of their low price andhigh current capability. An SSR relays could not be found with the specificationsneeded and there is no need for fast switching in this application.

3.3.5 BatteriesFor this project, two 12 V Victron VRLA batteries were used. The batteries wereconnected in series to give 24 V output, and they had a capacity of 90 Ah each.Their dimensions were 350 x 167 x 183 mm, and they weighed 26 Kg each[20]. Thesebatteries were chosen because of their deep discharge capability and good price inrelation to capacity.

3.3.6 Solar panel systemThe solar panel system consists of two parts, a solar panel and a regulator. Thesolar panel used was a SoliTek standard monocrystalline 60 cell module, which hasa rated power is 300 W and a rated voltage is 32.15 V. Its dimensions are 1645x 985 x 35 mm. The panel can take a snow load of 5400 Pa and the minimumtemperature is −40C [21].

The solar charge controller used was an EPsolar Tracer2215BN, which is an MPPTcontroller designed for both 12 VDC and 24 VDC systems. It has a peak conversionefficiency of 98 %, and the ability to monitor the solar panel system and settingscan be altered to handle different kinds of batteries. The regulator has rated outputload current of 20 A and can manage a minimum temperature of −35C [22].

3.3.7 Raspberry Pi 3B+Raspberry Pi 3B+ is a microcomputer with a 1,4 GHz 64-bit quad core processorand 1 GB RAM. The input via USB is 5 VDC and 2,5 A. There are 4 USB ports, anHDMI port and an ethernet port. It has Bluetooth 4.2, 2,4 GHz and 5 GHz wirelessLAN. The Raspberry Pi 3+ also has 40 GPIO pins and several other connectionsto be able to connect hardware. Raspbian Lite release 9.9, which is a Linux basedoperating system, and Python 3.5.3 is installed [23]. For demonstration purposeonly, a web server was setup using nginx 1.10.3 and a simple web page was made withvideo feedback from a Logitech E3500 web camera, implemented using a programcalled Motion.

15

Page 25: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 3. DEMONSTRATOR

3.3.8 PCBThe PCB schematic and board layout was made in Autodesk eagle version 9.3.2and was milled on a LPKF ProtoMat S63. The PCB consists of two parts, one forchecking the battery voltage using a voltage divider and connecting the analogueinput of the VCM to the PCB. This was done because the VCM’s analogue inputrange is 0-10VDC and the battery voltage is higher than that at a maximum of 14,4V when charging. The other part was for the relays and the end-position microswitches. For the end-position micro switches, there is one pull-down resistor foreach switch, so that the VCM will have a well-defined high and low state on itsdigital input. The schematics and board layout can be seen in Appendix A.1.

3.4 Software

3.4.1 MQTTMQTT stands for Message Queuing Telemetry Transport and is a lightweight tcp/ipprotocol which uses a client publish/subscribe structure [24]. This means a clientcan subscribe or publish messages on certain topics using a server called a broker. Aschematic visualization of this can be seen in Figure 3.3. Clients can both subscribeand publish to a topic or either. The information from a client that publishes on onetopic can then, for example execute commands on another client which subscribeto the same topic. A client can be a computer, a display, a sensor, etc.

Figure 3.3. Schematic visualization of MQTT, drwan in Microsoft PowerPoint.

The protocol, which is an ISO-standard is simple, open and easy to use. This makesit optimal for applications with machine to machine communication and Internet ofThings (IoT) [24]. For this project Eclipse Mosquitto was chosen and is the samethat Envac uses. Eclipse Mosquitto is open source and uses MQTT protocol ver-sions 3.1 and 3.1.1[25].

All communication over the MQTT protocol goes via the broker. To send com-mands to the VCM a computer was set up as a client. The computer was running

16

Page 26: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 3. DEMONSTRATOR

Python 3.6.7 and used Eclipse Paho MQTT library for python. This library usesversion 3.1 and 3.1.1 of the MQTT protocol. The python code which the computeruses can be found in Appendix B.1.

17

Page 27: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 3. DEMONSTRATOR

3.4.2 JSP flow chart

Create valveopening client

Setup client withconnection and functions

Publish message tobroker to start motor

Turn off motor andpause for 4 sec

Publish message tobroker to reverse motor

Turn off motorand disconnected

Publish message to turnoff motor and disconnect

Recives message end is reached

Recives message start is reached

18

Page 28: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Chapter 4

Calculations and result

4.1 Pneumatic systemThe energy consumption, was calculated with equation (2.1) and gave that thepneumatic actuator uses approximately 16,1 Wh per day. The number of cycleswas given from Envac as six per day and the rest of the parameters can be foundin the chapter Theory.

4.2 Electric systemTo be able to know if the solar panel system was sufficient and to be able to re-produce the result in different similar projects a program was written in GoogleSpreadsheets. On the first three spreadsheet pages, the program takes input aboutthe actuator, solar system and constants regarding environment and safety factor.All input about the hardware should be possible to find in datasheets and informa-tion about weather conditions needs to be estimated with help from statistics fromformer years. All input should be given as worst-case scenarios to ensure the solarpanel system is sufficient even in the worst conditions.

All formulas used in the calculation can be found in Hans B Johansson’s book”Elektroteknik” [26] and is regarded as trivial. Other used formulas that are re-garded as non-trivial, can be found in this report under Chapter 2, Theory.

The program with given input data can be seen in Appendix B.2. The result wasthat four 12 V VRLA batteries of 90 Ah each and three solar panels with a ratedpower output of 300 W each were needed. The solar charger must be able to handle900 W and give an output current of 25,5 A. The electric actuator will consume 4Wh per day in average if the valve is opened six times a day. The VCM’s power con-sumption 165,6 Wh per day. This gives a total power consumption of 169,6 Wh per

19

Page 29: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 4. CALCULATIONS AND RESULT

day on average for the complete valve opening system. Due to the lower irradiancein the winter season, the panels angle will be fixed for, 44, which is optimal forwinter, throughout the year. This results is acquired by using Stockholm’s latitudeof 59 and (2.2) and is implemented into the program.

20

Page 30: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Chapter 5

Discussion and conclusions

5.1 DiscussionThe first prediction was that a 300 W solar panel and two 12 V batteries of 90Ah each would be sufficient to supply the VCM and the actuator all year around,which in total consumes 170 Wh per day. This was approximated with the averagesolar irradiance each year in Stockholm and a rather big safety factor to take intoaccount for winter when the solar irradiance is much lower.

With data from SMHI giving the solar irradiance each month from 1983 to 2014it could be observed that the lowest solar irradiance was in December 1997 of 3,59kWh [15]. This was much lower than expected and made the original solar panelsystem insufficient this part of the year which meant that it needed to be scaled up.The second worst month is January which had a minimal solar irradiance of 6 kWhthe same year, which is significantly higher than in December.

When the solar panel system was fully analyzed the result was that the solar panelsystem needed to be redesigned as in the calculation chapter. The new solution isa balance between minimizing cost, space and making sure that the system is ableto supply all components with power even in worst possible conditions. With thesolar irradiance of December 1997, the batteries would have discharged 70 % after34 days. January the same year the system would have gained positive net energyinto the system (more energy in than out) and would so, have made it through theentire year. As this is the worst-case year, it is reasoned that this system will beenough to manage all year around.

This solar panel system might seem excessive to only power one actuator and theVCM, but this is only because of the low irradiance in December. One motivationto implement this larger solar panel system would be if more than one actuatoris powered. Due to the low energy consumption of the actuator compared to theVCM over a day, this would be possible. If the system is used in another part of

21

Page 31: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

CHAPTER 5. DISCUSSION AND CONCLUSIONS

the world with a more even distribution of irradiance, it can be greatly reduced.

In the result, it is presented that the electric actuator power consumption is 4Wh per day. This compared to the old pneumatic actuator that consumes 16,1 Wh,is a rather great improvement. The power consumption of the pneumatic actuatordoes not consider the power that is consumed because of potential leakage in thesystem. This is one of the major downsides in today’s pneumatic configuration.The actuators cycle time is only a few seconds a couple of times a day, the idle timeis therefore high and leakage over time will be a pure waste of energy. With theelectric actuator, energy is only consumed when doing work and none during idle.

Another aspect is the maintenance side, where the pneumatic system needs moremaintenance on both the actuators but also the piping, making sure that there areno massive leaks and the compressor. Regarding the electric actuator and the solarpanel system, the maintenance required is less. The actuator has little to nonemaintenance due to its low run time and same goes for the solar panel system..However, the batteries may need some attention after a few years, but they arerated for many years of use and is easily replaceable.

5.2 ConclusionThe solar panel system can be designed in many ways depending on the site andlocation. To power one actuator this system might be excessive, but if it is scaledup powering three or more actuators, it might be more economically justifiable.

The electric actuator will need about four times less power than the pneumaticactuator. That energy is almost negligible compared to the VCM which needs 42,5times more energy on average per day than the electric actuator. The biggest ad-vantages are the lowered energy consumption due to no power losses during idleand less maintenance.

22

Page 32: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Chapter 6

Recommendations and future work

To improve the system, there are a few things that could be done. Due to lack oftime, this project only investigated the possibility to use actuators from SKF Mo-tion Technology. To get a faster valve opening mechanism other actuator suppliersshould be considered.

In the result, it is given that the VCM’s power consumption is 165,6 Wh per day.To reduce the solar system, making it cheaper and more environmentally friendly asolution to reduce this power consumption could be looked upon. Now the VCM isalways on, but maybe it would be possible to have it start only once every hour orsuch to measure the level in the waste system.

The solar system also gets extensive to be able to power the system through De-cember which has the lowest solar irradiance. If it is possible to power the systemin another way, e.g. Wind power, for the darkest part of the year the solar panelsystem can be reduced.

All the calculations for the solar system are based on former data from SMHI inStockholm. To make sure the solar system is optimal a more detailed sun investi-gation at the specific location should be done.

23

Page 33: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Bibliography

[1] Myles Allen et al. “GLOBAL WARMING OF 1.5oC - an IPCC special reporton the impacts of global warming of 1.5oC above pre-industrial levels and re-lated global greenhouse gas emission pathways, in the context of strengtheningthe global response to the threat of climate change, sustainable development,and efforts to eradicate poverty”. In: (Oct. 2018).

[2] Envac AB. Electrification of waste inlet. Jan. 2019.[3] SKF. High performance actuator catalogue. 2019. url: https://www.skf.

com/binary/21-455810/High-performance-actuator_PDF-file,_low_resolution,_72_DPI_locked_for_editing.pdf (visited on 02/03/2019).

[4] MQTT. MQTT. 2019. url: http://mqtt.org/ (visited on 02/03/2019).[5] SKF. url: https://www.skfmotiontechnologies.com/sites/default/

files/Actuator_range_catalogue.pdf (visited on 02/13/2019).[6] Festo. Standards-based cylinders DSBC, to ISO 15552. Apr. 2019. url: https:

//www.festo.com/cat/xdki/data/doc_engb/PDF/EN/DSBC_EN.PDF.[7] Festo. Cylinder Air Consumption. May 2019. url: https://www.festo.com/

cat/sv_se/products?PreSelID=90010.[8] BIAB Tryckluft. Tryckluftsguiden. Apr. 2019. url: http://www.jemtluft.

se / shop / assets / shop _ files / tryckluftguiden _ 2011 _ .pdf ? fbclid =IwAR3sPE4MO8r1UpVEm9jmrJhHy11Nd_URVMN5mDg6rrPSfEIMMIcHC2CsrpI.

[9] CA Solid States Optronics San Jose. Application Note, Solid State RElaysVs Electromechanical Relays. Oct. 2014. url: http://www.ssousa.com/application-notes/AppNote040_Solid-State-Relays-vs-Electromechanical-Relays.pdf.

[10] Sony Corporation. Lithium Ion Rechargeable Batteries Technical Handbook.url: https://web.archive.org/web/20090411024100/http://www.sony.com.cn/products/ed/battery/download.pdf.

[11] Victron Energy B.V — De Paal 35 — 1351 JG Almere — The Netherlands.url: https://www.victronenergy.se/upload/documents/Datasheet-GEL-and-AGM-Batteries-EN.pdf (visited on 03/21/2019).

24

Page 34: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

BIBLIOGRAPHY

[12] Fraunhofer. url: https://www.ise.fraunhofer.de/content/dam/ise/de/documents/publications/studies/Photovoltaics- Report.pdf (visitedon 02/13/2019).

[13] M. G. Vemula et al. “Power rating of photovoltaic modules per IEC 61853-1standard using a new outdoor test method”. In: 2013 IEEE 39th PhotovoltaicSpecialists Conference (PVSC). June 2013, pp. 0724–0728. doi: 10.1109/PVSC.2013.6744253.

[14] Johan Lindahl. National Survey Report of PV Power Applications in Sweden2016. Oct. 2017.

[15] Sveriges meteorologiska och hydrologiska institut. Stralningsdata manadsvarden.2015. url: https://www.smhi.se/kunskapsbanken/meteorologi/solstralning-i-sverige-1.89984.

[16] Omaymah Husni Bany Salman Qais Azzam Khasawneh Qatada AbdullahDamra. Determining the Optimum Tilt Angle for Solar Applications in North-ern Jordan. Tech. rep. P.O. Box 3030, Irbid, Jordan: Jordan University ofScience and Technology, May 2015. url: http://jjmie.hu.edu.jo/vol9-3/JJMIE-181-14-01%5C%20Proof%5C%20Reading%5C%20ok.pdf.

[17] Victron Energy B.V — De Paal 35 — 1351 JG Almere — The Nether-lands. url: https://www.victronenergy.com/upload/documents/White-paper-Which-solar-charge-controller-PWM-or-MPPT.pdf (visited on02/13/2019).

[18] SONIA LEVA ROBERTO FARANDA. url: https://pdfs.semanticscholar.org/a535/786eaceec7333e1e2c1325a538c4a2b1265b.pdf (visited on 02/13/2019).

[19] SKF Motion Technologies. CAHB-22E datasheet. url: https://www.skfmotiontechnologies.com/sites/default/files/CAHB-22E_datasheet.pdf (visited on 03/21/2019).

[20] Victron Energy. Certifikat victron md 12v 90ah gel deep cycle batt. June 2018.url: https : / / shop . solelgrossisten . se / Media / filarkiv / victron /batterier % 5C % 20victron / gel - batterier / certifikat / certifikat -victron-md-12v-90ah-gel-deep-cycle-batt..pdf (visited on 03/21/2019).

[21] SoliTek. Solitek datasheet mono 60 cell 300 W. Mar. 2019. url: https://shop.solelgrossisten.se/Media/filarkiv/solitek/datablad/solitek-datablad-mono-60-cell-300w.pdf.

[22] EP Solar. MPPT Solar charge controller. url: https://shop.solelgrossisten.se/Media/filarkiv/epsolar/tracerbn/tracer-bn-spec.pdf (visited on03/21/2019).

[23] the Raspberry Pi Foundation. Raspberry Pi 3 Model B+. url: https://static.raspberrypi.org/files/product-briefs/Raspberry-Pi-Model-Bplus-Product-Brief.pdf (visited on 03/21/2019).

[24] International Organization for Standardization. June 2016. url: https://www.iso.org/standard/69466.html (visited on 03/18/2019).

25

Page 35: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

BIBLIOGRAPHY

[25] Eclipse Foundation. Eclipse Mosquitto: An open source MQTT broker. url:https://mosquitto.org/ (visited on 03/22/2019).

[26] Hans B Johansson. Elektroteknik. Kungliga Tekniska Hogskolan. Institutionenfor Maskinkonstruktion, Mekatronik., 2013.

26

Page 36: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Appendix A

Circuitry

A.1 PCB schematic

Figure A.1. Schematic for the PCB made in Autodesk eagle v.9.3.2.

A.2 PCB board layout

Figure A.2. Board layout for the PCB made in Autodesk eagle v.9.3.2.

27

Page 37: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX A. CIRCUITRY

A.3 Complete circuit diagram

Figure A.3. Complete circuit diagram made in Autodesk eagle v.9.3.2.

28

Page 38: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Appendix B

Software code

B.1 Python valve opening code

# MATHIAS NORDQVIST and OLLE SVENSSON# Python code for MF133X, 2019 Bachelors thesis in Mechatronics, # Electrification of valve system

import timeimport paho . mqtt . c l i e n t as mqttimport j s o nimport s y s

# Define b r o k e r IP−a d d r e s s and system p r e f i xbroker=” 1 3 0 . 2 3 7 . 5 9 . 1 1 2 ”s y s t e m p r e f i x = ” kth /000593 ”

######################################################## #Inputs , o u t p u t s and c o n s t a n t s ########################################################

# Define d i g i t a l o u t p u t s connected t o r e l a y 1 and r e l a y 2

actuator open do = 17 #p u r p l e c a b l e co lor , r e l a y 1a c t u a t o r c l o s e d o = 20 #brown c a b l e co lor , r e l a y 2

# Define d i g i t a l i n p u t s connected to s t a r t and end sensors e n s o r e n d d i = 19 # gray c a b l e c o l o rs e n s o r s t a r t d i = 23 #pink c a b l e c o l o r

# Define time the v a l v e w i l l be open in secondst ime open = 3#########################################################Topics######################################################### Define t o p i c f o r sending commands to d i g i t l a o u t p u t s and read ing# s t a t u s on d i g i t a l inpu t

29

Page 39: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

a c t u a t o r o p e n t o p i c = s y s t e m p r e f i x + ”/ i o /cmd/do/” + str ( actuator open do )a c t u a t o r c l o s e t o p i c = s y s t e m p r e f i x + ”/ i o /cmd/do/” + str ( a c t u a t o r c l o s e d o )s e n s o r t o p i c = s y s t e m p r e f i x + ”/ i o / s t a t u s / d i ”

######################################################### Payload######################################################### Define j son s t r i n g s f o r tu rn in g on and o f f d i g i t a l o u t p u t son = json . dumps( ” value ” : 1 )o f f = j son . dumps( ” value ” : 0 )

######################################################### C a l l b a c k f u n c t i o n s f o r the l i m i t s w i t c h e s######################################################### Define f u n c t i o n f o r when l i m i t s w i t c h e s s t a t u s changedef l i m i t s w i t c h c a l l b a c k ( c l i e n t , userdata , message ) :

# Reading data from message sen t over MQTTpayload = json . l oads ( message . payload . decode ( ’UTF−8 ’ ) )

# Take out the s t a t u s f o r end and s t a r t l i m i t s w i t c hs ta tu s end = payload [ ’ va lue ’ ] [ ’ i o d i ’ ] [ s en so r end d i −1]s t a t u s s t a r t = payload [ ’ va lue ’ ] [ ’ i o d i ’ ] [ s e n s o r s t a r t d i −1]

# I f end s t a t u s i s zero means i t i s p res s edi f s ta tu s end == 0 :

# P u b l i s h message to s top motorc l i e n t . pub l i sh ( ac tua to r open top i c , o f f )

print ( ’The va lve i s now open ’ )

# I f s t a r t s t a t u s i s zero means i t i s pres sede l i f s t a t u s s t a r t == 0 :

print ( ’The va lve i s now c l o s e d ’ )# P u b l i s h message to s top motorc l i e n t . pub l i sh ( a c t u a t o r c l o s e t o p i c , o f f )

# Disconnects the c l i e n t ending the programc l i e n t . d i s connec t ( )print ( ’ Disconnected ’ )

# Define f u n c t i o n to r e v e r s e the motor

30

Page 40: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

def r e v e r s e c a l l b a c k ( c l i e n t , userdata , message ) :

# Reading data from message sen t over MQTTpayload = json . l oads ( message . payload . decode ( ’UTF−8 ’ ) )

# Take out the s t a t u s f o r the motors t a t u s = payload [ ’ va lue ’ ]

# I f the opening i s f i n i s h e di f s t a t u s == 0 :

# Pause f o r t ime open secondstime . s l e e p ( t ime open )

# Then s t a r t c l o s i n g the v a l v ec l i e n t . pub l i sh ( a c t u a t o r c l o s e t o p i c , on )

# Function to s t a r t opening the v a l v edef open va lve ( ) :

# Creates c l i e n t to open the v a l v ec l i e n t = mqtt . C l i en t ( ” V a l v e c o n t r o l l ” )

#####################################################Binding c a l l b a c k f u n c t i o n s####################################################

# Adds f u n c t i o n s to the c l i e n tc l i e n t . message ca l lback add ( s e n s o r t o p i c , l i m i t s w i t c h c a l l b a c k )c l i e n t . message ca l lback add ( ac tua to r open top i c , r e v e r s e c a l l b a c k )

#####################################################Connecting to broker , s u b s c r i b i n g to se nsor s# and s t a r t s l o o p i n g####################################################

# Connect c l i e n t to the brokerc l i e n t . connect ( broker , 10883)

# S u b s c r i b e to the sensor t o p i c to g e t updates when they changec l i e n t . su b s c r i b e ( s e n s o r t o p i c )

# S u b s c r i b e to a c t u a t o r open t o p i c to know when the v a l v e i s openc l i e n t . su b s c r i b e ( a c t u a t o r o p e n t o p i c )

31

Page 41: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

##################################################### Open v a l v e####################################################

# P u b l i s h message to s t a r t opening the v a l v ec l i e n t . pub l i sh ( ac tua to r open top i c , on )

# S t a r t l o o p i n g the c l i e n t u n t i l i t d i s c o n n e c t sc l i e n t . l o o p f o r e v e r ( )print ( ’ Loop ended ’ )

32

Page 42: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

B.2 Solar system calculator

33

Page 43: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

34

Page 44: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

35

Page 45: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX B. SOFTWARE CODE

36

Page 46: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

Appendix C

Datasheets

37

Page 47: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX C. DATASHEETS

C.1 Festo actuator

38

Page 48: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX C. DATASHEETS

C.2 Victron Battery

39

Page 49: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX C. DATASHEETS

C.3 SoliTek solar panel

40

Page 50: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

APPENDIX C. DATASHEETS

C.4 Relay

41

Page 51: Electrification of valve system - kth.diva-portal.org1373920/FULLTEXT01.pdf · Referat Elkonvertering av ventilsystem Den h¨ar rapporten kommer att unders ¨oka m ¨ojlighten att

TRITA ITM-EX 2019:20

www.kth.se