2023年10月21日土曜日

日本古代史のまとめ

 高地性集落の分布は、弥生中期に中部瀬戸内と大阪湾岸に[3]、弥生後期に近畿とその周辺部にほぼ限定されている。倭国大乱は弥生末期の2世紀後半(桓霊の間)。


神功皇后は193年に立后 『古事記』分注の没年干支では仲哀天皇の崩御は西暦362年に比定される。69年間も摂政をしていたとされる。。。。



高地性集落は、古墳時代(3世紀中ごろから6世紀末まで、592年に飛鳥がはじまる)前期には、西日本の広島・鳥取に、北陸の富山・石川・新潟に分布する 

3世紀は尾張の協力で大和建国(卑弥呼は247年に死亡、トヨの記事266年以降150年は大陸との交流なし 369年に百済より石上神宮の七支刀) 古墳は3世紀中頃より出現!

実在したとすれば崇神(ニギハヤヒ?)は4世紀前半で以後応神以前まで纒向に宮あり、

関裕二が同時期という神武と欠史八代は橿原に宮の記載あり、また神功皇后もほぼ同時期という

4世紀に大和が北九州と融和?(吉備と出雲の協力) つまり神武、崇神、応神は同時代?

少なくとも近畿で3世紀末に九州の埋葬文化であった銅鏡が古墳におさめられるようになった

景行天皇は4世紀中期の人?、神功皇后が仲哀天皇をみとったのは362年(古事記)、

5世紀に瀬戸内航路の安全開拓(雄略天皇) 

応神〜雄略が5世紀(倭の五王) 河内王朝として河内湖の干拓と巨大古墳

6世紀に前飛鳥時代が始まる(継体と磐井) 

7世紀は飛鳥時代! 8世紀が奈良時代!

Jlius latest memo

 ----------------julius latest--------------------------------------------------------------------------------------


https://kocoffy.com/iot/post-519/ これが一番ていねい

https://qiita.com/en129/items/31b0f67c1d886df2aef6 :: 4.6で辞書つくり 空白の説明がくわしい

https://qiita.com/chiapis2/items/a2ed64414c9e49b6cb42 音声操作編

https://dk521123.hatenablog.com/entry/37451114 これでgrammerでなくgrammarとしる

2023年10月9日月曜日

radicon-car-esp32, ラズピコのサーボ位置決め など

TB1622FNGのピン配置

PWMA 12,AIN1 13,AIN2 14, STBY 3V3, GND TO ESP32

VM FROM 5V-BATTERY,VCC 5V,GND FROM 5V-BATTERY,GND TO ESP32

https://404background.com/circuit/tb6612fng/#%E5%9B%9E%E8%B7%AF%E3%82%92%E7%B5%84%E3%82%80 に詳しい説明があるがアルディーノUNO用にて注意

#include <ESP32Servo.h> // pwm freq 50hz固定

#include <BluetoothSerial.h>

// 定数の定義

#define SERVO 5        // MG996R アルディーノではpwm可能なPIN必須

#define PWMA 12       // TB6612FNGのPWMA アルディーノではpwm可能なPIN必須

#define AIN1 13          / TB6612FNGのAIN1

#define AIN2 14               // TB6612FNGのAIN2

#define LEDC_CHANNEL 6        // PWMのチャンネル for dcmotor

#define LEDC_BASE_FREQ 10000  // PWMの周波数 for dcmotor

#define MAX_SPEED 3           // 速度の最大値

#define MIN_SPEED -1          // 速度の最小値

#define ANGLE_STEP 6          // 角度の増分

#define ANGLE_MAX 18          // 角度の最大値

// Bluetoothシリアルにつける名前

const char *btname = "ESP32Car";

// MG996Rの角度調整

const int servo_offset = -5;

// 速度・角度 を保存するグローバル変数

int speed = 0;

int angle = 0;

// MG996RとBluetoothシリアルに対応するグローバル変数

Servo myServo;

