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
7#include <chips/AD9834.h>
8#include <chips/DAC60508.h>
9#include <chips/SR74HCT595.h>
10
11namespace platform {
12class TeensySignalGenerator : public SignalGenerator {
13public:
16 bool init() override;
17
20 bool is_installed() const override { return installed; }
21
24 void set_frequency(float frequency) override;
27 void set_phase(float phase) override;
29 void set_wave_form(WaveForm wave_form) override;
32 bool set_amplitude(float amplitude) override;
35 bool set_square_voltage_levels(float low, float high) override;
38 bool set_square_voltage_low(float low) override;
41 bool set_square_voltage_high(float high) override;
44 bool set_offset(float offset) override;
45
47 float get_real_frequency() const override;
50 float get_real_phase() const override;
51
52 float get_frequency() const override;
53 float get_phase() const override;
54 WaveForm get_wave_form() const override;
55 float get_amplitude() const override;
56 float get_square_voltage_low() const override;
57 float get_square_voltage_high() const override;
58 float get_offset() const override;
59 bool get_sleep() const override;
60
61 float get_dac_out0() const override;
62 float get_dac_out1() const override;
63
66 void sleep() override;
69 void awake() override;
70
72 bool set_dac_out0(float value) override;
74 bool set_dac_out1(float value) override;
75
76 utils::status write_to_hardware() override;
77
78private:
79 const functions::DAC60508 digital_analog_converter;
80 functions::AD9834 function_generator;
81
83 static constexpr float _map_dac_levelshift(float x) {
84 return (x + 2.0f) * (0.0f - 2.5f) / (2.0f + 2.0f) + 2.5f;
85 }
86
87 float _frequency = 0.0f;
88 float _phase = 0.0f;
89 WaveForm _wave_form = WaveForm::SINE;
90 float _amplitude = 0.0f;
91 float _square_low_voltage = 0.0f;
92 float _square_high_voltage = 0.0f;
93 float _offset = 0.0f;
94 float _dac_out0 = 0.0f;
95 float _dac_out1 = 0.0f;
96
97 bool _sleep = true;
98
99 bool installed = false;
100
101 static constexpr uint8_t FUNCTION_GENERATOR_IDX = 2;
102 static constexpr uint8_t DAC_IDX = 3;
103
104 static constexpr uint8_t DAC_AMPLITUDE_CH = 0;
105 static constexpr uint8_t DAC_SQUARE_HIGH_CH = 1;
106 static constexpr uint8_t DAC_SQUARE_LOW_CH = 2;
107 static constexpr uint8_t DAC_OFFSET_CH = 3;
108 static constexpr uint8_t DAC_OUT0_CH = 4;
109 static constexpr uint8_t DAC_OUT1_CH = 5;
110};
111
112} // namespace platform
The DAC60508 is the 12-Bit 8-channel DAC, used in the MInt-Block for the initial conditions.
Definition DAC60508.h:17
float get_frequency() const override
float get_real_frequency() const override
Returns the actually set frequency of the function generator, containing rounding errors.
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_dac_out1() const override
bool set_dac_out0(float value) override
Writes the DACout0 constant voltage output. Possible values are: [-2V, 2V].
float get_square_voltage_high() const override
float get_square_voltage_low() const override
void sleep() override
Sets the sine / triangle output of the function generator to zero.
bool set_square_voltage_high(float high) override
Sets the upper value of the square output 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 init() override
Initializes the signal generator and puts it to sleep.
void set_frequency(float frequency) override
Sets the frequency of the sine / triangle output in Hz.
void set_wave_form(WaveForm wave_form) override
Sets the wave form of the function generator output.
bool is_installed() const override
Returns wether an signal generator module is actually installed and active.
float get_offset() const override
float get_real_phase() const override
Returns the actually set phase of the function generator, containing rounding errors.
bool set_amplitude(float amplitude) override
Sets the amplitude of the sine or triangle wave in machine units.
void awake() override
Resumes outputs of the function generator to regular operation, according to the previously specified...
float get_amplitude() const override
WaveForm get_wave_form() const override
bool set_square_voltage_low(float low) override
Sets the lower value of the square output in machine units.
float get_dac_out0() const override
void set_phase(float phase) override
Sets the phase of the frequency outputs synchronised to the reset pin.
bool set_dac_out1(float value) override
Writes the DACout1 constant voltage output. Possible values are: [-2V, 2V].
Definition leds.h:7