REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
signal_generator.cpp
Go to the documentation of this file.
1
2#include <proto/main.pb.h>
4
6
8
9void platform::NativeSignalGenerator::set_frequency(float frequency) { _frequency = frequency; }
10
11void platform::NativeSignalGenerator::set_phase(float phase) { _phase = phase; }
12
13void platform::NativeSignalGenerator::set_wave_form(WaveForm wave_form) { _wave_form = wave_form; }
14
16 if (amplitude < 0.0f || amplitude > 1.0f)
17 return false;
18 _amplitude = amplitude;
19 return true;
20}
21
25
27 if (fabs(low) > 1.0f)
28 return false;
29 _square_low_voltage = low;
30 return true;
31}
32
34 if (fabs(high) > 1.0f)
35 return false;
36 _square_high_voltage = high;
37 return true;
38}
39
41 if (fabs(offset) > 1.0f)
42 return false;
43 _offset = offset;
44 return true;
45}
46
48 throw std::runtime_error("not impl");
49}
50
52 throw std::runtime_error("not impl");
53}
54
55float platform::NativeSignalGenerator::get_frequency() const { return _frequency; }
56
57float platform::NativeSignalGenerator::get_phase() const { return _phase; }
58
59WaveForm platform::NativeSignalGenerator::get_wave_form() const { return _wave_form; }
60
61float platform::NativeSignalGenerator::get_amplitude() const { return _amplitude; }
62
63float platform::NativeSignalGenerator::get_square_voltage_low() const { return _square_low_voltage; }
64
66 return _square_high_voltage;
67}
68
69float platform::NativeSignalGenerator::get_offset() const { return _offset; }
70
71bool platform::NativeSignalGenerator::get_sleep() const { return _sleep; }
72
73float platform::NativeSignalGenerator::get_dac_out0() const { return _dac_out0; }
74
75float platform::NativeSignalGenerator::get_dac_out1() const { return _dac_out1; }
76
78
80
82 if (fabs(value) > 1.0f)
83 return false;
84 _dac_out0 = value;
85 return true;
86}
87
89 if (fabs(value) > 1.0f)
90 return false;
91 _dac_out1 = value;
92 return true;
93}
94
95// TODO: Implement smart write to hardware for signal generator
97 // TODO: not impl
98 return utils::status::success();
99}
bool set_square_voltage_low(float low) override
Sets the lower value of the square output in machine units.
void set_phase(float phase) override
Sets the phase of the frequency outputs synchronised to the reset pin.
float get_dac_out1() const override
bool set_dac_out1(float value) override
Writes the DACout1 constant voltage output. Possible values are: [-2V, 2V].
void set_wave_form(WaveForm wave_form) override
Sets the wave form of the function generator output.
float get_frequency() const override
WaveForm get_wave_form() const override
float get_square_voltage_low() const override
bool init() override
Initializes the signal generator and puts it to sleep.
float get_real_phase() const override
Returns the actually set phase of the function generator, containing rounding errors.
bool set_square_voltage_high(float high) override
Sets the upper value of the square output in machine units.
float get_amplitude() const override
float get_offset() const override
void sleep() override
Sets the sine / triangle output of the function generator to zero.
bool set_offset(float offset) override
Sets the constant offset of the sine or triangle output in machine units.
utils::status write_to_hardware() override
float get_square_voltage_high() const override
bool set_square_voltage_levels(float low, float high) override
Sets the lower and upper value of the square output in machine units.
void awake() override
Resumes outputs of the function generator to regular operation, according to the previously specified...
float get_dac_out0() const override
bool set_amplitude(float amplitude) override
Sets the amplitude of the sine or triangle wave in machine units.
float get_real_frequency() const override
Returns the actually set frequency of the function generator, containing rounding errors.
bool set_dac_out0(float value) override
Writes the DACout0 constant voltage output. Possible values are: [-2V, 2V].
void set_frequency(float frequency) override
Sets the frequency of the sine / triangle output in Hz.