rpm function added for part 1
This commit is contained in:
Vendored
+4
-4
@@ -8,8 +8,8 @@
|
|||||||
{
|
{
|
||||||
"name": "PlatformIO",
|
"name": "PlatformIO",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/include",
|
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/include",
|
||||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/src",
|
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/src",
|
||||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/cores/arduino",
|
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/cores/arduino",
|
||||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs",
|
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs",
|
||||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
|
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
"browse": {
|
"browse": {
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
"path": [
|
"path": [
|
||||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/include",
|
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/include",
|
||||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/src",
|
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/src",
|
||||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/cores/arduino",
|
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/cores/arduino",
|
||||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs",
|
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs",
|
||||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
|
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
|
||||||
|
|||||||
Vendored
+3
-3
@@ -12,7 +12,7 @@
|
|||||||
"type": "platformio-debug",
|
"type": "platformio-debug",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "PIO Debug",
|
"name": "PIO Debug",
|
||||||
"executable": "C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/.pio/build/nanoatmega328new/firmware.elf",
|
"executable": "C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/.pio/build/nanoatmega328new/firmware.elf",
|
||||||
"projectEnvName": "nanoatmega328new",
|
"projectEnvName": "nanoatmega328new",
|
||||||
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"type": "platformio-debug",
|
"type": "platformio-debug",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "PIO Debug (skip Pre-Debug)",
|
"name": "PIO Debug (skip Pre-Debug)",
|
||||||
"executable": "C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/.pio/build/nanoatmega328new/firmware.elf",
|
"executable": "C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/.pio/build/nanoatmega328new/firmware.elf",
|
||||||
"projectEnvName": "nanoatmega328new",
|
"projectEnvName": "nanoatmega328new",
|
||||||
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"type": "platformio-debug",
|
"type": "platformio-debug",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "PIO Debug (without uploading)",
|
"name": "PIO Debug (without uploading)",
|
||||||
"executable": "C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/.pio/build/nanoatmega328new/firmware.elf",
|
"executable": "C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/.pio/build/nanoatmega328new/firmware.elf",
|
||||||
"projectEnvName": "nanoatmega328new",
|
"projectEnvName": "nanoatmega328new",
|
||||||
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
int position();
|
int position();
|
||||||
void update_delta();
|
void update_delta();
|
||||||
float count_per_sec();
|
float count_per_sec();
|
||||||
|
float rpm();
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+4
-2
@@ -16,8 +16,10 @@ int main() {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
_delay_ms(50);
|
_delay_ms(50);
|
||||||
Serial.print("Counts per second: ");
|
// Serial.print("Counts per second: ");
|
||||||
Serial.println(encoder.count_per_sec());
|
// Serial.println(encoder.count_per_sec());
|
||||||
|
Serial.print("RPM: ");
|
||||||
|
Serial.println(encoder.rpm());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <avr/io.h>
|
/* #include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@@ -47,4 +47,4 @@ int main() {
|
|||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} */
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
#include <avr/io.h>
|
/* #include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@@ -63,3 +63,4 @@ int main() {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
#include <avr/io.h>
|
/* #include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@@ -66,3 +66,4 @@ int main() {
|
|||||||
ISR(INT0_vect) {
|
ISR(INT0_vect) {
|
||||||
encoder.update();
|
encoder.update();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -46,6 +46,10 @@ float RotaryEncoderDriver::count_per_sec() {
|
|||||||
return delta / (256.0f * 0.0001f);
|
return delta / (256.0f * 0.0001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float RotaryEncoderDriver::rpm() {
|
||||||
|
return (count_per_sec() * 60) / 1050.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ISR(INT0_vect) {
|
ISR(INT0_vect) {
|
||||||
driver->update();
|
driver->update();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "timer_usec.h"
|
#include "timer_usec.h"
|
||||||
|
|
||||||
|
Timer_usec::Timer_usec() = default;
|
||||||
|
|
||||||
void Timer_usec::init(uint16_t period_us) { // for custom duty cycle duration in ms in part 1
|
void Timer_usec::init(uint16_t period_us) { // for custom duty cycle duration in ms in part 1
|
||||||
TCCR1A = 0;
|
TCCR1A = 0;
|
||||||
TCCR1B = 0;
|
TCCR1B = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user