2007年4月21日 星期六

ATmega-128 的 16-Channels PWM 輸出(三)

問題終於解決了!原來又是自己一時大意...。在程式中,我設定 PWM 的範圍是從 21 到 34,亦即是 1543us 到 2272us。問題就是 21 這個數值是等如移動到中間位置,難怪移到一半便回轉...。把 21 改為 6 之後,便完全正常了!哈哈!

不過,由 6 到 34 當中只有 29 個層次,以 180/29 來計算,數值加一便會增加 6.2 度,是一個很大的數值。按R大人所說,這樣大的數值是很難做出順暢的動作,甚至有些高難度的動作也做不來...。看來又要想想辦法了...。

4 則留言:

BloodKeith 提到...

係呀 6.2度其實相差好多. 你見我踎低及起身的動作是小轉動角度是 3度, 但在有 3度的同一個動作裹面不可以有超過 10度出現, 因為唔會可以同一時間完成 3度同 10度, 除非有得用 Timer 叫個 Program 自己計時同一時間開始完成, 但問過 Dr. Victor 這是一個相當難的 Program, 所以現在只有自己手計, 再 keep reference 方便日後改了

匿名 提到...

Hi Pacess,

I used AVR MCUs for my MT chips, MT-08 and MT-14, which make use of the internal RC OSC to produce 8MHz clocking speed. When using 8MHz, I can make the servo resolution to 180/135, i.e. 1.33 resolution per degree. So, if I use 16MHz external crystal, I should able to make the resolution to 180/270, which is 0.67 resolution per degree.

It's a bit strange in your case! You should redesign your program in order to utilize the full power of AVR! One method you can do is to replace the 8MHz crystal with a 16MHz one, if your AVR is the one without the letter 'L' in it's model number! I can do this simple operation for you in Tuesday Seminar!

Cheers!

Victor

Pacess 提到...

Keith,我諗黎諗去都諗唔到有其他辦法...,好在我塊 ATmega-128 係俾我隻三號機(初階機),所以大角度都可能 Work。

我都有諗過用兩塊 ATmega-128 黎控制,而板與板之間就用 RS-232 溝通。不過,咁就變得成本高而效率低,所以唔 Work。其實我果時買 ATmega-128 都係因為日本仔用開果d板俾佢差少少都掂,諗住呢個會 OK...

Pacess 提到...

Victor, thank you for your comment. My ATmega-128 is "L" version. :P

By the way, I may not appear on seminar, maybe we can meet later to discuss about that. Moreover, regarding to the two 火牛, R will help on this, of course he will pay to you for me. And I want to buy Li-battery, do you have stocks? I want 3 with charger. Thanks~