Veja como ficou:
Esse é o codigo:
// incluir a library do LCD#include <LiquidCrystal.h>
// inicializar a library do LCD com nos pinosLiquidCrystal lcd(11, 12, 7, 8, 9, 10);int holdTime = 1500; // tempo do hold (botao pressionado)int botao = 0; // botao apertadoint hold = 0; // botao pressionado x tempolong onTime = 0; // conta tempo botao apertado
void setup() { // Mensagem de abertura. lcd.begin(16, 2); lcd.print("5 botoes + hold v1"); lcd.setCursor(0,1); lcd.print("by Renato Brant"); delay(1000); lcd.clear(); long onTime = 0; pinMode (A5, INPUT); lcd.clear();}
void loop() { int valorBotao = analogRead(5); // le valor da tensao causado pelas resistencias dos botoes int botao = 0; // considera que nenhum botao esta apertado // vamos definir o valor lido na porta analogica para cada botao if (valorBotao > 304 && valorBotao < 394) botao = 1; //botao UP if (valorBotao > 484 && valorBotao < 574) botao = 2; //botao OK if (valorBotao > 666 && valorBotao < 749) botao = 3; //botao RIGHT if (valorBotao > 824 && valorBotao < 887) botao = 4; //botao LEFT if (valorBotao > 938 && valorBotao < 989) botao = 5; //botao DOWN // agora começa o sistema para fazer o HOLD // enquanto nenhum botao é apertado, nos guardamos o valor do millis no onTime e deixamos o valor do HOLD zerado if (valorBotao < 304){ onTime = millis(); hold=0; } // quando algum botao for apertado E o tempo que o botao esta apertado for maior que o holdTime, o valor do HOLD vai para 1. if (valorBotao > 304 && ((millis() - onTime) > holdTime)) hold =1;//Neste ponto, já temos as duas variaveis que nos interessa://botao => retorna o numero do botao que está sendo apertado//hold => vira 1 se algum botão for apertado por mais de 3 segundos//Para uma melhor visualização, vamos mandar alguns valores para o LCD
//obs: agora é só "firula"
// vamos visualizar o valor lido pela porta analogica
lcd.clear();
lcd.setCursor(0,0); lcd.print("V"); lcd.print(valorBotao);
// vamos visualizar o valor de "botao" lcd.setCursor(5,0); lcd.print("B"); lcd.print(botao); // vamos ver quanto tempo algum botao está apertado lcd.setCursor(8,0); lcd.print("T"); lcd.print((millis() - onTime)/1000); // vamos ver se o "hold" está habilitado lcd.setCursor(11,0); lcd.print("H"); lcd.print(hold); // na segunda linha, vamos mostrar o estado de forma escrita lcd.setCursor(0,1); if (botao == 0) lcd.print(" "); else if (botao == 1) lcd.print("UP"); else if (botao == 2) lcd.print("OK"); else if (botao == 3) lcd.print("RIGHT"); else if (botao == 4) lcd.print("LEFT"); else if (botao == 5) lcd.print("DOWN"); if (hold == 1) lcd.print("+HOLD"); delay(250);}
Aqui estão os esquemas:
Eu ainda não montei fisicamente, mas assim que eu tiver um tempo, eu farei e colocarei o video aqui.
…
Adicionado por renatobrant ao 16:56 em 17 janeiro 2012
era alterar o codigo, para que quando eu clicasse NESSA imagem, que me acendesse um led e quando eu voltasse a clicar que me desligasse o led.
Alguem e capaz de modificar esse codigo?
/* * This is a web server that allows you to host a fully functional html * webpage on the World Wide Web. * Initial coding was done with the help from the many people in the Arduino community. * Thanks guys!! * * Arduino Setup: You need an Ethernet Shield SD, and and Arduino. * Optionally pins 8 and 9 can be used for two LEDs that can indicate traffic. * * SD Card Setup: On the SD card, which must be formated as fat, you must have * an HTML file with the file name of 'index.htm'. All file names on this card * must be written in the old 8.3 file format. In other words, all files must be * named with no more then 8 characters for the name, and 3 for the extension. * * Note: If you don't know HTML, a good place that I found useful was w3schools * http://www.w3schools.com/html/html_examples.asp * */ #include <LiquidCrystal.h> #include <SPI.h> #include <SdFat.h> #include <SdFatUtil.h> #include <Ethernet.h> #define BUFSIZ 128 #define greenLEDandBEEP 2 #define redLEDpin 3 boolean led2 = true; int hits = 0; // Set the number of hits the hit counter will start at. int units = 0; int count = 0; int photocellPin = 2; int photocellReading; LiquidCrystal lcd(4, 5, 6, 7, 8, 9); //Local ethernet setup byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x1C, 0x0E }; byte ip[] = { 192, 168, 1, 80 }; char rootFileName[] = "index.htm"; Server server(8080); //SD card stuff Sd2Card card; SdVolume volume; SdFile root; SdFile file; #define error(s) error_P(PSTR(s)) void error_P(const char* str) { PgmPrint("error: "); SerialPrintln_P(str); if (card.errorCode()) { PgmPrint("SD error: "); Serial.print(card.errorCode(), HEX); Serial.print(','); Serial.println(card.errorData(), HEX); } while(1); } void setup() { lcd.begin(16, 2); lcd.print("Web Server v2.00"); lcd.setCursor(0, 1); lcd.print("Hits:"); Serial.begin(9600); pinMode(greenLEDandBEEP, OUTPUT); pinMode(redLEDpin, OUTPUT); PgmPrint("Free RAM: "); Serial.println(FreeRam()); pinMode(10, OUTPUT); digitalWrite(10, HIGH); if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!"); if (!volume.init(&card)) error("vol.init failed!"); PgmPrint("Volume is FAT"); Serial.println(volume.fatType(),DEC); Serial.println(); if (!root.openRoot(&volume)) error("openRoot failed"); PgmPrintln("Files found in root:"); root.ls(LS_DATE | LS_SIZE); Serial.println(); PgmPrintln("Files found in all dirs:"); root.ls(LS_R); Serial.println(); PgmPrintln("Done"); Ethernet.begin(mac, ip); server.begin(); } void loop() { if(count >=500) { led2 = !led2; digitalWrite(redLEDpin, led2); count = 0; } count +=1; char clientline[BUFSIZ]; char *filename; int image = 0; int index = 0; Client client = server.available(); if (client) { boolean current_line_is_blank = true; index = 0; while (client.connected()) { if (client.available()) { char c = client.read(); if (c != '\n' && c != '\r') { clientline[index] = c; index++; if (index >= BUFSIZ) index = BUFSIZ -1; continue; } clientline[index] = 0; filename = 0; Serial.println(clientline); if (strstr(clientline, "GET / ") != 0) { filename = rootFileName; } if (strstr(clientline, "GET /") != 0) { if (!filename) filename = clientline + 5; (strstr(clientline, " HTTP"))[0] = 0; Serial.println(filename); if (! file.open(&root, filename, O_READ)) { client.println("HTTP/1.1 404 Not Found"); client.println("Content-Type: text/html"); client.println(); client.println("<h2>Error 404</h2>"); client.println("<s2>The file does not exist.<s2>"); client.println(""); break; } Serial.println("Opened!"); //File types client.println("HTTP/1.1 200 OK"); if (strstr(filename, ".htm") != 0) client.println("Content-Type: text/html"); else if (strstr(filename, ".css") != 0) client.println("Content-Type: text/css"); else if (strstr(filename, ".png") != 0) client.println("Content-Type: image/png"); else if (strstr(filename, ".jpg") != 0) client.println("Content-Type: image/jpeg"); else if (strstr(filename, ".gif") != 0) client.println("Content-Type: image/gif"); else if (strstr(filename, ".3gp") != 0) client.println("Content-Type: video/mpeg"); else if (strstr(filename, ".pdf") != 0) client.println("Content-Type: application/pdf"); else if (strstr(filename, ".js") != 0) client.println("Content-Type: application/x-javascript"); else if (strstr(filename, ".xml") != 0) client.println("Content-Type: application/xml"); else client.println("Content-Type: text"); client.println(); int16_t c; while ((c = file.read()) >= 0) { //Serial.print((char)c); //Prints all HTML code to serial (For debuging) client.print((char)c); //Prints all HTML code for web page } //Hit counter math if(units >= 2) { hits ++; units = 0; } units +=1; //End hit counter math //Print the hit counters and light value lcd.setCursor(6, 1); lcd.print(hits); //Print hits for LCD hit counter client.print("<html><body>"); //HTML code starts here client.print("<P align=\"center\">"); client.print("Hits since reset: <b>"); client.print(hits); //Print hits to client client.print("</b><br>"); photocellReading = analogRead(photocellPin); client.print("Light reading: "); client.print(photocellReading); //Prints light reading to client // A few threshholds if (photocellReading < 10) { client.print(" - Dark"); } else if (photocellReading < 200) { client.print(" - Dim"); } else if (photocellReading < 500) { client.print(" - Light"); } else if (photocellReading < 800) { client.print(" - Bright"); } else { client.print(" - Very bright"); } client.print("</p></body></html>"); //HTML code ends here //End hit counter and light value file.close(); } else { client.println("HTTP/1.1 404 Not Found"); client.println("Content-Type: text/html"); client.println(); client.println("<h2>Error 404</h2>"); client.println(""); } break; } } digitalWrite(greenLEDandBEEP, HIGH); delay(1); digitalWrite(greenLEDandBEEP, LOW); client.stop(); } } //The End /*
…
poderia me ajudar a entender a sintaxe da parte que eu destaquei em vermelho?
Seria interessante utilizar uma rede MODBUS sem supervisórios em aplicações onde o custo total da instalação é reduzido...
#include <SimpleModbusMaster.h>
/* SimpleModbusMaster allows you to communicate to any slave using the Modbus RTU protocol. To communicate with a slave you need to create a packet that will contain all the information required to communicate to the slave. Information counters are implemented for further diagnostic. These are variables already implemented in a packet. You can set and clear these variables as needed. The following modbus information counters are implemented: requests - contains the total requests to a slave successful_requests - contains the total successful requests failed_requests - general frame errors, checksum failures and buffer failures retries - contains the number of retries exception_errors - contains the specific modbus exception response count These are normally illegal function, illegal address, illegal data value or a miscellaneous error response. And finally there is a variable called "connection" that at any given moment contains the current connection status of the packet. If true then the connection is active. If false then communication will be stopped on this packet until the programmer sets the connection variable to true explicitly. The reason for this is because of the time out involved in modbus communication. Each faulty slave that's not communicating will slow down communication on the line with the time out value. E.g. Using a time out of 1500ms, if you have 10 slaves and 9 of them stops communicating the latency burden placed on communication will be 1500ms * 9 = 13,5 seconds! Communication will automatically be stopped after the retry count expires on each specific packet. All the error checking, updating and communication multitasking takes place in the background. In general to communicate with to a slave using modbus RTU you will request information using the specific slave id, the function request, the starting address and lastly the number of registers to request. Function 3, 4 & 16 are supported. In addition to this broadcasting (id = 0) is supported for function 16. Constants are provided for: Function 3 - READ_HOLDING_REGISTERS Function 4 - READ_INPUT_REGISTERS Function 16 - PRESET_MULTIPLE_REGISTERS Note: The Arduino serial ring buffer is 128 bytes or 64 registers. Most of the time you will connect the Arduino using a MAX485 or similar. In a function 3 or 4 request the master will attempt to read from a slave and since 5 bytes is already used for ID, FUNCTION, NO OF BYTES and two BYTES CRC the master can only request 122 bytes or 61 registers. In a function 16 request the master will attempt to write to a slave and since 9 bytes is already used for ID, FUNCTION, ADDRESS, NO OF REGISTERS, NO OF BYTES and two BYTES CRC the master can only write 118 bytes or 59 registers. Note: Using a USB to Serial converter the maximum bytes you can send is limited to its internal buffer which differs between manufactures. Since it is assumed that you will mostly use the Arduino to connect without using a USB to Serial converter the internal buffer is set the same as the Arduino Serial ring buffer which is 128 bytes.*/
//////////////////// Port information ///////////////////#define baud 9600#define timeout 1000#define polling 200 // the scan rate
// If the packets internal retry register matches// the set retry count then communication is stopped// on that packet. To re-enable the packet you must// set the "connection" variable to true.#define retry_count 5
// used to toggle the receive/transmit pin on the driver#define TxEnablePin 2
// This is the easiest way to create new packets// Add as many as you want. TOTAL_NO_OF_PACKETS// is automatically updated.enum{ PACKET1, PACKET2, // leave this last entry TOTAL_NO_OF_PACKETS};
// Create an array of Packets to be configuredPacket packets[TOTAL_NO_OF_PACKETS];
// Create a packetPointer to access each packet// individually. This is not required you can access// the array explicitly. E.g. packets[PACKET1].id = 2;// This does become tedious though...packetPointer packet1 = &packets[PACKET1];packetPointer packet2 = &packets[PACKET2];
// The data from the PLC will be stored in the regs arrayunsigned int regs[10];
void setup(){ // The modbus packet constructor function will initialize // the individual packet with the assigned parameters. You can always do this // explicitly by using struct pointers. The first parameter is the address of the // packet in question. It is effectively the "this" parameter in Java that points to // the address of the passed object. It has the following form: // modbus_construct(packet, id, function, address, number of registers, register array) // read 2 registers starting at address 0 modbus_construct(packet1, 2, READ_HOLDING_REGISTERS, 0, 2, regs); // write the 10 registers to the PLC starting at address 2 modbus_construct(packet2, 2, PRESET_MULTIPLE_REGISTERS, 2, 10, regs); // P.S. the register array entries above can be different arrays // Initialize communication settings etc... modbus_configure(baud, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);}
void loop(){ modbus_update();
// update the array with the counter data regs[2] = packet1->requests; regs[3] = packet1->successful_requests; regs[4] = packet1->failed_requests; regs[5] = packet1->exception_errors; regs[6] = packet2->requests; regs[7] = packet2->successful_requests; regs[8] = packet2->failed_requests; regs[9] = packet2->exception_errors;
}…
controlo por potenciômetro e quando chego no angulo q eu quero aperto um botão na placa shield e ele grava na eprom esse valor e vou fazendo ate pegar o objeto e levar para outro lugar, quando termino aperto outro botão que repeti os movimentos que gravei e tá funcionando só que ele repeti 4x de boa depois ele perde um movimento e começa a fazer movimentos que não havia gravado, gostaria de saber pq acontece depois da quarta repetição! alguem pode me ajudar não manjo de programação e não sei se o código esta correto,!
Placa Shield
Programação do Braço Robótico
#include <Servo.h> #include <EEPROM.h> // Biblioteca
Servo Garra; Servo Ggarra; Servo Lgarra; Servo Cotovelo; Servo Ombro; Servo Base; int buzzer = 7; int state = LOW; int state1 = LOW; int button = 3; int button1 = 2; int potgarra = 0; //Canal Analógico A0 int potggarra = 1; //Canal Analógico A1 int potlgarra = 2; //Canal Analógico A2 int potombro = 3; //Canal Analógico A3 int potcot = 4; //Canal Analógico A4 int potbase = 5; //Canal Analógico A5 int valbase; // Constante p/ valor do ângulo servomotor Base int valombro; // Constante p/ valor do ângulo servomotor Ombro int valcot; // Constante p/ valor do ângulo servomotor Cotovelo int valgarra; // Constante p/ valor do ângulo servomotor Garra int valggarra; // Constante p/ valor do ângulo servomotor Giro da Garra int vallgarra; // Constante p/ valor do ângulo servomotor Levantar Garra int addr = 0; // Endereço de escrita na memória int cont; int address = 0; // endereço de leitura na memória byte value; // valor lido da EEPROM
void setup() { pinMode(button, INPUT); pinMode(button1, INPUT); pinMode(buzzer, OUTPUT); Garra.attach(13); Ggarra.attach(12); Lgarra.attach(11); Ombro.attach(10); Cotovelo.attach(9); Base.attach(8); Serial.begin(9600); } void loop(){ state=digitalRead(button); // Se o botão for pressionado grava a posição dos servos if(state==HIGH){ digitalWrite(buzzer, HIGH); //Liga sinal de aviso do buzzer delay(100); digitalWrite(buzzer, LOW); //desliga sinal de aviso do buzzer delay(100); valbase= analogRead(potbase); // Lê e o valor do potenciometro valbase= map(valbase, 0, 1023, 0, 179); // Converte o valor lido p/ respetiva referência entre (0° a 180°) EEPROM.write(addr, valbase); // Grava o valor lido na EEPROM Serial.print(addr); //Printa o endereço e os respectivos ângulos para cada servomotor Serial.println(" - Endereço"); Serial.println("Base"); Serial.println(valbase); addr = addr + 1; //Incremento p/ o proximo endereço delay(100);
valombro= analogRead(potombro); // valombro= map(valombro, 0, 1023, 53, 90); EEPROM.write(addr, valombro); Serial.print(addr); Serial.println(" - Endereço"); Serial.println("Ombro"); Serial.println(valombro); addr = addr + 1; delay(100);
valcot = analogRead(potcot); valcot = map(valcot, 0, 1023, 48, 158); EEPROM.write(addr, valcot); Serial.print(addr); Serial.println(" - Endereço"); Serial.println("Cotovelo"); Serial.println(valcot); addr = addr + 1; delay(100);
valgarra= analogRead(potgarra); valgarra= map(valgarra, 0, 1023, 34, 110); EEPROM.write(addr, valgarra); Serial.print(addr); Serial.println(" - Endereço"); Serial.println("Garra"); Serial.println(valgarra); addr = addr + 1; delay(100); valggarra= analogRead(potggarra); // valggarra= map(valgarra, 0, 1023, 0, 179); EEPROM.write(addr, valggarra); Serial.print(addr); Serial.println(" - Endereço"); Serial.println("Ggarra"); Serial.println(valggarra); addr = addr + 1; delay(100);
vallgarra= analogRead(potlgarra); // vallgarra= map(valgarra, 0, 1023, 5, 90); EEPROM.write(addr, vallgarra); Serial.print(addr); Serial.println(" - Endereço"); Serial.println("Lgarra"); Serial.println(vallgarra); addr = addr + 1; delay(100);
if (addr == 1024){ // Aviso para limite de posições salvas na EEPROM delay(10); digitalWrite(buzzer, HIGH); delay(10); digitalWrite(buzzer, LOW); delay(10); digitalWrite(buzzer, HIGH); delay(10); digitalWrite(buzzer, LOW); delay(10); } } else { //leitura do analogico valbase= analogRead(potbase); //Lê o valor do potenciometro de ( 0 - 1023) valbase= map(valbase, 0, 1023, 0, 179); //converte o valor lido de ( 0 - 1023) p/ (0 °– 180°) Base.write(valbase);
valombro = analogRead(potombro); valombro = map(valombro, 0, 1023, 53, 90); Ombro.write(valombro);
valcot = analogRead(potcot); valcot = map(valcot, 0, 1023, 48, 158); Cotovelo.write(valcot);
valgarra = analogRead(potgarra); valgarra = map(valgarra, 0, 1023, 34, 110); Garra.write(valggarra);
valggarra = analogRead(potggarra); valggarra = map(valggarra, 0, 1023, 0, 179); Ggarra.write(valggarra);
vallgarra = analogRead(potlgarra); vallgarra = map(vallgarra, 0, 1023, 5, 90); Lgarra.write(vallgarra);
} state1=digitalRead(button1); // Botão p/ acionamento das movimentações gravadas if(state1==HIGH){ digitalWrite(buzzer, HIGH); delay(100); digitalWrite(buzzer, LOW); delay(100); digitalWrite(buzzer, HIGH); delay(100); digitalWrite(buzzer, LOW); delay(100); Play(); //Chamada da função p/ movimentar } } void movServo(Servo &s, int ANGfinal, int veloc){ int ANGinicial = s.read(); // lê a posição atual do servo e o coloca como o angulo inicial de movimento if(ANGinicial > ANGfinal){ for(int i= ANGinicial; i > ANGfinal; i--){ //decremanta 1º grau s.write(i); // 'escreve' o valor 'i' no servo selecionado delay(veloc); // tempo de espera. } } else{ for(int i= ANGinicial; i <= ANGfinal; i++){ //incremanta 1º grau s.write(i); // 'escreve' o valor 'i' no servo selecionado delay(veloc); // tempo de espera. } } } void Play(){ // Função de movimento automático dos servos delay(1000); state1=digitalRead(button1); while(state1==LOW){ state1=digitalRead(button1); if(state1==HIGH){ zerar(); delay(100); } int l; LDR=0; //Zera a variável LDR for(l=0;l<10;l++){ //Faz 10 vezes a leitura do sensor cont=analogRead(sensor); //Lê o valor do sensor e guarda na variável LDR LDR = LDR+cont; //Armazenamento na varíavel LDR o valor lido + o valor anterior delay(10); //Delay se 10 milissegundos } LDR=LDR/10; //Divide o valor armazenado por 10 Serial.println(LDR); //Imprime o valor do LDR
if(LDR > 80){ // Se o valor do LDR for maior ou igual a 400 movServo(Base, valbase, 15); movServo(Ombro, valombro, 15); movServo(Cotovelo, valcot, 15); movServo(Garra, valgarra, 15); Serial.println("Home Position"); delay(100); } if(LDR < 400){ int j; address=0; addr=addr-1; Serial.println("addr"); Serial.println(addr); for(j=0; j<addr; j+=4){ value = EEPROM.read(address); // Leitura da EEPROM movServo(Base, value, 15); delay(100); Serial.print(address); Serial.println(" - Posicao Base"); Serial.print(value, DEC); Serial.println(); address = address + 1; delay(100); value = EEPROM.read(address); movServo(Ombro, value, 15); delay(100); Serial.print(address); Serial.println(" - Posicao Ombro"); Serial.print(value, DEC); Serial.println(); address = address + 1; delay(100); value = EEPROM.read(address); movServo(Cotovelo, value, 15); delay(100); Serial.print(address); Serial.println(" - Posicao Cotovelo"); Serial.print(value, DEC); Serial.println(); address = address + 1; delay(100); value = EEPROM.read(address); movServo(Garra, value, 15); delay(100); Serial.print(address); Serial.println(" - Posicao Garra"); Serial.print(value, DEC); Serial.println(); delay(100); address = address + 1; value = EEPROM.read(address); movServo(Ggarra, value, 15); delay(100); Serial.print(address); Serial.println(" - Posicao Giro da Garra"); Serial.print(value, DEC); Serial.println(); delay(100); address = address + 1; value = EEPROM.read(address); movServo(Lgarra, value, 15); delay(100); Serial.print(address); Serial.println(" - Posicao Levanta Garra"); Serial.print(value, DEC); Serial.println(); delay(100); address = address + 1; } } } } void zerar(){ // Zera o endereço da EEPROM p/ realizar novas gravações digitalWrite(buzzer, HIGH); // Aviso p/ realizar novas gravações delay(100); digitalWrite(buzzer, LOW); delay(100); digitalWrite(buzzer, HIGH); delay(100); digitalWrite(buzzer, LOW); delay(100); addr=0; Serial.print("Modo Gravar");…
=7;
int led4=6;
int buzzer=10;
Tone player;
int note[]={NOTE_A3,NOTE_G4};
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
Serial.begin(9600);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Lab de Garagem");
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(buzzer,OUTPUT);
player.begin(10);
}
void loop() {
int reading = analogRead(sensorPin);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
float voltage = (reading) * 5.0;
voltage /= 1024.0;
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 10 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((volatge - 500mV) times 100)
Serial.print(temperatureC);
Serial.println(" degrees C");
lcd.print(temperatureC);
lcd.print(" Celsius");
// now convert to Fahrenheight
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
if(temperatureC<25)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
}
if((temperatureC>=25) && (temperatureC<30))
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
}
if((temperatureC>=30) )
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
player.play(note[0]);
delay(200);
player.play(note[1]);
delay(200);
player.stop();
}
delay(500);
}
e está dando erro. Poderiam me ajudar?…
roladora para um sistema de captação e reaproveitamento de aguá de chuva para fins não potáveis em residências. A confecção do hardware está ok, tudo conferido e funcionando corretamente.
Estou trabalhando com dois sensores ultrassônicos HC-SR04, usados para medir o nível de água nos reservatório, variando entre 0 e 100%. e de acordo com os níveis lidos irei acionar uma bomba ou então uma válvula solenoide. O microcontrolador utilizado na placa é um ATmega328P ( o mesmo da plataforma Arduino UNO).
A lógica de programação foi desenvolvida e um êxito na rodagem de testes, no entanto os dados enviados ao display ficam sempre piscando. Eu gostaria de saber o porquê.
Logo abaixo vou deixar algumas fotos para que todos possam ter uma noção mais clara ao que estou me referindo. Abraço e conto com a colaboração de todos.
CÓDIGO:
#include <LiquidCrystal.h> //Biblioteca do display.
#include <LinkedList.h> //
#include <Gaussian.h> //Bibliotecas para cálculo da média móvel.
#include <GaussianAverage.h> //
#include <Ultrasonic.h> //Biblioteca dos sensores ultrassônicos.
#define trigger1 6 //Trigger do US1 no pino 6.
#define echo1 5 //Trigger do US1 no pino 5.
#define trigger2 4 //Trigger do US2 no pino 4.
#define echo2 3 //Trigger do US2 no pino 3.
#define pulsoSOLENOIDE A4 //Botão da solenóde no pino A4.
#define pulsoBOMBA A5 //Botão da bomba no pino A5.
#define AUTO_MANU 0 //Bot. para sel. do modo de trabalho no pino 0.
#define SOLENOIDE 1 //Saída para acionamento da solenóide no pino 1.
#define BOMBA 2 //Saída para acionamento da bomba no pino 2.
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //Pinos de comu com o display.
GaussianAverage myMovingAverage1(10);
GaussianAverage myMovingAverage2(10);
Ultrasonic ultrasonic1(trigger1, echo1); //Pinos trigger e echo do US1.
Ultrasonic ultrasonic2(trigger2, echo2); //Pinos trigger e echo do US2.
float caixadagua = 28.5; //Caixa d'água com 28,5cm.
float reservatorio = 28.5; //Reservatório com 28,5cm.
int porcentagem1, nivel1, US1; //Variáveis do tipo inteira.
int porcentagem2, nivel2, US2, estadoNivel, setLCD, estadoSolen;
//=========================================================================
void setup(){ //Inícialização do programa.
lcd.begin(20,4); //Define o display com 20 colunas e quatro linhas.
pinMode(pulsoBOMBA,INPUT_PULLUP) //Entrada com pullup interno.
pinMode(pulsoSOLENOIDE,INPUT_PULLUP); //Entrada com pullup interno.
pinMode(AUTO_MANU,INPUT_PULLUP); //Entrada com pullup interno.
pinMode(SOLENOIDE,OUTPUT); //Saída digital.
pinMode(BOMBA,OUTPUT); //Saída digital.
digitalWrite(SOLENOIDE,LOW); //Inicia com a solenóide desligada.
digitalWrite(BOMBA,LOW); //Inicia com a bomba desligada.
estadoNivel = 0; //Atribui valor zero a variável estadoNivel.
estadoSolen = 0; //Atribui valor zero a variável estadoSolen.
} //Fim setup.
//=========================================================================
void loop(){ //Loop do programa.
if(digitalRead(AUTO_MANU) == LOW){ //Cond. que habilita o modo manual.
float cmMsec1;
long microsec1 = ultrasonic1.timing();
cmMsec1 = ultrasonic1.convert(microsec1, Ultrasonic::CM);
porcentagem1 = (((cmMsec1-6.5)*100)/reservatorio);
nivel1 = (100-porcentagem1);
myMovingAverage1 += nivel1;
myMovingAverage1.process();
US1 = myMovingAverage1.mean; //Lógica responsável pela leitura do US1.
if(US1 > 100){
US1 = 100;
}
if(US1 < 0){
US1 = 0;
}
float cmMsec2;
long microsec2 = ultrasonic2.timing();
cmMsec2 = ultrasonic2.convert(microsec2, Ultrasonic::CM);
porcentagem2 = ((cmMsec2-12)*100)/caixadagua;
nivel2 = (100-porcentagem2);
myMovingAverage2 += nivel2;
myMovingAverage2.process();
US2 = myMovingAverage2.mean; //Lógica responsável pela leitura do US2.
if(US2 > 100){
US2 = 100;
}
if(US2 < 0){
US2 = 0;
}
lcd.clear(); //limpa a tela do display.
lcd.setCursor(4,0);
lcd.print("MODO MANUAL"); //Imprime na coluna quatro, linha zero.
lcd.setCursor(0,1);
lcd.print("RESERVATORIO = "); //Imprime na coluna zero linha um.
lcd.setCursor(15,1);
lcd.print(US1); //Impr. US1 na coluna quinze, linha um.
lcd.setCursor(18,1);
lcd.print("%"); //Impr. % na coluna dezoito, linha um.
lcd.setCursor(0,2);
lcd.print("CAIXA D'AGUA = "); //Imprime na coluna zero, linha dois.
lcd.setCursor(15,2);
lcd.print(US2); //Impr. US2 na coluna , linha dois.
lcd.setCursor(18,2);
lcd.print("%"); //Impr. % na coluna dezoito,linha dois.
if(digitalRead(pulsoSOLENOIDE) == LOW){
digitalWrite(SOLENOIDE, HIGH); //Aciona a solenóide.
lcd.setCursor(0,3);
lcd.print("SOLEN=ON"); //Imprime ON na coluna zero, linha 3.
}
else{
digitalWrite(SOLENOIDE, LOW); //Desaciona a solenóide.
lcd.setCursor(0,3);
lcd.print("SOLEN=OFF"); //Impr OFF na coluna zero, linha três.
}
if(digitalRead(pulsoBOMBA) == LOW){
digitalWrite(BOMBA, HIGH); //Aciona a bomba.
lcd.setCursor(10,3);
lcd.print("BOMBA=ON"); //Imprime ON na coluna dez, linha três.
}
else{
digitalWrite(BOMBA, LOW); //Desaciona a bomba.
lcd.setCursor(10,3);
lcd.print("BOMBA=OFF"); //Imprime OFF na coluna dez, linha três.
}
} //Fim manual.
//========================================================================
if(digitalRead(AUTO_MANU) == HIGH){ //Cond. que habilita o modo automát.
float cmMsec1;
long microsec1 = ultrasonic1.timing();
cmMsec1 = ultrasonic1.convert(microsec1, Ultrasonic::CM);
porcentagem1 = (((cmMsec1-6.5)*100)/reservatorio);
nivel1 = (100-porcentagem1);
myMovingAverage1 += nivel1;
myMovingAverage1.process();
US1 = myMovingAverage1.mean; //Lógica responsável pela leitura do US1.
if(US1 > 100){
US1 = 100;
}
if(US1 < 0){
US1 = 0;
}
float cmMsec2;
long microsec2 = ultrasonic2.timing();
cmMsec2 = ultrasonic2.convert(microsec2, Ultrasonic::CM);
porcentagem2 = ((cmMsec2-12)*100)/caixadagua;
nivel2 = (100-porcentagem2);
myMovingAverage2 += nivel2;
myMovingAverage2.process();
US2 = myMovingAverage2.mean; //Lógica responsável pela leitura do US2.
if(US2 > 100){
US2 = 100;
}
if(US2 < 0){
US2 = 0;
}
lcd.clear(); //limpa a tela do display
lcd.setCursor(2,0);
lcd.print("MODO AUTOMATICO"); //Imprimme na coluna dois, linha zero.
lcd.setCursor(0,1);
lcd.print("RESERVATORIO = "); //Imprime na coluna zero, linha um.
lcd.setCursor(15,1);
lcd.print(US1); //Imp. US1 na coluna quinze, linha um.
lcd.setCursor(18,1);
lcd.print("%"); //Impr. % na coluna dezoito, linha um.
lcd.setCursor(0,2);
lcd.print("CAIXA D'AGUA = "); //Imprime na coluna zero, linha dois.
lcd.setCursor(15,2);
lcd.print(US2); //Imp. US2 coluna quinze, linha dois.
lcd.setCursor(18,2);
lcd.print("%"); //Impri. % coluna dezoito, linha dois.
switch(estadoNivel){ //Switch responsável pelo controle da bomba.
case 0:
estadoNivel = 1; //Atribui valor um à variável estadoNivel.
if((US2 < 20) && (US1 >10)){ //Se US2>20% e US1>10%.
digitalWrite(BOMBA, HIGH); //Aciona a bomba.
}
break;
case 1:
estadoNivel = 2; //Atribui valor dois a var. estadoNivel.
if(US2 > 90){ //Habilita se US2>90%.
digitalWrite(BOMBA, LOW); //Desaciona a bomba.
setLCD = 0;
}
break;
case 2:
estadoNivel = 0; //Atribui valor zero à var. estadoNivel.
if(US1 < 10){ //Habilita se US1<10%.
digitalWrite(BOMBA, LOW); //Desaciona a bomba.
setLCD = 0;
}
break;
}
if (digitalRead(BOMBA) == LOW){ //Se a bomba estiver desligada.
lcd.setCursor(10,3);
lcd.print("BOMBA=OFF"); //Imprime na coluna zero, linha três.
}
else{
lcd.setCursor(10,3);
lcd.print("BOMBA=ON"); //Imprime na coluna dez, linha três.
}
switch(estadoSolen){ //Switch responsável pelo controle da solenóide.
case 0:
//Atribui valor um a var. estadoSolen.
if((US2 <20) && (US1 < 10)){ //Se US2> 20% e US1<20%.
digitalWrite(SOLENOIDE, HIGH); //Aciona solenóide.
}
break;
case 1:
estadoSolen = 0; //Atribui valor zero a var. estadoSolen.
if(US2 > 90){ //Se US2>90%.
digitalWrite(SOLENOIDE, LOW); //Desaciona a solenóide.
}
break;
}
if (digitalRead(SOLENOIDE) == LOW){ //Se a sol. estiver desligada.
lcd.setCursor(0,3);
lcd.print("SOLEN=OFF"); //Imprime na coluna zero, linha três.
}
else{
lcd.setCursor(0,3);
lcd.print("SOLEN=ON"); //Imprime na coluna zero, linha três.
}
}
delay(500);
} //Fim loop.
…
// Piezo no pino 8const int ldrPin = 0; // LDR no pino analógico 0const int ledPin = 3; // LED no pino digital 3const int LDR = 0;int ValorLido = 0;int ldrValue = 0; // Valor lido do LDRconst int freq = 5; // altera frequencia do sonorizadorvoid setup() {pinMode(ledPin, OUTPUT);pinMode(buzzerPin, OUTPUT);Serial.begin(9600);}void loop() {ValorLido = analogRead(LDR);Serial.print("Valor lido pelo LDR = ");Serial.println(ValorLido);delay(500);ldrValue = analogRead(ldrPin); // lê o valor do LDRtone(buzzerPin,1000); // toca um tom de 1000 Hz do piezodigitalWrite(ledPin, HIGH);delay(25); // espera um pouconoTone(buzzerPin); // interrompe o tomdigitalWrite(ledPin, LOW);delay(ldrValue/freq);if (ldrPin >= 1017) {digitalWrite (ledPin, LOW);digitalWrite (buzzerPin, LOW);
}}
eu consigo fazer ele bipar com a luz acesa porem quando ela se apaga não consigo fazer parar de bipar.
meu monitor da luminosidade acusa:
acesa: 955
apagada: 1017
abraços garagistas…
Adicionado por Pablo Joenck ao 23:06 em 30 maio 2018
re/Marlin] * * Based on Sprinter and grbl. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>;. * */
/** * Configuration.h * * Basic settings such as: * * - Type of electronics * - Type of temperature sensor * - Printer geometry * - Endstop configuration * - LCD controller * - Extra features * * Advanced settings can be found in Configuration_adv.h * */ #ifndef CONFIGURATION_H #define CONFIGURATION_H #define CONFIGURATION_H_VERSION 010109
//=========================================================================== //============================= Getting Started ============================= //===========================================================================
/** * Here are some standard links for getting your machine calibrated: * * http://reprap.org/wiki/Calibration * http://youtu.be/wAL9d7FgInk * http://calculator.josefprusa.cz * http://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide * http://www.thingiverse.com/thing:5573 * https://sites.google.com/site/repraplogphase/calibration-of-your-reprap * http://www.thingiverse.com/thing:298812 */
//=========================================================================== //============================= DELTA Printer =============================== //=========================================================================== // For a Delta printer start with one of the configuration files in the // example_configurations/delta directory and customize for your machine. //
//=========================================================================== //============================= SCARA Printer =============================== //=========================================================================== // For a SCARA printer start with the configuration files in // example_configurations/SCARA and customize for your machine. //
//=========================================================================== //============================= HANGPRINTER ================================= //=========================================================================== // For a Hangprinter start with the configuration file in the // example_configurations/hangprinter directory and customize for your machine. //
// @section info
// User-specified version info of this build to display in [Pronterface, etc] terminal window during // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_CONFIG_H_AUTHOR "Falcos CAD-CAM" // Who made the changes. //#define SHOW_BOOTSCREEN #define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION // will be shown during bootup in line 1 #define STRING_SPLASH_LINE2 WEBSITE_URL // will be shown during bootup in line 2
/** * *** VENDORS PLEASE READ *** * * Marlin allows you to add a custom boot image for Graphical LCDs. * With this option Marlin will first show your custom screen followed * by the standard Marlin logo with version number and web URL. * * We encourage you to take advantage of this new feature and we also * respectfully request that you retain the unmodified Marlin boot screen. */
// Enable to show the bitmap in Marlin/_Bootscreen.h on startup. //#define SHOW_CUSTOM_BOOTSCREEN // descomentar para exibir bootscreen
// Enable to show the bitmap in Marlin/_Statusscreen.h on the status screen. //#define CUSTOM_STATUS_SCREEN_IMAGE
// @section machine
/** * Select the serial port on the board to use for communication with the host. * This allows the connection of wireless adapters (for instance) to non-default port pins. * Serial port 0 is always used by the Arduino bootloader regardless of this setting. * * :[0, 1, 2, 3, 4, 5, 6, 7] */ #define SERIAL_PORT 0
/** * This setting determines the communication speed of the printer. * * 250000 works in most cases, but you might try a lower speed if * you commonly experience drop-outs during host printing. * You may try up to 1000000 to speed up SD file transfer. * * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] */ #define BAUDRATE 115200
// Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH
// The following define selects which electronics board you have. // Please choose the name from boards.h that matches your setup #ifndef MOTHERBOARD #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif
// Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message #define CUSTOM_MACHINE_NAME "Falcos 400" // descomentar para colocar o nome da impressora
// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) //#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
// @section extruder
// This defines the number of extruders // :[1, 2, 3, 4, 5] #define EXTRUDERS 1
// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc. #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75
// For Cyclops or any "multi-extruder" that shares a single nozzle. //#define SINGLENOZZLE
/** * Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants. * * This device allows one stepper driver on a control board to drive * two to eight stepper motors, one at a time, in a manner suitable * for extruders. * * This option only allows the multiplexer to switch on tool-change. * Additional options to configure custom E moves are pending. */ //#define MK2_MULTIPLEXER #if ENABLED(MK2_MULTIPLEXER) // Override the default DIO selector pins here, if needed. // Some pins files may provide defaults for these pins. //#define E_MUX0_PIN 40 // Always Required //#define E_MUX1_PIN 42 // Needed for 3 to 8 steppers //#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers #endif
// A dual extruder that uses a single stepper motor //#define SWITCHING_EXTRUDER #if ENABLED(SWITCHING_EXTRUDER) #define SWITCHING_EXTRUDER_SERVO_NR 0 #define SWITCHING_EXTRUDER_SERVO_ANGLES { 0, 90 } // Angles for E0, E1[, E2, E3] #if EXTRUDERS > 3 #define SWITCHING_EXTRUDER_E23_SERVO_NR 1 #endif #endif
// A dual-nozzle that uses a servomotor to raise/lower one of the nozzles //#define SWITCHING_NOZZLE #if ENABLED(SWITCHING_NOZZLE) #define SWITCHING_NOZZLE_SERVO_NR 0 #define SWITCHING_NOZZLE_SERVO_ANGLES { 0, 90 } // Angles for E0, E1 //#define HOTEND_OFFSET_Z { 0.0, 0.0 } #endif
/** * Two separate X-carriages with extruders that connect to a moving part * via a magnetic docking mechanism. Requires SOL1_PIN and SOL2_PIN. */ //#define PARKING_EXTRUDER #if ENABLED(PARKING_EXTRUDER) #define PARKING_EXTRUDER_SOLENOIDS_INVERT // If enabled, the solenoid is NOT magnetized with applied voltage #define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE LOW // LOW or HIGH pin signal energizes the coil #define PARKING_EXTRUDER_SOLENOIDS_DELAY 250 // Delay (ms) for magnetic field. No delay if 0 or not defined. #define PARKING_EXTRUDER_PARKING_X { -78, 184 } // X positions for parking the extruders #define PARKING_EXTRUDER_GRAB_DISTANCE 1 // mm to move beyond the parking point to grab the extruder #define PARKING_EXTRUDER_SECURITY_RAISE 5 // Z-raise before parking #define HOTEND_OFFSET_Z { 0.0, 1.3 } // Z-offsets of the two hotends. The first must be 0. #endif
/** * "Mixing Extruder" * - Adds G-codes M163 and M164 to set and "commit" the current mix factors. * - Extends the stepping routines to move multiple steppers in proportion to the mix. * - Optional support for Repetier Firmware's 'M164 S<index>' supporting virtual tools. * - This implementation supports up to two mixing extruders. * - Enable DIRECT_MIXING_IN_G1 for M165 and mixing in G1 (from Pia Taubert's reference implementation). */ //#define MIXING_EXTRUDER #if ENABLED(MIXING_EXTRUDER) #define MIXING_STEPPERS 2 // Number of steppers in your mixing extruder #define MIXING_VIRTUAL_TOOLS 16 // Use the Virtual Tool method with M163 and M164 //#define DIRECT_MIXING_IN_G1 // Allow ABCDHI mix factors in G1 movement commands #endif
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). // For the other hotends it is their distance from the extruder 0 hotend. //#define HOTEND_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis //#define HOTEND_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis
// @section machine
/** * Select your power supply here. Use 0 if you haven't connected the PS_ON_PIN * * 0 = No Power Switch * 1 = ATX * 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC) * * :{ 0:'No power switch', 1:'ATX', 2:'X-Box 360' } */ #define POWER_SUPPLY 1
#if POWER_SUPPLY > 0 // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin #if ENABLED(AUTO_POWER_CONTROL) #define AUTO_POWER_FANS // Turn on PSU if fans need power #define AUTO_POWER_E_FANS #define AUTO_POWER_CONTROLLERFAN #define POWER_TIMEOUT 30 #endif
#endif
// @section temperature
//=========================================================================== //============================= Thermal Settings ============================ //===========================================================================
/** * --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table * * Temperature sensors available: * * -4 : thermocouple with AD8495 * -3 : thermocouple with MAX31855 (only for sensor 0) * -2 : thermocouple with MAX6675 (only for sensor 0) * -1 : thermocouple with AD595 * 0 : not used * 1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup) * 2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) * 3 : Mendel-parts thermistor (4.7k pullup) * 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! * 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan & J-Head) (4.7k pullup) * 501 : 100K Zonestar (Tronxy X3A) Thermistor * 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) * 71 : 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) * 8 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) * 9 : 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) * 10 : 100k RS thermistor 198-961 (4.7k pullup) * 11 : 100k beta 3950 1% thermistor (4.7k pullup) * 12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) * 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" * 15 : 100k thermistor calibration for JGAurora A5 hotend * 20 : the PT100 circuit found in the Ultimainboard V2.x * 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 * 66 : 4.7M High Temperature thermistor from Dyze Design * 70 : the 100K thermistor found in the bq Hephestos 2 * 75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor * * 1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k. * (but gives greater accuracy and more stable PID) * 51 : 100k thermistor - EPCOS (1k pullup) * 52 : 200k thermistor - ATC Semitec 204GT-2 (1k pullup) * 55 : 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) * * 1047 : Pt1000 with 4k7 pullup * 1010 : Pt1000 with 1k pullup (non standard) * 147 : Pt100 with 4k7 pullup * 110 : Pt100 with 1k pullup (non standard) * * Use these for Testing or Development purposes. NEVER for production machine. * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. * * :{ '0': "Not used", '1':"100k / 4.7k - EPCOS", '2':"200k / 4.7k - ATC Semitec 204GT-2", '3':"Mendel-parts / 4.7k", '4':"10k !! do not use for a hotend. Bad resolution at high temp. !!", '5':"100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '501':"100K Zonestar (Tronxy X3A)", '6':"100k / 4.7k EPCOS - Not as accurate as Table 1", '7':"100k / 4.7k Honeywell 135-104LAG-J01", '8':"100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9':"100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10':"100k / 4.7k RS 198-961", '11':"100k / 4.7k beta 3950 1%", '12':"100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13':"100k Hisens 3950 1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '20':"PT100 (Ultimainboard V2.x)", '51':"100k / 1k - EPCOS", '52':"200k / 1k - ATC Semitec 204GT-2", '55':"100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '60':"100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '66':"Dyze Design 4.7M High Temperature thermistor", '70':"the 100K thermistor found in the bq Hephestos 2", '71':"100k / 4.7k Honeywell 135-104LAF-J01", '147':"Pt100 / 4.7k", '1047':"Pt1000 / 4.7k", '110':"Pt100 / 1k (non-standard)", '1010':"Pt1000 / 1k (non standard)", '-4':"Thermocouple + AD8495", '-3':"Thermocouple + MAX31855 (only for sensor 0)", '-2':"Thermocouple + MAX6675 (only for sensor 0)", '-1':"Thermocouple + AD595",'998':"Dummy 1", '999':"Dummy 2" } */ #define TEMP_SENSOR_0 1 #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 #define TEMP_SENSOR_4 0 #define TEMP_SENSOR_BED 1 #define TEMP_SENSOR_CHAMBER 0
// Dummy thermistor constant temperature readings, for use with 998 and 999 #define DUMMY_THERMISTOR_998_VALUE 25 #define DUMMY_THERMISTOR_999_VALUE 100
// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // from the two sensors differ too much the print will be aborted. //#define TEMP_SENSOR_1_AS_REDUNDANT #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
// Extruder temperature must be close to target for this long before M109 returns success #define TEMP_RESIDENCY_TIME 10 // (seconds) #define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one #define TEMP_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
// Bed temperature must be close to target for this long before M190 returns success #define TEMP_BED_RESIDENCY_TIME 10 // (seconds) #define TEMP_BED_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one #define TEMP_BED_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
// The minimal temperature defines the temperature below which the heater will not be enabled It is used // to check that the wiring to the thermistor is not broken. // Otherwise this would lead to the heater being powered on all the time. #define HEATER_0_MINTEMP 5 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 #define HEATER_3_MINTEMP 5 #define HEATER_4_MINTEMP 5 #define BED_MINTEMP 5
// When temperature exceeds max temp, your heater will be switched off. // This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure! // You should use MINTEMP for thermistor short/failure protection. #define HEATER_0_MAXTEMP 260 #define HEATER_1_MAXTEMP 260 #define HEATER_2_MAXTEMP 260 #define HEATER_3_MAXTEMP 260 #define HEATER_4_MAXTEMP 260 #define BED_MAXTEMP 150
//=========================================================================== //============================= PID Settings ================================ //=========================================================================== // PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning
// Comment the following line to disable PID and enable bang-bang. #define PIDTEMP #define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current #define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) //#define PID_AUTOTUNE_MENU // Add PID Autotune to the LCD "Temperature" menu to run M303 and apply the result. //#define PID_DEBUG // Sends debug data to the serial port. //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
// Ultimaker #define DEFAULT_Kp 22.2 #define DEFAULT_Ki 1.08 #define DEFAULT_Kd 114
// MakerGear //#define DEFAULT_Kp 7.0 //#define DEFAULT_Ki 0.1 //#define DEFAULT_Kd 12
// Mendel Parts V9 on 12V //#define DEFAULT_Kp 63.0 //#define DEFAULT_Ki 2.25 //#define DEFAULT_Kd 440
#endif // PIDTEMP
//=========================================================================== //============================= PID > Bed Temperature Control =============== //===========================================================================
/** * PID Bed Heating * * If this option is enabled set PID constants below. * If this option is disabled, bang-bang will be used and BED_LIMIT_SWITCHING will enable hysteresis. * * The PID frequency will be the same as the extruder PWM. * If PID_dT is the default, and correct for the hardware/configuration, that means 7.689Hz, * which is fine for driving a square wave into a resistive load and does not significantly * impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W * heater. If your configuration is significantly different than this and you don't understand * the issues involved, don't use bed PID until someone else verifies that your hardware works. */ //#define PIDTEMPBED
//#define BED_LIMIT_SWITCHING
/** * Max Bed Power * Applies to all forms of bed control (PID, bang-bang, and bang-bang with hysteresis). * When set to any value below 255, enables a form of PWM to the bed that acts like a divider * so don't use it unless you are OK with PWM on your bed. (See the comment on enabling PIDTEMPBED) */ #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
#if ENABLED(PIDTEMPBED)
//#define PID_BED_DEBUG // Sends debug data to the serial port.
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) #define DEFAULT_bedKp 10.00 #define DEFAULT_bedKi .023 #define DEFAULT_bedKd 305.4
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from pidautotune //#define DEFAULT_bedKp 97.1 //#define DEFAULT_bedKi 1.41 //#define DEFAULT_bedKd 1675.16
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED
// @section extruder
/** * Prevent extrusion if the temperature is below EXTRUDE_MINTEMP. * Add M302 to set the minimum extrusion temperature and/or turn * cold extrusion prevention on and off. * * *** IT IS HIGHLY RECOMMENDED TO LEAVE THIS OPTION ENABLED! *** */ #define PREVENT_COLD_EXTRUSION #define EXTRUDE_MINTEMP 5 // colocar 170 segurança do extrude
/** * Prevent a single extrusion longer than EXTRUDE_MAXLENGTH. * Note: For Bowden Extruders make this large enough to allow load/unload. */ #define PREVENT_LENGTHY_EXTRUDE #define EXTRUDE_MAXLENGTH 200
//=========================================================================== //======================== Thermal Runaway Protection ======================= //===========================================================================
/** * Thermal Protection provides additional protection to your printer from damage * and fire. Marlin always includes safe min and max temperature ranges which * protect against a broken or disconnected thermistor wire. * * The issue: If a thermistor falls out, it will report the much lower * temperature of the air in the room, and the the firmware will keep * the heater on. * * If you get "Thermal Runaway" or "Heating failed" errors the * details can be tuned in Configuration_adv.h */
#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders #define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed
//=========================================================================== //============================= Mechanical Settings ========================= //===========================================================================
// @section machine
// Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics /Remova o comentario de uma dessas opcoes para ativar a cinematica CoreXY, CoreXZ ou CoreYZ // either in the usual order or reversed /na ordem usual ou invertida //#define COREXY //#define COREXZ //#define COREYZ //#define COREYX //#define COREZX //#define COREZY
//=========================================================================== //============================== Endstop Settings =========================== //===========================================================================
// @section homing
// Specify here all the endstop connectors that are connected to any endstop or probe. // Almost all printers will be using one per axis. Probes will use one or more of the // extra connectors. Leave undefined any used for non-endstop and non-probe purposes. #define USE_XMIN_PLUG #define USE_YMIN_PLUG #define USE_ZMIN_PLUG //#define USE_XMAX_PLUG //#define USE_YMAX_PLUG //#define USE_ZMAX_PLUG
// Enable pullup for all endstops to prevent a floating state //#define ENDSTOPPULLUPS //deve ser desativada (comentada) quando voce esta usando os endstops #if DISABLED(ENDSTOPPULLUPS) // Disable ENDSTOPPULLUPS to set pullups individually //#define ENDSTOPPULLUP_XMAX //#define ENDSTOPPULLUP_YMAX //#define ENDSTOPPULLUP_ZMAX //#define ENDSTOPPULLUP_XMIN //#define ENDSTOPPULLUP_YMIN //#define ENDSTOPPULLUP_ZMIN //#define ENDSTOPPULLUP_ZMIN_PROBE #endif
// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). #define X_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. o meu endstop X e normalmente aberto, precisa esta true #define Y_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. o meu endstop X e normalmente aberto, precisa esta true #define Z_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. o meu endstop X e normalmente aberto, precisa esta true #define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Y_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the probe.
/** * Stepper Drivers * * These settings allow Marlin to tune stepper driver timing and enable advanced options for * stepper drivers that support them. You may also override timing options in Configuration_adv.h. * * A4988 is assumed for unspecified drivers. * * Options: A4988, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100, * TMC2130, TMC2130_STANDALONE, TMC2208, TMC2208_STANDALONE, * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, * TMC5130, TMC5130_STANDALONE * :['A4988', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE'] */ #define X_DRIVER_TYPE A4988 #define Y_DRIVER_TYPE A4988 #define Z_DRIVER_TYPE A4988 //#define X2_DRIVER_TYPE A4988 //#define Y2_DRIVER_TYPE A4988 //#define Z2_DRIVER_TYPE A4988 #define E0_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 //#define E4_DRIVER_TYPE A4988
// Enable this feature if all enabled endstop pins are interrupt-capable. // This will remove the need to poll the interrupt pins, saving many CPU cycles. //#define ENDSTOP_INTERRUPTS_FEATURE
/** * Endstop Noise Filter * * Enable this option if endstops falsely trigger due to noise. * NOTE: Enabling this feature means adds an error of +/-0.2mm, so homing * will end up at a slightly different position on each G28. This will also * reduce accuracy of some bed probes. * For mechanical switches, the better approach to reduce noise is to install * a 100 nanofarads ceramic capacitor in parallel with the switch, making it * essentially noise-proof without sacrificing accuracy. * This option also increases MCU load when endstops or the probe are enabled. * So this is not recommended. USE AT YOUR OWN RISK. * (This feature is not required for common micro-switches mounted on PCBs * based on the Makerbot design, since they already include the 100nF capacitor.) */ //#define ENDSTOP_NOISE_FILTER
//============================================================================= //============================== Movement Settings ============================ //============================================================================= // @section motion
/** * Default Settings * * These settings can be reset by M502 * * Note that if EEPROM is enabled, saved values will override these. */
/** * With this option each E stepper can have its own factors for the * following movement settings. If fewer factors are given than the * total number of extruders, the last value applies to the rest. */ //#define DISTINCT_E_FACTORS
/** * Default Axis Steps Per Unit (steps/mm) * Override with M92 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 1600, 223.71 }//estava 159.5, 159.5, 778, 223.71
/** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ #define DEFAULT_MAX_FEEDRATE { 250, 250, 0.2, 25 } //250, 250, 3.3, 25
/** * Default Max Acceleration (change/s) change = mm/s * (Maximum start speed for accelerated moves) * Override with M201 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ #define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 }
/** * Default Acceleration (change/s) change = mm/s * Override with M204 * * M204 P Acceleration * M204 R Retract Acceleration * M204 T Travel Acceleration */ #define DEFAULT_ACCELERATION 1000 // X, Y, Z and E acceleration for printing moves #define DEFAULT_RETRACT_ACCELERATION 1000 // E acceleration for retracts #define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration for travel (non printing) moves
/** * Default Jerk (mm/s) * Override with M205 X Y Z E * * "Jerk" specifies the minimum speed change that requires acceleration. * When changing speed and direction, if the difference is less than the * value set here, it may happen instantaneously. */ #define DEFAULT_XJERK 10.0 #define DEFAULT_YJERK 10.0 #define DEFAULT_ZJERK 0.3 #define DEFAULT_EJERK 5.0
/** * S-Curve Acceleration * * This option eliminates vibration during printing by fitting a Bézier * curve to move acceleration, producing much smoother direction changes. * * See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained */ //#define S_CURVE_ACCELERATION
//=========================================================================== //============================= Z Probe Options ============================= //=========================================================================== // @section probes
// // See http://marlinfw.org/docs/configuration/probes.html //
/** * Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN * * Enable this option for a probe connected to the Z Min endstop pin. */ //#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN //precisa descomentar quando estiver usando nivelamento automatico
/** * Z_MIN_PROBE_ENDSTOP * * Enable this option for a probe connected to any pin except Z-Min. * (By default Marlin assumes the Z-Max endstop pin.) * To use a custom Z Probe pin, set Z_MIN_PROBE_PIN below. * * - The simplest option is to use a free endstop connector. * - Use 5V for powered (usually inductive) sensors. * * - RAMPS 1.3/1.4 boards may use the 5V, GND, and Aux4->D32 pin: * - For simple switches connect... * - normally-closed switches to GND and D32. * - normally-open switches to 5V and D32. * * WARNING: Setting the wrong pin may have unexpected and potentially * disastrous consequences. Use with caution and do your homework. * */ //#define Z_MIN_PROBE_ENDSTOP
/** * Probe Type * * Allen Key Probes, Servo Probes, Z-Sled Probes, FIX_MOUNTED_PROBE, etc. * Activate one of these to use Auto Bed Leveling below. */
/** * The "Manual Probe" provides a means to do "Auto" Bed Leveling without a probe. * Use G29 repeatedly, adjusting the Z height at each point with movement commands * or (with LCD_BED_LEVELING) the LCD controller. */ #define PROBE_MANUALLY // descomente para calibrar manualmente //#define MANUAL_PROBE_START_Z 0.2
/** * A Fix-Mounted Probe either doesn't deploy or needs manual deployment. * (e.g., an inductive probe or a nozzle-based probe-switch.) */ //#define FIX_MOUNTED_PROBE
/** * Z Servo Probe, such as an endstop switch on a rotating arm. */ //#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector. //#define Z_SERVO_ANGLES {70,0} // Z Servo Deploy and Stow angles
/** * The BLTouch probe uses a Hall effect sensor and emulates a servo. */ //#define BLTOUCH
/** * Enable one or more of the following if probing seems unreliable. * Heaters and/or fans can be disabled during probing to minimize electrical * noise. A delay can also be added to allow noise and vibration to settle. * These options are most useful for the BLTouch probe, but may also improve * readings with inductive probes and piezo sensors. */ //#define PROBING_HEATERS_OFF // Turn heaters off when probing #if ENABLED(PROBING_HEATERS_OFF) //#define WAIT_FOR_BED_HEATER // Wait for bed to heat back up between probes (to improve accuracy) #endif //#define PROBING_FANS_OFF // Turn fans off when probing //#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors
// A probe that is deployed and stowed with a solenoid pin (SOL1_PIN) //#define SOLENOID_PROBE
// A sled-mounted probe like those designed by Charles Bell. //#define Z_PROBE_SLED //#define SLED_DOCKING_OFFSET 5 // The extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
// // For Z_PROBE_ALLEN_KEY see the Delta example configurations. //
/** * Z Probe to nozzle (X,Y) offset, relative to (0, 0). * X and Y offsets must be integers. * * In the following example the X and Y offsets are both positive: * #define X_PROBE_OFFSET_FROM_EXTRUDER 10 * #define Y_PROBE_OFFSET_FROM_EXTRUDER 10 * * +-- BACK ---+ * | | * L | (+) P | R <-- probe (20,20) * E | | I * F | (-) N (+) | G <-- nozzle (10,10) * T | | H * | (-) | T * | | * O-- FRONT --+ * (0,0) */ #define X_PROBE_OFFSET_FROM_EXTRUDER 10 // X offset: -left +right [of the nozzle] #define Y_PROBE_OFFSET_FROM_EXTRUDER 10 // Y offset: -front +behind [the nozzle] #define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle]
// Certain types of probes need to stay away from edges #define MIN_PROBE_EDGE 10
// X and Y axis travel speed (mm/m) between probes #define XY_PROBE_SPEED 8000
// Feedrate (mm/m) for the first approach when double-probing (MULTIPLE_PROBING == 2) #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
// Feedrate (mm/m) for the "accurate" probe of each point #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
// The number of probes to perform at each point. // Set to 2 for a fast/slow probe, using the second probe result. // Set to 3 or more for slow probes, averaging the results. //#define MULTIPLE_PROBING 2
/** * Z probes require clearance when deploying, stowing, and moving between * probe points to avoid hitting the bed and other hardware. * Servo-mounted probes require extra space for the arm to rotate. * Inductive probes need space to keep from triggering early. * * Use these settings to specify the distance (mm) to raise the probe (or * lower the bed). The values set here apply over and above any (negative) * probe Z Offset set with Z_PROBE_OFFSET_FROM_EXTRUDER, M851, or the LCD. * Only integer values >= 1 are valid here. * * Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle. * But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle. */ #define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow #define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points #define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes //#define Z_AFTER_PROBING 5 // Z position after probing is done
#define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping
// For M851 give a range for adjusting the Z probe offset #define Z_PROBE_OFFSET_RANGE_MIN -20 #define Z_PROBE_OFFSET_RANGE_MAX 20
// Enable the M48 repeatability test to test probe accuracy //#define Z_MIN_PROBE_REPEATABILITY_TEST
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 // :{ 0:'Low', 1:'High' } #define X_ENABLE_ON 0 #define Y_ENABLE_ON 0 #define Z_ENABLE_ON 0 #define E_ENABLE_ON 0 // For all extruders
//Continua…
Adicionado por Richard Falcos ao 11:33 em 8 dezembro 2019