From 198feef12febdc555fc2727960b0d905bbc0772c Mon Sep 17 00:00:00 2001 From: Tristan Krause Date: Fri, 7 Jun 2019 10:47:34 +0200 Subject: [PATCH] PWM update --- control/examples/pwm/main.cpp | 10 ++++++---- control/examples/register/main.cpp | 4 ---- control/src/drv/b15f.h | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/control/examples/pwm/main.cpp b/control/examples/pwm/main.cpp index dd8af86..349ccab 100644 --- a/control/examples/pwm/main.cpp +++ b/control/examples/pwm/main.cpp @@ -3,12 +3,14 @@ #include #include -const char PLOT_FILE[] = "plot.bin"; - +/* + * Erzeugt ein PWM Signal an PB4 mit 100KHz. + * Beste Frequenz: 31300 + */ int main() { B15F& drv = B15F::getInstance(); - std::cout << "TOP: " << (int) drv.pwmSetFrequency(100000) << std::endl; - drv.pwmSetValue(40); + std::cout << "TOP: " << (int) drv.pwmSetFrequency(31300) << std::endl; + drv.pwmSetValue(127); } diff --git a/control/examples/register/main.cpp b/control/examples/register/main.cpp index ec23afc..b90fe5f 100644 --- a/control/examples/register/main.cpp +++ b/control/examples/register/main.cpp @@ -1,10 +1,6 @@ -#include -#include #include #include -const char PLOT_FILE[] = "plot.bin"; - /* * Dieses Beispiel erzeugt einen 300ms langen Impuls an PB0. * diff --git a/control/src/drv/b15f.h b/control/src/drv/b15f.h index 3580058..b708e3e 100644 --- a/control/src/drv/b15f.h +++ b/control/src/drv/b15f.h @@ -202,6 +202,7 @@ public: /** * Setzt die Register so, dass näherungsweise die gewünschte Frequenz erzeugt wird. * Ist freq == 0 wird PWM deaktiviert. + * Standardfrequenz: 31300 (empfohlen, da dann TOP == 255) * \param freq PWM Frequenz * \return Top Wert des PWM Value für die gesetzte Frequenz * \throws DriverException