DIY Auto-Correlator 1.0
Auto-Correlator Card implementation using Teensy 4.x microcontrollers.
multi_tau.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include "./../types.hpp"
5
7#include "accumulator.hpp"
8#include "discarder.hpp"
9#include "monitor_channel.hpp"
10#ifdef CORR_SIMULATOR
11 #include "pseudoSerial.hpp"
12#endif
13
14
15//Example
16//MultiTauACorrRTTeensy<9, 27, 3> multy;
17
19//using Lin_Corr_t = Lin_ACorr_RT_Teensy; //→ S //→P //→m
20template <unsigned int Lin_channels, index_t Series_size, unsigned int Bin_Ratio>
22{
23
24private:
25
26 Accumulator Accumulators[Lin_channels];
28 DiscarderTeensy<Series_size, int(Series_size/Bin_Ratio), 0> Discarder;
29
30public:
31 MonitorChannel<true> MeanMonitor; //< Calculates the mean of the signal
32 uint32_t DataCounter = 0;
33
34
35 //1
38 {
39 //Initalize the Accumulators
40 for(unsigned int s = 0; s < Lin_channels; s++)
41 {
43 }
44 }
45
46
47 //2
49 void inline push_datum(counter_t datum) __attribute__((flatten))
50 {
52
53 //Monitor Channel for mean
55
56 //Lin Corr 0 - No coarsening
57 Lin_Corrs[0].push_datum(datum);
58
59 //Other channels with coarsening.
60 //#pragma unroll Lin_channels
61 for(unsigned int i = 1; i < Lin_channels; i++)
62 {
63 Accumulators[i].pipe(Lin_Corrs[i], datum);
64 //Lin_Corrs[i].push_datum(datum);
65 }
66 }
67
68
69 //3
71 void push_data(const counter_t *container, const index_t size) __attribute__((flatten))
72 {
73 for(unsigned int i = 0; i < size; i++)
74 {
75 this->push_datum(container[i]);
76 }
77 }
78
79
80 //4
82 void ch_out() const __attribute__((flatten))
83 {
84 Lin_Corrs[0].ch_out(); //Output without discarding
85 //Output with discarding for all subsequent correlators
86 for(unsigned int s = 1; s < Lin_channels; s++)
87 {
88 Discarder.output(Lin_Corrs[s]);
89 }
90 }
91
92
93 //5
96 index_t time_scaling_factor() const __attribute__((always_inline))
97 {
98 return (Series_size - Bin_Ratio);
99 }
100
101
102 //6
104 index_t tau_scaling_scheme(unsigned int s) const __attribute__((always_inline))
105 {
106 return index_t(pow(Bin_Ratio, s));
107 }
108
109};
110
111
112
113
114
Adapter object responsible for accumulating the points and coarsening the time-series as per the rela...
Definition: accumulator.hpp:8
void pipe(LinCorrType &channel, const counter_t datum)
Accumulates data points until the BufferPoints criteria is satisfied, after which the points are push...
Definition: accumulator.hpp:26
void do_accumulate(unsigned int buffer_cnt)
Sets the number of points to buffer(accumulate) before pushing to Correlator object.
Definition: accumulator.hpp:16
Teensy specific Front back discarder implementation.
Definition: discarder.hpp:15
This is an implementation of Lin_ACorr_RT_Base for Teensy with (No normalisation or baseline subtract...
Definition: Lin_ACorr_RT_Teensy.hpp:17
Template specialization.
Definition: monitor_channel.hpp:14
void push_back(DataType data)
Adds datum to the channel.
Definition: monitor_channel.hpp:23
MultiTau Auto-Correlator object that is composed of multiple linear - autocorrelators....
Definition: multi_tau.hpp:22
index_t tau_scaling_scheme(unsigned int s) const __attribute__((always_inline))
Returns the relavent Tau scaling factor, based on the specialised scheme. It is used by the accumulat...
Definition: multi_tau.hpp:104
MultiTauACorrRTTeensy()
Counts the total number of data points sent to the counter.
Definition: multi_tau.hpp:37
index_t time_scaling_factor() const __attribute__((always_inline))
Definition: multi_tau.hpp:96
void push_datum(counter_t datum) __attribute__((flatten))
Pushes the datum to each of the Linear Correlators through the Accumulator adapter.
Definition: multi_tau.hpp:49
MonitorChannel< true > MeanMonitor
Definition: multi_tau.hpp:31
Accumulator Accumulators[Lin_channels]
Accumulator Objects for each channel (Accumulator '0' is redundant.)
Definition: multi_tau.hpp:26
uint32_t DataCounter
Definition: multi_tau.hpp:32
LinACorrRTTeensy< Series_size, false > Lin_Corrs[Lin_channels]
Linear ACorrelators.
Definition: multi_tau.hpp:27
void push_data(const counter_t *container, const index_t size) __attribute__((flatten))
Repeatedly calls the MultiTau_ACorr_RT::push_datum() on the given container of counter values.
Definition: multi_tau.hpp:71
DiscarderTeensy< Series_size, int(Series_size/Bin_Ratio), 0 > Discarder
Discarder that discards first #Bin_Ratio points.
Definition: multi_tau.hpp:28
void ch_out() const __attribute__((flatten))
Outputs the Linear Correlator channels through the discarder adapter.
Definition: multi_tau.hpp:82
uint32_t counter_t
Data type received from the pulse counter. It is the fundamental type used for representing series da...
Definition: types.hpp:7
uint_fast8_t index_t
It is used as the array indices and thus determine the maximum size of the Channel_array and the Seri...
Definition: types.hpp:10