-
Fototrend
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
- Precision 7770 17.3" FHD IPS i7-12850HX RTX A3000 32GB 1TB NVMe ujjlolv IR kam gar
- Airpods 4 fülhallgató
- T14 Gen2i 14" FHD IPS i7-1185G7 16GB 512GB NVMe magyar vbill ujjlolv IR kam gar
- Latitude 7420 27% 14" FHD IPS i5-1145G7 16GB 512GB NVMe ujjlolv IR kam gar
- Dell Latitude 9520 15" FHD IPS i7-1185G7 16GB 512GB NVMe ujjlolv IR kam gar
- Apple iPhone 15 Pro 256GB,Dobozával,12 hónap garanciával
- HIBÁTLAN iPhone 12 mini 128GB Green -1 ÉV GARANCIA - Kártyafüggetlen, MS3400, 94% Akkumulátor
- Jabra Speak2 75 MS Teams USB-bluetooth hangszóró
- Apple iPhone 13 Mini 128GB /Kártyafüggetlen / 12Hó Garancia / 99% akku
- 134 - Lenovo Legion Pro 7 (16IRX8H) - Intel Core i9-13900HX, RTX 4090 - 3 év garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest