Bachelor of Engineering Technology ENB7904 Co-operative Learning Project (Electronics) Weather Station PLC Project Hussain Mustafa Student Name: Hassan Radhi Student ID: 20900009 CPR: 910404577 Tutor: David Krause Table of Contents Table of Figures ....................................................................................................................................... 2 Table of Tables ........................................................................................................................................ 4 Abstract: .................................................................................................................................................. 5 Introduction: ........................................................................................................................................... 6 Industry applications:.............................................................................................................................. 6 Objectives and task description: ............................................................................................................. 7 Weather station circuit: Mbed circuit:................................................................................................ 8 Pressure sensor circuit: ................................................................................................................... 9 Wind vane sensor circuit:.............................................................................................................. 12 The anemometer circuit: .............................................................................................................. 13 Temperature sensor:..................................................................................................................... 16 7-segment circuit: ......................................................................................................................... 18 Voltage circuit using LM2576:....................................................................................................... 20 LEDs circuit: ................................................................................................................................... 23 Humidity circuit:............................................................................................................................ 24 Thumbwheel switch: ..................................................................................................................... 25 Hardware Fabricarion: ...................................................................................................................... 26 Weather station box: .................................................................................................................... 26 Printed circuit board: .................................................................................................................... 29 Board platform: ............................................................................................................................. 31 Software: ............................................................................................................................................... 32 Program functionality: ...................................................................................................................... 32 MBED code:................................................................................................................................... 33 PLC code: ....................................................................................................................................... 41 the input/output list: ........................................................................................................................ 56 Virtual Instruments: .......................................................................................................................... 57 SCADA (supervisory and data acquisition): ................................................................................... 57 HMI (Human machine interface): ................................................................................................. 58 .............................................................................................................................................................. 60 Disscusion: ............................................................................................................................................ 61 Voltage regulators:............................................................................................................................ 61 Instrument Amplifier for the pressure sensor: ................................................................................. 63 Temperature sensor: ........................................................................................................................ 63 1|Page Pressure simulation mechanism: ...................................................................................................... 64 Recommantoinas: ................................................................................................................................. 65 Appendix: .............................................................................................................................................. 66 Footprints with 3D models ............................................................................................................... 66 References ............................................................................................................................................ 74 Table of Figures Figure 1 sensor circuit ................................................................................................................ 7 Figure 2 Voltage divider diagram ............................................................................................... 8 Figure 3 Pressure sensor ............................................................................................................ 9 Figure 4 Instrumentation amplifierINA126 with pin configuration ........................................... 9 Figure 5 Pressure sensor circuit ............................................................................................... 10 Figure 6 Wind Vane Internal Connection................................................................................. 12 Figure 7 Wind speed sensor ..................................................................................................... 13 Figure 8 weather head circuit .................................................................................................. 14 Figure 9 4 To 20 mA Current Source (0°C to +100°C) circuit ................................................... 16 Figure 10 temperature sensor LM35DZ ................................................................................... 16 Figure 11 7-segment circuit ..................................................................................................... 17 Figure 12 Decoder Pin Out ....................................................................................................... 18 Figure 13 Voltage divider diagram ........................................................................................... 19 Figure 14 LM2576-Adj 5 volt circuit ......................................................................................... 20 Figure 15 LM2576-Adj 10 volt circuit ....................................................................................... 20 Figure 16 Inductor value selection graph guide ...................................................................... 21 Figure 17 LED circuit ................................................................................................................ 23 Figure 18 LinPicco A05 Basic humidity sensor ......................................................................... 24 Figure 19 Truth table Figure 20 Thumbwheel switch ................................................................................................................. 25 Figure 21 Thumbwheel circuit ................................................................................................. 25 Figure 22 Top dimensions (sizes in millimeter) ....................................................................... 26 Figure 23 Sides and bottom dimensions.................................................................................. 27 Figure 24 3D model top view of the weather station .............................................................. 28 Figure 25 3D model of the Weather head ............................................................................... 28 Figure 26 PCB of the weather station ...................................................................................... 29 Figure 27 3D model of the weather station PCB ..................................................................... 30 Figure 28 weather station on the board platform ................................................................... 31 Figure 29 SCADA control panel ................................................................................................ 57 Figure 30 Page 1 of the HMI .................................................................................................... 58 Figure 31 Page 2 of the HMI .................................................................................................... 58 Figure 32 Page 3 of the HMI .................................................................................................... 59 2|Page Figure 33 Page 4 of the HMI .................................................................................................... 59 Figure 34 Page 5 of the HMI .................................................................................................... 59 Figure 35 Page 6 to 9 of the HMI ............................................................................................. 60 Figure 36 LM2576 circuit ......................................................................................................... 61 Figure 37 LM317 circuit ........................................................................................................... 61 Figure 38 MC34063 pin out ..................................................................................................... 62 Figure 39 MC34063 circuit ....................................................................................................... 62 Figure 40 the new temperature circuit .................................................................................... 63 Figure 41 the pressure sensor connected to the injection via plastic pipe ............................. 64 Figure 42 To-92 through-hole component Figure 43 Sot -32 surface mounted device ....................................................................................................................................... 66 Figure 44 a footprint of a 16 pin IC socket............................................................................... 66 Figure 45 DO-41 3D model Figure 46 DO-41 footprint .......... 66 Figure 47 TO-18 3D model Figure 48 TO-18 footprint ...... 67 Figure 49 16 pin IC socket 3D model Figure 50 16 pin IC socket footprint ................................................................................................................................... 67 Figure 51 5mm diameter LED 3D model .................................................................................. 67 Figure 52 5mm diameter LED footprint ................................................................................... 68 Figure 53 TO-92 3D model Figure 54 TO-92 footprint .................. 68 Figure 55 TO-220 3D model Figure 56 TO-220 footprint .............. 68 Figure 57 AXIAL-0.4 resistor 3D model Figure 58 AXIAL-0.4 footprint ................................................................................................................................... 69 Figure 59 Mbed with 40 pin connector 3D model Figure 60 40 pin connector footprint ................................................................................................................. 69 Figure 61 10 pin connector 3D model Figure 62 10 pin connector footprint .................................................................................................................................................. 69 Figure 63 Touch screen PanelView Plus 600 3D model ........................................................... 70 Figure 64 2x16 LCD 3D model .................................................................................................. 70 Figure 65 Thumbwheel 3D model ......................................................................................... 71 Figure 66 PCB circuit ................................................................................................................ 71 Figure 67 weather station panel 1 ........................................................................................... 72 Figure 68 weather station panel 2 .......................................................................................... 72 Figure 69 weather station wiring ............................................................................................ 73 Figure 70 PCB placed on top of the board ............................................................................... 73 3|Page Table of Tables Table 1 Pin Configuration........................................................................................................... 9 Table 2 Measured voltage v.s Voltage out direction Table ..................................................... 12 Table 3 Input Specifications – 1769-HSC ................................................................................. 15 Table 4 Output Specifications – 1769-HSC .............................................................................. 15 Table 5 humidity circuit ........................................................................................................... 24 Table 6 Digital output of module 6 Table 7 Digital output of module 4 ............................ 56 4|Page Abstract: The main purpose of the project is to design and construct a model of weather station using programmable logic controller (PLC) to control its functionality. It is proposed that the model will be used as an educational resource within the PLC system courses at Bahrain polytechnic. Two different options have been considered of doing the project which is programming it either by the Mbed or the PLC. The benefits of the PLC outweigh the benefits of the other option. The model will consist of these main components circuits, sensors, SCADA and the PLC. The Gantt chart will show the schedule of carrying out the project phases. 5|Page Introduction: This is a co-op industry student engineering program for the final year student which is to make a project with the purpose to implement the experience gained throughout the Engineering Bachelor of five years to make an industry project. The project will be used as an educational resource for the students that will enroll in the PLC (Programmable Logic Controller) course at the Polytechnic. The project was proposed by the tutor, which was to make a weather station to be used in the PLC course by the students to test the students comprehension of the PLC programming and its difficulty. For the project to be approved by the Bahrain Polytechnic an interview will be held at the tutor’s office, the student will get acquainted with room designated by the Polytechnic to work in and the student can complete the project with is confidence. After choosing the desired project, the proposal report will be handed to the tutor for the approval of the project. As for this project, this report will describe the process of designing the weather station, which was requested by the student, it will show information on how both software and hardware were designed and integrated together. Industry applications: The purpose of the weather station in the industry is to auto control and interlock with the instruments and equipment via SCADA or special software. The instruments and equipment can are fully operational respectively in specific order to be able to manage the turning on and off of the process flow. During failure throughout the process, the machine or the computer that controls the system make different responses if any problems with it and alarms/sirens. Both SCADA and HMI VIs are implemented for convenience for the operator. It also simultaneously display the condition of the system both on the computer and on the weather station project. 6|Page 7|Page circuit head Weather D N G D N G D N G 3 BC547B Anemometer 2 2 Q 2 2 R58 Direction Wind 1 K 0 1 K 0 1 R57 R56 Head Weather 2.4K 1 1 P R55 V 5 + Figure 1 sensor circuit D N G V 5 + circuit sensor Temrature V 4 2 + D N G - D E L 5 0 5 1 6 1 + D E L Tap Res 62.5 R54 1 0 1watt / 15 R53 R34 2 D 3 D D N G D N G D N G D N G 9 1 3 1 D 8 V 5 + 2 0 4 A G circuit LCD 0 D D N R52 7 J D 6.2k 6.2k 6.2k 6.2k Out Vout R33 R32 R31 R30 2 Vcc 2 I n 2 2 1 2 P22/PWM P21/PWM 9 0 P19/AIN 1 3 1 2 4 1 6 D P20/AIN 7 D P23/PWM P18/AIN/AO 5 D 3 1 LM317 LM35 Temp k 9 3 k 9 3 k 9 3 k 9 3 3 2 8 1 2 1 U13 U15 R29 R28 R27 R26 P24/PWM P17/AIN 4 D 4 2 7 1 1 1 P25/PWM P16/AIN E 5 2 6 1 6 2N2907 D N G P26/PWM P15/AIN S R 1 Q 6 2 5 1 4 K 1 4.7k o V R51 5X2 Header 7 1 9 0 1N4003 Diode P27/RXD/SCL 2 P28/TXD/SDA P13/TXD/SCK 4 1 R25 P14/RXD 3 R/W 5 7 8 8 2 3 1 5 6 D N G P29/CANTD P12/MISO 1 3 4 9 2 2 1 V 5 + 9 D 1 2 Vcc P30/CANRD P11/MOSI 2 0 3 1 1 2 P D+ USB P10/RXD/SCL 2x16 LCD 1 3 0 1 3 P D- USB P9/TXD/SDA 2 3 9 TD+ ETH 8 P 3 3 8 TD- ETH P7/SCK 4 3 7 RD+ ETH P6/MISO circuit sensor Pressure 5 3 6 D N G D N G D N G RD+ ETH P5/MOSI Sensor Pressure 6 3 5 Amp Instrumental IF+ R n Ref - V 5 4 V o Vin- 6 2 Vin+ 2 1 1 0 4 1 0 5 G R G R50 + V R 3 C 4 T U O V D N G C 3 A Output 9 3 2 D U V VIN N B Output 8 3 3 V IF- B V V 5 + G 7 3 4 D N G 7 1 8 MBED 5 1 P U11 U10 V 0 1 + V 0 1 + Objectives and task description: Weather station circuit: Mbed circuit: The Vcc of the LCD is connected to Vout of the Mbed which has a 3.3v output. The 1k resistor is used for the contrast of LCD, LED- is connected to ground and the LED+ is the back light of the LCD, at first the LCD directly took about 270mA which is considered as a high current draw component comparing to others, so a 5β¦/1 watt resistor was placed to lower the current. The voltage supply for the LED+ in the LCD is given by the output of the LM2576 switching regulator. The PLC digital output pins is voltage 24v and the digital inputs of the Mbed is at least3.3v to 5v, therefore a voltage divider is used to drop the 24v of the PLC output to 3.5v for the digital inputs in order for them to work properly as the inputs will display the conditions of the weather sensors on the LCD such as (humidity, temperature, air pressure and wind speed warnings). Mbed voltage divider Figure 2 Voltage divider diagram The calculation of the Rb using the Voltage divider law: Vout = 3.5V needed πππ’π‘ = π π π π +π π π₯ πππ Vin = 24V Ra = 39kβ¦ 3.5 = π 39π +39π π π₯ 24 π π = 6658.54 ≈ 6.8kβ¦ After making much calculation and according to the available resistors at the polytechnic I choose Ra as 39k and Rb as 6.8k, because it was the closest value I found near to the calculations and I measured the current and it was 0.0546 mA between the voltage divider to the Mbed. 8|Page Pressure sensor circuit: Note: this sensor will simulate the barometer which measures the differential air pressure, because I didn’t find a cheap/efficient barometer to purchase that is suitable for the PLC. The 24PCEFA6Dpressure sensor provides reliable differential pressure sensing performance in a compact package. The sensor features a proven sensing technology that utilizes a specialized piezo resistive micro-machined sensing element. The low power, non-amplified, non-compensated Wheatstone bridge circuit design provides inherently stable mV outputs ±0.5 psi sensing range. Type Vcc Output A GND Output B Pin 1 2 3 4 Table 1 Pin Configuration Figure 3 Pressure sensor Input voltage: 10 - 12 V Current consumption: 2 mA Output signal: 70 mV Pressure range: ± 0.5 The output signal was too low, so an amplifier was used to make the output signal from 0– 70mV to 0 – 10V to be used on the PLC. Instrumentation Amplifier The INA126 is a precision instrumentation amplifier is used for accurate, low noise differential signal acquisition. The op-amp design provides excellent performance with very low current (175μA/channel). This combined with a wide operating voltage range of {1.35V to 18V}. Figure 4 Instrumentation amplifierINA126 with pin configuration Input voltage: 1.35 - 18 V Current consumption: 175μA 9|Page As seen the pressure sensor is connected to the amplifier the Vcc is 10V. Output A (the positive) is connected to the Vin+ of the amplifier and Output B (the negative) is connected to the Vin- of the amplifier. The amplifier also can operate on 10V with an adjustable gain controlled by the RG. Figure 5 Pressure sensor circuit Calculation: The normal air pressure is 14.7 psi (pound-force per square inch) to convert it to hPa (hectopascal) 1 hectopascal [hPa] = 0.014503773773 psi [psi], so hPa = ππ π 14.7 = = 1013.53 hPa 0.014503773773 0.014503773773 Minimum and maximum of the pressure capabilities: The pressure range is ± 0.5 in psi about 1, so Minimum pressure: Minimum = 14.7 - 0.5 = 14.2 psi Convert it to hPa = ππ π 0.014503773773 = 14.2 0.014503773773 = 979.06 hPa = 15.2 0.014503773773 = 1048 hPa Maximum pressure: Maximum = 14.7 + 0.5 = 15.2 psi Convert it to hPa = ππ π 0.014503773773 hPa calculation: First scale down the PLC analog in percentage from 10000 to 10 by diving it by 1000 to get the voltage and then convert the voltage to hPa with minimum and maximum decided with equation. ππ’π‘ππ’π‘ ππππππ = ((π£πππ‘πππ − 0.6) π₯ 7.35) + 979.06 10 | P a g e Calculation: The calculation of the gain: πΊπππ = πππ’π‘ 10 = = 285.7 πππ 35π The calculation of the resistor that will produce the gain: πΊπππ = 5 + π πΊ = 80π π πΊ 80π 285.7−5 11 | P a g e = 285.2β¦ Wind vane sensor circuit: The wind vane sensor (p/n 80422) will indicate the direction of the wind. It has eight switches, each connected to a different resistor. An external resistor can be used to form a voltage divider, producing a voltage output that can be measured with an analog to digital converter. The switch and resistor arrangement Resistance values for all 8 possible positions are given in are used in the project .Resistance values for positions between those shown in the diagram are the result of two adjacent resistors connected in parallel when the vane’s magnet activates two switches simultaneously. The sensor Specifications ο· Power supply rang: 3.3 - 5.5 Volts (typical supply is 3.3). Table 2 Measured voltage v.s Voltage out direction Table Direction Degree Voltage Out Measured Voltage Resistance Switch ( Ω) North North East East South East South South West West North West 0 45 90 135 180 225 270 315 3.84 2.25 0.45 0.90 1.40 3.08 4.62 4.78 3.87 2.27 0.459 0.911 1.41 3.1 4.66 4.37 33k 8.2k 1k 2.2k 3.9k 16k 120k 64.9k Figure 6 Wind Vane Internal Connection 12 | P a g e The anemometer circuit: The wind speed sensor uses the rotations to calculate the speed of the wind. The wind speed is detected with pulses and the wind direction is detected with voltage. The time between transition pulse to the output and the next pulse is used to calculate the speed. For example, if the time between the pulses is one second, the speed is going to be around 2.4km. The speed detection range is from 0 to 30Kmh. The wind speed blade rotates and each rotation the magnet connects the output to the Vcc input 5v and creates a pulse. The sensor specification - 3.3v to 5v supply voltage - pulse output type - Speed detection from 0 to 30 kmh. - Current draw 0.5mA Figure 7 Wind speed sensor The current of the anemometer is too low for the high speed counter of the PLC, a circuit was used to upscale the current atlest above 6.8mA to work on the HSC. To measure the maximum speed of the anemometer, an Anemometer Wind Speed Meter was used. Were it was found that it is at 10Hz which is equal to 30km/h. 13 | P a g e In order for the wind directoin sensor to work, a 10k pull-up is connected the input signal with 5v and then connected the direction signal to the analog In of the PLC. Same goes for the anemometer connected the input signal with a 10k pull-up resistor with 5v and then connected the anemometer signal to the high speed counter of the PLC. The current of the anemometer was too low for the high speed counter of the PLC, a current step-up circuit is used that would upscale the current atlest above 6.8mA to work on the HSC in this case 10mA. Figure 8 weather head circuit Calculation: The calculation of the R1: The voltage of the signal is 5v minus the voltage of transistor base 0.7v and divided by the current of the transistor Ohm’s law π = π πΌ = 5−0.7 200π = 21.5 ≈ 22β¦ The calculation of the R2: 6.8mA is needed, so higher up to 10mA is enough Ohm’s law π = 14 | P a g e π πΌ = 24 10π = 2.4πβ¦ PLC High speed counter Specifications: attribute Input voltage range On-state voltage, max On-state voltage, min On-state current, min Off-state voltage, max Off-state current, max Off-state leakage current, max Input current, max Input current, min Input impedance, nom Pulse width, min Pulse separation, min Input frequency, max 1769-HSC 2.6…30V DC 30V DC 2.6V DC 6.8 mA 1.0V DC 1.5 mA 1.5 mA 15 mA 6.8 mA 1950 Ω 250 ns 131 ns 1 MHz Table 3 Input Specifications – 1769-HSC attribute Output voltage range On-state voltage, max On-state current, min On-state voltage drop, max Off-state leakage current, max Turn-on time, max Turn-off time, max Reverse polarity protection 1769-HSC 5…30V DC User power – 0.1V DC 1 mA 0.5V DC 5 µA 400 µs 200 µs 30V DC Table 4 Output Specifications – 1769-HSC 15 | P a g e Temperature sensor: The LM35DZ is an integrated-circuit temperature sensor with an output voltage which is linearly proportional to the Celsius temperature. Features: ο· ο· ο· ο· Calibrated directly in ° Celsius Operates from 4 to 30 volts Output current 0 to 10mA Less than 60 μA current drain Figure 9 4 To 20 mA Current Source (0°C to +100°C) circuit Figure 10 temperature sensor LM35DZ 16 | P a g e Figure 11 7-segment circuit 17 | P a g e D N G D N G D N G D N G k 0 1 k 0 1 k 0 1 k 0 1 R24 R23 R22 R21 D N G D N G Driver 7-Seg 9 G D d 5X2 Header C 2 D N 1 1 0 1 9 6 0 1 9 2 1 5 1 0 c 1 D N 1 7 e 8 8 D N G 6 G k 3 9 R20 k 0 1 8 7 b B R19 6 5 3 1 4 2 1 1 k 0 1 4 3 a A 4 1 3 3 1 R64 2 1 7 g E L 4 1 P 5 1 2 4 1 5 f I B 6 1 1 5 1 4 D D T L V 220 Pack Resistor 6 1 3 8 U V 5 + 7 U V 5 + D N G D N G D N G Driver 7-Seg 9 8 D N G e 8 k 0 1 9 G 0 1 7 D N R18 G D d 6 1 5X2 Header G D N 1 1 6 0 D N C 1 c 0 1 9 2 1 5 1 1 2 k 0 k 9 3 k k 3 9 R17 0 1 8 7 R63 b B R16 R15 6 5 3 1 4 2 1 1 k 0 1 4 3 a A 4 1 3 3 1 R62 2 1 7 g E L 3 1 P 5 1 2 4 1 5 f I B 6 1 1 5 1 4 D N G D D T L V 220 Pack Resistor 6 1 3 6 U V 5 + 5 U V 5 + k 0 1 D N G R14 Driver 7-Seg 9 8 D N G e 8 0 1 7 9 k 9 3 D N G D d 6 R13 1 1 6 0 1 5X2 Header D N G c C 0 1 9 2 1 5 1 1 2 5X2 Header 8 7 b B 0 1 9 6 5 3 1 4 2 1 1 8 7 k 0 1 4 3 a A 6 5 4 1 3 3 1 R61 2 1 7 4 3 g E L 2 1 P 2 1 5 1 2 4 1 5 1 P f I B 6 1 1 5 1 4 D N G D N G D N G D N G D D T L V 220 Pack Resistor 6 1 3 4 U V 5 + 3 U V 5 + G D N Driver 7-Seg 8 G 9 D N e k 9 3 k 9 3 k R12 R11 0 1 k 0 1 k 9 3 k 9 3 k R10 9 R 0 1 k 0 1 D N G D N G 8 0 1 7 9 8 R 7 R 6 R 5 R D N G D d 6 1 1 6 0 1 5X2 Header k 0 1 k 0 1 D N G c C 4 R 3 R D N G 0 1 9 2 1 5 1 1 2 8 7 b B 6 5 3 1 4 2 1 1 4 3 a k 0 1 A 4 1 3 3 1 k 0 1 k 9 3 k 9 3 2 1 7 R60 R59 2 R 1 R g E L 4 P 5 1 2 4 1 5 f I B 6 1 1 5 1 4 D D T L V 220 Pack Resistor 6 1 3 2 U V 5 + 1 U V 5 + 7-segment circuit: Figure 12 Decoder Pin Out Decoder information: Input voltage: 3 – 18 V Max Current: 25mA The CD4511 is a BCD to 7-segment decoder driver. Its function is to convert the logic states at the outputs of a BCD, which will drive a 7-segment display. The display shows the decimal numbers 0-9 and is easily understood. The 7-segment circuit (Fig 30) holds 4x 7-segment Decoder CD4511, 4x 220 ohm resistor pack, 4x 7segment displays and voltage dividers and the header that will be inputted to the PLC output module. The decoder converts the binary coded decimal from the ABCD pins to 7-segment lights. The 10k resistors are pull down resistors to prevent any leakage or false readings on another switch The Vcc and the LT pins of the CD4511 7-segment decoder will be connected to the +5v coming from the LM2576 switching regulator. The voltage has to be stepped down from 24v coming from the PLC outputs to 5vin order for the BCD inputs, blanks and strobes in the decoder to able to read a signal. The calculation of the Ra value by using Ohm’s law: π=πΌπ₯π π πΌ π π = = 24 − 5 0.5π = 38k ≈ 39kβ¦ Then calculated the Rb using the Voltage divider law: Vout = 5V needed π π π +π π πππ’π‘ = π π₯ πππ π π = 10263.16 ≈ 10kβ¦ 18 | P a g e Vin = 24V Ra = 39kβ¦ 3.9π π +3.9π 5=π π₯ 24 Figure 13 Voltage divider diagram The 220 ohm resistor packs will step down the current, to prevent excess current going to the 7sgements LEDs The calculation for the resistor packs: The 7-seg display has maximum current of 15mA, so if I applied ohm’s law on it: π=πΌπ₯π 19 | P a g e π = π πΌ = 5−1.8 15π = 213β¦ ≈ 220β¦ k c a b d e e V 5 1 1 V 0 1 + 2 L 2 Vout D ON/Off G Inductor N C 3 4 K 3 F u 0 0 0 D N D N G D N G 1.8K D N G R66 G 1N5822 Diode 5 3 1 D11 1 C R65 H u 0 2 2 F u 0 0 1 D N G Figure 15 LM2576-Adj 10 volt circuit The LM2576 switching regulator circuit is inclulded in the prjoect to get 5v out from a 24v input. It is used to supply the main components such as, temperature, CD4511 decoder, Mbed, wind vane and the anemometer. The other LM2576 circuit is used to supply the pressure sensor and its instrument amplifier with 10v. The components of the LM2576 are calculated due to the recommantations of the datasheet. The calculation for LM2576-Adj +5 volts: Vref = 1.23V, R1 has to between 1k and 5k πππ’π‘ = ππππ π₯ ( 1 + 20 | P a g e π 2 )π₯ π 1 πππ’π‘ 1.23 π₯ ( 1 + 6800 ) 2200 = 5.03 ≈ 5v F 2 C k c a b d e e Vin 1 F V 4 2 + 4 LM2576T-ADJ U14 Figure 14 LM2576-Adj 5 volt circuit u 0 0 0 1 D N D N G D N G 2.2K D N G D N G R70 G 1N5822 Diode 5 3 D N G D10 6.8K R69 H u 0 2 2 ON/Off G F u 0 0 1 Inductor N 2H Header C D Vout 2 L 2 + Vin 1 1 7 P F V 4 2 + 4 LM2576T-ADJ U12 Voltage circuit using LM2576: The calculation for LM2576-Adj +10 volts: Vref = 1.23V, R1 has to between 1k and 5k πππ’π‘ = ππππ π₯ ( 1 + π 2 )π₯ π 1 πππ’π‘ 1.23 π₯ ( 1 + 13000 ) 1800 = 10.11≈ 10v The calculation of LM2576 components: Inductor: The Calculation of the inductorusing the following formula: L = (πππ − πππ’π‘)π₯ 5 L = (24 − 5)π₯ 24 π₯ πππ’π‘ 1000 π₯ πππ πΉ(ππ πΎβπ§) 1000 52 = 76.12 L = 76.12 μH Iload = 2A Inductance Region = H150 Figure 16 Inductor value selection graph guide 21 | P a g e Cout: The value of the output capacitor together with the inductor defines the smooth the switching regulator loop. To stable the operation of the regulator, the capacitor must be calculated as the following: Cout = 13000π₯ Cout = 13000π₯ πππ πππ’π‘ π₯ πΏ(π’π») 24 = 283.63 π’πΉ 5 π₯ 220 However, for acceptable output ripple voltage select: COUT ≥ 680 μF COUT = a 1000 μF 35V electrolytic capacitor was choosen due to datasheet recomandation. The capacitor's voltage rating should be at last 1.5 times greater than the output voltage. Diode: The diode current rating must be at least 1.2 times greater than the maximum load current.in this case a 2.4A current rating is adequate. The avialable at the polytechnic is schottkey diode (1N5822). The LM2576 regulator needs the 1N5822 diode to provide a return route for the inductor current when the circuit is off. This diode should be located close to the LM2576 using short leads and short printed circuit traces. CIn: The 100 μF aluminum electrolytic capacitor is palced at the input voltage and ground pins to provide stable operation and forsufficient bypassing of voltage. 22 | P a g e s D E L 6 P 2 4 1 8 0 1 7 2 1 1 1 1 4 6 1 1 3 5 8 1 7 1 0 2 9 1 0 2 10X2H Header 1.2K R43 1.2K R44 1.2K R45 1.2K R46 1.2K R42 1.2K R41 10X2H Header 1.2K R40 8 1 7 1 9 1 1.2K 1 1 4 6 1 3 5 1 1 R39 2 1 1 1 1.2K 9 8 0 1 9 7 R35 Figure 17 LED circuit The circuit will be connected from the PLC outputs to the PCB via 20pin headers. The LEDS will include North West, North, North East, West, East, South West, South, South East, on, off, fault, temperature, pressure, humidity and wind speed LEDs. The PLC voltage 24V, Voltage drop on the LED is 2V. The calculation for the LED resistor: The LED has maximum current of 20mA, so if I applied ohm’s law on it: π=πΌπ₯π π = π πΌ = 24−2 20π = 1.1 ≈ 1.2kβ¦ And the power calculation is: π=ππ₯πΌ 23 | P a g e π = 24 π₯ 20π = 0.48 π€ππ‘π‘ D N G 6 5 6 5 1.2K 3 2 4 3 1 R36 5 P 1.2K R37 PLC 1.2K R38 1.2K R49 1.2K R48 1.2K R47 LEDs circuit: The 1.2k was chosen because; it had the best outcome of all resistors in luminosity and current value and it needs at least a 1 watt power rating, the polytechnic has only 3 watt resistors. Humidity circuit: A humidity sensor is a device which consists of a special plastic material whose electrical characteristics change according to the amount of humidity in the air. Figure 18 LinPicco A05 Basic humidity sensor Input voltage: 8 - 32 V Current consumption: < 3 mA Output signal: 0 - 5 V V 4 2 9 In Analog D N G GND Signal 1 D N G 2 Out Analog 3 Vcc 4 Sensor Humidity U + The Vcc of the sensor will be connected to the 24v of the PLC and both grounds will be common with the PLC and the analog out of the sensor will connected to the analog in 0 - 5v of the PLC which will give the relative humidity in % range (0-100). Table 5 humidity circuit 24 | P a g e Thumbwheel switch: The thumbwheel is a rotary device that allows an operator to input numerical information into a counter which uses binary coded decimal (BCD). Figure 19 Truth table Figure 20 Thumbwheel switch For the diodes for the thumbwheel the 1N4148 diodes were used, because they are high fast recovery diodes. In this circuit, diodes have been added to prevent the switch settings of one switch from creating false readings on another switch and prevent reverse voltage. The 8,4,2,1 are the input switches to the PLC and both of the Cs will also be connected to the PLC as strobes for the tens and units. Figure 21 Thumbwheel circuit 25 | P a g e Hardware Fabricarion: Weather station box: The weather station box was designed to be portable and to fit the all the weather station compoents with enough height to make sure that the HMI doesn’t touch the bottom of the box and a square cut was made to pass the wiring of the control panel. The weather station box is user friendly and it is designed to be elegant and in a way to tidey the wire. Also holes were made to pass the wiring under the board, to make more appleying for the user. Top dimensions: Thickness: 6mm Length: 300mm Width: 350mm (1 pieces) The 73x25.60rectangle cut is for the LCD to be placed, the 41x15rectangle cut is for the four 7segment displays, the 6.5 holes are for the LEDs, the 25x55 rectangle cut is for the thumbwheel switch, the 23 hole is for the buzzer and the 158x125rectangle cut is for the touch panel. Figure 22 Top dimensions (sizes in millimeter) 26 | P a g e Sides and bottom dimensions: (Front and back) Thickness: 6mm Length: 300 mm Width: Thickness: 6mm with a 60x60mm square cut Length: 338 mm Width: 105 mm (2 pieces) Width: 350 mm (1 pieces) 105 mm (2 pieces) (Right and left) (Bottom) Thickness: 6mm Length: 300 mm Figure 23 Sides and bottom dimensions 27 | P a g e Figure 24 3D model top view of the weather station The weather head will be attached to the side of the box. Figure 25 3D model of the Weather head 28 | P a g e Printed circuit board: Routing the PCB with Altuim Designer. This is the LEDs circuit that will be connected to the direction LEDs of the weather station. P9 and P5 connectors will be connected to the PLC and P6, P7, P8 and P10 will be connected to the LEDs to the resistors loads (1.2kβ¦/3 watt). The MBED circuit will be connteced to the LCD screen with DS5 and pins p21 - p24 will be connected to the PLC via P2 connected to voltage divder resistors values of 39kβ¦ and 6.2kβ¦. The 7-segment circuit will be connected both the PLC and 7-segment displays. DS1 – DS4 will be connected to the 7- segment display. P1 will be connected to the strobes, blanking and the ABCD pins of the decoders which are U1, U3, U5 and U7 to the PLC. The PCB was made to make the outputs on the right side and the inputs on the left side with minimum jumpers as possible and to be more compacted. Figure 26 PCB of the weather station 29 | P a g e The purpose of the 3D model of the circuit, was to make sure that the components had their real-life sizes with the respect of the correct footprints to prevent any conflict between them. Figure 27 3D model of the weather station PCB 30 | P a g e Board platform: The board platform was made to place the weather on top it,including the PCB circuit with the connections to the PLC. Holes were made on the board to allow the wiring to be placed neatly and Cable ties were used to tidey the wiring. Figure 28 weather station on the board platform 31 | P a g e Software: Program functionality: Below are the proposed features, of this weather station project. The features of the project are: a) Sensors: ο· Anemometer (Wind speed sensor) ο· Temperature sensor ο· Wind vane/direction sensor ο· Humidity sensor ο· Atmospheric pressure sensor b) Display ο· 7-segment ο· LCD ο· Thumbwheel switch to input set points (temperature, humidity, etc.) c) SCADA d) Alarms, LEDs, Buzzer e) Voltage regulator As the weather station starts working all sensors will work simultaneously to give readings both on the7-segment and the SCADA program. The LCD will display warnings of the sensors if they reached a specific value. The SCADA software displays the state operation of the weather station components such as sensors, displays and alarms onto a single PC and will also contain the average value of the sensors over a period of time. Also alarms will be made if the sensors either went below or above the placed values in the Program and also the values are set point can be inputted into the PLC program. The SCADA program will display both the system information and system state. The sensors will be placed on a platform and the 7-segment, LCD displays and the circuits will also be placed under a plastic casing on the platform. The HMI (Human machine interface) will display the systems condition, graph of the sensors, real-time values, average values and inputted values chosen by the user to set the sensors alarm range. 32 | P a g e MBED code: /*********************************************************/ /* ENB7904 Co-operative Learning Project (Electronics) */ /* Weather Station project */ /* Done by: Hassan Radhi */ /*********************************************************/ #include "mbed.h" #include "TextLCD.h" /* identifying the inputs*/ TextLCD lcd(p15, p16, p17, p18, p19, p20); DigitalIn w_hum(p21); //Humidity warning DigitalIn w_temp(p22); //Temperature warning DigitalIn w_pres(p23); //Air Pressure warning DigitalIn w_speed(p24); //Wind Speed warning int main() { /* Start the program by displaying Name, ID and Date for 5 seconds */ lcd.printf("N: Hassan Radhi\n"); lcd.printf("ID: 20900009\n"); wait(5); lcd.cls(); lcd.printf("Date: 14/04/2014\n"); wait(5); lcd.cls(); while(1) { /* incase a signal turns on, a warning displayed on the LCD*/ if (w_hum == 1 && w_temp == 0 && w_pres == 0 && w_speed == 0) { /* Humidity Warning */ lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); } else if ((w_hum == 0 && w_temp == 1 && w_pres == 0 && w_speed == 0)) { /* Temperature Warning */ lcd.locate(3,0); 33 | P a g e lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); } else if ((w_hum == 0 && w_temp == 0 && w_pres == 1 && w_speed == 0)) { /* Air Presure Warning */ lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); } else if ((w_hum == 0 && w_temp == 0 && w_pres == 0 && w_speed == 1)) { /* Wind Speed Warning */ lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 1 && w_pres == 0 && w_speed == 0)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); 34 | P a g e lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 0 && w_pres == 1 && w_speed == 0)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 0 && w_pres == 0 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); 35 | P a g e lcd.cls(); } else if ((w_hum == 0 && w_temp == 1 && w_pres == 1 && w_speed == 0)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); } else if ((w_hum == 0 && w_temp == 1 && w_pres == 0 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else if ((w_hum == 0 && w_temp == 0 && w_pres == 1 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); 36 | P a g e lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 1 && w_pres == 1 && w_speed == 0)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 1 && w_pres == 0 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); 37 | P a g e wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 0 && w_pres == 1 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); 38 | P a g e lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else if ((w_hum == 0 && w_temp == 1 && w_pres == 1 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else if ((w_hum == 1 && w_temp == 1 && w_pres == 1 && w_speed == 1)) { lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n High Humidity"); wait(1); lcd.cls(); 39 | P a g e lcd.printf(" !Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Temperature"); wait(1); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Air Presure"); wait(1); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\n"); wait(0.5); lcd.cls(); lcd.locate(3,0); lcd.printf("!Warning!\nHigh Wind Speed"); wait(1); lcd.cls(); } else { /* Display all sensors are normal if there are no probelms */ lcd.printf("All sensors are Normal"); wait(1); lcd.cls(); } } } 40 | P a g e PLC code: This is the main routine of the weather station program using structure code in Rslogix5000. /* jump to sub-routine for switching 7 segment display */ jsr(Switching_Seg_Routine); /* jump to sub-routine for 7-segment display */ jsr(Seven_Seg_Routine); /* jump to sub-routine for Thumbwheel switch */ jsr(Thumbwheel_Routine); /*pressure sensor */ Pressure_scale := Pressure_in / 1000; Pressure_value :=((Pressure_scale - 0.6) * 6.49) + 979; /*Temprature sensor */ Temp_scale := Temprature_In / 10; /* humidity sensor */ Humidity_scale := Humidity_In/100; /* count the first value when the timer starts*/ counter_enable := 1; count_value := counter_acc; if Timer_5.acc = 0 then First_Value := count_value; end_if; /* count the last value when the timer finishs*/ if Timer_5.dn then Last_Value := count_value; /* then calculate the speed in rpms */ Speed := ((Last_Value - First_Value)/100) * 60; end_if; /*calculate the speed in KM/h */ KM := (2*3.14*0.08881*Speed*60)/1000; /* Timer for anemometer */ RTOR ( Timer_5); Timer_5.pre := 5000; Timer_5.TimerEnable := not Timer_5.dn; Timer_5.Reset := Timer_5.dn; /* equation to scale the wind direction in understandable values */ scale := Wind_Vane_In / 1000; value := (scale/2)*0.66; 41 | P a g e /* either the on switch turns on the system or the from the SCADA/HMI */ if On_switch or On_Internal then On_LED:=1; else On_LED:=0; end_if; /* if the On LED turn on the off LED switchs off */ if On_LED then Off_LED := 0; else Off_LED := 1; end_if; /*identifying the direction */ /////////////////////////////////////////////// if (( 2.55 > value) and (value > 2.45 ))//1.North then Wind_degres := 0; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 1.55 > value) and (value > 1.45 ))//2.North East then Wind_degres := 45; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 0.35 > value) and (value > 0.29 ))//3.East then Wind_degres := 90; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 0.65 > value) and (value > 0.55 ))//4.South East then Wind_degres := 135; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 0.95 > value) and (value > 0.85 ))//5.South 42 | P a g e then Wind_degres := 180; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 2.05 > value) and (value > 1.95 ))//6.South West then Wind_degres := 225; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 3.03 > value) and (value > 2.93 ))//7.West then Wind_degres := 270; else Wind_degres := Wind_degres; end_if; /////////////////////////////////////////////// /////////////////////////////////////////////// if (( 2.9 > value) and (value > 2.7 ))//8.North West then Wind_degres := 315; else Wind_degres := Wind_degres;// if the wind degree gone to a invalid value gives it the last valid value end_if; /* if the wind degrees is equal to 0 turn on the north LED */ if (On_switch or On_Internal) and Wind_degres = 0 then N_LED := 1; else N_LED := 0; end_if; /* if the wind degrees is equal to 45 turn on the north east LED */ if (On_switch or On_Internal) and Wind_degres = 45 then NE_LED := 1; else NE_LED := 0; end_if; /* if the wind degrees is equal to 90 turn on the east LED */ if (On_switch or On_Internal) and Wind_degres = 90 then E_LED := 1; 43 | P a g e else E_LED := 0; end_if; /* if the wind degrees is equal to 135 turn on the south east LED */ if (On_switch or On_Internal) and Wind_degres = 135 then SE_LED := 1; else SE_LED := 0; end_if; /* if the wind degrees is equal to 180 turn on the south LED */ if (On_switch or On_Internal) and Wind_degres = 180 then S_LED := 1; else S_LED := 0; end_if; /* if the wind degrees is equal to 225 turn on the south west LED */ if (On_switch or On_Internal) and Wind_degres = 225 then SW_LED := 1; else SW_LED := 0; end_if; /* if the wind degrees is equal to 270 turn on the west LED */ if (On_switch or On_Internal) and Wind_degres = 270 then W_LED := 1; else W_LED := 0; end_if; /* if the wind degrees is equal to 315 turn on the north west LED */ if (On_switch or On_Internal) and Wind_degres = 315 then NW_LED := 1; else NW_LED := 0; end_if; /* if the Humidity value exceeded the inputted value in the touch panel/SCADA, triggers the warining on the LCD */ if Humidity_scale > Humidity_Inputed_value then Humi_warning := 1; else Humi_warning := 0; 44 | P a g e end_if; /* if the temperature value exceeded the thumbwheel value, triggers the warining on the LCD */ if Temp_scale > Output_Number then Temp_warning := 1; else Temp_warning := 0; end_if; /* if the wind speed value exceeded the inputted value in the touch panel/SCADA, triggers the warining on the LCD */ if KM > Speed_Inputed_value then Speed_warning := 1; else Speed_warning := 0; end_if; /* if the Pressure value exceeded the inputted value in the touch panel/SCADA, triggers the warining on the LCD */ if Pressure_value > Pressure_Inputed_value then Pressure_warning := 1; else Pressure_warning := 0; end_if; /* Humidity average Senor Value Add - on */ Average_filter( Humidity_average_addOn ); Humidity_average_addOn.Start := 1; Humidity_average_addOn.Sensor_value := Humidity_scale; Humidity_average := Humidity_average_addOn.Average_Sensor; /* Pressure average Senor Value Add - on */ Average_filter( Pressure_average_addOn ); Pressure_average_addOn.Start := 1; Pressure_average_addOn.Sensor_value := Pressure_value; Pressure_average := Pressure_average_addOn.Average_Sensor; /////////////////// /* Temperature average Senor Value Add - on */ Average_filter( Temperature_average_addOn ); Temperature_average_addOn.Start := 1; Temperature_average_addOn.Sensor_value := Temp_scale; Temperature_average := Temperature_average_addOn.Average_Sensor; /* Wind Speed average Senor Value Add - on */ Average_filter( WindSpeed_average_addOn ); WindSpeed_average_addOn.Start := 1; WindSpeed_average_addOn.Sensor_value := KM; WindSpeed_average := WindSpeed_average_addOn.Average_Sensor; 45 | P a g e /* if humidity value is bigger than inputted value by the SCADA/HMI turn on an alarm */ if Humidity_scale > Humidity_Inputed_value then Timer_11.TimerEnable:= 1; else Timer_11.TimerEnable:= 0; end_if ; /* when one of these timers are done turn on the alarm */ if Timer_13.dn or Timer_11.dn or Timer_15.dn or Timer_17.dn then Buzzer := 1; else Buzzer := 0; end_if; /* if temperature value is bigger than inputted value by the SCADA/HMI turn on an alarm */ if Temp_scale > Output_Number then Timer_13.TimerEnable:= 1; else Timer_13.TimerEnable:= 0; end_if ; /* if wind speed value is bigger than inputted value by the SCADA/HMI turn on an alarm */ if KM > Speed_Inputed_value then Timer_15.TimerEnable:= 1; else Timer_15.TimerEnable:= 0; end_if ; /* if pressure value is bigger than inputted value by the SCADA/HMI turn on an alarm */ if Pressure_value > Pressure_Inputed_value then Timer_17.TimerEnable:= 1; else Timer_17.TimerEnable:= 0; end_if ; /* humidity alarm */ TONR (Timer_11); Timer_11.PRE:= 500; Timer_11.reset := Timer_12.dn; TONR (Timer_12); Timer_12.PRE:= 500; Timer_12.TimerEnable:= Timer_11.dn; 46 | P a g e Timer_12.reset := Timer_12.dn; /* temperature alarm */ TONR (Timer_13); Timer_13.PRE:= 250; Timer_13.reset := Timer_14.dn; TONR (Timer_14); Timer_14.PRE:= 250; Timer_14.TimerEnable:= Timer_13.dn; Timer_14.reset := Timer_14.dn; /* wind speed alarm */ TONR (Timer_15); Timer_15.PRE:= 125; Timer_15.reset := Timer_16.dn; TONR (Timer_16); Timer_16.PRE:= 125; Timer_16.TimerEnable:= Timer_15.dn; Timer_16.reset := Timer_16.dn; /* pressure alarm */ TONR (Timer_17); Timer_17.PRE:= 750; Timer_17.reset := Timer_18.dn; TONR (Timer_18); Timer_18.PRE:= 750; Timer_18.TimerEnable:= Timer_17.dn; Timer_18.reset := Timer_18.dn; /* Rest the Timers */ if Timer_12.DN then Timer_11.Reset := 1; Timer_12.reset := 1; else Timer_11.Reset := 0; Timer_12.reset := 0; end_if; if Timer_14.DN then Timer_13.Reset := 1; Timer_14.reset := 1; else Timer_13.Reset := 0; Timer_14.reset := 0; end_if; 47 | P a g e if Timer_16.DN then Timer_15.Reset := 1; Timer_16.reset := 1; else Timer_15.Reset := 0; Timer_16.reset := 0; end_if; if Timer_18.DN then Timer_17.Reset := 1; Timer_18.reset := 1; else Timer_17.Reset := 0; Timer_18.reset := 0; end_if; /* if either the pressure sensor or the wind direction sensor gets unplugged from the analog module turn a fault LED */ if (Pressure_value <= 975) or (scale <= 0.1) then Fault_LED := 1; else Fault_LED := 0; end_if; 48 | P a g e This is a sub routine is used to control the 7-segment strobing using ladder logic code. 49 | P a g e 50 | P a g e This is a sub routine is used to control the thumbwheel switch strobing using ladder logic code. 51 | P a g e This is a sub routine written in struturce text used to display the sensors value each one at a time for 10 seconds in a loop. /* this routine changes the 7-segment values each sensor at a time*/ /* Timer for the Humidity */ RTOR ( Humidity_Timer); Humidity_Timer.pre := 10000; Humidity_Timer.TimerEnable := On_switch or On_Internal ; Humidity_Timer.Reset := Anemometer_Timer.DN; /* start displaying the humidity value for 10 sec on the 7-segment and turn on its LED */ if Humidity_Timer.TT then Humi_LED := 1; Number := Humidity_scale; else Humi_LED := 0; end_if; /* Timer for the Pressure */ RTOR ( Pressure_Timer); Pressure_Timer.pre := 10000; Pressure_Timer.TimerEnable := Humidity_Timer.DN and (On_switch or On_Internal); Pressure_Timer.Reset := Anemometer_Timer.DN; /* start displaying the Pressure value for 10 sec on the 7-segment and turn on its LED */ if Pressure_Timer.TT then Pressure_LED := 1; Number := Pressure_value; else Pressure_LED := 0; end_if; /* Timer for the Humidity */ RTOR ( Temprature_Timer); Temprature_Timer.pre := 10000; Temprature_Timer.TimerEnable := Pressure_Timer.DN and (On_switch or On_Internal); Temprature_Timer.Reset := Anemometer_Timer.DN; 52 | P a g e /* start displaying the Pressure value for 10 on the 7-segment sec and turn on its LED */ if Temprature_Timer.TT then Temp_LED := 1; Number := Temp_scale; else Temp_LED := 0; end_if; /* Timer for the anemometer */ RTOR ( Anemometer_Timer); Anemometer_Timer.pre := 10000; Anemometer_Timer.TimerEnable := Temprature_Timer.DN and (On_switch or On_Internal); Anemometer_Timer.Reset := Anemometer_Timer.DN; /* start displaying the speed value for 10 sec on the 7-segment and turn on its LED */ if Anemometer_Timer.TT then Speed_LED := 1; Number := KM; else Speed_LED := 0; end_if; 53 | P a g e This is an add-on in ladder logic used to average the values of the sensors over time which takes 6 values and divdies them over 6 to get an average. 54 | P a g e 55 | P a g e the input/output list: these are the inputs and outputs list of the PLC. Digital Outputs Module (6) Tag Name Address Off_LED On_LED Fault_LED E_LED NE_LED NW_LED N_LED SW_LED W_LED SE_LED S_LED Humi_LED Pressure_LED Speed_LED Temp_LED Buzzer Digital Outputs Module (4) Tag Name Address Local:6:O.Data.0 Local:6:O.Data.1 Local:6:O.Data.2 Local:6:O.Data.3 Local:6:O.Data.4 Local:6:O.Data.5 Local:6:O.Data.6 Local:6:O.Data.7 Local:6:O.Data.8 Local:6:O.Data.9 Local:6:O.Data.10 Local:6:O.Data.11 Local:6:O.Data.12 Local:6:O.Data.13 Local:6:O.Data.14 Local:6:O.Data.15 Table 6 Digital output of module 6 7_seg_A 7_seg_B 7_seg_C 7_seg_D seg _Strobe_1 seg _Strobe_2 seg _Strobe_3 seg _Strobe_4 Blank_1 Blank_2 Thumb_Strobe_1 Thumb_Strobe_2 Temp_warning Pressure_warning Humi_warning Speed_warning Local:4:O.Data.0 Local:4:O.Data.1 Local:4:O.Data.2 Local:4:O.Data.3 Local:4:O.Data.4 Local:4:O.Data.5 Local:4:O.Data.6 Local:4:O.Data.7 Local:4:O.Data.8 Local:4:O.Data.9 Local:4:O.Data.10 Local:4:O.Data.11 Local:4:O.Data.12 Local:4:O.Data.13 Local:4:O.Data.14 Local:4:O.Data.15 Table 7 Digital output of module 4 Digital Inputs Module (5) Tag Name Address Thumb_A Thumb_B Thumb_C Thumb_D On_switch Local:5:I.Data.0 Local:5:I.Data.1 Local:5:I.Data.2 Local:5:I.Data.3 Local:5:I.Data.4 Table 8 Digital inputs of module 5 Analog Inputs Module (2) Tag Name Address Wind_Vane_In Humidity_In Pressure_in Temprature_In Local:2:I.Ch0Data Local:2:I.Ch1Data Local:2:I.Ch2Data Local:2:I.Ch3Data Table 9 Analog in and HSC inputs modules 56 | P a g e High speed counter Module (1) Tag Name Address counter_acc - Local:1:I.Ctr0CurrentCount - Virtual Instruments: SCADA (supervisory and data acquisition): Figure 29 SCADA control panel the scada program displays and control the weather station via computer. The 7-segment will display the humidity, air pressure, temperature and wind speed.Each sensor has 10 seconds to be displayed on the 7-segment with the corrponding LED of the sensor being displayed to know which sensor value is it. For the wind direction a pattern of circuilar LEDs will display the wind direction with each direction has its own LED and the On,Off and fault shows the status of the system.The LCD displays the warnings of the 4 main sensors, if they went over their input ranges which can be contreolled by the SCADA a warning will be displayed on the LCD with its own alarm on the buzzer. The On/Off switch turns on/off the system, the thumbwheel value controls the temperature inputted value and if the temperature value exceed a warning will be displayed on the LCD. The graph shows the history and present data of the sensors and with each one has its own scale. 57 | P a g e HMI (Human machine interface): Figure 30 Page 1 of the HMI The first page of the HMI will display the system status via LED indicators, the 7-segment display which holds the sensors values, the start/stop button, Next and Before button to go back or to go forward between pages and the system shutdown button shutsdown the HMI. Figure 31 Page 2 of the HMI The second page include the LEDs of the wind vane sensor, as the wind vane points in a specifiec direction the LED corrspoing to it lights up. 58 | P a g e Figure 32 Page 3 of the HMI The third page conjtains the real-time values of the analog sensors and each sensor has its own numaric display. Figure 33 Page 4 of the HMI The fourth page conjtains the average values of the analog sensors and each sensor has its own numaric display. Figure 34 Page 5 of the HMI 59 | P a g e the fiveth page has the inputted values,where a any centrian value can be placed , then the value gets compared with sensor value and if sensor value is bigger a warning will be displayed on the LCD. The pages from six to nine, each sensor has its own graph and it will be plotted on it with the x-axis will be time and the y-axis will the sensor's value. Figure 35 Page 6 to 9 of the HMI 60 | P a g e Disscusion: Voltage regulators: These are the voltage regulators that were used to make a comparison, to choose which one is more suitable for the weather station project: ο· ο· ο· LM2576 MC34063 LM317 Voltage regulator: LM2576, adjustable Input voltage range: 3v – 60v Output voltage range: 1.23v – 37v Output current range: 3A Figure 36 LM2576 circuit The LM2576 voltage regulator is a step-down regulator that is capable of 3A load and load regulation. The LM2576 series are available in fixed output voltages of 3.3V, 5V, 12V, 15V, and an adjustable output version. Voltage regulator: LM317, adjustable Input voltage range: 3v – 40v Output voltage range: 1.2v – 37v Output current range: 1.5A Figure 37 LM317 circuit The LM317 voltage regulator is an adjustable 3 pin regulator has an input range of 3v to 40v with a 1.2v to 37v output voltage range/ 1.5A output current and if the chip gets overheated or current limited it shutdown to protect the chip. 61 | P a g e Voltage regulator: MC34063, adjustable Input voltage range: 3v – 40v Output voltage range: -12v – 30v Output current range: 1.5A Figure 38 MC34063 pin out Figure 39 MC34063 circuit The MC34063A is a DC to DC converter IC. Its primary purpose is to step-up/step-down the voltage depending on the circuit design. Its internal structure contains comparator, controlled duty cycle oscillator with a current limit circuit and an internal temperature compensated reference. Also it can incorporate an External Current Boost circuit. 62 | P a g e The LM2576 voltage regulator was choosen, because it fits the project criteria in the current load 3A. where the other voltage regulators, the LM317 and the MC34063 had a 1.5A load which is not suffient to supply the project, so the best choice was the LM2576. Instrument Amplifier for the pressure sensor: The instrument amplifier INA126 was chosen over the LM358, because it is made specifically for instruments for accurate and precise amplification, low noise and low offset differential signal acquisition. Temperature sensor: 5 v D N G D N G 3 k 2 8 G R53 N D Vout In Analog 2 Vcc 1 LM35 Temp U15 + The problem that was encountered with temperature sensor was about the temperature circuit, after connecting the circuit it didn’t work as expected and didn’t find any solution, because all the components seemed fine and works properly on their own circuit, to solve my sensor problem I connected the temperature circuit by its own. Figure 40 the new temperature circuit 63 | P a g e Pressure simulation mechanism: An injection will be used to simulate air pressure and by pressing and pulling on it. The plastic pipe will act as the medium for the air flow to the pressure sensor. Figure 41 the pressure sensor connected to the injection via plastic pipe After testing the 3ml injector it had a lot of psi force about 19.53 psi it was found that the smaller injector the better control of air flow to the pressure sensor. The smaller the injector the better control on the pressure air flow. 64 | P a g e Recommantoinas: The project can be enhanced by: 1. 2. 3. 4. 5. A better and more clearer graphic design for both the SCADA and HMI. Enable the system to store daily statistics for future decision making. Include reverse polarity circuit to prevent reverse voltage. Include better quality sensors for more precision and accuracy in the weather station. Include more weather sensors such as rain gauge and light intensity. 65 | P a g e Appendix: Footprints with 3D models Footprints are the physical layout that is required on the printed circuit board in order to mount a component or physical attachment. It can be anything from through-holes, such as TO-92 package to surface mounted device (SMD), such as Sot-32 package. Figure 42 To-92 through-hole component Figure 43 Sot -32 surface mounted device Figure 44 a footprint of a 16 pin IC socket The footprints will be the physical layout of the components in order to mount them by soldering them on top of the PCB. The 3D models will confirm the footprints dimensions and will be used in the box concept of the weather station in SolidWorks. The diode 1N4003 comes in a DO-41 package. Figure 45 DO-41 3D model The PNP transistor 2N2907 comes in a TO-18 package. 66 | P a g e Figure 46 DO-41 footprint Figure 47 TO-18 3D model Figure 48 TO-18 footprint The resistor pack and the 7-segment decoder come in 16 Duel-in-line package (DIP) so they can be placed on top of the socket. Figure 49 16 pin IC socket 3D model Figure 50 16 pin IC socket footprint The 5mm diameter LED with a pitch of 2.54mm. Figure 51 5mm diameter LED 3D model 67 | P a g e Figure 52 5mm diameter LED footprint The Temperature sensor LM35DZ comes in a TO-92 package. Figure 53 TO-92 3D model Figure 54 TO-92 footprint The Voltage regulator LM317 comes in a TO-220 package. Figure 55 TO-220 3D model The ¼ watt resistor comes in an Axial-0.4 package. 68 | P a g e Figure 56 TO-220 footprint Figure 57 AXIAL-0.4 resistor 3D model Figure 58 AXIAL-0.4 footprint The Mbed will be placed on top of a 40 pin connector. Figure 59 Mbed with 40 pin connector 3D model Figure 60 40 pin connector footprint The 10 pin connector will be used to connect the 7-segment to the PCB. Figure 61 10 pin connector 3D model 69 | P a g e Figure 62 10 pin connector footprint These components will be used in the box concept that will hold the weather station to get the exact dimensions needed. Figure 63 Touch screen PanelView Plus 600 3D model Figure 64 2x16 LCD 3D model 70 | P a g e Figure 65 Thumbwheel 3D model Figure 66 PCB circuit 71 | P a g e Figure 67 weather station panel 1 Figure 68 weather station panel 2 72 | P a g e Figure 69 weather station wiring Figure 70 PCB placed on top of the board 73 | P a g e References http://www.bobtech.ro/tutoriale/componente-electronice/43-calculator-online-mc34063amc34063-step-down-step-up-inverter http://appnote.avrportal.com/calculator/lm2575 http://www.electronics-lab.com/articles/LM317/ 74 | P a g e