-
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
-
Tomika86
senior tag
válasz
vargalex #15675 üzenetére
const byte PulsesPerRevolution = 2;
const unsigned long ZeroTimeout = 100000; // For high response time, a good value would be 100000.
// For reading very low RPM, a good value would be 300000.
// Calibration for smoothing RPM:
const byte numReadings = 2; // Number of samples for smoothing. The higher, the more smoothing, but it's going to
// react slower to changes. 1 = no smoothing. Default: 2.
/////////////
// Variables:
/////////////
volatile unsigned long LastTimeWeMeasured; // Stores the last time we measured a pulse so we can calculate the period.
volatile unsigned long PeriodBetweenPulses = ZeroTimeout+1000; // Stores the period between pulses in microseconds.
// It has a big number so it doesn't start with 0 which would be interpreted as a high frequency.
volatile unsigned long PeriodAverage = ZeroTimeout+1000; // Stores the period between pulses in microseconds in total, if we are taking multiple pulses.
// It has a big number so it doesn't start with 0 which would be interpreted as a high frequency.
unsigned long FrequencyRaw; // Calculated frequency, based on the period. This has a lot of extra decimals without the decimal point.
unsigned long FrequencyReal; // Frequency without decimals.
unsigned long RPM; // Raw RPM without any processing.
unsigned int PulseCounter = 1; // Counts the amount of pulse readings we took so we can average multiple pulses before calculating the period.
unsigned long PeriodSum; // Stores the summation of all the periods to do the average.
unsigned long LastTimeCycleMeasure = LastTimeWeMeasured;
unsigned long CurrentMicros = micros();
unsigned int AmountOfReadings = 1;
unsigned int ZeroDebouncingExtra; // Stores the extra value added to the ZeroTimeout to debounce it.
// The ZeroTimeout needs debouncing so when the value is close to the threshold it
// doesn't jump from 0 to the value. This extra value changes the threshold a little
// when we show a 0.
// Variables for smoothing tachometer:
unsigned long readings[numReadings]; // The input.
unsigned long readIndex; // The index of the current reading.
unsigned long total; // The running total.
unsigned long average; // The RPM value after applying the smoothing.Annyit szeretnék, hogy ami itt 3db const van, azokat az értékeket, kijelzőn keresztül szeretném módosítani. De nem működik.
Persze a const elhagyva, és itt van a Zerotimeoutnál a +1000
Új hozzászólás Aktív témák
- sziku69: Szólánc.
- Xiaomi 15 - kicsi telefon nagy energiával
- exHWSW - Értünk mindenhez IS
- E-roller topik
- Linux Mint
- SzDavid99: Van 20 perced? Akkor tanulj meg koreait olvasni!
- Autós topik
- Jövő hónapban érkezik a Sacred 2: Remaster
- Épített vízhűtés (nem kompakt) topic
- Végre elkezdődik a DGX Spark gépek szállítása
- További aktív témák...
- AKCIÓ ÚJ Bontatlan Macbook Pro 14 M4 MAX 14 32GPU 36GB 1TB Magyar billentyűzet Azonnal átvehető Deák
- BONTATLAN Új Ipad 9th 10th 11 gen. Air 6 7 , Ipad Pro Mini 7 IPADEK Azonnal DEÁK Térnél Átvehető.
- BONTATLAN Új iPhone 17 PRO MAX 256-512GGB Független 1év Apple GARANCIA Deák Térnél Azonnal Átvehető.
- Dell Precision 7740 Workstation 17,3", i9-9980HQ, 32GB, RTX3000 6GB
- Gamer PC - i5 14600k, RTX 3080 és 32gb RAM + GARANCIA
- HIBÁTLAN iPhone 14 128GB Starlight -1 ÉV GARANCIA -Kártyafüggetlen, MS3680, 100% Akkumulátor
- Bomba ár! Dell Latitude E6320 - i5-2GEN I 4GB I 250GB I DVD I 13,3" HD I Cam I W10 I Garancia!
- DELL Universal Dock UD22
- BESZÁMÍTÁS! MSI B450 R7 5800X 32GB DDR4 1TB SSD RTX 3080 10GB ZALMAN S2 TG Cooler Master 700W
- Samsung Galaxy S24 Ultra 256GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: Promenade Publishing House Kft.
Város: Budapest