BluetoothSerial SerialBT;

void setup() {

  // Bluetoothシリアルの初期化

  SerialBT.begin(btname);

  // PWMの初期化

  ledcSetup(LEDC_CHANNEL, LEDC_BASE_FREQ, 8); 

// チャンネル指定と周波数、分周ビットの指定 8ビットなら0から255

  ledcAttachPin(PWMA, LEDC_CHANNEL); //上記チャンネルをPINに紐付け

  // MG996Rの初期化

  myServo.attach(SERVO); // MG996Rのピン番号を指定

  myServo.write(90 + servo_offset);

  // GPIOピンの初期化

 pinMode(PWMA, OUTPUT);

  pinMode(AIN1, OUTPUT);

  pinMode(AIN2, OUTPUT);

 }


void loop() {

  // Bluetoothシリアルから文字を読み込んで処理する

  read_bt();

   // モーターを操作する

  operate_motor();

}


// Bluetoothシリアルから文字を読み込んで処理する

void read_bt() {

  // Bluetoothシリアルから文字を受信しているかどうかを判断する

  if (SerialBT.available()) {

    // Bluetoothシリアルから1文字読み込む

    int ch = SerialBT.read();

    // 文字が「e」の場合

    if (ch == 'e') {

      // speedがMAX_SPEEDより小さければ1増やす(加速)

      if (speed < MAX_SPEED) {

        speed++;

      }

    }

    // 文字が「x」の場合

    else if (ch == 'x') {

      // speedがMIN_SPEEDより大木れば1減らす(減速)

      if (speed > MIN_SPEED) {

        speed--;

      }

    }

    // 文字が「d」の場合

    else if (ch == 'd') {

      // angleがANGLE_MAXより小さければANGLE_STEPだけ増やす(ハンドルを右に切る)

      if (angle < ANGLE_MAX) {

        angle += ANGLE_STEP;

      }

    }

    // 文字が「s」の場合

    else if (ch == 's') {

      // angleが-ANGLE_MAXより大きいければANGLE_STEPだけ減らす(ハンドルを左に切る)

      if (angle > -ANGLE_MAX) {

        angle -= ANGLE_STEP;

      }

    }

    // 文字が「i」の場合

    else if (ch == 'i') {

      // モーターを止め、ハンドルを中心に戻す

      speed = 0;

      angle = 0;

    }

  }

}


// モーターを操作する

void operate_motor() {

  // speedがプラス

  if (speed > 0 ) {

    // モーターを正転させる

    digitalWrite(AIN1, HIGH);

    digitalWrite(AIN2, LOW);

  }

  // speedがマイナスの場合

  else if (speed < 0) {

    // モーターを逆転させる

    digitalWrite(AIN1, LOW);

    digitalWrite(AIN2, HIGH);

  }

  // その他の場合

  else {

    // モーターを止める

    speed = 0;

    digitalWrite(AIN1, LOW);

    digitalWrite(AIN2, LOW);

  }

  // モーターの回転速度を決める ledcWriteはアルディーノではanalogWriteに相当

  ledcWrite(LEDC_CHANNEL, 30 + 40 * abs(speed));

  // MG996Rの角度を決める

  myServo.write(90 + angle + servo_offset);

}

------------------------------------------------------------------------------------------


ラズピコは以下の通り まずdig_0でニュートラルにホーンをとりつける

あとは(+)(ー)で左右に振る!

 

from machine import PWM, Pin

import time

IN1=Pin(1,Pin.OUT)

IN2=Pin(2,Pin.OUT)

servo1 = PWM(Pin(28))

servo1.freq(50)

dig_0 = 0.0725    #0° almost 4700

dig_90 = 0.12     #90° almost 7800

dig__90 = 0.025     #-90° almost 1600

max_duty = 65025


