-
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
- Dior Sauvage Eau de Parfum 200 ml
- Ryzen 5 2600X, MSI 1060 Armor OC 6GB, 16GB DDR4 RAM
- Sony PlayStation 5 (PS5) Slim Ghost of Yōtei Gold Limited Edition 3 év garancia
- Iphone 13 PRO MAX 128GB GOLD 91% Akku! CSODASZÉP, DOBOZBAN MINT AZ ÚJ!
- Intel Core i9-13900K + ASUS ROG MAXIMUS Z790 HERO + Opcionálisan G.SKILL 32GB CL34 6800 és hűtő
- Apple iPhone 13 256GB / Kártyafüggetlen / 12Hó Garancia / 100% Akku
- Azonnali készpénzes AMD Radeon RX 5000 sorozat videokártya felvásárlás személyesen / csomagküldéssel
- DELL PowerEdge R740 rack szerver - 2xGold 6130 (16c/32t, 2.1/3.7GHz), 64GB RAM, 10Gbit HBA330, áfás
- BESZÁMÍTÁS! Asus B560M i5 10400F 16GB DDR4 512B SSD RX 6600XT 8GB AeroCool DS Cube ADATA 600W
- ÁRGARANCIA!Épített KomPhone Ryzen 7 7700X 32/64GB RAM RX 7800 XT 16GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest
ekkold
