5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

オムロンの透明リレー G2R-1

Posted at

店頭で見て、か、かわいい…。ということで購入。

20151010-DSC04497.jpg

リレーがどういう挙動をするか、Make: Electronics ―作ってわかる電気と電子回路の基礎 でもリレーをカッターで削って中身を取り出してみてみる、ということをしてるけど、これならカッターで取り出さなくても見れる!!!

リレーの「カチッ」という音が良い。またどれぐらいまで高速に操作できるのか試してみたら、10msぐらいなら高速にスイッチできるみたい、通常の使い方じゃ使わないだろうけど…。また 5V のコイル電圧もどれぐらいの電圧(PWM)で動くんだろうと試してみたけど、Arduino UNO の analogWrite で 230 までは動いたので、1割ぐらい低くとも動くっぽい。

↑の動画デモコード。easing 関数は AHEasing より。何かと便利な easing 関数だけど、素のままだと使い勝手悪いので、もうちょい Arduino から手軽に使いたいな(あとで書くかも)。


#include "easing.h" // AHEasing
#define OUT_PIN 3

void setup() {
  pinMode(OUT_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  Serial.println("loop");
  float s = 1000, e = 100, p;
  unsigned long t = millis(), duration = 10000;
  unsigned long dt;
  while((dt = millis() - t) < duration) {
    p = QuinticEaseOut((float)(dt) / duration);
    toggle((uint16_t)((p*(e-s))+s));
  }
  delay(3000);
}

void toggle(uint16_t wait) {
  uint16_t wait_half = wait / 2;
  Serial.println(wait);
  digitalWrite(OUT_PIN, HIGH);
  delay(wait_half);
  digitalWrite(OUT_PIN, LOW);
  delay(wait_half);
}
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?