while True:

    #servo1.duty_u16(int(max_duty*dig_90))

    servo1.duty_u16(6000)

    print("40")

    time.sleep(3)

    servo1.duty_u16(int(max_duty*dig_0))

    print("0")

    time.sleep(3)

 #servo1.duty_u16(int(max_duty*dig__90))

    servo1.duty_u16(3000)

    print("-40")

    time.sleep(3)

2023年10月6日金曜日

httpd by c, dcm-boad on micricobit

 

https://daeudaeu.com/c-http-server/

-------------------------------------------------------------------------------

dcm-driver-boad::

input.onButtonPressed(Button.A, function () {
    radio.sendString("f")
    basic.showLeds(`
        . . # . .
        . # # # .
        # . # . #
        . . # . .
        . . # . .
        `)
})
input.onButtonPressed(Button.AB, function () {
    radio.sendString("s")
    basic.showIcon(IconNames.Diamond)
})
radio.onReceivedString(function (receivedString) {
    basic.showString(receivedString)
    if (receivedString == "f") {
        basic.showLeds(`
            . . # . .
            . # # # .
            # . # . #
            . . # . .
            . . # . .
            `)
        pins.analogWritePin(AnalogPin.P1, 602)
        pins.digitalWritePin(DigitalPin.P13, 1)
        pins.digitalWritePin(DigitalPin.P12, 0)
    }
    if (receivedString == "b") {
        basic.showLeds(`
            . . # . .
            . . # . .
            # . # . #
            . # # # .
            . . # . .
            `)
        pins.analogWritePin(AnalogPin.P1, 543)
        pins.digitalWritePin(DigitalPin.P13, 0)
        pins.digitalWritePin(DigitalPin.P12, 1)
    }
    if (receivedString == "s") {
        basic.showIcon(IconNames.Diamond)
        pins.analogWritePin(AnalogPin.P1, 576)
        pins.digitalWritePin(DigitalPin.P13, 1)
        pins.digitalWritePin(DigitalPin.P12, 1)
    }
})
input.onButtonPressed(Button.B, function () {
    radio.sendString("b")
    basic.showLeds(`
        . . # . .
        . . # . .
        # . # . #
        . # # # .
        . . # . .
        `)
})
radio.setGroup(132)
basic.showIcon(IconNames.Heart)
pins.digitalWritePin(DigitalPin.P14, 1)
basic.forever(function () {
    
})

2023年9月9日土曜日

VNC/SSH on raspi4,3,0,scratch1.4 / micropython pedia

 ラズパイ4ではssh/vncサーバをダウンしておく! キーボードレスでうごかすラズパイ3子艦ではvnc/sshサーバをオンに これでラズパイ4からクライアントビューワでラズパイ3を操作

まずssh pi@raspberrypi.localで接続してifonfigでラズパイ3のipを確認、あとはvnc viewerで、そのipで接続できる ラズパイ4で完動したファイル群をラズパイ3にうつし実行する

この際、単体駆動するためラズパイ3はバッテリ駆動とする dc/servoはそれぞれ電池ボックス駆動とする 
問題はラズパイ3駆動のバッテリ要件で.25A以上となっており、4では3A以上
手持ちのバッテリは100均の500円のやつが1A、コンビニでかった大容量のバッテリは.24Aだったが、
かろうじてラズパイ3はうごいた ちなみに3Aが出るバッテリは5000円と非常に高価
手持ちの大容量バッテリは2000円台 
-------------scratcj1.4 memo -------------------------------------------------------------------------------------------

PIR and LED on srcratch1

led/dcmotor on scratch1 (dcmotorはgpioピンを2個つかう、あたりまえだが)

servomotor on scratch1

switch and led on scratch1

-----------------------------------micropython esp32 and pico/w----------------------------------------------------------

https://tech-and-investment.com/raspberrypi-picow-12-servo/ 
ssd1306.pyはOK i2c(0)はimport machine,machine.i2c(0)でsda:19,scl:18だった

2023年9月3日日曜日

DRV8833 まとめ

 gnd    bout1    bout2    aout1     aout2     gnd      nc       vm


                                                ■■ □

                                                ■■ □


