If now you were told that during the comutation sequence you could obtain certain advantages by chopping the applied DC in a particular fashion ( that is to produce half sinusoidal magnetic flux during each of six comutation segments ) you still would not worry about internal wiring. If the winding configuration was invisible to You and all you had were three connections for coil drive and three sensor signals coming from Hall sensors and You were told the particular phasing arrangemnt and particular drive sequence would produce rotation you wouldnot worry too much about internal winding arrangement. PORTD = ~((1<< PWM5) | ((1<< PWM0)& (average_dc_voltage))) Īverage_dc_voltage = ~average_dc_voltage * reverse direction stepping sequences */ * and now set the output phase sequence to rotate the shaft */ * mask the content of PORTC inputs to select HALL and direction signals */ * step is a function of HALL inupts PC2 PC3 PC4 * Wait for the AD conversion to complete */ĪDCSRA|=0x10 /*clear ADIF ADC Interupt Flag */ Unsigned int read_adc(unsigned char adc_input)ĪDCSRA|=0x40 /* Start the AD conversion */ * all peripherals are now initialized */ Timer_enable_int(_BV(OCIE2)) /*enable output compare interupts */ TIMSK = 0x00 /* timer interrupt sources */ * stop errant interrupts until set up */ * call this routine to initialize all peripherals */ * SFIOR is set to 0 above so SFIOR &= is always 0 */ * ADCSRA ADC Control and Status Registerīit6 ADSC 1 => start each conversion in single modeīit4 ADIF bit set at conversion end cleared by ISR or writng 1 to ADIFīit3 ADIE I bit in SRE = 1 & ADIE =1 -> ADC Interrpt Enableīit7 ADTS2 ADC Auto Trigger Source Selectorīit3 ACME 1 => Analog Comparator Mux Enable when ADC offīit0 PSR10 1 => Timer Counter s 0 & 1 Reset */ TCCR2 = 0x43 /* start but OC2 output disabled */ĪDMUX=ADC_VREF_TYPE /* set AVREF and right result */ #define _MCU_CLOCK_FREQUENCY_ _8.0000_MHzīit7 REFS1 set AREF refference voltage sourceīit6 REFS0 00=> AREF internal VREF turned offīit4 MUX4 select channel number and channel gainīit3 MUX3 also in case of QFP select differential inputsīit2 MUX2 in this case valid inputs 0 -> 3 inclusive
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |