Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 5ecos Display Analitico 3 mar 19
- // falta mapfoats e calibracoes gerais
- // falta IHM no touch
- #include <MovingAverage.h>
- #include "max6675.h"
- #include <SimpleTimer.h>
- SimpleTimer timer; // instantiate
- #include <UTFT.h>
- extern uint8_t SmallFont[];// Declare which fonts we will be using
- extern uint8_t BigFont[];// Declare which fonts we will be using
- extern uint8_t SevenSegNumFont;// Declare which fonts we will be using
- UTFT myGLCD(CTE32_R2,38,39,40,41);
- // Create moving average with window size of 100.
- MovingAverage average(100);
- // A function that computes and returns the value that we want (in this case
- // the value of the analog pin 0 remapped to [0, 1].
- int pino;
- int thermoDO = 50;
- int thermoCS = 20;
- int thermoCS2 = 21;
- int thermoCLK = 52;
- MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
- MAX6675 thermocouple2(thermoCLK, thermoCS2, thermoDO);
- int vccPin = 3;
- int gndPin = 2;
- float temperatura1;
- float temperatura2;
- int pesoOptico;
- int pesoAnalogico;
- int corrente1;
- int corrente2;
- int corrente3;
- float readInput() {return 1023 - analogRead(pino); }
- //--------------------------------SETUP---------------------------------------
- void setup() {
- average.reset( readInput );
- for (int thisPin = 0; thisPin <= 7; thisPin++) {
- pinMode(thisPin, INPUT_PULLUP);
- }
- analogReference(INTERNAL1V1);
- myGLCD.InitLCD();// Setup the LCD
- // myGLCD.setFont(SmallFont);
- myGLCD.setFont(BigFont);
- myGLCD.clrScr();
- myGLCD.setBackColor(VGA_TRANSPARENT);
- timer.setInterval(500L,lerTemp);
- timer.setInterval(500L,lerPeso);
- timer.setInterval(500L,lerCorrentes);
- timer.setInterval(1000L,showDisplay);
- Serial.begin(9600); // Manter 9600 para 5ecos = > Bluetooth log
- // use Arduino pins
- pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
- pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
- Serial.println("MAX6675 test");
- // wait for MAX chip to stabilize
- delay(500);
- }
- //------------------------------------------------------------LOOP----------------------------------------------
- void loop() {
- timer.run();
- }//-------------------------------------------------------E O LOOP----------------------------------------------
- ///--------------------------------------------------------- TAB CORRENTES----------------------------------------
- void lerCorrentes(){
- corrente1=0;corrente2=0;corrente3=0;
- int I1=0;int I2=0;int I3=0;
- int amostras = 20; // limitar amostras ( tempo e estouro da variavel)
- int espera = 2;
- //for (int i = 0 ; i< amostras ; i++){
- //delay(espera);
- //
- //I1 = I1 + analogRead(A0);delay(espera);
- //
- //I2 = I2 + analogRead(A1);delay(espera);
- //
- //I3 = I3 + analogRead(A2);delay(espera);
- //
- //
- //}
- pino = 0; corrente1 = readInput();
- pino = 1; corrente2 = readInput();
- pino = 2; corrente3 = readInput();
- Serial.println( average.update( readInput() ) );
- Serial.print("Resistencias Grupo 1 = ");
- Serial.println(corrente1);
- delay(200);
- Serial.print("Resistencias Grupo 2 = ");
- Serial.println(corrente2);
- delay(200);
- Serial.print("Resistencias Grupo 3 = ");
- Serial.println(corrente3);
- delay(200);
- }
- //----------------------------------------------------- TAB DISPLAY------------------------------------------------
- void showDisplay(){
- myGLCD.setFont(SmallFont);
- myGLCD.setColor(255, 255, 0);
- myGLCD.print(" 5ecos Display Analitico V.19.2 ",CENTER,0); // Print the value of “num”
- // conteudo a mostrar:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- myGLCD.setFont(BigFont);
- //myGLCD.setBackColor(VGA_TRANSPARENT);
- myGLCD.setColor(0,255,255);
- // myGLCD.print(" Peso AN : ", LEFT, 20);
- myGLCD.print(" Peso AN :" + String(pesoAnalogico)+" ", LEFT, 20);
- // myGLCD.print(" Peso OP : ", LEFT, 40);
- myGLCD.print(" Peso OP :"+String(pesoOptico)+" ", LEFT, 40);
- myGLCD.drawRect(2,14,318,65); // Draw a rectangle
- myGLCD.setColor(VGA_RED);
- myGLCD.print(" Temperat M:"+String(temperatura1), LEFT, 80);
- myGLCD.print(" Temperat O:"+String(temperatura2), LEFT, 100);
- myGLCD.drawRect(2,74,318,125); // Draw a rectangle
- myGLCD.setColor(VGA_WHITE);
- // myGLCD.print(" Corrente 1: ", LEFT, 140);
- myGLCD.print(" Corrente 1:"+String(corrente1)+" ", LEFT, 140);
- // myGLCD.print(" Corrente 2: ", LEFT, 160);
- myGLCD.print(" Corrente 2:"+String(corrente2)+" ", LEFT, 160);
- // myGLCD.print(" Corrente 3: ", LEFT, 180);
- myGLCD.print(" Corrente 3:"+String(corrente3)+" ", LEFT, 180);
- myGLCD.drawRect(2,134,318,205); // Draw a rectangle
- //myGLCD.drawRect(2,14,318,65); // Draw a rectangle
- //myGLCD.drawRoundRect(4,4,316,236);
- myGLCD.setFont(SmallFont);
- myGLCD.setColor(255, 255, 0);
- myGLCD.setBackColor(0, 0, 0);
- myGLCD.print(String(millis()/1000)+ " www.5ecos.com.br", CENTER, 228);
- // myGLCD.printNumI(millis(), CENTER, 225);
- // myGLCD.setFont(SevenSegNumFont);
- //myGLCD.printNum(123.1234,CENTER,40); // Print the value of “num”
- myGLCD.setFont(BigFont);
- }
- // ---------------------------------------------------TAB PESO----------------------------------------------
- void lerPeso(){
- pesoOptico = 1023 - analogRead(A3); // le para baixo, a partir de pullup
- pesoAnalogico = analogRead(A4); // le 0-10V direto >>> 0 - 1 V do divisor 1k | 100R
- Serial.print("Peso Optico = ");
- Serial.println(pesoOptico);
- delay(200);
- Serial.print("Peso Analogico = ");
- Serial.println(pesoAnalogico);
- }
Advertisement
Add Comment
Please, Sign In to add comment