Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: p31_SerielDirectwithBytes_Generatoren_Rampe_Sinus_usw
Revision 0:2e0be62147b1, committed 2017-04-25
- Comitter:
- ogris
- Date:
- Tue Apr 25 06:52:25 2017 +0000
- Commit message:
- awers; ;
Changed in this revision
FuncGenFSST3.cpp | Show annotated file Show diff for this revision Revisions of this file |
FuncGenFSST3.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 2e0be62147b1 FuncGenFSST3.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FuncGenFSST3.cpp Tue Apr 25 06:52:25 2017 +0000 @@ -0,0 +1,72 @@ + +#include "FuncGenFSST3.h" + + +SingnedRampGen::SingnedRampGen() +{ + // sinnvolle frequenz/Periode setzen + SetPointsPerPeriod(50); +} + +void SingnedRampGen::SetPointsPerPeriod(float aPoints) +{ + _inc = 2.0/aPoints; +} + +void SingnedRampGen::SetFrequ(float aFrequ) +{ + SetPointsPerPeriod(1.0/aFrequ); +} + +void SingnedRampGen::CalcOneStep() +{ + val = val + _inc; + if( val>1.0 ) + val = -1 + (val - 1.0); +} + + +TriangleGen::SingnedRampGen() +{ + // sinnvolle frequenz/Periode setzen + SetPointsPerPeriod(100); +} + +void TriangleGen::SetPointsPerPeriod(float aPoints) +{ + _inc = 4.0/aPoints; +} + +void TriangleGen::SetFrequ(float aFrequ) +{ + SetPointsPerPeriod(2.0/aFrequ); +} + +void TriangleGen::CalcOneStep() +{ + phase = phase + _inc; + + if( phase>1.0 ) + { + phase = -1 + (phase - 1.0); + _state++; + } + + +} + + + + + + + + + + + + + + + +
diff -r 000000000000 -r 2e0be62147b1 FuncGenFSST3.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FuncGenFSST3.h Tue Apr 25 06:52:25 2017 +0000 @@ -0,0 +1,83 @@ + +#ifndef FuncGenFSST_h +#define FuncGenFSST_h + +//Sägezahn +class SingnedRampGen { + public: + float val; // momentaner Ausgangswert + private: + float _inc; + public: + SingnedRampGen(); + + void SetPointsPerPeriod(float aPoints); + + // bezogen auf Fsample 0..0.5 + void SetFrequ(float aFrequ); + + // Einen Abtastwert berechnen + // wird bei z.B. Fsample=100Hz 100x pro sec afgerufen + void CalcOneStep(); +}; + +//Dreieck +class TriangleGen { + public: + float val; // momentaner Ausgangswert + private: + float _inc; + int _state; + public: + TriangleGen(); + + void SetPointsPerPeriod(float aPoints); + + // bezogen auf Fsample 0..0.5 + void SetFrequ(float aFrequ); + + // Einen Abtastwert berechnen + void CalcOneStep(); +}; + +//Rechteck +class RectGen { + public: + float val; // momentaner Ausgangswert + private: + float _inc; + float _phase; + public: + RectGen(); + + void SetPointsPerPeriod(float aPoints); + + void SetFrequ(float aFrequ); + + // Dauer des ON-Pulses in Prozent ( 0..1 ) + void SetPulsWidth(float aPercent); + + // Einen Abtastwert berechnen + void CalcOneStep(); +}; + +#endif + + + + + + + + + + + + + + + + + + +