This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% data file loaded by prbs_scr.m | |
% speed filter not in feedback, but in forward loop at input to PI | |
% control. | |
% btremaine 2022 | |
U = [ | |
-5 -3861 | |
-5 -3878 | |
-5 -3911 | |
5 -3949 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% prbs.m -- analysis of bode using u(k) and y(k) | |
% load data, should be >> 2^15 values so transient dies out | |
% btremaine 2022 | |
% run m file to load data (prbs_data7, 8, 9 | |
prbs_data9 | |
% grab last 32767 data points | |
N= length(U); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Run the speed control loop ================================ */ | |
/* this code part of speed_torq_cntrl.c */ | |
/* Compute speed error */ | |
hTargetSpeed = ( int16_t )( wCurrentReference / 65536 ); | |
// Uses Moving Average Filter updated every PWM period | |
// and averaged for xxxx samples | |
hMeasuredSpeed = SPD_GetAvrgMecSpeedUnit( pHandle->SPD ); | |
/* system ID */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replicated from wikipeda, https://en.wikipedia.org/wiki/Pseudorandom_binary_sequence | |
// Example of PRBS7 | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
int main(int argc, char* argv[]) { | |
uint8_t start = 0x02; | |
uint8_t a = start; | |
int i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prbs_t is a struct used in the prbs function: | |
typedef struct | |
{ | |
uint16_t start; // start LFSR value | |
uint16_t lfsr; // LFSR current register | |
uint16_t index; // LFSR index | |
uint16_t newbit; // current newbit | |
} Prbs_t; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TremaineConsultingGroup | |
# Brian Tremaine | |
# prbs.py | |
# August 11, 2021 | |
# Prototype PRBS generator | |
# | |
# PRBS15 = x^15 + x^14 + 1 Wikipeda | |
# .--->X--------------------------------------------------------> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% System ID Example | |
% Aug 5, 2021 | |
% Uses MATLAB System ID Toolbox | |
%% Generate u(k) | |
Band= [0 1]; | |
Range= [-1 1]; % amplitude limits | |
Ts=5E-3; | |
N=2^16-1; % # points | |
% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* USER CODE BEGIN Header */ | |
/** | |
****************************************************************************** | |
* @file : main.c | |
* @brief : Main program body | |
****************************************************************************** | |
* @attention | |
* | |
* <h2><center>© Copyright (c) 2020 STMicroelectronics. | |
* All rights reserved.</center></h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @brief This function handles DMA1 channel1 global interrupt. | |
*/ | |
void DMA1_Channel1_IRQHandler(void) | |
{ | |
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */ | |
/* USER CODE END DMA1_Channel1_IRQn 0 */ | |
HAL_DMA_IRQHandler(&hdma_tim4_ch1); | |
/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */ |