Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 637a81682e | |||
| 2ac69a62b0 | |||
| 90314ff2bf | |||
| 53bbb1c55c |
BIN
BOM/0004-DenshaBekutoru_v0.2 - BOM and Vendor.ods
Normal file
BIN
BOM/0004-DenshaBekutoru_v0.2 - BOM and Vendor.ods
Normal file
Binary file not shown.
1
KiCad/0004-DenshaBekutoru_v0.2/.history
Submodule
1
KiCad/0004-DenshaBekutoru_v0.2/.history
Submodule
Submodule KiCad/0004-DenshaBekutoru_v0.2/.history added at 1344bb2526
@ -1,25 +1,30 @@
|
|||||||
"Reference","Value","Datasheet","Footprint","Qty","DNP"
|
"Source:","/home/tgohle/Desktop/git/ToGo-Lab/0004-DenshaBekutoru/KiCad/0004-DenshaBekutoru_v0.2/0004-DenshaBekutoru_v0.2.kicad_sch"
|
||||||
"A1","Arduino_Pro_Mini_Socket_NoSPH_V2","https://docs.arduino.cc/retired/boards/arduino-pro-mini","arduino-library:Arduino_Pro_Mini_Socket_NoSPH_V2","1",""
|
"Date:","2026-07-29T19:17:05"
|
||||||
"C4","4.7µF","~","Capacitor_THT:CP_Axial_L10.0mm_D6.0mm_P15.00mm_Horizontal","1",""
|
"Tool:","Eeschema 10.0.5-10.0.5~ubuntu24.04.1"
|
||||||
"C5","100nF","~","Capacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mm","1",""
|
"Generator:","/usr/share/kicad/plugins/bom_csv_grouped_by_value_with_fp.py"
|
||||||
"D1,D2","1N4148","https://assets.nexperia.com/documents/data-sheet/1N4148_1N4448.pdf","Diode_THT:D_DO-35_SOD27_P7.62mm_Horizontal","2",""
|
"Component Count:","32"
|
||||||
"D3","1N5819","http://www.vishay.com/docs/88525/1n5817.pdf","Diode_THT:D_DO-41_SOD81_P10.16mm_Horizontal","1",""
|
"Ref","Qnty","Value","Cmp name","Footprint","Description","Vendor","DNP"
|
||||||
"D4","LED Green","~","LED_THT:LED_D3.0mm","1",""
|
"A1","1","Arduino_Pro_Mini_Socket_NoSPH_V2","Arduino_Pro_Mini_Socket_NoSPH_V2","arduino-library:Arduino_Pro_Mini_Socket_NoSPH_V2","Socket for Arduino Pro Mini (without Programming Header Pins)","",""
|
||||||
"D5","LED Yellow","~","LED_THT:LED_D3.0mm","1",""
|
"C4","1","4.7µF","C_Polarized","Capacitor_THT:CP_Axial_L10.0mm_D6.0mm_P15.00mm_Horizontal","Polarized capacitor","",""
|
||||||
"D10","LED: HL_A.1","","LED_THT:LED_D5.0mm_Clear","1",""
|
"C5","1","100nF","C_Small","Capacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mm","Unpolarized capacitor, small symbol","",""
|
||||||
"D11","LED: HL_A.2","","LED_THT:LED_D5.0mm_Clear","1",""
|
"D1, D2","2","1N4148","1N4148","Diode_THT:D_DO-35_SOD27_P7.62mm_Horizontal","100V 0.15A standard switching diode, DO-35","",""
|
||||||
"D12","LED: HL_B.1","","LED_THT:LED_D5.0mm_Clear","1",""
|
"D3","1","1N5819","1N5819","Diode_THT:D_DO-41_SOD81_P10.16mm_Horizontal","40V 1A Schottky Barrier Rectifier Diode, DO-41","",""
|
||||||
"D13","LED: HL_B.2","","LED_THT:LED_D5.0mm_Clear","1",""
|
"D4","1","LED Green","LED","LED_THT:LED_D3.0mm","Light emitting diode","",""
|
||||||
"J1","from Lego","~","Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical","1",""
|
"D5","1","LED Yellow","LED","LED_THT:LED_D3.0mm","Light emitting diode","",""
|
||||||
"J2","Headlight GND","~","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","1",""
|
"D10","1","LED: HL_A.1","LED","LED_THT:LED_D5.0mm_Clear","Light emitting diode","",""
|
||||||
"J3","Headlight GND; A1,2/B1,2","~","Connector_PinSocket_2.54mm:PinSocket_1x05_P2.54mm_Vertical","1",""
|
"D11","1","LED: HL_A.2","LED","LED_THT:LED_D5.0mm_Clear","Light emitting diode","",""
|
||||||
"J4","Headlight Test","~","Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Horizontal","1",""
|
"D12","1","LED: HL_B.1","LED","LED_THT:LED_D5.0mm_Clear","Light emitting diode","",""
|
||||||
"J5","I2C","~","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","1",""
|
"D13","1","LED: HL_B.2","LED","LED_THT:LED_D5.0mm_Clear","Light emitting diode","",""
|
||||||
"J6","TX/RX","~","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","1",""
|
"J1","1","from Lego","Conn_01x04_Pin","Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical","Generic connector, single row, 01x04, script generated","",""
|
||||||
"J7","Add. Lights","~","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","1",""
|
"J2","1","Headlight GND","Conn_01x04_Socket","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","Generic connector, single row, 01x04, script generated","",""
|
||||||
"J8","LDR (~1MOhm) Option","~","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","1",""
|
"J3","1","Headlight GND; A1,2/B1,2","Conn_01x05_Socket","Connector_PinSocket_2.54mm:PinSocket_1x05_P2.54mm_Vertical","Generic connector, single row, 01x05, script generated","",""
|
||||||
"R1,R2","1.5k","~","Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal","2",""
|
"J4","1","Headlight Test","Conn_01x05_Pin","Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Horizontal","Generic connector, single row, 01x05, script generated","",""
|
||||||
"R3,R4,R5,R6,R7,R8","220","~","Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal","6",""
|
"J5","1","I2C","Conn_01x03_Pin","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","Generic connector, single row, 01x03, script generated","",""
|
||||||
"R9","10k","~","Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal","1",""
|
"J6","1","TX/RX","Conn_01x03_Pin","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","Generic connector, single row, 01x03, script generated","",""
|
||||||
"RV1","1MOhm","~","Potentiometer_THT:Potentiometer_Piher_PT-10-V10_Vertical","1",""
|
"J7","1","Add. Lights","Conn_01x04_Socket","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","Generic connector, single row, 01x04, script generated","",""
|
||||||
"U1,U2","PC817","http://www.soselectronic.cz/a_info/resource/d/pc817.pdf","Package_DIP:DIP-4_W7.62mm","2",""
|
"J8","1","LDR (~1MOhm) Option","Conn_01x02_Socket","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","Generic connector, single row, 01x02, script generated","",""
|
||||||
|
"R1, R2","2","1.5k","R","Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal","Resistor","",""
|
||||||
|
"R3, R4, R5, R6, R7, R8","6","220","R","Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal","Resistor","",""
|
||||||
|
"R9","1","10k","R","Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal","Resistor","",""
|
||||||
|
"RV1","1","1MOhm","R_Potentiometer","Potentiometer_THT:Potentiometer_Piher_PT-10-V10_Vertical","Potentiometer","",""
|
||||||
|
"U1, U2","2","PC817","PC817","Package_DIP:DIP-4_W7.62mm","DC Optocoupler, Vce 35V, CTR 50-300%, DIP-4","",""
|
||||||
|
|||||||
|
Can't render this file because it has a wrong number of fields in line 6.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
|||||||
|
{"hostname":"NUC2","username":"tgohle"}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"hostname":"NUC2","username":"tgohle"}
|
||||||
96
README.md
96
README.md
@ -1,12 +1,90 @@
|
|||||||
# DenshaBekutoru - Model Train Direction Sensor
|
# 電車ベクトル (DenshaBekutoru)
|
||||||
|
|
||||||
Get **direction** and **speed** from motor power signals.
|
## Model Train Direction Sensor
|
||||||
Target use case: **model trains**.
|
|
||||||
|
|
||||||
- Detects polarity (+/–) to identify train direction
|
DenshaBekutoru is a small controller board for brick-built model locomotives.
|
||||||
- Measures pulse width to calculate speed (% of maximum)
|
|
||||||
- Implemented with optocouplers and a state machine
|
|
||||||
- As small as possible, but I hope no SMD (beginner friendly)
|
|
||||||
|
|
||||||
Project is in an early stage. Currently running tests on target hardware.
|
The target use case is: read the motor power signals, detect the current driving direction, and switch the headlights accordingly. The software is also prepared to derive speed information from the motor signal behaviour.
|
||||||
More information and documentation will follow.
|
|
||||||
|
This project is built around one practical problem: the motor is driven from an H-bridge, so the signal is noisy, polarity changes are not “clean logic”, and inductive spikes make direct evaluation difficult.
|
||||||
|
|
||||||
|
## What it does
|
||||||
|
|
||||||
|
- detects train direction from the motor power signal
|
||||||
|
- evaluates two processed motor-side signals via analogue inputs
|
||||||
|
- switches the front / rear lights according to direction
|
||||||
|
- keeps the last valid direction if the train stops or the signal becomes unclear
|
||||||
|
- is designed as small as possible for installation in brick-built locomotives
|
||||||
|
|
||||||
|
## Technical approach
|
||||||
|
|
||||||
|
The current version is built around:
|
||||||
|
|
||||||
|
- optocoupler-based input isolation and signal conditioning
|
||||||
|
- Arduino Pro Mini 5V as controller
|
||||||
|
- software averaging of analogue inputs
|
||||||
|
- startup calibration to adapt to different controllers and builds
|
||||||
|
- threshold + hysteresis logic
|
||||||
|
- simple state machine with direction memory
|
||||||
|
- PWM-capable output pins for possible later LED dimming
|
||||||
|
|
||||||
|
The main idea is not to read one raw signal and react immediately.
|
||||||
|
The idea is to turn a noisy motor signal into a stable direction decision.
|
||||||
|
|
||||||
|
## Current status
|
||||||
|
|
||||||
|
**Version 2 (beta) is built and working.**
|
||||||
|
|
||||||
|
Current state:
|
||||||
|
|
||||||
|
- [x] schematic finished
|
||||||
|
- [x] PCB finished
|
||||||
|
- [x] firmware finished for the current beta state
|
||||||
|
- [x] three PCBs built and tested
|
||||||
|
- [x] first boards handed over for real-life testing in a model railway club
|
||||||
|
- [ ] Feedback and what to improve
|
||||||
|
|
||||||
|
## Design goals
|
||||||
|
|
||||||
|
- as small as possible
|
||||||
|
- beginner-friendly where possible
|
||||||
|
- no SMD if it can reasonably be avoided
|
||||||
|
- easy to reproduce later as a DIY kit
|
||||||
|
- modular PCB concept with main section, future-option section, and test section
|
||||||
|
|
||||||
|
## Repository content
|
||||||
|
|
||||||
|
Typical content of this repository:
|
||||||
|
|
||||||
|
- `KiCad/` – schematic and PCB files
|
||||||
|
- `firmware/` – Arduino test and controller software
|
||||||
|
- documentation and pictures will be added step by step
|
||||||
|
|
||||||
|
## Project status note
|
||||||
|
|
||||||
|
This is still a beta project.
|
||||||
|
|
||||||
|
The current hardware and software already work, but testing on real locomotives is still ongoing.
|
||||||
|
The next version will depend on real-life feedback from actual use.
|
||||||
|
|
||||||
|
Possible next steps:
|
||||||
|
|
||||||
|
- verify behaviour with different motor controllers
|
||||||
|
- check robustness in real train builds
|
||||||
|
- improve wiring / connector handling
|
||||||
|
- finalise optional features like LED dimming
|
||||||
|
- prepare a first “official” DIY kit version
|
||||||
|
|
||||||
|
## Blog / documentation
|
||||||
|
|
||||||
|
- Project overview: https://togo-lab.io/?p=223
|
||||||
|
- Hardware description: https://togo-lab.io/?p=233
|
||||||
|
- Software description: https://togo-lab.io/?p=243
|
||||||
|
|
||||||
|
## Short summary
|
||||||
|
|
||||||
|
DenshaBekutoru is a small Arduino-based direction sensor for brick-built model trains.
|
||||||
|
|
||||||
|
It reads the noisy motor signal from an H-bridge-driven setup, isolates and evaluates it, and switches the headlights automatically.
|
||||||
|
|
||||||
|
The current beta version is working and now entering real-life testing.
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
#if 0
|
||||||
|
// Project-specific instructions
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user