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

Changed computer communication for more robustness and less superfluous error...

Changed computer communication for more robustness and less superfluous error messages. Removed unused DSTAT1 file from project.
parent 816fe512
Branches
Tags
No related merge requests found
......@@ -471,6 +471,7 @@ void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[])
tc_write_cc(&TCC0, TC_CCA, TCC0.CNT+step_seconds[i]-1);
RTC.CNT=0;
max5443_set_voltage1(step_dac[i]);
printf("#DAC: %u\n\r", step_dac[i]);
//PORTE.INTCTRL = PORT_INT0LVL_LO_gc;
PORTD.INTCTRL = PORT_INT0LVL_LO_gc;
while (up !=0);
......
......@@ -25,35 +25,37 @@ int8_t command_handler(char command){
*/
switch (command){
case 'A': //ADS Buffer/rate/PGA values from ads1255.h
scanf("%1x%2x%1x",&o1,&o2,&o3);
//Sanity check goes here
scanf("%x%x%x",&o1,&o2,&o3);
printf("#A: %x %x %x\r\n",o1,o2,o3);
ads1255_setup(o1, o2, o3);
break;
case 'G': //Gain - start gain, autogain on/off, (min gain, max gain), low/high switch thresholds
//scanf("%1u%1u%7li%7li",&g_gain,&autogain_enable,&overcurrent_threshold,&undercurrent_threshold);
scanf("%1u",&g_gain);
scanf("%u",&g_gain);
printf("#G: %u\r\n", g_gain);
pot_set_gain(); //uses global g_gain, so no params
break;
case 'L': //LSV - start, stop, slope
scanf("%5i%5i%5u",&p1,&p2,&u1);
scanf("%i%i%u",&p1,&p2,&u1);
//printf("%i,%i,%i",&p1,&p2,&u1);
lsv_experiment(p1,p2,u1,2);
break;
case 'C': //CV - v1, v2, start, scans, slope
scanf("%5i%5i%5i%3u%5u",&p1,&p2,&p3,&p5,&u1);
scanf("%i%i%i%u%u",&p1,&p2,&p3,&p5,&u1);
cv_experiment(p1,p2,p3,p5,u1);
break;
case 'S': //SWV - start, stop, step size, pulse_height, frequency
scanf("%5i%5i%5u%3u%5u",&p1,&p2,&u1,&u2,&u3);
scanf("%i%i%u%u%u",&p1,&p2,&u1,&u2,&u3);
swv_experiment(p1,p2,u1,u2,u3);
break;
case 'R': //CA - steps, step_dac[], step_seconds[]
scanf("%u",&p5); //get number of steps
printf("#Steps: %u\n\r", p5);
//allocate arrays for steps
uint16_t * step_dac = malloc(p5*sizeof(uint16_t));
......@@ -68,10 +70,12 @@ int8_t command_handler(char command){
for (i=0; i<p5; i++){
scanf("%u", &step_dac[i]); // get voltage steps (dac units)
printf("#DAC: %u\n\r", step_dac[i]);
}
for (i=0; i<p5; i++){
scanf("%u", &step_seconds[i]); //get step durations (seconds)
printf("#Time: %u\n\r", step_seconds[i]);
}
ca_experiment(p5, step_dac, step_seconds);
......@@ -82,9 +86,10 @@ int8_t command_handler(char command){
break;
default:
printf("#ERR: Command not recognized\n\r");
printf("#ERR: Command %c not recognized\n\r", command);
return 1;
}
printf("no\n\r");
return 0;
}
......@@ -109,7 +114,7 @@ int main(void){
ads1255_init_pins();
ads1255_init_module();
ads1255_setup(ADS_BUFF_ON,ADS_DR_60,ADS_PGA_2);
pot_set_gain();
PORTD.INT0MASK = PIN5_bm;
PORTD.INT1MASK = PIN5_bm;
PORTD.INTCTRL = PORT_INT0LVL_OFF_gc | PORT_INT1LVL_OFF_gc;
......@@ -176,7 +181,8 @@ int main(void){
// step_seconds[0] = 10;
while (1){
while(getchar() != '!');
printf ("C\r\n");
command_handler(getchar());
printf("no\n\r");
}
}
\ No newline at end of file
......@@ -53,7 +53,7 @@ void max5443_set_voltage1(uint16_t dacindex){
// buffer.ui16 = dacindex+max5443_offset;
irqflags_t flags;
flags = cpu_irq_save();
flags = cpu_irq_save();
usart_spi_select_device(&USARTC1, &spi_device_conf_c);
usart_spi_write_single(&USARTC1, buffer.ui8[1]);
......@@ -62,6 +62,7 @@ void max5443_set_voltage1(uint16_t dacindex){
usart_spi_deselect_device(&USARTC1, &spi_device_conf_c);
cpu_irq_restore(flags);
return;
}
......

Microsoft Visual Studio Solution File, Format Version 11.00
# Atmel Studio Solution File, Format Version 11.00
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DSTAT1", "DSTAT1\DSTAT1.cproj", "{38800372-2811-4812-8069-46107EA45AA8}"
EndProject
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DSTAT-temp", "DSTAT-temp\DSTAT-temp.cproj", "{511F3FE1-F6B0-4E6D-877C-322C1167607E}"
EndProject
Global
......@@ -11,10 +9,6 @@ Global
Release|AVR = Release|AVR
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{38800372-2811-4812-8069-46107EA45AA8}.Debug|AVR.ActiveCfg = Debug|AVR
{38800372-2811-4812-8069-46107EA45AA8}.Debug|AVR.Build.0 = Debug|AVR
{38800372-2811-4812-8069-46107EA45AA8}.Release|AVR.ActiveCfg = Release|AVR
{38800372-2811-4812-8069-46107EA45AA8}.Release|AVR.Build.0 = Release|AVR
{511F3FE1-F6B0-4E6D-877C-322C1167607E}.Debug|AVR.ActiveCfg = Debug|AVR
{511F3FE1-F6B0-4E6D-877C-322C1167607E}.Debug|AVR.Build.0 = Debug|AVR
{511F3FE1-F6B0-4E6D-877C-322C1167607E}.Release|AVR.ActiveCfg = Release|AVR
......
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