Hirdetés
-
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
Köszi, kipróbáltam. A fordító hibaüzenetet dob, és a bekötés honnan derül ki?
Ez a jelenlegi program, de lehet valamit rosszul csináltam:
#define ROTE_CLK GPIO_NUM_xx
#define ROTE_DT GPIO_NUM_xx
#define ROTE_SPCTM 50000 // speed control time limit, not defined no speedctrl
volatile int32_t rotval = 0;
void IRAM_ATTR isrrot() {
volatile static uint8_t pinsta = 0x3, cwi = 0, ccwi = 0;
volatile static uint8_t cwexp[] = {0xD, 0x4, 0x2, 0xB};
volatile static uint8_t ccwexp[] = {0xE, 0x8, 0x1, 0x7};
int32_t rvchg;
#ifdef ROTE_SPCTM
volatile static uint32_t tc = 0, tm = 0;
uint32_t ctm, td;
#endif
pinsta = (pinsta << 2) & 0xf;
if (digitalRead(ROTE_DT)) pinsta |= 0x2;
if (digitalRead(ROTE_CLK)) pinsta |= 0x1;
if (pinsta == cwexp[cwi]) cwi++;
else if (pinsta == ccwexp[ccwi]) ccwi++;
if (cwi == 0x4 || ccwi == 0x4)
{
if (cwi == 4) rvchg = 1;
else rvchg = -1;
pinsta = 0x3; cwi = 0; ccwi = 0;
#ifdef ROTE_SPCTM
ctm = micros();
td = ctm - tm;
tm = ctm;
if (td < ROTE_SPCTM / 2) rvchg *= 7;
else if (td < (ROTE_SPCTM * 2) / 3) rvchg *= 4;
else if (td < ROTE_SPCTM) rvchg *= 2;
#endif
rotval += rvchg;
}
} // isrrot
int16_t getrotv() {
static int32_t lval = 0;
int32_t cval = rotval;
int16_t rotc = 0;
if (lval != cval) {
rotc = cval - lval;
lval = cval;
}
return (rotc);
} // getrotv
void inirotein(gpio_num_t clk, gpio_num_t dt) {
pinMode(clk, INPUT);
pinMode(dt, INPUT);
attachInterrupt(digitalPinToInterrupt(clk), isrrot, CHANGE);
attachInterrupt(digitalPinToInterrupt(dt), isrrot, CHANGE);
} // inirotein
void setup() {
inirotein(ROTE_CLK, ROTE_DT);
}
void loop() {
Serial.print("Encoder_positionp = "); Serial.println(rotval);
}
Új hozzászólás Aktív témák
- Windows 11
- Merész dizájn és új teleobjektív az iPhone 17 Pro mobilokban
- Az Apple bemutatta az iPhone 17-et
- PlayStation 5
- A magas vérnyomást is felismerheti az Apple Watch Series 11
- Nagyrobogósok baráti topikja
- Mobil flották
- LEGO klub
- Projektor topic
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- További aktív témák...
- EREDETI NINTENDO Pokemon Go Plus autocatcher dobozban eladó
- Panasonic CF-XZ6 AIO all-in-one laptop tablet 2k touch i5-7300u speciális ütésálló rugged
- MINI PC HP PRODESK 600 G2 G3 G4 G5 i3 és i5 6-9. gen gar. Budapest MPL Foxpost
- BESZÁMÍTÁS! ASUS H610M i5 12400F 16GB DDR4 1TB SSD RTX 4060 8GB Rampage Shiva Cooler Master 650W
- LicencAruhaz.hu OLCSÓ, LEGÁLIS SZOFTVEREK AZONNAL - Windows - Office - Win Server - ÖRÖK GARANCIÁVAL
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest