Loading 3D model… large boards can take a moment.
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.
No comments yet. Be the first to ask about this board.