Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2010
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. #include <XE164F.h>
  2. #include <../lcd_XE164.h>
  3. //----------------Variablendeklaration--------------------------------------
  4. //eingänge
  5. sbit grad60=P1_IN^1; //melder60
  6. sbit grad90=P1_IN^2; //melder90
  7. sbit sw_temp=P1_IN^3; //schalter60/90
  8. sbit einaus=P1_IN^4; //ein aus schalter
  9. sbit pegel1=P1_IN^5; //pegal wasserpegal S3
  10. //ausgänge
  11. sbit heizung=P1_OUT^0; //heizung
  12. sbit motor=P1_OUT^6; //motor M
  13. sbit zulauf=P1_OUT^7; //zulauf Y
  14. sbit ablauf=P4_OUT^0; //ablaufventil/pumpe P
  15. sbit schleudern=P4_OUT^1; //schleudern M(schleudern)
  16. int phase4=0;
  17. int sekzaehler=0; //zähler sekunden
  18.  
  19. //------------------Funktionsdeklaration------------------------------------
  20. void init (void);
  21. void MAIN_vUnlockProtecReg(void);
  22. void regelung (void);
  23. //------------------Hauptprogramm-------------------------------------------
  24. void main (void)
  25. {
  26. init();
  27. while(1)
  28. {
  29. regelung();
  30. }
  31.  
  32. }
  33. void init (void)
  34. {
  35. P1_IOCR00=0;
  36. P1_IOCR01=0;
  37. P1_IOCR02=0;
  38. P1_IOCR03=0;
  39. P1_IOCR04=0;
  40. P1_IOCR05=0;
  41. P1_IOCR06=0x80;
  42. P1_IOCR07=0x80;
  43. P4_IOCR00=0x80;
  44. P4_IOCR01=0x80;
  45. lcd_init();
  46. lcd_clr();
  47.  
  48. //timer aktivierung/definierung
  49. MAIN_vUnlockProtecReg();
  50. GPT12E_KSCCFG=0x0003;
  51. GPT12E_T2=39062; //timer auf einer sekunde
  52. GPT12E_T2CON=0x18C7;
  53. GPT12E_T3=39062; //timer auf einer sekunde
  54. GPT12E_T3CON=0x18C7;
  55.  
  56. //Interruptfreigaben
  57. GPT12E_T3IC=0x046;
  58. GPT12E_T2IC=0x046;
  59. PSW_IEN=1;
  60. }
  61. //----------------------unlock definition-------------------------------------------------
  62. void MAIN_vUnlockProtecReg(void)
  63. {
  64.  
  65. //timerentrigelung notwendig
  66. unsigned int uwPASSWORD;
  67.  
  68. SCU_SLC =0xAAAA;
  69. SCU_SLC =0x5554;
  70.  
  71. uwPASSWORD = SCU_SLS & 0x00FF;
  72. uwPASSWORD =
  73. (~uwPASSWORD)& 0x00FF;
  74. SCU_SLC= 0x9600 |uwPASSWORD;
  75. SCU_SLC= 0x0000;
  76.  
  77. }
  78.  
  79. void phase3f (void) interrupt 0x20
  80. {
  81. if(phase4==0)
  82. {
  83. sekzaehler++;
  84. GPT12E_T2=39062;
  85. motor=1;
  86. heizung=0;
  87. lcd_curs(0);
  88. lcd_str("phase3 t2 ");
  89.  
  90. if (sekzaehler==10)
  91. {
  92. motor=0;
  93. phase4=1;
  94.  
  95. sekzaehler=0;
  96. lcd_curs(0);
  97. lcd_str("phase3 t2 voll ");
  98. }
  99. }
  100. }
  101.  
  102. void phase4f (void) interrupt 0x21
  103. {
  104. if(phase4==1)
  105. {
  106. schleudern=1;
  107. sekzaehler++;
  108. ablauf=1;
  109. GPT12E_T3=39062;
  110. lcd_curs(0);
  111. lcd_str("phase4 t3 ");
  112.  
  113. if (sekzaehler==5)
  114. {
  115. ablauf=0;
  116. lcd_curs(0);
  117. lcd_str("phase4 t3 ablauf off ");
  118. }
  119. if (sekzaehler==10)
  120. {
  121. phase4=0;
  122. ablauf=0;
  123. schleudern=0;
  124. sekzaehler=0;
  125. lcd_curs(0);
  126. lcd_str("phase4 t3 zeit um schleudern aus");
  127.  
  128. }
  129. }
  130. }
  131.  
  132. void regelung (void)
  133. {
  134. //Füllen phase1
  135. while(pegel1==0&&!phase4)
  136. {
  137. zulauf=1;
  138. lcd_curs(0);
  139. lcd_str("phase1 füllen ");
  140. }
  141. zulauf=0;
  142. //heizung phase3
  143. if (phase4==0)
  144. {
  145. lcd_curs(0);
  146. lcd_str("phase3 +heizen ");
  147. if (sw_temp==0)
  148. {
  149. if (grad60==0)
  150. {
  151. heizung=1;
  152. }
  153. else
  154. {
  155. heizung=0;
  156. }
  157. }
  158. else
  159. {
  160. if (grad90==0)
  161. {
  162. heizung=1;
  163. }
  164. else
  165. {
  166. heizung=0;
  167. }
  168. }
  169.  
  170. }
  171.  
  172.  
  173.  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement