可以用来做毕业设计,输出1A
原理图
PCB
STM8的代码也是比较简单,就单纯检测下电压与灯亮。。。
void Led_tig(unsigned short adc_val)
{
static unsigned char flag = 0; //反转的标志
if(adc_val >= VAT_CAP_100)
{
LED_VOL_100();
}
else if(adc_val >= VAT_CAP_75)
{
if(flag)LED_VOL_100();
else LED_VOL_75();
}
else if(adc_val >= VAT_CAP_50)
{
if(flag)LED_VOL_75();
else LED_VOL_50();
}
else if(adc_val >= VAT_CAP_25)
{
if(flag)LED_VOL_50();
else LED_VOL_25();
}
else
{
if(flag)LED_VOL_25();
else LED_VOL_0();
}
flag = !flag;
}
unsigned short ADC_val_get(unsigned char ch)
{
unsigned short buf[3] , temp;
unsigned char i;
if(**_IOUT)
ADC1_ConversionConfig(ADC1_CONVERSIONMODE_SINGLE , ADC1_CHANNEL_3, ADC1_ALIGN_RIGHT);
else
ADC1_ConversionConfig(ADC1_CONVERSIONMODE_SINGLE, ADC1_CHANNEL_4 , ADC1_ALIGN_RIGHT);
for(i=0 ; i<3 ; i++)
{
ADC1_StartConversion();
while(SET == ADC1_GetFlagStatus(ADC1_FLAG_EOC)){;}
buf[i] = ADC1_GetConversionValue();
ADC1_ClearFlag(ADC1_FLAG_EOC);
}
temp = GET_MIN( buf[0] , buf[1]);
temp = GET_MIN( temp , buf[2]);
return temp;
}
USB Mobile Power Code.rar
(241.67 KB)
USB Mobile Power PCB.rar
(249.7 KB)
USB Mobile Power SCH.rar
(32.4 KB)
USB Mobile Power.pdf
(160.87 KB)
|