资源简介
数控电源制作资料、各种各样电源制作大全,数控电源制作资料、各种各样电源制作大全,数控电源制作资料、各种各样电源制作大全.
代码片段和文件信息
/* vim: set sw=8 ts=8 si : */
/*********************************************
* Author: Guido Socher Copyright: GPL
*
* Digital analog conversion of channel ADC0 and ADC1 in
* free running mode.
**********************************************/
#include
//#include
#include
#include
#include “avr_compat.h“
#include “dac.h“
#include “hardware_settings.h“
volatile static unsigned char channel=0;
volatile static unsigned char voltagecontrol=0; // 0=current limit 1=voltage control
volatile static uint16_t conversioncount=0; // changed at every conversion
// adc measurement results:
volatile static int analog_result[2]; // datatype int is 16 bit
// the value that is requested (control loop calibrates to this).
volatile static unsigned int target_val[2]; // datatype int is 16 bit
static unsigned char adlowadhigh;
static int dac_val=0;
/* You must enable interrupt with sei() in the main program
* before you call init_analog
*/
void init_analog(void)
{
// initialize the adc result to very high values
// to keep the control-loop down until proper measurements
// are done:
analog_result[0]=0;
analog_result[1]=1025;
target_val[0]=0; // initialize to zero
target_val[1]=0; // initialize to zero
/* enable analog to digital conversion in free run mode
* without noise canceler function. See datasheet of atmega8 page 195
* We set ADPS2=1ADPS1=0ADPS0=1 to have a clock division factor of 32.
* This is needed to stay in the recommended range of 50-200kHz
* ADEN: Analog Digital Converter Enable
* ADIE: ADC Interrupt Enable
* ADIF: ADC Interrupt Flag
* ADFR: ADC Free Running Mode
* ADCSR: ADC Control and Status Register
* ADPS2..ADPS0: ADC Prescaler Select Bits
* REFS: Reference Selection Bits (page 203)
*/
// int-ref with external capacitor at AREF pin:
// 2.56V int ref=REFS1=1REFS0=1
// write only the lower 3 bit for channel selection
// 2.56V ref start with channel 0
ADMUX=(1<
ADCSR=(1<
/* start conversion */
sbi(ADCSRADSC);
//wait until both channels are measured twice
while(conversioncount < 4);
}
int is_dacval(void)
{
return(dac_val);
}
signed char is_current_limit(void)
{
// return 1 if current control loop active
if (voltagecontrol==0){
return(1);
}
return(0);
}
/* set the target adc value for the control loop
* values for item: 0 = u 1 = i units must be of the same as the values
* from the dac.
*/
void set_target_adc_val(unsigned char itemunsigned int val)
{
// here we can directly write to target_val
target_val[item]=val;
}
/* get the result of an analog conversion.
* The problem here is that we need to read more than 8 bit. Therefore
* it will always result in two assembler instruction. In other words
* it is not an atomic operation. To get i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 14272 2007-06-26 12:16 数字电源资料\atem8数控电源-PCB.MDI
文件 17694 2007-06-26 12:16 数字电源资料\atem8数控电源元件面.MDI
文件 30882 2007-06-26 12:15 数字电源资料\atem8数控电源电路图.MDI
文件 18889 2006-03-25 03:36 数字电源资料\ddcp_pre.hex
文件 141795 2007-06-26 11:20 数字电源资料\digital power.DSN
文件 55898 2007-06-21 09:38 数字电源资料\digital power.LYT
文件 15656 2007-06-26 11:23 数字电源资料\原版电路图.pdf
目录 0 2007-12-25 09:01 数字电源资料
文件 5006 2007-07-09 01:04 数字电源资料\源程序\analog.c
文件 653 2005-06-26 02:23 数字电源资料\源程序\analog.h
文件 1108 2007-07-10 06:09 数字电源资料\源程序\avr_compat.h
文件 913 2006-01-08 21:46 数字电源资料\源程序\dac.c
文件 375 2005-06-26 02:23 数字电源资料\源程序\dac.h
文件 1505 2007-07-09 00:59 数字电源资料\源程序\hardware_settings.h
文件 1505 2007-07-09 01:18 数字电源资料\源程序\hardware_settings.h.22
文件 1503 2006-07-04 03:02 数字电源资料\源程序\hardware_settings.h.30
文件 2491 2007-07-09 01:28 数字电源资料\源程序\i2c-comm\i2ctalk_linux.c
文件 7287 2007-07-09 01:34 数字电源资料\源程序\i2c-comm\i2c_m.c
文件 1079 2005-06-26 02:23 数字电源资料\源程序\i2c-comm\i2c_m.h
文件 2487 2005-08-05 20:25 数字电源资料\源程序\i2c-comm\i2c_rs232_pintest.c
文件 11655 2007-07-10 06:15 数字电源资料\源程序\i2c-comm\linux_pre\i2ctalk
文件 11259 2006-01-22 20:52 数字电源资料\源程序\i2c-comm\linux_pre\i2c_rs232_pintest
文件 94 2007-07-10 06:16 数字电源资料\源程序\i2c-comm\linux_pre\md5sum.txt
文件 602 2007-07-09 13:37 数字电源资料\源程序\i2c-comm\Makefile
文件 18160 2005-08-05 18:28 数字电源资料\源程序\i2c-comm\other_OS\macOSX\i2ctalk
文件 18224 2005-08-05 18:28 数字电源资料\源程序\i2c-comm\other_OS\macOSX\i2c_rs232_pintest
文件 108 2005-08-05 18:29 数字电源资料\源程序\i2c-comm\other_OS\macOSX\md5sum.txt
文件 1665 2005-08-05 20:06 数字电源资料\源程序\i2c-comm\other_OS\macOSX\README.txt
文件 11612 2005-08-05 20:05 数字电源资料\源程序\i2c-comm\other_OS\solaris\i2ctalk
文件 12108 2005-08-05 20:05 数字电源资料\源程序\i2c-comm\other_OS\solaris\i2c_rs232_pintest
............此处省略38个文件信息
- 上一篇:单片机课程设计任务书,单片机课程设计任务书
- 下一篇:单片机常用电源电路
评论
共有 条评论