閲覧総計:10927  (本日:1  昨日:1)

ライントレースカー(コースアウト処理追加)

「基本機能のみ搭載」では、カーブの際、ラインセンサ2ケ共が黒ラインから
はずれ、車がラインから外れてしまいました。
この問題を解決する為、今回はラインの外れ方の履歴をold_flagに持たせ
ラインセンサ2ケ共に外れた際の動作指示を定義しました。
【結果】ライントレースカーは常に正しくラインに沿って走行出来る様に
なりました。 06/11/05

/** 
* ライントレースカー(コースアウト処理追加)
* 
* PIC 16F628A 
* 発信器:内臓4MHz 
* 電源:PIC 乾電池4本(6.0V) モータ 乾電池3本(4.5V) 
* ライトセンサー:RA0, RA1 
* モーター:左 RB6,RB7 右 RB0,RB1 
* 
* Device Flags: _BODEN_OFF _BOREN_OFF _CP_OFF _PWRTE_ON 
*    _WDT_OFF _LVP_OFF _MCLRE_OFF _INTRC_OSC_NOCLKOUT 
* 
* プログラム言語:MikroC v6.0 
*/ 
void main() { //メインプログラム 

  unsigned short int old_flag; //完全コースアウト前の状況を記録flag

 //マイコンの初期化 
 PORTA = 0b00000000; //PORTAの中身をきれいにする 
 PORTB = 0b00000000; //PORTBの中身をきれいにする 

 CMCON = 0b00000111; //PORTAをデジタル入出力使用に設定 

 TRISA = 0b00000011; //PORTAをRA0,1を1:入力に、他は0:出力に設定 
 TRISB = 0b00000000; //PORTBを8つ全て0:出力に設定 
 //マイコンの初期化終わり 

 do{ //doとwhileの間を繰り返す 
  if(PORTA.F1 == 1) { //左センサー黒 
   if(PORTA.F2 == 1) { //右センサー黒 
    //車がラインの上にある 
    //左右モーター前進 
    PORTB.F2 = 1; //左モーター前進 
    PORTB.F3 = 0; 
    PORTB.F5 = 1; //右モーター前進 
    PORTB.F4 = 0; 
        
        old_flag = 0; //両センサコース上
        
   } else { //右センサ白 
    //右にコースアウト 
    //左モーター停止、右モーター前進で 
    //コースにもどる 
    PORTB.F2 = 0; //左モーター停止 
    PORTB.F3 = 0; 
    PORTB.F5 = 1; //右モーター前進 
    PORTB.F4 = 0; 
        
        old_flag = 1; //右にコースアウト
        
   } 
  } else { //左センサー白 
   if(PORTA.F2 == 1) { //右センサー黒 
    //左にコースアウト 
    //左モーター前進、右モーター停止で 
    //コースにもどる 
    PORTB.F2 = 1; //左モーター前進 
    PORTB.F3 = 0; 
    PORTB.F5 = 0; //右モーター停止 
    PORTB.F4 = 0; 
        
        old_flag = 2; //左にコースアウト
        
   } else { //右センサー白 
    //左右センサー共に白、完全コースアウトした場合 
        if(old_flag == 1) {
      //右にコースアウト 
      //左モーター停止、右モーター前進で 
      //コースにもどる 
      PORTB.F2 = 0; //左モーター停止 
      PORTB.F3 = 0; 
      PORTB.F5 = 1; //右モーター前進 
      PORTB.F4 = 0; 
          
          old_flag = 1; //右にコースアウト
          
        } else {
      //左にコースアウト 
      //左モーター前進、右モーター停止で 
      //コースにもどる 
      PORTB.F2 = 1; //左モーター前進 
      PORTB.F3 = 0; 
      PORTB.F5 = 0; //右モーター停止 
      PORTB.F4 = 0; 
          
          old_flag = 2; //左にコースアウト
          
        }
   } 
  } 
 } while(1); //doとwhileの間を繰り返す 
} //メインプログラム終わり 

★この情報は役に立ちましたか?

選択肢 投票
はい 5  
いいえ 5  


*1 ( <a href=" http://www.maid-of-honor.net/phpbb3//viewtopic.php?f=4&t=232190 ">literotica lick under table cramp</a> 8-DD <a href=" http://www.cyber-room.com//viewtopic.php?f=7&t=223038 ">slutload phoenix</a> %-] <a href=" http://www.suzannefranco.com/bootcamp-forum//viewtopic.php?f=17&t=23159 ">teen samantha gets fucked on slutload</a> eeoi <a href=" http://www.maid-of-honor.net/phpbb3//viewtopic.php?f=4&t=232227 ">literotica her rump</a> eblfm <a href=" http://www.suzannefranco.com/bootcamp-forum//viewtopic.php?f=17&t=23220 ">xvideos brandi teen pussy</a> qrr <a href=" http://islipdental.com/forums///viewtopic.php?f=2&t=174708 ">literotica storie</a> 010925 <a href=" http://www.maid-of-honor.net/phpbb3//viewtopic.php?f=4&t=232241 ">xhamster movies aunt peg</a> =
*2 <a href=" http://www.chathamsoccerclub.com/bulletin//viewtopic.php?f=2&t=23189 ">xhamster great grannys</a> >:-P <a href=" http://islipdental.com/forums///viewtopic.php?f=2&t=174685 ">asian pee imagefap</a> %
*3 <a href=" http://www.maid-of-honor.net/phpbb3//viewtopic.php?f=4&t=244035 ">grannie porn tube</a> ayz <a href=" http://www.badgerhunters.com/forums//viewtopic.php?f=4&t=10497 ">red porn tube</a> jqqokk <a href=" http://eastkentuckychat.com//viewtopic.php?f=4&t=80406 ">dirty talk porn tube</a> 8549 <a href=" http://www.chathamsoccerclub.com/bulletin//viewtopic.php?f=2&t=26694 ">porntubes big booties doggie styles</a> kgwv <a href=" http://www.maid-of-honor.net/phpbb3//viewtopic.php?f=4&t=244037 ">porntube heven</a> 8) <a href=" http://www.suzannefranco.com/bootcamp-forum//viewtopic.php?f=17&t=34159 ">categorized tube porn swallow</a> 8
*4 <a href=" http://www.zeuspaul.com/forum//viewtopic.php?f=2&t=207060 ">sister porntube</a> =-