概要
micropythonでshrike-lite、やってみた。
oscilloscope 見つけたので、やってみた。
ch1にクランクパルス、ch2にカムパルスを送ってみた。
写真
サンプルコード
import utime
from machine import Pin
from sys import stdin
RESOLUTION_DEG = 5
TOTAL_DEG = 720
STEPS = TOTAL_DEG // RESOLUTION_DEG
t = 1000
step = 0
while True:
t = t + RESOLUTION_DEG
step = step + RESOLUTION_DEG
if step > 720:
step = 0
deg = step * RESOLUTION_DEG
crank_rotation_deg = deg % 360
tooth_phase = crank_rotation_deg % 30
if 330 <= crank_rotation_deg < 360:
ch1 = 0
else:
ch1 = 1 if tooth_phase >= 25 else 0
if 630 <= deg < 655:
ch2 = 1
else:
ch2 = 0
print(f"T {t} CH1 {ch1} CH2 {ch2}")
以上。
