Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: Add ADMT Plugin for ADMT4000 #1878

Open
wants to merge 102 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
718a439
cmake: added post build to copy .DLLs when debugging or launching scopy
JJuanill May 29, 2024
a63abe9
tools/plugingenerator: modified CMake list template to output generat…
JJuanill May 29, 2024
c6f3b9c
doc: Included documentation for building Scopy locally on Windows env…
JJuanill May 29, 2024
3298760
admt: Initialized plugin files
JJuanill May 30, 2024
c420a2c
admt: Configured ADMT plugin
JJuanill May 30, 2024
8267a16
admt: Added test GUI textbox and button for rotation, count, and angle
JJuanill Jun 3, 2024
4f205fc
Merge remote-tracking branch 'origin/dev' into dev_windows_build
JJuanill Jun 5, 2024
7a20c0f
Merge remote-tracking branch 'origin/dev_windows_build' into dev_admt
JJuanill Jun 6, 2024
47bbf6d
admt: Renamed plugin and include directories
JJuanill Jun 6, 2024
290f4ec
admt: Connected button to output to text field
JJuanill Jun 10, 2024
6799ce1
admt: Added GRTimePlotAddon
JJuanill Jun 12, 2024
3eb4887
Merge remote-tracking branch 'origin/dev' into dev_admt
JJuanill Jun 12, 2024
69af835
admt: Implemented channel control and init methods
JJuanill Jun 14, 2024
76202a3
Merge remote-tracking branch 'origin/dev' into dev_admt
JJuanill Jun 18, 2024
6f1d4d8
admt: Update CMakeList
JJuanill Jun 18, 2024
0d3048f
Merge remote-tracking branch 'origin/dev' into dev_windows_build
JJuanill Jun 19, 2024
eced5a4
cmake: Added post build to copy library to binary path
JJuanill Jun 19, 2024
8f38f67
Merge remote-tracking branch 'origin/dev_windows_build' into dev_admt
JJuanill Jun 19, 2024
3b82d92
admt: Added historical graph
JJuanill Jun 26, 2024
32992dd
Merge remote-tracking branch 'origin/dev' into dev_admt
JJuanill Jun 26, 2024
292fe36
admt: Implemented GUI interface and controller
JJuanill Jul 9, 2024
c42ce79
admt: Fixed axis scales when changing displayed graph
JJuanill Jul 9, 2024
082b2bd
admt: Added calibration tab
JJuanill Jul 16, 2024
c11588f
admt: Implemented export and import raw calibration data
JJuanill Jul 18, 2024
e3138d9
admt: Implemented calibration routine in controller
JJuanill Jul 23, 2024
e51d571
admt: Layout for motor controls
JJuanill Jul 31, 2024
c2fe9a1
admt: Added stepper motor control for calibration
JJuanill Aug 9, 2024
995ed2f
admt: Adjusted Calibration GUI
JJuanill Aug 15, 2024
578d08d
admt: Added read device registry
JJuanill Aug 15, 2024
574d315
admt: Removed raw motor controls
JJuanill Aug 29, 2024
bfa930c
admt: Added registers tab
JJuanill Sep 2, 2024
6319781
admt: Added Sine and Cosine channels to raw calibration graph
JJuanill Sep 5, 2024
c4fcd2a
admt: Added calibration graph toggles
JJuanill Sep 6, 2024
9ea492e
admt: Refactored read and write to registry
JJuanill Sep 9, 2024
07499ac
admt: Implement compatible selected plugin
JJuanill Sep 10, 2024
fa0ae6f
admt: Adjusted UI
JJuanill Sep 10, 2024
7e1f45f
admt: Set debug to false
JJuanill Sep 11, 2024
f8e54a3
admt: Implemented status indicators for registers in utility tab
JJuanill Sep 25, 2024
44e8003
Update admtcontroller.cpp
RainDalena Sep 25, 2024
c8b07ea
admt: Implemented sequence read and write
JJuanill Sep 26, 2024
8c92443
admt: Corrected string output for binary and hex values
JJuanill Sep 26, 2024
c94c7a6
admt: Fixed pre-calibration FFT calculation
JJuanill Sep 26, 2024
bf8133b
admt: Fixed replot pre-calibration FFT graph after clear
JJuanill Sep 26, 2024
f740677
admt: Implemented GMR reset
JJuanill Sep 27, 2024
a4774ba
admt: Added min and max for line edit
JJuanill Oct 7, 2024
cc87dc8
Update admtcontroller.cpp
RainDalena Oct 7, 2024
0edc0a3
Update admtcontroller.cpp
RainDalena Oct 7, 2024
355f9ea
admt: Implemented GPIO Control
JJuanill Oct 8, 2024
d6d1669
admt: Implemented multithread for calibration data sampling
JJuanill Oct 10, 2024
c27de5a
Update admtcontroller.cpp
RainDalena Oct 10, 2024
7fb9806
admt: Fixed controls for post calibration data
JJuanill Oct 10, 2024
9b07a7f
Update admtcontroller.cpp
RainDalena Oct 10, 2024
eb8a263
Update admtcontroller.cpp
RainDalena Oct 10, 2024
bad4d54
Mag FFT and Harmonic Cal Algorithm adjustments.
RainDalena Oct 11, 2024
cc191b3
admt: Adjusted calibration and post calibration behaviors
JJuanill Oct 14, 2024
c0bdba7
Wrap angle errors to [-π, π] range
JJuanill Oct 15, 2024
5ff3060
Update admtcontroller.cpp
RainDalena Oct 15, 2024
fe18eac
Update admtcontroller.cpp
RainDalena Oct 16, 2024
5d57caa
Refactor angle error calculations and FFT in ADMTController
JJuanill Oct 16, 2024
b2ecf9f
Update admtcontroller.cpp
RainDalena Oct 16, 2024
0e66c72
Update admtcontroller.cpp
RainDalena Oct 16, 2024
c0e5839
Update admtcontroller.cpp
RainDalena Oct 16, 2024
aa16da0
Revert "Update admtcontroller.cpp"
RainDalena Oct 17, 2024
2274dc5
Revert "Update admtcontroller.cpp"
RainDalena Oct 17, 2024
31c2424
Revert "Update admtcontroller.cpp"
RainDalena Oct 17, 2024
6975b2a
Revert "Refactor angle error calculations and FFT in ADMTController"
RainDalena Oct 17, 2024
e9eae82
Revert "Update admtcontroller.cpp"
RainDalena Oct 17, 2024
b89654f
admt: Fixed admtcontroller.h
JJuanill Oct 22, 2024
ac61bac
admt: Adjusted UI to hide and show specific fault registers based on …
JJuanill Oct 30, 2024
87298fa
admt: Included motor controls in acquisition tab
JJuanill Oct 31, 2024
3cb74dc
Merge branch 'dev' of https://github.com/JJuanill/scopy into dev_admt
JJuanill Oct 31, 2024
cfed47f
admt: Merge to latest dev build
JJuanill Nov 4, 2024
322096c
admt: Hide MT Diagnostic indicator and register
JJuanill Nov 4, 2024
2cfe891
admt: Hide registers on sequence mode
JJuanill Nov 4, 2024
eb676ab
admt: Updated graph style
JJuanill Nov 5, 2024
05fa370
admt: Add read all registers
JJuanill Nov 6, 2024
de0b902
admt: Reverted changes to calibration samples graph
doun-doughnut Nov 12, 2024
ba825b3
admt: Initial implement of style helper
doun-doughnut Nov 12, 2024
e814721
admt: Included import samples in calibration data
doun-doughnut Nov 13, 2024
813a576
admt: Initial implement of acquisition graph data
doun-doughnut Nov 13, 2024
55814c9
admt: Added state for MT Diagnostics
doun-doughnut Nov 15, 2024
9607812
admt: Removed resizing acquisition list
doun-doughnut Nov 15, 2024
c227e44
admt: Improved stability for applying sequence
JJuanill Nov 25, 2024
83801bf
admt: Write zeros to fault register before read
JJuanill Nov 25, 2024
5dd5dcc
admt: Added fine control for DIGIOEN register
JJuanill Nov 26, 2024
6059ae7
admt: Applied fixes for calibration
JJuanill Nov 27, 2024
ada74cc
admt: Implemented multi-channel acquisition graph
JJuanill Dec 2, 2024
786f4cf
admt: Fixed crashing issue when calibrating
JJuanill Dec 5, 2024
80e15c3
admt: Implemented mapping and graph for acquisition graph variables
JJuanill Jan 7, 2025
9257431
admt: Implemented multi-thread operations to acquisition tab
JJuanill Jan 8, 2025
6c7b05c
admt: Implemented device status fault monitoring
JJuanill Jan 10, 2025
f7b34b2
admt: Code cleanup
JJuanill Jan 15, 2025
f3cb3b9
admt: Added disable states for tab widget while calibrating
JJuanill Jan 15, 2025
6303702
admt: Adjusted GPIO Monitor and Control
JJuanill Jan 16, 2025
1fee592
Merge branch 'dev' of https://github.com/JJuanill/scopy into dev_admt
JJuanill Jan 17, 2025
c87a533
admt: Applied latest dev branch
JJuanill Jan 17, 2025
0020c57
admt: File cleanup
JJuanill Jan 17, 2025
9623c06
admt: Added spinbox to new style property
JJuanill Jan 22, 2025
d6cc350
admt: Replaced timers with threads for utility tab
Jan 31, 2025
5e2b175
admt: Added license headers
Jan 31, 2025
17309a8
admt: Cleanup license headers for remaining files
Jan 31, 2025
53dac52
admt: Added regmap debug method
JJuanill Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,4 @@ set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_SET_DESTDIR ON)
set(CPACK_COMPONENTS_ALL ${SCOPY_PDK})
include(CPack)
include(CPack)
6 changes: 6 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ option(ENABLE_PLUGIN_SWIOT "Enable SWIOT plugin" ON)
option(ENABLE_PLUGIN_PQM "Enable PQM plugin" ON)
option(ENABLE_PLUGIN_DATALOGGER "Enable DATALOGGER plugin" ON)
option(ENABLE_PLUGIN_DAC "Enable DAC plugin" ON)
option(ENABLE_PLUGIN_ADMT "Enable ADMT plugin" ON)

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SCOPY_PLUGIN_BUILD_PATH})
Expand Down Expand Up @@ -125,6 +126,11 @@ if(ENABLE_PLUGIN_M2K)
endif()
endif()

