⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minid_20050711.c

📁 平缝机的单片机伺服控制系统源代码。本程序为用单片机控制永磁同步电机的低成本方案
💻 C
字号:
//ICC-AVR application builder : 2005-7-11 14:38:07
// Target : M48
// Crystal: 8.0000Mhz

#include "Minid.h"


//函数定义
void adc_init(void); 					       //ADC initialize
void adc_isr(void);
word AdcPedal(word adcp);						//踏板信号转换为对应的控制值


void port_init(void)
{
 PORTB = 0xff;
 DDRB  = 0x00;
 PORTC = 0xff; //m103 output only
 DDRC  = 0x00;
 PORTD = 0xff;
 DDRD  = 0x00;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();
 timer1_init();

 MCUCR = 0x00;
 EICRA = 0x00; //extended ext ints
 EIMSK = 0x00;
 
 TIMSK0 = 0x00; //timer 0 interrupt sources
 TIMSK1 = 0x21; //timer 1 interrupt sources
 TIMSK2 = 0x00; //timer 2 interrupt sources
 
 PCMSK0 = 0x00; //pin change mask 0 
 PCMSK1 = 0x00; //pin change mask 1 
 PCMSK2 = 0x00; //pin change mask 2
 PCICR = 0x00; //pin change enable 
 PRR = 0x00; //power controller
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

//
void main(void)
{
	dword i;
	word j,jj;
	byte d;
	init_devices();
	
	//insert your functional code here...
	PIDInit (&sPID);
	while (1)
	{
	i = g_DeltaEnc;
	j ++;
	jj = AdcPedal(j);
	sPID.I = 0;
	sPID.P = 0;
	sPID.SetValue = 5000;
	d = PIDCalc(&sPID, i);
	
	}
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -