AVR

AVR Урок 14. ПИД часть 1.

Posted on

#include <math.h> #include <mega328p.h> #include <delay.h> #include <stdio.h> #define FIRST_ADC_INPUT 0 #define LAST_ADC_INPUT 0 unsigned int adc_data[LAST_ADC_INPUT-FIRST_ADC_INPUT+1]; #define ADC_VREF_TYPE ((0<<REFS1) | (1<<REFS0) | (0<<ADLAR)) interrupt [ADC_INT] void adc_isr(void) { static unsigned char input_index=0; adc_data[input_index]=ADCW; if (++input_index > (LAST_ADC_INPUT-FIRST_ADC_INPUT)) input_index=0; ADMUX=(FIRST_ADC_INPUT | ADC_VREF_TYPE)+input_index; delay_us(10); ADCSRA|=(1<<ADSC); } void main(void) { float y = 0.00001; float i = […]