Hysteresis Code - C/C++

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Hysteresis Code - C/C++

39,306 次查看
briancavanagh
Contributor III

Hi, in my design I'm charging a battery using a USB connection.  

I'm using the MK22FN256VLH12 uC in my project.

I will attach my code that I wrote.  I'm adding Hysteresis so the LED doesn't blink both Green and Red at the same time when I'm at the threshold from Charged / Not Charged.  I'm not sure if it's correct. 

Any feedback would be great.

Thanks,

Brian

标签 (1)
0 项奖励
回复
1 回复

35,205 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Brian,

I do not know your application clearly. But for the Hysteresis function, pls refer to the following figure, you have to define the threshold f16HystOFF and f16HystON value, when the input variable f16In is greater than f16HystON, f16OUT=f16OUTON.  When the input variable f16In is less than f16HystOFF, f16OUT=f16OUTOFF. When the input variable f16In is greater than f16HystOFF and less than f16OUTOFF, f16OUT variable remains it's value.

This is the code:

if( f16In>f16HystON) f16OUT=f16OUTON;

if( f16In<f16HystOFF) f16OUT=f16OUTOFF;

it is okay.

Hope it can help you

BR

Xiangjun Rong

pastedImage_1.png

0 项奖励
回复