完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
PCB3D视角 连续调压 过流保护 保护恢复
系统框图如上,首先说明我这款电压是从HP电源的基础上增加人机界面和改善栅极驱动做的,也是征得了原作者的同意,在此表示感谢,借这个机会分享下自己的心得。 BUCK电路的基本结构如上图所示,相信大家基本或多或少对这个结构都有一定的了解。简单说下,S1闭合时,输入的通路为S1到L1到电容C2以及负载,S2关断时,L1中储存的能量经过D1形成新的回路,如此循环往复,在此过程中实现能量的转移,输出与输入电压的比值为占空比D。 同步BUCK,就是采用导通电阻特别低的mosfet来代替续流二极管,以此来提高整个拓扑的工作效率。基本图如下:
图中采用了无电解电容设计,这样虽然纹波可能会大一点,但是响应的体积却小了很多,实际测试中,纹波在100MV以下。电感和电容的取值有响应公式可以推到,这里不多赘述,直接给大家提供一个小工具,输入参数就可以计算出结果的小工具: |
|
相关推荐
|
|
下面谈一谈程序的设计思路,因为这款设计为了尽可能减少体积,因此使用了较大频率的PWM波,取值为250k,所采用的主控stm32f334是意法半导体专为数控电源所设计的一款MCU。STM32F334xx微控制器具有高分辨率定时器(HRTIM)外设,可产生多达10个信号,能够处理用于控制、同步或保护的各种不同输入信号。其模块化架构允许对大部分转换拓扑和多并联转换器进行处理,并可在运行中重新配置它们。
需要注意的是,有关AD采样的触发时机选择是一个很关键的点,如下图所示,对于特定占空比的PWM波,在其中央触发AD工作,这样可以避免纹波的影响。 [size=0.83em]QQ截图20160823135730.jpg (28.96 KB, 下载次数: 0) 下载附件 [color=rgb(153, 153, 153) !important]3 小时前 上传 由此,通过AD采样的输出电压与设定的电压一起,配合PI调节占空比,即完成了闭环反馈过程,通过对输出电压电流的编程,即完成电池充电程序的编写。 |
|
|
|
|
|
这里给出配置的代码和PI的代码。
/*************************************************************************** #define PWM_PERIOD = 144000000*32/switchfrequency #define DT_RISING = risingtime*switchfrequency*PWM_PERIOD #define DT_FALLING = fallingtime*switchfrequency*PWM_PERIOD ***************************************************************************/ /** * @brief 用于配置HRTIM_A的输出,关闭deadtime时,为单输出,开启deadtime时,为双输出。 * @param 死区使能,配套AD采样使能,错误使能,中断使能,初始频率,初始占空比(HO),中断频率,上升死区时间(单位纳秒),下降死区时间 * @retval None */ void MY_BSP_Init_HRTIM_A(BOOLEAN deadtime,BOOLEAN adenable,BOOLEAN faultenable,BOOLEAN interrupt,uint32_t Initial_Fre,uint8_t Initial_Duty,uint8_t n_ISR,uint8_t risingtime,uint8_t fallingtime) { HRTIM_TimeBaseCfgTypeDef timebase_config; HRTIM_TimerCfgTypeDef timer_config; HRTIM_OutputCfgTypeDef output_config_TA; HRTIM_CompareCfgTypeDef compare_config; /* ----------------------------*/ /* HRTIM Global initialization */ /* ----------------------------*/ /* Initialize the hrtim structure (minimal configuration) */ hhrtimA.Instance = HRTIM1; hhrtimA.Init.HRTIMInterruptResquests = HRTIM_IT_NONE; hhrtimA.Init.SyncOptions = HRTIM_SYNCOPTION_NONE; /* Initialize HRTIM */ HAL_HRTIM_Init(&hhrtimA); /* HRTIM DLL calibration: periodic calibration, set period to 14祍 */ HAL_HRTIM_DLLCalibrationStart(&hhrtimA, HRTIM_CALIBRATIONRATE_14); /* Wait calibration completion*/ if (HAL_HRTIM_PollForDLLCalibration(&hhrtimA, 100) != HAL_OK) { Error_Handler(); // if DLL or clock is not correctly set } /* --------------------------------------------------- */ /* TIMERA initialization: timer mode and PWM frequency */ /* --------------------------------------------------- */ timebase_config.Period = 4608000000/Initial_Fre; /* 400kHz switching frequency */ timebase_config.RepetitionCounter = n_ISR - 1; /* n ISR every 128 PWM periods */ timebase_config.PrescalerRatio = HRTIM_PRESCALERRATIO_MUL32; timebase_config.Mode = HRTIM_MODE_CONTINUOUS; HAL_HRTIM_TimeBaseConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, &timebase_config); /* --------------------------------------------------------------------- */ /* TIMERA global configuration: cnt reset, sync, update, fault, burst... */ /* timer running in continuous mode, with deadtime enabled */ /* --------------------------------------------------------------------- */ timer_config.DMARequests = HRTIM_TIM_DMA_NONE; timer_config.DMASrcAddress = 0x0; timer_config.DMADstAddress = 0x0; timer_config.DMASize = 0x0; timer_config.HalfModeEnable = HRTIM_HALFMODE_DISABLED; timer_config.StartOnSync = HRTIM_SYNCSTART_DISABLED; timer_config.ResetOnSync = HRTIM_SYNCRESET_DISABLED; timer_config.DACSynchro = HRTIM_DACSYNC_NONE; timer_config.PreloadEnable = HRTIM_PRELOAD_ENABLED; timer_config.UpdateGating = HRTIM_UPDATEGATING_INDEPENDENT; timer_config.BurstMode = HRTIM_TIMERBURSTMODE_MAINTAINCLOCK; timer_config.RepetitionUpdate = HRTIM_UPDATEONREPETITION_ENABLED; timer_config.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED; if(interrupt == TRUE) { timer_config.InterruptRequests = HRTIM_TIM_IT_REP; } else timer_config.InterruptRequests = HRTIM_TIM_IT_NONE; timer_config.PushPull = HRTIM_TIMPUSHPULLMODE_DISABLED; if(faultenable == TRUE) timer_config.FaultEnable = HRTIM_TIMFAULTENABLE_FAULT1; else timer_config.FaultEnable = HRTIM_TIMFAULTENABLE_NONE; timer_config.FaultLock = HRTIM_TIMFAULTLOCK_READWRITE; timer_config.DeadTimeInsertion = HRTIM_TIMDEADTIMEINSERTION_ENABLED; timer_config.DelayedProtectionMode = HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_DISABLED; timer_config.UpdateTrigger= HRTIM_TIMUPDATETRIGGER_NONE; timer_config.ResetTrigger = HRTIM_TIMRESETTRIGGER_NONE; HAL_HRTIM_WaveformTimerConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, &timer_config); /* Set compare registers for duty cycle on TA1 */ compare_config.CompareValue = 46080000*Initial_Duty/Initial_Fre; /*duty cycle */ HAL_HRTIM_WaveformCompareConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_1, &compare_config); /* --------------------------------- */ /* TA1 and TA2 waveforms description */ /* --------------------------------- */ output_config_TA.Polarity = HRTIM_OUTPUTPOLARITY_HIGH; output_config_TA.SetSource = HRTIM_OUTPUTSET_TIMPER; output_config_TA.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1; output_config_TA.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE; output_config_TA.IdleLevel = HRTIM_OUTPUTIDLELEVEL_INACTIVE; output_config_TA.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_INACTIVE; output_config_TA.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED; output_config_TA.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR; HAL_HRTIM_WaveformOutputConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA1, &output_config_TA); if(deadtime == TRUE) { HAL_HRTIM_WaveformOutputConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA2, &output_config_TA); } if(deadtime == TRUE) { HRTIM_DeadTimeCfgTypeDef HRTIM_TIM_DeadTimeConfig; /* Deadtime configuration for Timer A */ HRTIM_TIM_DeadTimeConfig.FallingLock = HRTIM_TIMDEADTIME_FALLINGLOCK_WRITE; HRTIM_TIM_DeadTimeConfig.FallingSign = HRTIM_TIMDEADTIME_FALLINGSIGN_POSITIVE; HRTIM_TIM_DeadTimeConfig.FallingSignLock = HRTIM_TIMDEADTIME_FALLINGSIGNLOCK_READONLY; HRTIM_TIM_DeadTimeConfig.FallingValue = risingtime*4096/1000; HRTIM_TIM_DeadTimeConfig.Prescaler = HRTIM_TIMDEADTIME_PRESCALERRATIO_MUL8; HRTIM_TIM_DeadTimeConfig.RisingLock = HRTIM_TIMDEADTIME_RISINGLOCK_WRITE; HRTIM_TIM_DeadTimeConfig.RisingSign = HRTIM_TIMDEADTIME_RISINGSIGN_POSITIVE; HRTIM_TIM_DeadTimeConfig.RisingSignLock = HRTIM_TIMDEADTIME_RISINGSIGNLOCK_READONLY; HRTIM_TIM_DeadTimeConfig.RisingValue = fallingtime*4096/1000; HAL_HRTIM_DeadTimeConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, &HRTIM_TIM_DeadTimeConfig); } if(adenable == TRUE) { HRTIM_ADCTriggerCfgTypeDef adc_trigger_config; /* ------------------------------------------- */ /* ADC trigger intialization (with CMP4 event) */ /* ------------------------------------------- */ compare_config.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR; compare_config.AutoDelayedTimeout = 0; if(Initial_Duty >=50) compare_config.CompareValue = 46080000*Initial_Duty/Initial_Fre; /* Samples in middle of ON time */ else compare_config.CompareValue = 23040000*(100+Initial_Duty)/Initial_Fre; HAL_HRTIM_WaveformCompareConfig(&hhrtimA, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_4, &compare_config); adc_trigger_config.Trigger = HRTIM_ADCTRIGGEREVENT24_TIMERA_CMP4; adc_trigger_config.UpdateSource = HRTIM_ADCTRIGGERUPDATE_TIMER_A; HAL_HRTIM_ADCTriggerConfig(&hhrtimA, HRTIM_ADCTRIGGER_2, &adc_trigger_config); } if(faultenable == TRUE) { HRTIM_FaultCfgTypeDef fault_config; /* ---------------------*/ /* FAULT initialization */ /* ---------------------*/ fault_config.Filter = HRTIM_FAULTFILTER_NONE; fault_config.Lock = HRTIM_FAULTLOCK_READWRITE; fault_config.Polarity = HRTIM_FAULTPOLARITY_LOW; fault_config.Source = HRTIM_FAULTSOURCE_DIGITALINPUT; HAL_HRTIM_FaultConfig(&hhrtimA, HRTIM_FAULT_1, &fault_config); HAL_HRTIM_FaultModeCtl(&hhrtimA, HRTIM_FAULT_1, HRTIM_FAULTMODECTL_ENABLED); } if(deadtime == TRUE) { /* ---------------*/ /* HRTIM start-up */ /* ---------------*/ /* Enable HRTIM's outputs TA1 and TA2 */ /* Note: it is necessary to enable also GPIOs to have outputs functional */ /* This must be done after HRTIM initialization */ HAL_HRTIM_WaveformOutputStart(&hhrtimA, HRTIM_OUTPUT_TA1 | HRTIM_OUTPUT_TA2); } else HAL_HRTIM_WaveformOutputStart(&hhrtimA, HRTIM_OUTPUT_TA1); /* Start both HRTIM TIMER A, B and D */ if(interrupt == TRUE) HAL_HRTIM_WaveformCounterStart_IT(&hhrtimA, HRTIM_TIMERID_TIMER_A); else HAL_HRTIM_WaveformCounterStart(&hhrtimA, HRTIM_TIMERID_TIMER_A); GPIO_InitTypeDef GPIO_InitStruct; /* Enable GPIOA clock for timer A outputs */ __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure HRTIM output: TA1 (PA8) */ GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL;; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;; GPIO_InitStruct.Alternate = GPIO_AF13_HRTIM1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); if(deadtime == TRUE) { /* Configure HRTIM output: TA2 (PA9) */ GPIO_InitStruct.Pin = GPIO_PIN_9; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } } |
|
|
|
|
|
/**
* @brief This function calculates new duty order with PI. * @param None * @retval New duty order */ int32_t PI_Buck(uint32_t RealVol,uint32_t SetVol,int32_t dec2hex(int32_t temp)) { /* Compute PI for Buck Mode */ /* Every time the PI order sets extreme values then CTMax or CTMin are managed */ int32_t seterr, pid_out; int32_t error; error = ((int32_t ) RealVol - (int32_t) SetVol); error = dec2hex(error); seterr = (-Kp * error) / 200; Int_term_Buck = Int_term_Buck + ((-Ki * error) / 200); if (Int_term_Buck > SAT_LIMIT) { Int_term_Buck = SAT_LIMIT; } if (Int_term_Buck < -(SAT_LIMIT)) { Int_term_Buck = -(SAT_LIMIT); } pid_out = seterr + Int_term_Buck; pid_out += BUCK_PWM_PERIOD / 2; if (pid_out >= MAX_DUTY_A) { pid_out = MAX_DUTY_A; CTMax++; } else { if (CTMax != 0) { CTMax--; } } if (pid_out <= MIN_DUTY_A) { pid_out = MIN_DUTY_A; CTMin++; } else { if (CTMin != 0) { CTMin--; } } return pid_out; } |
|
|
|
|
|
给出原理图和工程文件:
|
|
|
|
|
|
|
|
|
|
|
|
199 浏览 0 评论
使用Keil建立完整的工程,并使用外部中断0触发数码管显示903
748 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-使用AHT20进行环境监测之AHT20传感器介绍
1122 浏览 0 评论
874 浏览 0 评论
910 浏览 1 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11835 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 11:04 , Processed in 0.901501 second(s), Total 78, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号