博文

目前显示的是 四月, 2025的博文

How to drive a DC motor fan with Arduino?

图片
  This guide covers   how to control a DC motor fan   (like a cooling fan) using an Arduino , including   speed control with PWM, direction control with an H-bridge, and protection circuits . 1. Components Needed Component Purpose Arduino (Uno/Nano) Motor control logic DC Motor Fan (5V/12V) Example: 12V PC fan Transistor (TIP120, 2N2222) For small motors (≤500mA) MOSFET (IRF540N, IRLB8721) For high-current motors (≥1A) Diode (1N4007) Flyback protection Resistor (220Ω-1kΩ) Limits base/gate current Power Supply Must match motor voltage (e.g., 9V battery, 12V adapter) 2. Basic On/Off Control (No Speed Control) Circuit Diagram Arduino 5V → Motor (+) Arduino GND → Motor (-) ⚠️ Warning:  Only works for  very small motors  (≤100mA). For larger motors, use a transistor/MOSFET. 3. Using a Transistor (TIP120) for Medium Loads Wiring (NPN Transistor) Arduino Pin 9 → Resistor (1kΩ) → TIP120 Base TIP120 Collector → Motor (+) TIP120 Emitter → GND Motor (-) ...

How to run IEEE-1588 on Raspberry Pi hardware?

图片
  IEEE-1588 (Precision Time Protocol, PTP) provides sub-microsecond clock synchronization for networked devices. Here's how to implement it on Raspberry Pi : 1. Hardware Requirements Raspberry Pi 4 /5 (recommended) or Pi 3B+ Ethernet connection (PTP works best with wired networking) Optional: GPS module (for grandmaster clock functionality) 2. Software Setup Install Required Packages bash sudo apt update sudo apt install linuxptp ethtool Configure Network Interface Check your Ethernet interface name: bash ip a (typically  eth0  for wired connections) Enable hardware timestamping (if supported): bash sudo ethtool -T eth0 Look for: Hardware Transmit Timestamping: yes Hardware Receive Timestamping: yes If supported, enable PTP features: bash sudo ethtool --set-ts eth0 rx-filter ptpv2 3. Running PTP Option A: Ordinary Clock (Slave) bash sudo ptp4l -i eth0 -m -S -i : Interface -m : Print messages to stdout -S : Software timestamping (use  -H  for hardwa...