9 #include <dpsim-models/Signal/CosineFMGenerator.h>
14 Real modulationFrequency,
15 Real modulationAmplitude,
18 mMagnitude = Math::abs(initialPhasor);
19 mInitialPhase = Math::phase(initialPhasor);
20 mBaseFrequency = frequency;
21 mModulationFrequency = modulationFrequency;
22 mModulationAmplitude = modulationAmplitude;
27 **mSigOut = initialPhasor;
30 SPDLOG_LOGGER_INFO(
mSLog,
"Parameters:");
31 SPDLOG_LOGGER_INFO(
mSLog,
33 "\nModulation Frequency={} [Hz]"
34 "\nModulation Amplitude={}"
35 "\nBase Frequency={} [Hz]",
36 Logger::phasorToString(initialPhasor), modulationFrequency,
37 modulationAmplitude, frequency);
41 Real phase = 2. * PI * mBaseFrequency * time + mInitialPhase;
44 Real tmp = 2 * time * mModulationFrequency;
45 Real sign = (((int)floor(tmp)) % 2 == 0) ? -1 : 1;
46 phase += 2 * mModulationAmplitude *
47 (pow(2 * (tmp - floor(tmp)) - 1, 2) - 1) / PI * sign;
48 **mFreq = mBaseFrequency +
49 mModulationAmplitude * (2 * (tmp - floor(tmp)) - 1) * sign;
51 phase += mModulationAmplitude / mModulationFrequency *
52 sin(2. * PI * mModulationFrequency * time);
53 **mFreq = mBaseFrequency +
54 mModulationAmplitude * cos(2. * PI * mModulationFrequency * time);
57 **mSigOut = Complex(mMagnitude * cos(phase), mMagnitude * sin(phase));
void setParameters(Complex initialPhasor, Real modulationFrequency, Real modulationAmplitude, Real frequency=0.0, bool zigzag=false)
set the source's parameters
void step(Real time)
implementation of inherited method step to update and return the current signal value
Logger::Log mSLog
Component logger.