- Hamarosan megkezdődik a nubia 2,8K-s táblagépének szállítása
- Barátokká váltak az eddig rivális AI-óriások
- ASUS blog: Ideális olcsó utazós gép lett az új Vivobook S14
- Az Aura Displays hordozható monitorhármasa jól felturbózhatja a produktivitást
- Dual Mode-os IPS monitorral adott magáról életjelet a Gigabyte
-
PROHARDVER!
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
Imy
veterán
Beleraktam a programba, de jelen esetben is össze vissza ugrál. Ha csak az encoder van benne, a hőmérséklet mérés ls kiírás nem, akkor jó. Okés, hogy a sok serial print, de az interuptnak nem kellene azt kiküszöbölnie?
#include <Adafruit_MAX31865.h>
// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(5, 6, 7, 8);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(10);
// Rotary Encoder Module connections
const int PinSW=3; // Rotary Encoder Switch
const int PinDT=4; // DATA signal
const int PinCLK=2; // CLOCK signal
// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF 430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL 100.0
//Resistance meter
float Ra = 0.00385;
float R0 = 20.9;
float Rt;
float T;
///////ENCODER//////////////////////////
// Variables to debounce Rotary Encoder
long TimeOfLastDebounce = 0;
int DelayofDebounce = 0.01;
// Store previous Pins state
int PreviousCLK;
int PreviousDATA;
int displaycounter=0; // Store current counter value
/////////////////////////////// TEMPERATURE_SET///////////////////////////////////////////
int Temp_set_pos;
int Temp_set_last;
int Temp_up;
void setup() {
Serial.begin(115200);
Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
thermo.begin(MAX31865_2WIRE); // set to 2WIRE or 4WIRE as necessary
pinMode(PinCLK,INPUT_PULLUP);
pinMode(PinDT,INPUT_PULLUP);
pinMode(PinSW,INPUT_PULLUP);
// Put current pins state in variables
PreviousCLK=digitalRead(PinCLK);
PreviousDATA=digitalRead(PinDT);
// Set the Switch pin to use Arduino PULLUP resistors
pinMode(PinSW, INPUT_PULLUP);
}
void loop() {
///////////MAX31865////////////////////////////////////////////////////////////////////////////
uint16_t rtd = thermo.readRTD();
//Serial.print("RTD value: "); Serial.println(rtd);
float ratio = rtd;
ratio /= 32768;
Rt = RREF * ratio;
T = ((Rt - R0) / (R0 * Ra));
//Serial.print("Ratio = "); Serial.println(ratio,8);
Serial.print("Resistance = "); Serial.print(RREF * ratio, 2); Serial.println(" ohm");
//Serial.print("Temperature = "); Serial.println(thermo.temperature(RNOMINAL, RREF));
Serial.print("PakaTemp = "); Serial.print(T, 2); Serial.println(" C");
// Check and print any faults
uint8_t fault = thermo.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (fault & MAX31865_FAULT_HIGHTHRESH) {
Serial.println("RTD High Threshold");
}
if (fault & MAX31865_FAULT_LOWTHRESH) {
Serial.println("RTD Low Threshold");
}
if (fault & MAX31865_FAULT_REFINLOW) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (fault & MAX31865_FAULT_REFINHIGH) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_RTDINLOW) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_OVUV) {
Serial.println("Under/Over voltage");
}
thermo.clearFault();
}
Serial.println();
//delay(500);
// If enough time has passed check the rotary encoder
if ((millis() - TimeOfLastDebounce) > DelayofDebounce) {
check_rotary(); // Rotary Encoder check routine below
PreviousCLK=digitalRead(PinCLK);
PreviousDATA=digitalRead(PinDT);
TimeOfLastDebounce=millis(); // Set variable to current millis() timer
}
// Check if Rotary Encoder switch was pressed
if (digitalRead(PinSW) == LOW) {
displaycounter=0; // Reset counter to zero
Serial.print("Counter = "); Serial.println(displaycounter);
}
}
// Check if Rotary Encoder was moved
void check_rotary() {
if ((PreviousCLK == 0) && (PreviousDATA == 1)) {
if ((digitalRead(PinCLK) == 1) && (digitalRead(PinDT) == 0)) {
displaycounter++;
Serial.print("Counter = "); Serial.println(displaycounter);
}
if ((digitalRead(PinCLK) == 1) && (digitalRead(PinDT) == 1)) {
displaycounter--;
Serial.print("Counter = "); Serial.println(displaycounter);
}
}
if ((PreviousCLK == 1) && (PreviousDATA == 0)) {
if ((digitalRead(PinCLK) == 0) && (digitalRead(PinDT) == 1)) {
displaycounter++;
Serial.print("Counter = "); Serial.println(displaycounter);
}
if ((digitalRead(PinCLK) == 0) && (digitalRead(PinDT) == 0)) {
displaycounter--;
Serial.print("Counter = "); Serial.println(displaycounter);
}
}
if ((PreviousCLK == 1) && (PreviousDATA == 1)) {
if ((digitalRead(PinCLK) == 0) && (digitalRead(PinDT) == 1)) {
displaycounter++;
Serial.print("Counter = "); Serial.println(displaycounter);
}
if ((digitalRead(PinCLK) == 0) && (digitalRead(PinDT) == 0)) {
displaycounter--;
Serial.print("Counter = "); Serial.println(displaycounter);
}
}
if ((PreviousCLK == 0) && (PreviousDATA == 0)) {
if ((digitalRead(PinCLK) == 1) && (digitalRead(PinDT) == 0)) {
displaycounter++;
Serial.print("Counter = "); Serial.println(displaycounter);
}
if ((digitalRead(PinCLK) == 1) && (digitalRead(PinDT) == 1)) {
displaycounter--;
Serial.print("Counter = "); Serial.println(displaycounter);
}
}
Serial.print("Counter = "); Serial.println(displaycounter);
}
Új hozzászólás Aktív témák
- iKing.Hu - Samsung S25 Ultra - Titanium Black - Használt, karcmentes
- Apple Ipad 10.generáció
- Új HP Pavilion x360 14-ek Érintős hajtogatós Laptop Tab 14" -35% i5-1335U 8/512 FHD IPS Iris Xe
- RTX 4080 SUPER,16GB. Ryzen 7 7800X3D, 32 RAM Fury RGB! Garancia!
- Asztali PC , i7 9700K , RX 5700 XT , 32GB DDR4 , 500GB NVME , 1TB HDD
- Telefon felvásárlás!! iPhone 16/iPhone 16 Plus/iPhone 16 Pro/iPhone 16 Pro Max
- ÁRGARANCIA!Épített KomPhone i3 10105F 16/32/64GB RAM RTX 3050 6GB GAMER PC termékbeszámítással
- Bomba ár! Dell Latitude E6540 - i5-4GEN I 8GB I 320GB I DVDRW I 15,6" FHD I HDMI I W10 I Gari
- BESZÁMÍTÁS! Gamer számítógép Asus B150M i3 6100 16GB DDR4 240GB SSD GTX 1050 Ti 4GB Sharkoon 500W
- iKing.Hu - Motorola Edge 50 Ultra - Nordic Wood - Használt, karcmentes
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: PC Trade Systems Kft.
Város: Szeged