added twincat plotting

This commit is contained in:
Nicolas Trimborn
2021-08-24 11:38:13 +02:00
parent 1230e96c1f
commit 58bba21ef3
14 changed files with 2570 additions and 811 deletions

View File

@@ -65,12 +65,15 @@ void initialize_ads()
/* Write Config Registers */
ADS1299_WREG(CONFIG1,0x94); // Set Config 1 Register
ADS1299_WREG(CONFIG2,0xC0); // Set Config 2 Register
//ADS1299_WREG(CONFIG2,0xC0); // Set Config 2 Register - Standard
ADS1299_WREG(CONFIG2,0xD4); // Set Config 2 Register - internal test signal, pulsed
//ADS1299_WREG(CONFIG2,0xD7); // Set Config 2 Register - internal test signal, DC
ADS1299_WREG(CONFIG3,0xEC); // Set Config 3 Register
ADS1299_WREG(LOFF,0x02); // Set LOFF Register
for(uint8_t i=CH1SET; i<=CH4SET; i++) // set up to modify the 4 channel setting registers
{
ADS1299.regData[i] = 0x68; // the regData array mirrors the ADS1299 register addresses
ADS1299.regData[i] = 0x68; // the regData array mirrors the ADS1299 register addresses
//ADS1299.regData[i] = 0x6D; // Test signal
}
ADS1299_WREGS(CH1SET,3); // write new channel settings
ADS1299_WREG(BIAS_SENSP,0xFF); // Set BIAS_SENSP Register

View File

@@ -81,18 +81,18 @@ void enable_NVIC_IRQ(void)
NVIC_EnableIRQ(DMAC_0_IRQn);
NVIC_EnableIRQ(DMAC_1_IRQn);
NVIC_SetPriority(DMAC_0_IRQn, 1);
NVIC_SetPriority(ADC1_0_IRQn, 3);
NVIC_SetPriority(ADC1_0_IRQn, 2);
NVIC_EnableIRQ(TCC0_0_IRQn);
NVIC_EnableIRQ(TCC1_0_IRQn);
NVIC_EnableIRQ(EIC_2_IRQn);
NVIC_SetPriority(EIC_2_IRQn, 3);
//NVIC_SetPriority(EIC_2_IRQn, 3);
//NVIC_SetPriority(TCC0_0_IRQn, 3);
//NVIC_EnableIRQ(EIC_5_IRQn);
}
void APPLICATION_StateMachine(void)
{
Motor1.timerflags.current_loop_tic = false;
//Motor1.timerflags.current_loop_tic = false;
if (applicationStatus.fault)
{
@@ -177,10 +177,11 @@ int main(void)
angle_sensor_init();
initialize_ads();
/* External IRQ Config */
ext_irq_register(GPIO_PIN(ADS_DATA_RDY), ADS1299_dataReadyISR);
enable_NVIC_IRQ();
__enable_irq();
//ADS1299_START();
enable_NVIC_IRQ();
ext_irq_register(GPIO_PIN(ADS_DATA_RDY), ADS1299_dataReadyISR);
ADS1299_START();
/* Replace with your application code */
while (1) {
@@ -195,10 +196,10 @@ int main(void)
//_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_RECEIVE, false);
//_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_TRANSMIT, false);
//int16_t* angles;
//angles = read_angle();
//Motor1.motor_status.abs_position = degrees(angles[0]);
//Motor2.motor_status.abs_position = degrees(angles[1]);
int16_t* angles;
angles = read_angle();
Motor1.motor_status.abs_position = degrees(angles[0]);
Motor2.motor_status.abs_position = degrees(angles[1]);
////field = ang_sense_read(AS_CMD_MAGNITUDE);
//*Spare1_tx = (field[0] & AS_MASK);
@@ -210,6 +211,7 @@ int main(void)
}
if (Motor1.timerflags.current_loop_tic) {
Motor1.timerflags.current_loop_tic = false;
APPLICATION_StateMachine();
exec_commutation(&Motor1);
exec_commutation(&Motor2);
@@ -217,7 +219,7 @@ int main(void)
if (ADS1299.data_ReadyFlag){
ADS1299.data_ReadyFlag = false;
//ADS1299_UPDATECHANNELDATA();
ADS1299_UPDATECHANNELDATA();
}
if (run_ECAT) {ECAT_STATE_MACHINE();}