
Controller
deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board
ControllerTHT is an open-source printed circuit board by deltaphi, from the deltaphi/RR32CanController repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board with 71 parts on 55 nets, routed with 169 tracks and 6 vias.
It is built around the 74LS367PC, CH340C and ESP32-WROOM-32, with the TJA1051T and BC547 among its other parts. Its parts include 22 resistors, 15 capacitors, 9 switches, 8 connectors and 6 ICs. It belongs with the interfaces and adapters boards and the ESP32 boards of this library.
Sketch for a Switchboard talking the Maerklin CAN protocol based on the ESP32 NodeMCU-Board.
Linux Unittest Build
Embedded Build
Windows Unittest Build
This project is built using PlatformIO. It makes use of some features that may not be easily portable to other Arduino-supported MCUs.
This project makes use of several libraries. Versioned links to those libraries are available as git submodules. Note that for seom libraries, using forks from the same source as this project may be required.
Note that the CAN driver from the lib directory must not be present when you want to compile using the ESP32-IDF driver. Otherwise, the Controller will just attempt to sit there without sending queued messages or receiving any messages transmitted on the bus.
This sketch only supports runtime-selection of CAN connection vs. WiFi connection. The WiFi connection information (SSID, Password, IP of CAN-Gateway) must be hardcoded.
To support hardcoding, a template file "_wificonfig.h" is provided. Copy the template to "wificonfig.h" and adjust the configuration information to your needs.
General: Shift + Direction Change enters the menu (cycles through menus) or leaves the menu without applying any changes.
Menu Levels:
Menuing is required to map turnout input buttons to turnouts or action lists.
TODO: Design.
Menuing is required for selecting an engine to control. This involves the following usecases:
Select locally known engine
Select locally unknown engine
Formula for acceleration curve: y = m*x + c. x is the time since the last rotation in the same direction, y is the number of actual increments to apply.
The acceleration is linear. It should be set up so that there is a cutoff at 500ms (no acceleration when increments are more than half a second apart) and that an "immediate" half rotation (e.g., within 50ms) hits the opposite end of engine velocity.
Thus, boundary conditions for an encoder with 24 increments per rotaton are: 1 Tick = m*500ms + c kMaxEngineVelocity Ticks / 12 increments = m * (50ms / 12 increments) + c
Formulas for calculating m and c:
m = (y1 - y2)/(x1 - x2) = (1 - (kMaxEngineVelocity/12))/(500 - (50/12)) = -0.16
c = y1 - m*x1 = 84.03
Menu Entries:
When in the Turnout mapping menu:
Possible extension: Use the function buttons to increase/decrease in steps of 10
This project includes a CMake project. The CMake project is purely used to run unit tests for some parts of the code on your development machine. You do not need to deal with unit tests (or the CMake project) unless you want to actively develop the software. To use the CMake project, create an out-of-tree build directoy (in-tree build will confuse the Automagic of PlatformIO). Unit testing should be possible using any C++14 capable compiler on any Desktop Operating System. It has been tested successefully using MSVC 2017 Community Edition.
There is a KiCAD PCB design included for turning this project into a handheld device. The PCB is designed for the Strapubox 2090 case.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 22 | 10k | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R1, R2, R3, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20, R21, R22 +6 |
| 10 | 10n | Capacitor_THT:C_Disc_D3.4mm_W2.1mm_P2.50mm | C1, C2, C3, C4, C5, C6, C7, C8, C9, C10 |
| 4 | PCB Screw | MountingHole:MountingHole_2.5mm_Pad_Via | H3, H4, H5, H6 |
| 2 | 100n | Capacitor_THT:C_Disc_D3.4mm_W2.1mm_P2.50mm | C11, C15 |
| 2 | BC547 | Package_TO_SOT_THT:TO-92_Inline | Q1, Q2 |
| 2 | Conn_01x02_Female | Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical | J7, J8 |
| 2 | D_Schottky | Diode_THT:D_A-405_P7.62mm_Horizontal | D1, D2 |
| 1 | 10u | Capacitor_THT:CP_Radial_D10.0mm_P5.00mm | C14 |
| 1 | 470u | Capacitor_THT:CP_Radial_D10.0mm_P5.00mm | C12 |
| 1 | 4u7 | Capacitor_THT:CP_Radial_D5.0mm_P2.50mm | C13 |
| 1 | 74LS367 | Package_DIP:DIP-16_W7.62mm_Socket | U3 |
| 1 | 8P8C | Connector_RJ:RJ45_Amphenol_54602-x08_Horizontal | J1 |
| 1 | CH340C | Package_SO:SOIC-16_3.9x9.9mm_P1.27mm | U4 |
| 1 | Case Screw | MountingHole:MountingHole_3.2mm_M3 | H1 |
| 1 | Conn_01x05_Female | Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Vertical | J6 |
| 1 | D24V10F3 | Controller:D24V10F3 | U5 |
| 1 | DOIT_ESP32_DEVKIT_V1 | Controller:ESP32-DEVKITV1 | U6 |
| 1 | ESP32-WROOM-32 | RF_Module:ESP32-WROOM-32 | U1 |
| 1 | LCD Header | Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical | J2 |
| 1 | PIN1 | Jumper:SolderJumper-3_P1.3mm_Open_Pad1.0x1.5mm_NumberLabels | JP1 |
| 1 | PIN2 | Jumper:SolderJumper-3_P1.3mm_Open_Pad1.0x1.5mm_NumberLabels | JP2 |
| 1 | Rotary_Encoder_Switch | Rotary_Encoder:RotaryEncoder_Alps_EC11E-Switch_Vertical_H20mm | SW1 |
| 1 | S88 | Connector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_Horizontal | J4 |
| 1 | SW_F0 | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW2 |
| 1 | SW_F1 | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW3 |
| 1 | SW_F2 | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW4 |
| 1 | SW_F3 | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW5 |
| 1 | SW_F4 | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW6 |
| 1 | SW_Push | Button_Switch_THT:SW_PUSH_6mm | SW9 |
| 1 | Screw_Terminal_01x05 | TerminalBlock_4Ucon:TerminalBlock_4Ucon_1x05_P3.50mm_Vertical | J5 |
| 1 | Shift | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW7 |
| 1 | Stop | Button_Switch_THT:SW_PUSH_6mm_H9.5mm | SW8 |
| 1 | TJA1051T | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U2 |
| 1 | USB_B_Micro | Connector_USB:USB_Micro-B_Molex_47346-0001 | J3 |

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board

deltaphi/RR32CanController
Sketch for a Switchboard talking the CAN CS2 protocol based on the ESP32 NodeMCU-Board



Sureshbkmr/Energy-Harvesting-Based-on-Beaden-Research-Paper
Based on Beaden Research Paper full custom PCB





71 parts, built around the 74LS367PC, CH340C, ESP32-WROOM-32 and TJA1051T. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the deltaphi/RR32CanController repository on GitHub, at the commit this page was made from: the board is Hardware/ControllerTHT/ControllerTHT.kicad_pcb and its schematic Hardware/SwitchboardSMD/SwitchboardSMD.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).