REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
signal_generator.h
Go to the documentation of this file.
1#pragma once
2
3#include <bus/bus.h>
4#include <entity/entity.h>
5#include <lucidac/signal_generator.h>
6
7namespace platform {
8class NativeSignalGenerator : public SignalGenerator {
9public:
12 bool init() override;
13
16 bool is_installed() const override { return installed; }
17
20 void set_frequency(float frequency) override;
23 void set_phase(float phase) override;
25 void set_wave_form(WaveForm wave_form) override;
28 bool set_amplitude(float amplitude) override;
31 bool set_square_voltage_levels(float low, float high) override;
34 bool set_square_voltage_low(float low) override;
37 bool set_square_voltage_high(float high) override;
40 bool set_offset(float offset) override;
41
43 float get_real_frequency() const override;
46 float get_real_phase() const override;
47
48 float get_frequency() const override;
49 float get_phase() const override;
50 WaveForm get_wave_form() const override;
51 float get_amplitude() const override;
52 float get_square_voltage_low() const override;
53 float get_square_voltage_high() const override;
54 float get_offset() const override;
55 bool get_sleep() const override;
56
57 float get_dac_out0() const override;
58 float get_dac_out1() const override;
59
62 void sleep() override;
65 void awake() override;
66
68 bool set_dac_out0(float value) override;
70 bool set_dac_out1(float value) override;
71
72 utils::status write_to_hardware() override;
73
74private:
76 static constexpr float _map_dac_levelshift(float x) {
77 return (x + 2.0f) * (0.0f - 2.5f) / (2.0f + 2.0f) + 2.5f;
78 }
79
80 float _frequency;
81 float _phase;
82 WaveForm _wave_form;
83 float _amplitude;
84 float _square_low_voltage;
85 float _square_high_voltage;
86 float _offset;
87 float _dac_out0;
88 float _dac_out1;
89
90 bool _sleep = true;
91
92 bool installed = false;
93
94 static constexpr uint8_t FUNCTION_GENERATOR_IDX = 2;
95 static constexpr uint8_t DAC_IDX = 3;
96
97 static constexpr uint8_t DAC_AMPLITUDE_CH = 0;
98 static constexpr uint8_t DAC_SQUARE_HIGH_CH = 1;
99 static constexpr uint8_t DAC_SQUARE_LOW_CH = 2;
100 static constexpr uint8_t DAC_OFFSET_CH = 3;
101 static constexpr uint8_t DAC_OUT0_CH = 4;
102 static constexpr uint8_t DAC_OUT1_CH = 5;
103};
104
105} // namespace platform
bool set_offset(float offset) override
Sets the constant offset of the sine or triangle output in machine units.
bool set_dac_out1(float value) override
Writes the DACout1 constant voltage output. Possible values are: [-2V, 2V].
float get_offset() const override
float get_real_phase() const override
Returns the actually set phase of the function generator, containing rounding errors.
float get_real_frequency() const override
Returns the actually set frequency of the function generator, containing rounding errors.
float get_dac_out0() const override
utils::status write_to_hardware() override
bool is_installed() const override
Returns wether an signal generator module is actually installed and active.
float get_frequency() const override
void awake() override
Resumes outputs of the function generator to regular operation, according to the previously specified...
void set_wave_form(WaveForm wave_form) override
Sets the wave form of the function generator output.
float get_square_voltage_low() const override
bool init() override
Initializes the signal generator and puts it to sleep.
bool set_dac_out0(float value) override
Writes the DACout0 constant voltage output. Possible values are: [-2V, 2V].
bool set_square_voltage_high(float high) override
Sets the upper value of the square output in machine units.
void sleep() override
Sets the sine / triangle output of the function generator to zero.
WaveForm get_wave_form() const override
void set_phase(float phase) override
Sets the phase of the frequency outputs synchronised to the reset pin.
bool set_amplitude(float amplitude) override
Sets the amplitude of the sine or triangle wave in machine units.
bool set_square_voltage_levels(float low, float high) override
Sets the lower and upper value of the square output in machine units.
bool set_square_voltage_low(float low) override
Sets the lower value of the square output in machine units.
float get_square_voltage_high() const override
void set_frequency(float frequency) override
Sets the frequency of the sine / triangle output in Hz.
float get_dac_out1() const override
float get_amplitude() const override
Definition leds.h:7