سلام میخوام کامپایلر این سورسو پیداکنم `پسوند پروجش (ewp) ممنون میشم کمکم کنید. :agree: :NO:
]
/**
* @file main.c
*
* Copyright (c) 2004 Atmel.
*
* @brief This module provide services to show a simple program for AT90PWM3 Only
* @version 1.0 (CVS revision : 1.7)
* @date 2006/03/08 17:02:35
* @author raubree
************************************************** ***************************/
#include "config.h"
#include "lib_mcu/compiler.h"
#include "lib_mcu/mcu.h"
#include "inavr.h"
#include <stdio.h>
#pragma vector = TIMER0_COMPA_vect
__interrupt void Tech(void);
#pragma vector = ADC_vect
__interrupt void Read_Measure(void);
#define MAX_PWM 2666
// 64MHz (PLL frequency) / 2666 / 2 = 12 kHz (PWM frequency)
#define MAX_THETA 80 // one sixth of the circle
#define K_scal 16 // used for the angle integrator
volatile U8 Flag_IT_timer0=0, Flag_IT_ADC=0 ;
U16 Softcounter = 0 ;
S16 Omega_meas;
S16 Omega_ref = 100;
S16 Command = 0;
U16 amplitude , OmegaTe = 64 ;
U8 direction = 0 ;
U16 PWM0, PWM1, PWM2;
#define DeadTime 32 // 32 => temps mort = 0.5 µs
#define MAX_AMPLITUDE ((MAX_PWM / 2) - DeadTime)
void init(void);
void ADC_Init(void);
void ADC_start_conv(void);
void DAC_Init(void);
void PSC_Init(unsigned int ot0, unsigned int ot1);
void PSC0_Load (unsigned int dt0, unsigned int dt1);
void PSC1_Load (unsigned int dt0, unsigned int dt1);
void PSC2_Load (unsigned int dt0, unsigned int dt1);
void PSC_Load (unsigned int dt0a, unsigned int dt1a,
unsigned int dt0b, unsigned int dt1b,
unsigned int dt0c, unsigned int dt1c);
S16 mc_control_speed_16b(S16 speed_ref , S16 speed_measure);
U16 controlVF(U16 Omega);
void SVPWM(U16 amp, U16 Omega);
S16 read_acquisition(void) ;
void main(void)
{
/* remove CKDIV8 fuse effect */
CLKPR = 0x80;
CLKPR = 0x00;
init();
// DAC_Init(); /* do not init DAC if you want to use PC7 as /IO */
ADC_Init();
PSC_Init(0x00, MAX_PWM);
while(1)
{
if (Flag_IT_timer0)
{
ADC_start_conv();
Flag_IT_timer0=0;
// generates speed reference steps in the software
/* Softcounter += 1 ;
if (Softcounter == 2500) {
Omega_ref = -400 ;
} //-128; }
if (Softcounter == 5000)
{
Omega_ref= -200 ;
}
if (Softcounter == 7500)
{
Omega_ref= 200 ;
}
if (Softcounter == 10000)
{
Omega_ref= 400 ;
Softcounter = 0 ;
}*/
}
if (Flag_IT_ADC)
{
// get the measured speed from the ADC
Omega_meas = ((U32)63 * Omega_meas + read_acquisition() )/ 64;
// Omega_meas = read_acquisition();
// compute the stator frequency (PI controller)
// Command = mc_control_speed_16b(Omega_ref,Omega_meas); // for use in closed loop
// Command = Omega_ref ; // // command with the generated steps
Command = ((512 - Omega_meas)*20) / 10; // command with the on board pot
// Command = (25 * (256 + 18 - Omega_meas))/8; // command with a pot on the 0-10V input
// direction management : extract sign and absolute value
if (Command > (S16)(0) ) {
direction = 0 ;
OmegaTe = Command;
}
else {
direction = 1 ;
OmegaTe = (~Command) + 1;
}.................................................[size=+2][/size
* @file main.c
*
* Copyright (c) 2004 Atmel.
*
* @brief This module provide services to show a simple program for AT90PWM3 Only
* @version 1.0 (CVS revision : 1.7)
* @date 2006/03/08 17:02:35
* @author raubree
************************************************** ***************************/
#include "config.h"
#include "lib_mcu/compiler.h"
#include "lib_mcu/mcu.h"
#include "inavr.h"
#include <stdio.h>
#pragma vector = TIMER0_COMPA_vect
__interrupt void Tech(void);
#pragma vector = ADC_vect
__interrupt void Read_Measure(void);
#define MAX_PWM 2666
// 64MHz (PLL frequency) / 2666 / 2 = 12 kHz (PWM frequency)
#define MAX_THETA 80 // one sixth of the circle
#define K_scal 16 // used for the angle integrator
volatile U8 Flag_IT_timer0=0, Flag_IT_ADC=0 ;
U16 Softcounter = 0 ;
S16 Omega_meas;
S16 Omega_ref = 100;
S16 Command = 0;
U16 amplitude , OmegaTe = 64 ;
U8 direction = 0 ;
U16 PWM0, PWM1, PWM2;
#define DeadTime 32 // 32 => temps mort = 0.5 µs
#define MAX_AMPLITUDE ((MAX_PWM / 2) - DeadTime)
void init(void);
void ADC_Init(void);
void ADC_start_conv(void);
void DAC_Init(void);
void PSC_Init(unsigned int ot0, unsigned int ot1);
void PSC0_Load (unsigned int dt0, unsigned int dt1);
void PSC1_Load (unsigned int dt0, unsigned int dt1);
void PSC2_Load (unsigned int dt0, unsigned int dt1);
void PSC_Load (unsigned int dt0a, unsigned int dt1a,
unsigned int dt0b, unsigned int dt1b,
unsigned int dt0c, unsigned int dt1c);
S16 mc_control_speed_16b(S16 speed_ref , S16 speed_measure);
U16 controlVF(U16 Omega);
void SVPWM(U16 amp, U16 Omega);
S16 read_acquisition(void) ;
void main(void)
{
/* remove CKDIV8 fuse effect */
CLKPR = 0x80;
CLKPR = 0x00;
init();
// DAC_Init(); /* do not init DAC if you want to use PC7 as /IO */
ADC_Init();
PSC_Init(0x00, MAX_PWM);
while(1)
{
if (Flag_IT_timer0)
{
ADC_start_conv();
Flag_IT_timer0=0;
// generates speed reference steps in the software
/* Softcounter += 1 ;
if (Softcounter == 2500) {
Omega_ref = -400 ;
} //-128; }
if (Softcounter == 5000)
{
Omega_ref= -200 ;
}
if (Softcounter == 7500)
{
Omega_ref= 200 ;
}
if (Softcounter == 10000)
{
Omega_ref= 400 ;
Softcounter = 0 ;
}*/
}
if (Flag_IT_ADC)
{
// get the measured speed from the ADC
Omega_meas = ((U32)63 * Omega_meas + read_acquisition() )/ 64;
// Omega_meas = read_acquisition();
// compute the stator frequency (PI controller)
// Command = mc_control_speed_16b(Omega_ref,Omega_meas); // for use in closed loop
// Command = Omega_ref ; // // command with the generated steps
Command = ((512 - Omega_meas)*20) / 10; // command with the on board pot
// Command = (25 * (256 + 18 - Omega_meas))/8; // command with a pot on the 0-10V input
// direction management : extract sign and absolute value
if (Command > (S16)(0) ) {
direction = 0 ;
OmegaTe = Command;
}
else {
direction = 1 ;
OmegaTe = (~Command) + 1;
}.................................................[size=+2][/size
دیدگاه