if(ENABLE_PLUGIN_ADMT)
add_subdirectory(admt)
list(APPEND PLUGINS ${ADMT_TARGET_NAME})
endif()

install(TARGETS ${PLUGINS} LIBRARY DESTINATION ${SCOPY_PLUGIN_INSTALL_PATH})

set(PLUGINS ${PLUGINS} PARENT_SCOPE)
Expand Down
2 changes: 2 additions & 0 deletions plugins/admt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include/admt/scopy-admt_export.h
include/admt/scopy-admt_config.h
109 changes: 109 additions & 0 deletions plugins/admt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#
# Copyright (c) 2024 Analog Devices Inc.
#
# This file is part of Scopy
# (see https://www.github.com/analogdevicesinc/scopy).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION 3.9)

set(SCOPY_MODULE admt)

message(STATUS "building plugin: " ${SCOPY_MODULE})

project(scopy-${SCOPY_MODULE} VERSION 0.1 LANGUAGES CXX)

set(PLUGIN_DISPLAY_NAME "ADMT")
set(PLUGIN_DESCRIPTION "Plugin for ADMT Harmonic Calibration")

include(GenerateExportHeader)

# TODO: split stylesheet/resources and add here TODO: export header files correctly

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)

file(
GLOB
SRC_LIST
src/*.cpp
src/*.cc
src/widgets/*.cpp
)
file(
GLOB
HEADER_LIST
include/${SCOPY_MODULE}/*.h
include/${SCOPY_MODULE}/*.hpp
include/${SCOPY_MODULE}/widgets/*.h
)
file(GLOB UI_LIST ui/*.ui)

set(ENABLE_TESTING ON)
if(ENABLE_TESTING)
add_subdirectory(test)
endif()

set(PROJECT_SOURCES ${SRC_LIST} ${HEADER_LIST} ${UI_LIST})
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS REQUIRED Widgets Core)

qt_add_resources(PROJECT_RESOURCES res/resources.qrc)
add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES} ${PROJECT_RESOURCES})

generate_export_header(
${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/${PROJECT_NAME}_export.h
)

include(ScopyStyle)
generate_style("--plugin" ${CMAKE_CURRENT_SOURCE_DIR}/style ${CMAKE_CURRENT_SOURCE_DIR}/include/admt)

configure_file(
include/${SCOPY_MODULE}/scopy-${SCOPY_MODULE}_config.h.cmakein
${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/scopy-${SCOPY_MODULE}_config.h @ONLY
)

target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE})

target_include_directories(${PROJECT_NAME} PUBLIC scopy-pluginbase scopy-gui)

target_link_libraries(
${PROJECT_NAME}
PUBLIC Qt::Widgets
Qt::Core
scopy-pluginbase
scopy-gui
scopy-iioutil
scopy-gr-util
scopy-iio-widgets
)

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(INSTALLER_DESCRIPTION "${PLUGIN_DISPLAY_NAME} ${PLUGIN_DESCRIPTION}")
configureinstallersettings(${SCOPY_MODULE} ${INSTALLER_DESCRIPTION} TRUE)
endif()

set(ADMT_TARGET_NAME ${PROJECT_NAME} PARENT_SCOPE)
256 changes: 256 additions & 0 deletions plugins/admt/include/admt/admtcontroller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef ADMTCONTROLLER_H
#define ADMTCONTROLLER_H

#include "scopy-admt_export.h"

#include <iio.h>
#include <bitset>

#include <QObject>
#include <QString>

#include <iioutil/connectionprovider.h>
#include <pluginbase/statusbarmanager.h>

#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <numeric>
#include <complex>
#include <iterator>
#include <cstdint>

using namespace std;

namespace scopy::admt {
class SCOPY_ADMT_EXPORT ADMTController : public QObject
{
Q_OBJECT
public:
ADMTController(QString uri, QObject *parent = nullptr);
~ADMTController();

int HAR_MAG_1, HAR_MAG_2, HAR_MAG_3, HAR_MAG_8 ,HAR_PHASE_1 ,HAR_PHASE_2 ,HAR_PHASE_3 ,HAR_PHASE_8;

vector<double> angle_errors_fft_pre,
angle_errors_fft_phase_pre,
angle_errors_fft_post,
angle_errors_fft_phase_post,
calibration_samples_sine,
calibration_samples_cosine,
calibration_samples_sine_scaled,
calibration_samples_cosine_scaled,
angleError,
FFTAngleErrorMagnitude,
FFTAngleErrorPhase,
correctedError,
FFTCorrectedErrorMagnitude,
FFTCorrectedErrorPhase;

enum Channel
{
ROTATION,
ANGLE,
COUNT,
TEMPERATURE,
CHANNEL_COUNT
};

enum Device
{
ADMT4000,
TMC5240,
DEVICE_COUNT
};

enum DeviceAttribute
{
PAGE,
SEQUENCER_MODE,
ANGLE_FILT,
CONVERSION_MODE,
H8_CTRL,
SDP_GPIO_CTRL,
SDP_GPIO0_BUSY,
SDP_COIL_RS,
REGMAP_DUMP,
DEVICE_ATTR_COUNT
};

enum MotorAttribute
{
AMAX,
ROTATE_VMAX,
DMAX,
DISABLE,
TARGET_POS,
CURRENT_POS,
RAMP_MODE,
MOTOR_ATTR_COUNT
};

enum MotorRampMode
{
POSITION,
RAMP_MODE_1
};

enum HarmonicRegister
{
H1MAG,
H1PH,
H2MAG,
H2PH,
H3MAG,
H3PH,
H8MAG,
H8PH,
HARMONIC_REGISTER_COUNT
};

enum ConfigurationRegister
{
CNVPAGE,
DIGIO,
FAULT,
GENERAL,
DIGIOEN,
ANGLECK,
ECCDCDE,
ECCDIS,
CONFIGURATION_REGISTER_COUNT
};

enum SensorRegister
{
ABSANGLE,
ANGLEREG,
ANGLESEC,
SINE,
COSINE,
SECANGLI,
SECANGLQ,
RADIUS,
DIAG1,
DIAG2,
TMP0,
TMP1,
CNVCNT,
SENSOR_REGISTER_COUNT
};

enum UniqueIDRegister
{
UNIQID0,
UNIQID1,
UNIQID2,
UNIQID3,
UNIQID_REGISTER_COUNT
};

const char* ChannelIds[CHANNEL_COUNT] = { "rot", "angl", "count", "temp" };
const char* DeviceIds[DEVICE_COUNT] = { "admt4000", "tmc5240" };
const char* DeviceAttributes[DEVICE_ATTR_COUNT] = { "page", "sequencer_mode", "angle_filt", "conversion_mode", "h8_ctrl", "sdp_gpio_ctrl", "sdp_gpio0_busy", "sdp_coil_rs", "regmap_dump" };
const char* MotorAttributes[MOTOR_ATTR_COUNT] = { "amax", "rotate_vmax", "dmax",
"disable", "target_pos", "current_pos",
"ramp_mode" };
const uint32_t ConfigurationRegisters[CONFIGURATION_REGISTER_COUNT] = { 0x01, 0x04, 0x06, 0x10, 0x12, 0x13, 0x1D, 0x23 };
const uint32_t ConfigurationPages[CONFIGURATION_REGISTER_COUNT] = { UINT32_MAX, UINT32_MAX, UINT32_MAX, 0x02, 0x02, 0x02, 0x02, 0x02 };
const uint32_t UniqueIdRegisters[UNIQID_REGISTER_COUNT] = { 0x1E, 0x1F, 0x20, 0x21 };
const uint32_t UniqueIdPages[UNIQID_REGISTER_COUNT] = { 0x02, 0x02, 0x02, 0x02 };
const uint32_t HarmonicRegisters[HARMONIC_REGISTER_COUNT] = { 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C };
const uint32_t HarmonicPages[HARMONIC_REGISTER_COUNT] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 };
const uint32_t SensorRegisters[SENSOR_REGISTER_COUNT] = { 0x03, 0x05, 0x08, 0x10, 0x11, 0x12, 0x13, 0x18, 0x1D, 0x1E, 0x20, 0x23, 0x14 };
const uint32_t SensorPages[SENSOR_REGISTER_COUNT] = { UINT32_MAX, UINT32_MAX, UINT32_MAX, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };

const char* getChannelId(Channel channel);
const char* getDeviceId(Device device);
const char* getDeviceAttribute(DeviceAttribute attribute);
const char* getMotorAttribute(MotorAttribute attribute);
const uint32_t getConfigurationRegister(ConfigurationRegister registerID);
const uint32_t getConfigurationPage(ConfigurationRegister registerID);
const uint32_t getUniqueIdRegister(UniqueIDRegister registerID);
const uint32_t getHarmonicRegister(HarmonicRegister registerID);
const uint32_t getHarmonicPage(HarmonicRegister registerID);
const uint32_t getUniqueIdPage(UniqueIDRegister registerID);
const uint32_t getSensorRegister(SensorRegister registerID);
const uint32_t getSensorPage(SensorRegister registerID);

void connectADMT();
void disconnectADMT();
int getChannelIndex(const char *deviceName, const char *channelName);
double getChannelValue(const char *deviceName, const char *channelName, int bufferSize = 1);
int getDeviceAttributeValue(const char *deviceName, const char *attributeName, double *returnValue);
int getDeviceAttributeValueString(const char *deviceName, const char *attributeName, char *returnValue, size_t byteLength = 512);
int setDeviceAttributeValue(const char *deviceName, const char *attributeName, double writeValue);
QString calibrate(vector<double> PANG, int cycles = 11, int samplesPerCycle = 256);
int writeDeviceRegistry(const char *deviceName, uint32_t address, uint32_t value);
int readDeviceRegistry(const char *deviceName, uint32_t address, uint32_t *returnValue);
void computeSineCosineOfAngles(const vector<double>& angles);
uint16_t calculateHarmonicCoefficientMagnitude(uint16_t harmonicCoefficient, uint16_t originalValue, const string& key);
uint16_t calculateHarmonicCoefficientPhase(uint16_t harmonicPhase, uint16_t originalValue);
double getActualHarmonicRegisterValue(uint16_t registerValue, const string key);
map<string, bool> getFaultRegisterBitMapping(uint16_t registerValue);
map<string, int> getGeneralRegisterBitMapping(uint16_t registerValue);
map<string, bool> getDIGIOENRegisterBitMapping(uint16_t registerValue);
map<string, bool> getDIGIORegisterBitMapping(uint16_t registerValue);
map<string, bool> getDiag1RegisterBitMapping_Register(uint16_t registerValue);
map<string, double> getDiag1RegisterBitMapping_Afe(uint16_t registerValue, bool is5V);
map<string, double> getDiag2RegisterBitMapping(uint16_t registerValue);
uint16_t setGeneralRegisterBitMapping(uint16_t currentRegisterValue, map<string, int> settings);
void postcalibrate(vector<double> PANG, int cycleCount, int samplesPerCycle);
int getAbsAngleTurnCount(uint16_t registerValue);
uint16_t setDIGIOENRegisterBitMapping(uint16_t currentRegisterValue, map<string, bool> settings);
uint16_t setDIGIORegisterBitMapping(uint16_t currentRegisterValue, map<string, bool> settings);
void unwrapAngles(vector<double>& angles_rad);
map<string, string> getUNIQID3RegisterMapping(uint16_t registerValue);
map<string, double> getSineRegisterBitMapping(uint16_t registerValue);
map<string, double> getCosineRegisterBitMapping(uint16_t registerValue);
map<string, double> getRadiusRegisterBitMapping(uint16_t registerValue);
map<string, double> getAngleSecRegisterBitMapping(uint16_t registerValue);
map<string, double> getSecAnglQRegisterBitMapping(uint16_t registerValue);
map<string, double> getSecAnglIRegisterBitMapping(uint16_t registerValue);
map<string, double> getTmp1RegisterBitMapping(uint16_t registerValue, bool is5V);
bool checkRegisterFault(uint16_t registerValue, bool isMode1);

private:
iio_context *m_iioCtx;
iio_buffer *m_iioBuffer;
Connection *m_conn;
QString uri;

unsigned int bitReverse(unsigned int x, int log2n);
template <typename Iter_T>
void fft(Iter_T a, Iter_T b, int log2n);
void performFFT(const vector<double>& angle_errors, vector<double>& angle_errors_fft, vector<double>& angle_errors_fft_phase, int cycleCount);
int linear_fit(vector<double> x, vector<double> y, double* slope, double* intercept);
int calculate_angle_error(vector<double> angle_meas, vector<double>& angle_error_ret, double* max_angle_err);
void getPreCalibrationFFT(const vector<double>& PANG, vector<double>& angle_errors_fft_pre, vector<double>& angle_errors_fft_phase_pre, int cycleCount, int samplesPerCycle);
void getPostCalibrationFFT(const vector<double>& updated_PANG, vector<double>& angle_errors_fft_post, vector<double>& angle_errors_fft_phase_post, int cycleCount, int samplesPerCycle);
};
} // namespace scopy::admt

#endif // ADMTCONTROLLER_H
Loading
Loading