Hirdetés
Hirdetés
Köszönjük a sok biztatást, támogatást! Egy rövid ideig még féláron tudsz hirdetni, előfizetni!
-
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
- Samsung Galaxy Watch7 44mm LTE (esim)
- Eladó 4 hónapos Asus Vivobook S14 M5406NA-PP014W 3 év garanciával
- Dell Precision 5540 i7-9850H 32GB 1000GB Nvidia Quadro T1000 15.6" FHD
- Lenovo IdeaPad Gaming 3 - 15.6" FHD IPS 165Hz - Ryzen 5-5600H - 16GB - 512GB - RTX 3050 Ti - Win11 P
- Dell Precision 5540 i7-9850H 16GB 512GB Nvidia Quadro T1000 15.6" FHD
- Bomba Ár! Lenovo ThinkPad L14 - Ryzen 5 I 16GB I 256SSD I 14" FHD Touch I HDMI I Cam I W11 I Gari!
- Xiaomi Redmi Note 13 Pro+ 512GB, Kártyafüggetlen, 1 Év Garanciával
- Eladó karcmentes Apple iPhone 12 128GB / 12 hó jótállással
- Lenovo ThinkPad dokkolók: USB-C 40A9/ 40AY/ 40AS/ Thunderbolt 3 40AC/ Hybrid USB-C DisplayLink 40AF
- HP 200W (19.5V 10.3A) kis kék, kerek, 4.5x3.0mm töltők + tápkábel, 928429-002
Állásajánlatok
Cég: FOTC
Város: Budapest