#freeze
閲覧総計:&counter();  (本日:&counter(today);  昨日:&counter(yesterday);)~
~
*サーボモータを動かす [#vbb42053]

PIC 16F628A内臓のTimer0割込み機能を利用し、サーボモータを制御する20ミリ秒
周期のパルス信号を発生させて、サーボモータを動かしてみよう。  06/10/29

サーボモータ:ミニスタジオ社製 MiniS RB-50 @1,300円
http://www.ministudio.co.jp/Japanese/Goods-RB50-1.htm

06/11/15追記
下記同一プログラムで大きいサーボモータを動かしてみました。
写真右:ミニスタジオ社製 RCサーボRB303c @1,300円
http://www.ministudio.co.jp/Cgi-bin/Order-JP/DetailJp.asp?GoodsNum=97
サーボの機種が変わっても同じ動きをする事を確認しました。

|&attachref(P1010189.JPG,zoom,150x150,button){新しい写真添付};|&attachref(P1010204.JPG,zoom,150x150,button){新しい写真添付};|

 /**
 * RCサーボモータ制御
 *
 * PIC16F628A   @4MHz
 * RB3: servo MiniS RB50
 * http://www.ministudio.co.jp/Japanese/Goods-RB50-1.htm
 * 電源:乾電池3本
 *
 * MikroC 6.2
 */
 
 // Global変数定義
 signed short int deg = 0; // deg: -85 ~ +85
 
 void interrupt() { //割込み関数
     // Timer0 Interval 20mS
     if (INTCON.T0IF) { //割込み種がTimer0割込みの場合
         TMR0 = -(20000 / 128); // Timer0 Interval 20mS (@4MHz)
         INTCON.T0IF = 0;
         
         PORTB.F3 = 1; // PWM RB3 on
         Delay_Cyc(150 + deg); // delay(150 + deg) * 10uS
         PORTB.F3 = 0; // PWM RB3 off
     }
 }
 
 void main() {
     PORTB = 0b00000000; //PORTBの中身をきれいにする
     TRISB = 0b00000000; //PORTB 8個全て0:出力設定
     
     OPTION_REG = 0x86; // TMR0プリスケーラ: 1/128
     TMR0 = -(20000 / 128); // Timer0 Interval 20mS (@4MHz)
     //TMR0割込み許可
     INTCON.T0IE = 1;
     INTCON.GIE = 1;
     
     do {
         //基準角度確認
         deg = 0; Delay_ms(1000);
         deg = -85; Delay_ms(1000);
         deg = 0; Delay_ms(1000);
         deg = 85; Delay_ms(1000);
         deg = 0; Delay_ms(1000);
         
         //-85度〜+85度までゆっくり首を振る
         for(deg = -85; deg <= 85; deg++)
             Delay_ms(50);
         for(deg = 85; deg >= -85; deg--)
             Delay_ms(50);
             
     } while(1);
 }

★この情報は役に立ちましたか?
#vote(はい[3],いいえ[0])
- Fun search test!!<a href="http://dependlaw.info/santa-baby-purse-pattern.html">santa baby purse pattern</a><a href="http://dependlaw.info/black-coach-purse.html">black coach purse</a><a href="http://dependlaw.info/wholesale-satin-bridal-purse.html">wholesale satin bridal purse</a>http://dependlaw.info/leather-waist-purses.htmlhttp://dependlaw.info/designer-purses-cheap.htmlhttp://dependlaw.info/allegra-fashion-purses.htmlhttp://dependlaw.info/pink-purses.htmlhttp://dependlaw.info/unique-handmade-purses.html<a href="http://dependlaw.info/vintage-inspired-purses.html">vintage inspired purses</a>http://dependlaw.info/custom-made-leather-purses.htmlhttp://dependlaw.info/handmade-handbags-purses.html<a href="http://dependlaw.info/juice-box-purses.html">juice box purses</a><a href="http://dependlaw.info/designer-handbags-purses.html">designer handbags purses</a>http://dependlaw.info/mustang-purse.html<a href="http://dependlaw.info/kavu-purse.html">kavu purse</a>^^^^^^^^^^Click and win! -- [[jackinth]] &new{2008-01-18 (金) 07:35:15};
- Fun search test!!<a href="http://dreamhomestudio.info/vintage-citizen-watch-porcelain.html">vintage citizen watch porcelain</a><a href="http://dreamhomestudio.info/energy-fields-effects-on-watch-batteries.html">energy fields effects on watch batteries</a>http://dreamhomestudio.info/making-beaded-watch-bands.htmlhttp://dreamhomestudio.info/heroes-episode11-watch.htmlhttp://dreamhomestudio.info/timex-expedition-watches-women.htmlhttp://dreamhomestudio.info/watch-gift-bands.html<a href="http://dreamhomestudio.info/interchangeable-beaded-watch-bands.html">interchangeable beaded watch bands</a>http://dreamhomestudio.info/swiss-pocket-watch.htmlhttp://dreamhomestudio.info/smallville-season-7-episode-1-watch-for-free.htmlhttp://dreamhomestudio.info/seiko-world-time.htmlhttp://dreamhomestudio.info/ladies-wrist-watches.html<a href="http://dreamhomestudio.info/casio-watch-manuals.html">casio watch manuals</a>http://dreamhomestudio.info/early-swatch-watch.html<a href="http://dreamhomestudio.info/antique-pocket-watch.html">antique pocket watch</a>http://dreamhomestudio.info/sagamore-pocket-watch.html^^^^^^^^^^Click and win! -- [[boombox]] &new{2008-01-18 (金) 11:15:54};

#comment