DIY Auto-Correlator 1.0
Auto-Correlator Card implementation using Teensy 4.x microcontrollers.
Lin_CrossCorr_RT_Teensy.hpp
Go to the documentation of this file.
1#pragma once
2#include "types.hpp"
3#include "Lin_CrossCorr_RT_Base.hpp"
4
5
9template <index_t Series_size>
10class Lin_CrossCorr_RT_Teensy : public Lin_CrossCorr_RT_Base
11{
12
13public:
14
15 counter_t Channel_array12[Series_size] = {0};
16 counter_t Channel_array21[Series_size] = {0};
17
18
22
23
26
27
28 //1
29 void __attribute__((flatten)) push_datum(counter_t datum1, counter_t datum2) override
30 {
31 Series_array1.push_back(datum1);
32 Series_array2.push_back(datum2);
33
34
35 for(unsigned int i = 0; i <= Series_size; i++)
36 {
37 Channel_array12[i] += (Series_array1[Series_index] * Series_array2[Series_index - i]);
38 Channel_array21[i] += (Series_array2[Series_index] * Series_array1[Series_index - i]);
39
40 }
41
44 }
45
46
47 //2
48 void __attribute__((flatten)) push_data(const counter_t *container1,const counter_t *container2, const index_t size) override
49 {
50 //unsigned int size = std::distance(std::begin(container), std::end(container));
51 for (int i = 0; i < size; i++)
52 {
53 push_datum(container1[i], container2[i]);
54 }
55 }
56
57
58 //3
61 double inline norm(unsigned int lag) {return 1;}
62
63
64 //4
65 void __attribute__((flatten)) ch_out() override
66 {
67 Serial.write(Channel_array12, sizeof(counter_t) * Series_size);
68 Serial.write(Channel_array21, sizeof(counter_t) * Series_size);
69
70 }
71
72
73 //5
74 void __attribute__((flatten)) ch_out_norm() override
75 {
76 #pragma unroll Series_size
77 for(unsigned int i = 0; i < Series_size; i++)
78 {
79 Serial.write(double(Channel_array12[i])/norm(i), sizeof(double));
80 Serial.write(double(Channel_array21[i])/norm(i), sizeof(double));
81
82 }
83 }
84
85 //6
86 counter_t* get_ch_array12() __attribute__((always_inline)) const
87 {
88 return Channel_array12;
89 }
90
91
92 //7
93 counter_t* get_ch_array21() __attribute__((always_inline)) const
94 {
95 return Channel_array21;
96 }
97
98};
This is an implementation of Lin_ACorr_RT_Base for Teensy with (No normalisation or baseline subtract...
Definition: Lin_CrossCorr_RT_Teensy.hpp:11
counter_t Channel_array21[Series_size]
Stores the Channel output - 12.
Definition: Lin_CrossCorr_RT_Teensy.hpp:16
Simpler_Circular_Buffer< counter_t, Series_size > Series_array1
Stores the Channel output - 21.
Definition: Lin_CrossCorr_RT_Teensy.hpp:20
void __attribute__((flatten)) push_data(const counter_t *container1
void __attribute__((flatten)) push_datum(counter_t datum1
Stores the last active index → Post-increment.
Simpler_Circular_Buffer< counter_t, Series_size > Series_array2
Definition: Lin_CrossCorr_RT_Teensy.hpp:21
index_t Series_index2
Stores the last active index → Post-increment.
Definition: Lin_CrossCorr_RT_Teensy.hpp:25
void const counter_t * container2
Definition: Lin_CrossCorr_RT_Teensy.hpp:48
counter_t Channel_array12[Series_size]
Definition: Lin_CrossCorr_RT_Teensy.hpp:15
index_t Series_index1
Definition: Lin_CrossCorr_RT_Teensy.hpp:24
Definition: simpler_circular_buffer.hpp:6
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