m33600

5ecos Display Analitico as of 3 mar 19

Mar 3rd, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.66 KB | None | 0 0
  1.  
  2. // 5ecos Display Analitico 3 mar 19
  3. // falta mapfoats e calibracoes gerais
  4. // falta IHM no touch
  5.  
  6. #include <MovingAverage.h>
  7. #include "max6675.h"
  8. #include <SimpleTimer.h>  
  9. SimpleTimer timer; // instantiate
  10.  
  11. #include <UTFT.h>
  12. extern uint8_t SmallFont[];// Declare which fonts we will be using
  13. extern uint8_t BigFont[];// Declare which fonts we will be using
  14. extern uint8_t SevenSegNumFont;// Declare which fonts we will be using
  15. UTFT myGLCD(CTE32_R2,38,39,40,41);
  16.  
  17.  
  18. // Create moving average with window size of 100.
  19. MovingAverage average(100);
  20. // A function that computes and returns the value that we want (in this case
  21. // the value of the analog pin 0 remapped to [0, 1].
  22.   int pino;
  23.  
  24. int thermoDO = 50;
  25. int thermoCS = 20;
  26. int thermoCS2 = 21;
  27. int thermoCLK = 52;
  28.  
  29. MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
  30. MAX6675 thermocouple2(thermoCLK, thermoCS2, thermoDO);
  31.  
  32. int vccPin = 3;
  33. int gndPin = 2;
  34.  
  35. float temperatura1;
  36. float temperatura2;
  37. int pesoOptico;
  38. int pesoAnalogico;
  39. int corrente1;
  40. int corrente2;
  41. int corrente3;  
  42.  
  43. float readInput() {return 1023 - analogRead(pino); }
  44.  
  45.  
  46. //--------------------------------SETUP---------------------------------------
  47. void setup() {
  48.  
  49.     average.reset( readInput );
  50.  
  51.     for (int thisPin = 0; thisPin <= 7; thisPin++) {
  52.     pinMode(thisPin, INPUT_PULLUP);
  53.      }
  54.      analogReference(INTERNAL1V1);
  55.  
  56.   myGLCD.InitLCD();// Setup the LCD
  57.  // myGLCD.setFont(SmallFont);
  58.     myGLCD.setFont(BigFont);
  59. myGLCD.clrScr();
  60. myGLCD.setBackColor(VGA_TRANSPARENT);
  61.  
  62.     timer.setInterval(500L,lerTemp);
  63.     timer.setInterval(500L,lerPeso);
  64.     timer.setInterval(500L,lerCorrentes);
  65.     timer.setInterval(1000L,showDisplay);
  66.   Serial.begin(9600); // Manter 9600 para 5ecos = > Bluetooth log
  67.   // use Arduino pins
  68.   pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  69.   pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  70.  
  71.   Serial.println("MAX6675 test");
  72.   // wait for MAX chip to stabilize
  73.   delay(500);
  74. }
  75. //------------------------------------------------------------LOOP----------------------------------------------
  76. void loop() {
  77. timer.run();
  78. }//-------------------------------------------------------E O LOOP----------------------------------------------
  79.  
  80.  
  81. ///--------------------------------------------------------- TAB CORRENTES----------------------------------------
  82. void lerCorrentes(){
  83.  
  84. corrente1=0;corrente2=0;corrente3=0;
  85. int I1=0;int I2=0;int I3=0;
  86. int amostras = 20;  // limitar amostras ( tempo e estouro da variavel)
  87. int espera = 2;
  88. //for (int i = 0 ; i< amostras ; i++){
  89. //delay(espera);
  90. //
  91. //I1 = I1 + analogRead(A0);delay(espera);
  92. //
  93. //I2 = I2 + analogRead(A1);delay(espera);
  94. //
  95. //I3 = I3 + analogRead(A2);delay(espera);
  96. //
  97. //
  98. //}
  99.  
  100. pino = 0; corrente1 = readInput();
  101. pino = 1; corrente2 = readInput();
  102. pino = 2; corrente3 = readInput();
  103.  
  104. Serial.println( average.update( readInput() ) );
  105.  
  106.    Serial.print("Resistencias Grupo 1 = ");
  107.    Serial.println(corrente1);
  108.    delay(200);
  109.    Serial.print("Resistencias Grupo 2 = ");
  110.    Serial.println(corrente2);
  111.    delay(200);
  112.    Serial.print("Resistencias Grupo 3 = ");
  113.    Serial.println(corrente3);
  114.    delay(200);
  115.  
  116. }
  117. //----------------------------------------------------- TAB DISPLAY------------------------------------------------
  118. void showDisplay(){
  119.  
  120. myGLCD.setFont(SmallFont);
  121. myGLCD.setColor(255, 255, 0);
  122. myGLCD.print("  5ecos Display Analitico V.19.2  ",CENTER,0); // Print the value of “num”
  123.  
  124. // conteudo a mostrar:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  125.  
  126. myGLCD.setFont(BigFont);
  127. //myGLCD.setBackColor(VGA_TRANSPARENT);
  128.     myGLCD.setColor(0,255,255);
  129.   //  myGLCD.print(" Peso AN :      ", LEFT, 20);
  130.     myGLCD.print(" Peso AN :" + String(pesoAnalogico)+"   ", LEFT, 20);
  131.    
  132.  //   myGLCD.print(" Peso OP :      ", LEFT, 40);
  133.     myGLCD.print(" Peso OP :"+String(pesoOptico)+"   ", LEFT, 40);
  134.     myGLCD.drawRect(2,14,318,65); // Draw a rectangle
  135.  
  136.        myGLCD.setColor(VGA_RED);
  137.        myGLCD.print(" Temperat M:"+String(temperatura1), LEFT, 80);
  138.        myGLCD.print(" Temperat O:"+String(temperatura2), LEFT, 100);
  139.        myGLCD.drawRect(2,74,318,125); // Draw a rectangle
  140.  
  141.               myGLCD.setColor(VGA_WHITE);
  142.              // myGLCD.print(" Corrente 1:      ", LEFT, 140);
  143.               myGLCD.print(" Corrente 1:"+String(corrente1)+"   ", LEFT, 140);
  144.          
  145.             //  myGLCD.print(" Corrente 2:      ", LEFT, 160);
  146.               myGLCD.print(" Corrente 2:"+String(corrente2)+"   ", LEFT, 160);
  147.            
  148.            //   myGLCD.print(" Corrente 3:      ", LEFT, 180);
  149.               myGLCD.print(" Corrente 3:"+String(corrente3)+"   ", LEFT, 180);
  150.               myGLCD.drawRect(2,134,318,205); // Draw a rectangle
  151.  
  152. //myGLCD.drawRect(2,14,318,65); // Draw a rectangle
  153. //myGLCD.drawRoundRect(4,4,316,236);
  154.  
  155.  
  156.  
  157.        
  158.       myGLCD.setFont(SmallFont);
  159.   myGLCD.setColor(255, 255, 0);
  160.   myGLCD.setBackColor(0, 0, 0);
  161.   myGLCD.print(String(millis()/1000)+ " www.5ecos.com.br", CENTER, 228);
  162. //  myGLCD.printNumI(millis(), CENTER, 225);
  163.  
  164.  //  myGLCD.setFont(SevenSegNumFont);
  165. //myGLCD.printNum(123.1234,CENTER,40); // Print the value of “num”
  166.  
  167.  
  168.       myGLCD.setFont(BigFont);
  169.  
  170. }
  171.  
  172. // ---------------------------------------------------TAB PESO----------------------------------------------
  173. void lerPeso(){
  174.  
  175.  
  176. pesoOptico = 1023 - analogRead(A3);  // le para baixo, a partir de pullup
  177. pesoAnalogico = analogRead(A4); // le 0-10V direto >>>  0 - 1 V do divisor 1k | 100R
  178.    Serial.print("Peso Optico = ");
  179.    Serial.println(pesoOptico);
  180.    delay(200);
  181.    Serial.print("Peso Analogico = ");
  182.    Serial.println(pesoAnalogico);
  183.  
  184. }
Advertisement
Add Comment
Please, Sign In to add comment