gnd    nocon    bin1        bin2      stby      ain1     ain2     nc


----------------------------------------------------------

VMとGND(上段)はモータ電源に、GNDとSTBYはマイコンのグランドと3Vに

https://coskxlabsite.stars.ne.jp/html/for_students/M5Stack/MotorDrivingDemo4/MotorDrivingDemo4.html に詳しい

2023年8月7日月曜日

obniz block prgrm :: os update,webhook,servo,dcm cf html/scrn-shot


webhook,10min,button-on,power-on をセットしてみた
---------------------------------------------------------------


なんか調子わるかったらOS更新でなおす

https://docs.obniz.com/ja/reference/cloud/device-management/remote-os-update-ota

----------------------------------------------------------------------------------------------------------

#obniz のブロックプログラムで作った仕組みを外部からの Webhook をトリガーにして動かす(アプリのインストールを利用) - Qiita

webhookでアプリ実行 ブロックプログラムから別のアプリをよぶにもつかえそう

------------------------------------------------------------------------------------------

html形式は以下のとおり

<html lang="en">

  <head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

    <script

      src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"

      integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"

      integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"

      crossorigin="anonymous"

    ></script>


    <link

      rel="stylesheet"

      href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"

    />

  </head>

  <body>

    <h3 id="bploading" style="text-align:center;">LOADING...</h3>

    <div id="OBNIZ_OUTPUT"></div>

    <br />

    

    <script

      src="https://unpkg.com/obniz@latest/obniz.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/iothome/index.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/airobot/index.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ui/index.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/howler2.1.2/howler.js"

      crossorigin="anonymous"

    ></script>

    

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/opencv3.4/opencv.js"

      crossorigin="anonymous"

    ></script>

    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.3.0"></script>

    <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet@2.1.0"></script>

    <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/posenet@2.2.2"></script>

    

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/clmtrackr/clmtrackr.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/clmtrackr/emotion_classifier.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/clmtrackr/emotionmodel.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/clmtrackr/model_pca_20_svm.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/ai/index.js"

      crossorigin="anonymous"

    ></script>

    <script

      src="https://unpkg.com/obniz-parts-kits@0.16.0/storage/index.js"

      crossorigin="anonymous"

    ></script>


    

    <script>

        $("#bploading").text("RUNNING...");

        (async function(){

  var obniz, button, button2, button3, button4, button5, servomotor, dcmotor;

  

  

  obniz = new Obniz('4998-4317');

  await obniz.connectWait();

  button = new ObnizUI.Button('forward');

  button2 = new ObnizUI.Button('back');

  button3 = new ObnizUI.Button('45');

  button4 = new ObnizUI.Button('90');

  button5 = new ObnizUI.Button('135');

  servomotor = obniz.wired("ServoMotor",{"signal":2, "vcc":1, "gnd":0});

  dcmotor = obniz.wired("DCMotor",{"forward":7, "back":11});

  servomotor.angle(90);

  while (true) {

  await ObnizUI.Util.wait(0);

    if (button.isClicked()) {

      dcmotor.move(true);

      await obniz.wait(600);

      dcmotor.stop();

    } else {

      if (button2.isClicked()) {

        dcmotor.move(false);

        await obniz.wait(600);

        dcmotor.stop();

      } else {

        if (button3.isClicked()) {

          servomotor.angle(45);

        } else {

          if (button4.isClicked()) {

            servomotor.angle(90);

          } else {

            if (button5.isClicked()) {

              servomotor.angle(135);

            }

          }

        }

      }

    }

  }

  

})();

    

    </script>

  </body>

</html>


obnizでブロックプログラムをxml保存してもシステムがかわるとうごかん

よってスクショをのせておく イフが入れ子になっていくのがコツだった

サーボモータで角度設定したあと休止を入れると過電流となりシステムダウンした!

DCモータでは動きっぱなしにするとこれまた過電流になるげな。。。。