Skip to content

nygma2004/Wifi_Throttle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wifi Throttle

This project is created for my Wifi LokRemote project (https://github.com/nygma2004/Wifi_LokRemote) so I can control my locos using a physical control as opposed to a mobile phone. This project contains a ESP32 Wifi microcontroller which is communicating with the Wifi LokRemote over wifi sending direction, speed, light and sound commands over UDP messages.

First version

You can also check out my video on how I am using this trhottle for my 7 1/4" gauge ride-on-loco: Prototype

Also check the project for the main "receiver" here: https://github.com/nygma2004/Wifi_LokRemote

Main Features

  • Connects to the Wifi network (AP) generated by the LokRemote controller to control the loco from a physical throttle
  • Power supply is from a separate 5V power source via the USB port of the ESP32 (e.g. phone battery bank)
  • 1.5 inch 128x128 color OLED screen
  • Rotary Encoder for speed control
  • Ignition switch which can also be wired in parallel with a dead-man switch
  • Direction switch
  • Keypad to active light functions using buttons 1-3
  • Keypad to active sound functions using buttons 4-9
  • Vibro motor for tactile feedback
  • Acceleration and deceleration is controlled by the LokRemote controller

Version History / Upcoming Features / Known Issues

V1.0

  • Main control implemented: speed, direction control, switching lights, activating sounds
  • Mainly designed to work with LokRemote which is configured to work with SaberTooth 3x32 controller, and data feedback such as battery voltage, controller current and temperature readings.
  • Wifi connection details hardcoded in the sketch, needs to be worked on
  • Create additional screen variants

V1.1

  • New feautre: 4 screens created (switch between with A, B, C and D) to show all information / battery voltage / current draw / temperature information
  • New feature: Auto reconnect to wifi network when the connection is lost
  • Bug: headlights direction does not change the the drive direction changes (this is a bug in the receiver code)

Hardware

The throttle is build on a custom PCB that you can order from PCBWay: https://www.pcbway.com/project/shareproject/Wifi_Throttle.html. The components used was mostly purchased from Aliexpress, small components like resistors were purchased from local shop.

Communication Protocol

The Wifi Throttle send UDP messages to LokRemote every 250ms. Each packet is 5 bytes long. The Throttle sends these packets all the time regardless if the ignition switch is on or off. There is a response sent by LokRemote for each message sent by the Throttle. Since these are UDP messages delivery is no guaranteed, but as there are only 2 devices on the network, it is assumed that the loss will be minimal. If the LokRemote does not recieve a message for 2 seconds it will stop the loco.

  • Byte 0: direction byte, which is either 0 or 1 depending on the position of the Direction switch
  • Byte 1: Speed byte with value from 0 to 255. If the Ignition is switched off, the speed changes to 0
  • Byte 2: Lights: Bit7: headlights on/off, Bit6: light 3, Bit5: light 4
  • Byte 3: Sound id to be played
  • Byte 4: unused These messages are sent to the LokRemote IP address, and port which is configured in settings.h

The response from LokRemote is 10 bytes, and a reponse is sent every time a message is received from the Throttle. The time between each message is measure by the Throttle and shown on the screen. Response sturcutre is:

  • Byte 0-1: Battery voltage * 10 as a 16 bit value where byte 0 is the upper 8 bit, and byte 1 is the lower 8 bit
  • Byte 2-3: Motor 1 current * 10 (format same as battery)
  • Byte 4: Motor 1 temperature in celcius
  • Byte 5-6: Motor 2 current * 10 (format same as battery)
  • Byte 7: Motor 2 temperature in celcius

Case

First version There is a 3D printed case available for this throttle. You can see the 3D files and also the Fusion 360 link in the PCB folder of this project. First version The current design is a very early version, I will most probably have to go back and make numerous changes to make it work properly:

  • I did not have time to properly battery so it runs off a Blitzwolf BW-P3 power bank and the case is also designed for this rather big battery. I need to work on a smaller and lighter power management for this.
  • I made some design errors, the battery is on the top (front) of the controller rather at the bottom (back), the weight distribution feels a bit odd
  • There are some measurement errors, the rotary encoder is about 2-3 mm lower than the hole, therefore the hole need some filing
  • The recess for the wheel also becomes offset
  • Screen is not completely centered between the button, and also not centered within the window. In fact I had to trim the corner of the screen to clear the right switch. This is an issue which also needs fixing on the PCB.
  • Cutout for the keypad is very tight, it needed a lot of filing to fit that in place

About

Wifi Throttle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published