Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/oldmakers/www/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340
倒立振子をまた作ってみました(その1)

https://blog.with2.net/link/?1965529

倒立振子をまた作ってみました(その1)

https://blog.with2.net/link/?1965529

しばらく続いていたESP-WROOM-02を離れてAruduinoに戻ってきました。久しぶりなので忘れていることも何か所かあって、それはそれで楽しいです。

それでなにを始めたかというと、部品箱に残っていた走行系キットを使って倒立振子をまた作ってみました。きっかけはサイトを検索していたら下記のような倒立振子を見つけたことが始まりです。倒立姿勢は比較的安定していて、砂利道のような路面でも倒立しています。

https://www.instructables.com/id/Arduino-Self-Balancing-Robot-1/

どこかで見たような車輪だなと部品箱を探してみたら同じものがなんとありました。ずいぶん前に購入してそのままになっていたようです。当方のモータはエンコーダ付きであることと減速比が違うというだけです。

こちらが筆者の部品箱にあったものです。搭載しているモータはGA12-N20モーター500 rpm (n20 15000 rpm、減速比30)となります。参考記事では200rpmですから減速比の分だけトルクが小さくなりますが、機体が軽いので問題はないでしょう。

エンコーダの使い道は後で考えるとして、一度このサイトで紹介されているスケッチにて倒立性を再現出来るのか試してみたいと製作してみました。参考記事ではマイコンはArduino ProMiniですが、今回は Arduino ProMicroを使用します。その他は参考記事とほぼ同じとなります。

製作にとりかかる前に参考記事のスケッチを復習してみます。倒立振子の最大のポイントはジャイロ・加速度センサ、今回はMPU6050のドリフト対策です。
下図は今回使用するMPU6050の取得値(角速度)から角度を算出したものです。水平に置いて放置しているだけですが、50秒ほどで 20°以上のドリフトが発生しました。壊れているんじゃないかと思うぐらいかなり大きな値です。

ついでに加速度センサーからの角度算出値を確認してみたところ、ドリフトこそないものの結構ノイズが載っています。途中激しく変動している個所はセンサーを前後に動かしてみた場合です。加速度の水平成分がy軸およびz軸の加速度値を妨害するためです。

参考記事での相補フィルターを通した状態が下図です、見事に平滑化されています。その仕組みについては沢山解説記事がネット上にありますが、簡単にはジャイロセンサーからの角度算出値と加速度センサーからの角度算出値を重み付け平均しているようです。

その他、PID制御などはごく普通に倒立振子で使われている手法のようです。

ということで参考記事の内容はほぼ把握は出来ましたので、今回の回路図です。

ESP-WROOM-02以外をブレッドボードに組んで試験してみました。何点か注意すべきポイントがありました。いすれも参考記事中に書かれていることなのでその通り実施しておけばクリアーできます。

第一はMPU6050のオフセット値を検定しておくことです。筆者の場合は以下の様になりました。ただ参考記事に紹介されているオフセット値を検定するスケッチはなぜかコンパイル出来ず、他のサイトで見つけたものを利用しました。

mpu.setYAccelOffset(-686);
mpu.setZAccelOffset(1369);
mpu.setXGyroOffset(125);

この手間をさぼっていたので、初めはとんでもない値が出てあせりました。

第二はDRV8835モータドライバの電源周りの問題です。注意点はモータ電源VMとロジック電源VCCそれぞれに別々のDCDCコンバータから供給するということです。参考記事に書かれていますが、筆者はこれまでの経験から当初VMに電池直接、VCCにはDCDCコンバータから3.3Vを供給していましたが、スケッチ実行中に突然停止します。どうも参考記事の作者も経験したようにノイズのようです。コンデンサ追加などの対策をすれば回避出来るかもしれませんが、面倒なので記事どおりVM用に5VのDCDCコンバータを別途設置しました。増設後はスケッチの停止もなく順調です。

参考までにその部分の記事を以下に訳しておきます。

 ”最初の設計では、5Vの昇圧レギュレータを使用して、コントローラとモータの電源に接続しました。 ロボットの電源を入れたとき、プログラムは断続的にフリーズします。 これは、コントローラとIMUに作用するモータ回路から発生するノイズに起因するものです。 これは、電圧レギュレータをコントローラとモータに分離し、モータ電源端子に10uFのコンデンサを追加することで効果的に排除されました。”

基板サイズは機体の都合でゆったりと47x60mmとれます。三次元CADで配列を確認しておきます。

とうことで、基板の製作にとりかかります。

シェアする

フォローする