Re: 請問浮點數
|
||||
---|---|---|---|---|
資深會員
|
做值域轉換,比較耗效能
數學演算法如下 PWM階數範圍從0x26~0x89,把開始的地方歸零 (0x26 - 0x26)~(0x89 - 0x26) = 0x00~0x63 --> 等比例放大(2.58倍) --> 0x00~0xFF
發表於: 2008/11/5 23:39
|
|||
|
Re: 請問浮點數
|
||||
---|---|---|---|---|
資深會員
|
了解
thanks ~~
發表於: 2008/11/5 16:45
|
|||
|
Re: 請問浮點數
|
||||
---|---|---|---|---|
資深會員
|
Good Question.
0.3 * 256 = 76.8 餘數不要 -->76 = 0x4C 還原-->76 / 256 = 0.296875很接近0.3吧!
發表於: 2008/11/5 16:30
|
|||
|
Re: 請問浮點數
|
||||
---|---|---|---|---|
資深會員
|
參照:
請問 4.3-->0x04.4C 4C是怎麼來的?
發表於: 2008/11/5 14:13
|
|||
|
Re: 請問浮點數
|
||||
---|---|---|---|---|
版主
|
用組語還是C ?
組語請參考 : AN575 提供了 IEEE754 Floating Point 轉 24-bit 整數的程式: http://www.microchip.com/stellent/idc ... eId=1824&appnote=en010961 經客戶修正過的程式: http://www.piclist.com/techref/microc ... th/round/fp-24bint-ng.htm
發表於: 2008/11/5 10:35
|
|||
|
Re: 請問浮點數
|
||||
---|---|---|---|---|
資深會員
|
把浮點部份當作整數看一樣可以用
4.3-->0x04.4C-->0000 0100.0100 1100 把沒有用到的高位元去掉,左旋5次得到 1000 1001.1000 0000 浮點部份捨棄-->1000 1001-->0x89-->PWM 如果PWM要0~255階,數值要另外轉換。 如不轉換 1.2-->0x01.33-->0000 0001.0011 0011 0010 0110.0110 0000 0010 0110-->0x26-->PWM PWM階數範圍從0x26~0x89
發表於: 2008/11/5 10:26
|
|||
|
請問浮點數
|
||||
---|---|---|---|---|
中級會員
|
請問浮點數要怎樣運算才能在8BIT的微控制器
裡面使用?? 假如4.3-1.2所得到的數字 想把他放在 PWM 做輸出 可是PWM只有二進制 沒有辦法有浮點數輸出 該怎麼做??
發表於: 2008/11/4 16:07
|
|||
|