Skip to content
Snippets Groups Projects
Commit 1f6017f7 authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

Add command for setting switches for potentiometry (pot_exp_start()). Add...

Add command for setting switches for potentiometry (pot_exp_start()). Add pot_experiment() for acquiring voltage measurements from RE input for potentiometry or OCP. (currently not called anywhere)
parent a7dd0cfe
Branches
Tags
No related merge requests found
......@@ -237,6 +237,15 @@ void volt_exp_stop(void){
#endif
}
void pot_exp_start(void){
/**
* All switches open.
*/
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
arch_ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, 0);
#endif
}
void precond(int16_t v1, uint16_t t1, int16_t v2, uint16_t t2){ //assumes potentiostat switches are already set
/**
* Performs experiment preconditioning.
......@@ -564,6 +573,67 @@ static void lsv_cca_callback(void){
return;
}
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
void pot_experiment(uint16_t time_seconds){
/**
* Performs a potentiometry experiment. Assumes either pot_exp_start() or ocp_exp_start() has been called and appropriate switches are set.
*
* @param time_seconds Time until automatic stop. If 0, can only be cancelled by abort signal.
*/
while (RTC.STATUS & RTC_SYNCBUSY_bm);
RTC.PER = 999;
while (RTC.STATUS & RTC_SYNCBUSY_bm);
RTC.CTRL = RTC_PRESCALER_DIV1_gc; //1ms tick
RTC.CNT = 0;
EVSYS.CH0MUX = EVSYS_CHMUX_RTC_OVF_gc; //EV CH0 -- RTC overflow 1s
portd_int0_callback = portd_int0_ca; //ADC interrupt
tc_enable(&TCC0);
ads1255_mux(ADS_MUX_POT);
ads1255_rdatac();
ads1255_wakeup();
tc_write_period(&TCC0,0xffff);
tc_write_clock_source(&TCC0, TC_CLKSEL_EVCH0_gc);
tc_set_direction(&TCC0, TC_UP);
TCC0.CNT = 0;
up = 1;
if (time_seconds >= 1){ //only enable interrupt if non-zero timeout specified
tc_set_cca_interrupt_callback(&TCC0, ca_cca_callback);
tc_write_cc(&TCC0, TC_CCA, time_seconds-1);
tc_enable_cc_channels(&TCC0, TC_CCAEN);
tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_MED);
}
RTC.CNT=0;
PORTD.INTCTRL = PORT_INT0LVL_LO_gc;
while (up !=0){
if (udi_cdc_is_rx_ready()){
if (getchar() == 'a'){
ca_cca_callback();
printf("##ABORT\n\r");
goto aborting;
}
}
}
aborting:
tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_OFF);
tc_write_clock_source(&TCC0, TC_CLKSEL_OFF_gc);
tc_disable(&TCC0);
volt_exp_stop();
ads1255_standby();
return;
}
#endif
void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]){
/**
* Performs a chronoamperometry experiment.
......
......@@ -78,9 +78,15 @@ void pot_init(void);
void pot_set_gain(void);
void volt_exp_start(void);
void volt_exp_stop(void);
void pot_exp_start(void);
void precond(int16_t v1, uint16_t t1, int16_t v2, uint16_t t2);
void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_t slope);
uint8_t lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first_run);
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
void pot_experiment(uint16_t time_seconds);
#endif
void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]);
void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_height, uint16_t frequency, uint16_t scans);
void dpv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_height, uint16_t pulse_period, uint16_t pulse_width);
......
No preview for this file type
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment