EXAMINATION OF STATE 2006 SECOND WRITTEN TEST TEST AUTOMATION OF ELECTRONIC SYSTEMS AND ADDRESS: ELECTRONIC AND TELECOMMUNICAT

IONS Theme No. 2 solution proposed by PROF. SERGIO BOLOGNINI Initial comments and additional hypotheses: The subject requires to design a mic rocontroller or microprocessor. Because of the limited performance requirements to the system (on / off device in a very long time and accuracy required no push ing) it prefers a solution to the microcontroller. The micro chosen must have an analog line input (for temperature sensor), an A / D converter inside, 4 digita l outputs (for electronic) and a digital input (on off) for the level sensor. Th e pump is always under tension so that only valves are controlled through a simp le interface from the micro power. It is supposed to use with 12V solenoid excit ation current of about 100mA. It is hypothesized that the level transducer provi des a digital signal 0-5V (5V level to sup. A simple example is provided by two wires immersed in water and placed close to the desired level if the water reach es the wires close contact . A central element of the matter is certainly the de termination time. The system must be equipped with a clock and in this sense the re are three distinct possibilities: a. provide the system with a real time cloc k module that provides time correct the system via a serial connection to the mi cro b. provide a 1Hz clock that allows cells to increase about three seconds, mi nutes and hours. c. Use the clock through the micro and make the internal timer clock for determining effective time. The solution to even more performance requ ires an external module generally quite expensive (especially if it is expected that the time update takes place via radio). The other two solutions are equival ent with the advantage of not requiring a third circuitry additional. In both of these will be provided during the setup of the system in which to insert the ex act time from which to start the internal clock. For this feature can provide up to a two-button entry and one enabling plug the 'correct time (press Enter hour entry and modifying them up and confirmed with a second keypress entry, I move to minutes and so on. after the release of the second pressing the entry back to normal operation). As the solution that we choose c so that the assumption on (install) a period of time setting initializes hours minutes and seconds. For the specifications abov e, is suitable for a low-end 8-bit microcontroller. Is chosen for its widespread micro MICROCHIP PIC series 16F87x BLOCK DIAGRAM 12V ALIM. 5V clock Interf. Power 12V Valv1 Trasd. Temp of level sensor Condit. μC Interf. Power

Valv4 Power: Assuming you have a general power to 12 V (useful for solenoid valves) th e sect. of ALIM. Will consist of one simple voltage regulator 7805 which provide s a stable output to 5 volts. The power 12 will also be used for conditioning se ction of the signal from the transducer. Power Interface for solenoid valves: As said solenoid coil is electrically a command it can use a simple transistor int erface, as shown in the figure. The protection diode protects the transistor fro m overvoltage generated by the coil inside the solenoid changeover. 12V Valve Rb dimensioned so as to ensure that the excitation current of the solenoid. Rb = 5V - 0.6 V 4.4 V = 4.4 KΩ ≅ 100mA / 1mA hFE μC Rb Choosing Rb = 2.2 KΩ assure saturation. Conditioning temperature transducer: The signal from the temperature transducer provides a voltage Vt = 10mV / ° K · T Assuming a T ranging from 0 ° C to 50 ° C , it follows that the value in Kelvin ranges from 273K to 323K This provides a V t ranging from 2.73 V to 3.23 V. The chosen micro accepts input values from 0 to 5V is therefore necessary to amplify and translate the signal voltage. The form ula can be at 0V to 5V at 2.73 V and 3.23 V = Vo (Vt-voffset) · While G-Max voff set = Vt where G = Vo max-min 5V Vo = Vt = 10 max-min Vt 0.5 V Vo max = 3.23 V - 0.5 V = 2.73 V 10 Hence the following circuit, a differential subtracts 2.73 and a noninverting am plifier with a gain of 10. R Vt 2.73 V R R + + - R R1 R2 5V + 2.73 V So that the gain of the second stage is 10 is necessary that G = 1 + R2 = 10 from which we obtain R1 R2 = 9KΩ (available with the series of 2.2 KΩ and 6.8 KΩ) and R1 = 1KΩ.€It was n

ot considered necessary to include a low pass filter because the operation of av erage temperatures is actually a low pass digital filtering. Programme management: before submitting the flowchart considerations. The progra m is from 7.00 to 19.00 acquire and maintain the average temperature is therefor e not necessary to save the individual values, all data will be added in one var iable (two 8-bit MEDIAH cells and medial). In this phase also checked the level, if the line is found to 0 (level less than 2m) is the next day and wait for the day does not make irrigation (it's conceivable that the well is natural then th at we can fill only long time average) is performed at 19.00 Average temperature : less than 15 if we do not have irrigation (still expect the 7.00). The tempera ture determines the contents of a variable index that directs a table (below) th at contains the run time of different areas. Ind min. 1 20 2 26 3 30 4 30 5 39 6 45 7 30 8 39 9 45 10 40 11 52 12 60 If the temp is between 15 ° and 25 ° on the index is 1 and the time will refer t o cell 1, 4, 7, 10. Addressing the table with the area 1, +3 for 2, +6 to +9 for the third and fourth determine without further checks the correct time of irrig ation (note in this way that the time is easily modified by changing the table). The clock management is done in interrupt timer. Is set to trigger interrupt ev ery second, eg. 16-bit timer, cycle time 1μs, prescaler 64 and timer preloaded 1 5,625 (counting is made up from 65,536 to 15,625 = 49,911). FLOW CHART START Setup timers, interrupts, A / D, I / O ports, loading TAB STEP = 7, mean = 0 TIME STEP =? NOW S <20? START CONV S / D Fine.conv.? S V1, 2,3,4 <= OFF TIME = 20? STEP = 7 S V1 <= ON LIV = 0? S Sum 16-bit S = Media + MEDIA NOW ADDRESS = 19? S = MEDIA = Media · MEDIA/13 TM 50/255 STEP = STEP +1 TIME = 21? MIN = TAB (I)? STEP = STEP +1 S V1 <= OFF S V2 <= ON LIV = 0? STEP STEP = STEP +1 = 7 I = 1 TM> TM 15 S> 25 S S I = I 2 = 2 TM> 30 S

MIN = TAB (I +3)? S V2 <= OFF STEP = STEP +1 SEE PAG. FOLLOWING FLOW CHART Part 2 go to top CONTINUE go to shut down valves TIME = 22? S V3 <= ON TIMER INTERRUPT CLEAR FLAG = INT SEC SEC +1 LIV = 0? S MIN = TAB (I +6)? S V3 <V4 = OFF <= ON LIV = 0? SEC = 60? STEP = STEP +1 S SEC MIN = MIN +1 = 0 MIN = TAB (I +9)? MIN = 60? S V4 <= OFF STEP = 7 MIN = 0 TIME = TIME +1 TIME = 24? TIME = 0 BACK Note that the variable contains the time step of the next operation, and that th e variable is loaded to 7 when the level drops below two meters (the same off th e two valves). In that case irrigation should be discontinued and awaits the nex t day (during which the level will be checked again). It is noted that during th e setup is loading the table of the times previously stated. ENCODE follows the coding in assembler for PIC 16F87x portion of the program tha t performs the division by 13 and the subsequent multiplication by 10 and divide by 51 (TM = equivalent transaction MEDIA * 50/255) You use a procedure that div ides the DIVIDE 16-bit value contained in MEDIAH and medial to the value in work ing and puts the result into the variable RES. The division is performed for sub traction and ignoring the rest, while the multiplication is made by the method o f successive sums. Movlw movwf movlw movwf MOVF CALL MOVF ADDWF Cycle BTFSC GOTO

DECFSZ incf movlw movwf DIVIDE CALL CLRF MOVF Loop SUBWF DECFSZ BTFSC GOTO GOTO GOTO btfss SUBWF Loop1 incf incf incf increments GOTO END GOTO RETURN SPLIT RES ULTING 13d, 9d IND MEDIAL MEDIAL MEDIAL W, F STATUS C MEDIAH INDEX Cycle 51d DIV IDE RIS TM , Calls the procedure that divides mediah-media for 13, put the result in medial office in the variable ind 9 (for the moltiplicaz. For 10), makes working in me dial, medial = medial + w, if there was carry-increment mediah , The routine divides mediah-medial 51; copy the result in TM RIS Media, F STATUS, C increments increments MEDIAH RIS Media, F STATUS, C END L OOP RIS RIS LOOP ; Zero result, medial = medial-w, if there loan (medial <w) Skip prox. Instructi on; go to increments, decrements to zero and if mediah jumps prox. Instruction, and if the jump is zero mediah prox. Instr go to increments, medial = medial-w, if there loan (medial <w) Skip prox. Instruction; go to increments, the subrouti ne returns