Ejercicio N°3: Sistema de control de una heladera
Dependencies: DS1820 KL25zOTEROlib TSI mbed
Fork of DS1820_HelloWorld by
Revision 5:109b192b40a5, committed 2018-06-05
- Comitter:
- JAgustinOtero
- Date:
- Tue Jun 05 23:31:11 2018 +0000
- Parent:
- 4:01060b5e01b4
- Commit message:
- Ejercicio N?3:; Sistema de control de una heladera
Changed in this revision
diff -r 01060b5e01b4 -r 109b192b40a5 KL25zOTEROlib.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KL25zOTEROlib.lib Tue Jun 05 23:31:11 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/JAgustinOtero/code/KL25zOTEROlib/#c274503f9285
diff -r 01060b5e01b4 -r 109b192b40a5 TSI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Tue Jun 05 23:31:11 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
diff -r 01060b5e01b4 -r 109b192b40a5 main.cpp --- a/main.cpp Fri Jan 13 18:30:37 2017 +0000 +++ b/main.cpp Tue Jun 05 23:31:11 2018 +0000 @@ -1,18 +1,27 @@ -#define MULTIPLE_PROBES -#define DATA_PIN A0 - - -#ifdef MULTIPLE_PROBES - +#define DATA_PIN PTE20 +#define MAX_PROBES 16 #include "mbed.h" #include "DS1820.h" +#include "Display16.h" +#include "SETdata_TSI.h" +#include "ME_Compresor.h" +#include "ME_Ventilador.h" +#include "ME_Alarma.h" +void __interruptDisplay(void); +void __interruptSETData(void); +void __Alarma(void); -#define MAX_PROBES 16 - +unsigned char VSet=4; +unsigned char TRet=0; +unsigned int var_alarma=0; +unsigned int alarmav=0; +Ticker display; DS1820* probe[MAX_PROBES]; - -int main() { - // Initialize the probe array to DS1820 objects +Ticker SetData; +Ticker Alarma; +float promedio,t1,t2,t1r,t2r; +int main() +{ int num_devices = 0; while(DS1820::unassignedProbe(DATA_PIN)) { probe[num_devices] = new DS1820(DATA_PIN); @@ -20,30 +29,43 @@ if (num_devices == MAX_PROBES) break; } - printf("Found %d device(s)\r\n\n", num_devices); + display.attach(&__interruptDisplay,0.003); + SetData.attach(&__interruptSETData,0.1); + Alarma.attach(&__Alarma,0.1); while(1) { probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready - for (int i = 0; i<num_devices; i++) + t1r=probe[0]->temperature(); + t2r=probe[1]->temperature(); + if(t1r>0) t1=t1r; + if(t2r>0) t2=t2r; + promedio=((t1/3*10)+(t2/3*10))/2; + for (int i = 0; i<num_devices; i++) { printf("Device %d returns %3.1foC\r\n", i, probe[i]->temperature()); - printf("\r\n"); - wait(1); - } - -} - -#else -#include "mbed.h" -#include "DS1820.h" - -DS1820 probe(DATA_PIN); - -int main() { - while(1) { - probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready - printf("It is %3.1foC\r\n", probe.temperature()); - wait(1); + printf("\r\n"); + } + ME_Ventilador(t1,t2); + ME_Compresor(VSet,promedio); + ME_Alarma(var_alarma); + } } -#endif \ No newline at end of file +void __interruptDisplay () +{ + if(ME_Alarma_estado==A_on)alarmav=1; + else alarmav=0; + display16(TRet,VSet,promedio,alarmav); +} +void __interruptSETData (void) +{ + VSet=SETData(); + TRet=RetainData(); +} + +void __Alarma() +{ + if(ME_Alarma_estado==espera && var_alarma>0) { + var_alarma--; + } +} \ No newline at end of file