-
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
Arduinoval szeretnék megoldani egy ellenállás mérést, ami hőt mér, és egy KY-040-el egy hőmérséklet beállítást. Ha ezt a kódot [link] futtatom a doksi végén, akkor hiba nélkül megy az encoder poziciójának számolása. Ha ez után beteszem a hőmérséklet mérést, akkor már nem mey, össze-vissza számol:
#include <Adafruit_MAX31865.h>
// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(10);
// 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;
//HW-040 encoder
int pinA = 3; // Connected to CLK on KY-040
int pinB = 4; // Connected to DT on KY-040
int encoderPosCount = 0;
int pinALast;
int aVal;
boolean bCW;
void setup() {
Serial.begin(115200);
Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
thermo.begin(MAX31865_2WIRE); // set to 2WIRE or 4WIRE as necessary
pinMode (pinA, INPUT);
pinMode (pinB, INPUT);
pinALast = digitalRead(pinA);
}
void loop() {
/////////////ENCODER//////////////////////////////////////////////////////////////////////////////
aVal = digitalRead(pinA);
if (aVal != pinALast) { // Means the knob is rotating
// if the knob is rotating, we need to determine direction
// We do that by reading pin B.
if (digitalRead(pinB) != aVal) { // Means pin A Changed first - We're Rotating Clockwise
encoderPosCount ++;
bCW = true;
} else {// Otherwise B changed first and we're moving CCW
bCW = false;
encoderPosCount--;
}
Serial.print ("Rotated: ");
if (bCW) {
Serial.println ("clockwise");
} else {
Serial.println("counterclockwise");
}
}
pinALast = aVal;
Serial.print("Encoder Position: ");
Serial.println(encoderPosCount);
///////////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(1000);
}
Új hozzászólás Aktív témák
- Dell Latitude E6540 akár Játékra is.15"6 FHD,I7 4800MQ,HD8790,16GBram,500GB sshd,gyári töltö
- HP ELITEBOOK 855 G8 Ryzen 3 5400U 16gb ram 256ssd FHD IPS Gari
- HP ELITEBOOK 850 G8 i5 1145G7/16GB ram 256ssd/FHD
- Újszerű Lenovo Legion 5 - 15,6"FHD IPS - Ryzen 5 5600H - 16GB - 512GB SSD - RTX 3050 - Win11 -MAGYAR
- ÚJ Lenovo LOQ 15IRX9 - QHD 165Hz - i7-13650HX - 16GB - 1TB - RTX 4060 - Win11 - 3 év garancia
- HP Victus 15-fb1002AX - 15,6"FHD IPS - Ryzen 5 7535HS - 8GB - 512GB SSD - RTX 2050 - Win11
- AKCIÓ! Asus TUF F15 FX506HM Gamer notebook - i5 11400H 16GB DDR4 RAM 512GB SSD RTX 3060 6GB W10
- ÁRGARANCIA! Épített KomPhone i5 13400F 32/64GB RAM RX 7700 XT 12GB GAMER PC termékbeszámítással
- LG 27UL500-W - 27" IPS - 3840x2160 4K - 60Hz 5ms - HDR10 - AMD FreeSync - 300 Nits - sRGB 99%
- Bomba ár! Dell Latitude 5310 - i5-10GEN I 16GB I 256SSD I HDMI I 13,3" FHD I Cam I W11 I Garancia!
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest