In my project I use a 8 bits resolution ADC to measure battery . 3.0 V as 100% and 2.2 V as 0%.
When input is 3.0 V the ADC value is 255 and 2.2 V for 180. Because it's unnecessary to be very accurate so I use simple equation y = ax +b to calculate the percentage of the battery.
100 = 255 a + b ........ (1)
0 = 180 a + b ........ (2)
Use 1 and 2 we can calculate a = 4/3 and b = -240.
Ref:
Float divide and integer divide in C.
2017年4月19日 星期三
訂閱:
張貼留言 (Atom)
Linux driver: How to enable dynamic debug at booting time for built-in driver.
Dynamic debug is useful for debug driver, and can be enable by: 1. Mount debug fs #>mount -t debugfs none /sys/kernel/debug 2. Enable dy...
-
The root cause is miss use a pointer to a static variable like: int x = 1; int y = (int) &x; Modify version int x = 1; int *y =...
-
We can easily get all the serial port in windows using regedit.exe In our application we read the windows register key `HARDW...
-
1.Create the project folder and win_gui_v1.go in your go work space > cd ..\src\ > mkdir win_gui_v1 2.Copy the .manifest file...
沒有留言:
張貼留言