Eugene Griffin EGRX

This BLOG contains the development of software and testing of electronics for a DIY Wi-FI engine controller. Initially a ESP8266 will be used for testing followed by the ESP32.

 

This project will initially be used to control O scale engines.

 

Working on:   https://forum.mrhmag.com/post/office-switching-layout-using-a-2018-ho-module-13636599

Holding Pattern: https://forum.mrhmag.com/post/office-switching-layout-using-two-salvaged-proto48-modules-12775340

Reply 1
Eugene Griffin EGRX

Step 1 - Initial Design

Design.jpg 

 

Direct communication from any computing device's web browser using established Wi-Fi standards.

 

This requires an onboard computer capable of controlling an engine, acting as a Wi-Fi access point and WEB Server. Based on the cost and size the ESP8266 and ESP32 MCUs will be tested as an onboard computer.

 
Reply 1
Eugene Griffin EGRX

User Interface (Initial Design)

IMG_0501.jpg  

The onboard computer will act as a WEB server as well as a Wi-Fi Access Point. 

 

After the Wi-Fi connection is established to engine’s MCU. The onboard WEB SEVER will transmit the engines control page to a web browser. 

 

The user will access the engines control page by typing " http://esp8266.local/" into web browser’s address bar. (The engine ID will replace esp8266)

 

The initial design for the engine’s control page is shown above. Key features are a throttle control (slider) that can be notched representing the 8 notches and neutral on the prototype. The throttle can also be reconfigured to be continuous value representing a speed control on traditional model throttles. A slider is also used to control reverse and forward settings.

 

Lights (FRONT, REAR, DITCH) will be controlled by buttons as shown in the middle of the screen. The BRAKE button will result in speed reduction but will not alter throttle setting. The STOP button will set the throttle to zero and lock the throttle controls.

 

Feedback

 

Every control shown on the above engine control page can be set with code residing on that page independent of the WEB server (engine). This makes this page entertaining but not informative.

 

The objective is to send values to the engine’s MCU, have the MCU control the engine based on those values and then confirm that the engine’s state has changed.

 

Part one of this feedback loop is accomplished by pressing the control and having code on the page transmit the new value to the engine’s MCU.

 

Part two is accomplished by the engine’s MCU transmitting the same setting back to the engine control page and having code on that page place the value from the engine’s MCU into the appropriate control. (circled in red on the above photo)

 

For the throttle notch setting, the feedback loads the current value that the engine’s MCU has sent.The buttons that control the lights will change color from blue as shown to yellow to indicate that the engine has received the “Light ON” command. Additionally, that STATUS area will be updated by values sent from the engine.

 

 

IMG_0504.jpg IMG_0505.jpg 

 

 

The above photo shows the result of pressing the “Front LIght” button. The engine control page sent the command via Wi-Fi to the ESP8266 MCU, the MCU activated the LED representing the light and transmitted back the value that changed the button color to yellow

 
IMG_0507.jpg IMG_0509.jpg 
 
Eugene
 
Reply 1
Eugene Griffin EGRX

Testing With Older iPhone

IMG_0522.jpg 

Connect to the Wi-Fi Access Point as generated by the engine’s MCU.

 

IMG_0526.jpg 

 

Connect to “ http://esp8266.local" engine’s control page.

 

IMG_0527.jpg 

 

Turn on a LED.

 

IMG_0529.jpg 

 

Turn on more LEDs. The Ditch lights are actually cycling from full brightness to half brightness using PWM.

 

IMG_0532.jpg 

 

Check STATUS.

 

 

Eugene

Reply 1
Eugene Griffin EGRX

Motor Control

IMG_0539.jpg 

This is the next part of the project. I will test the DRV8871 with the ESP8266.

In addition, testing will be transferred to the ESP32.

 

There is another older motor driver being shipped, that I will also test.

 

Eugene

 
Reply 1
txlarr

Very Interesting

This is very interesting. Do you expect that in the final result of your tests, the applicable MCU devices for on board locomotive control would fit within an HO loco or car assuming the breadboard wiring can be compressed without having a production type board?  Even if it can't be compressed and there wou!d be wires hanging all over a car, I think  this thread is going to be very neat to follow.  Good Luck!

Steve Gratke

Reply 1
Michael Tondee

Yes, interesting indeed

I look forward to following your progress.

Michael, A.R.S. W4HIJ

Model Rail and "mad scientist" for over 50 years.

Member of "The Amigos", Co-Inventor of the A.O.S.T.

I call what I do "An artistic impression of reality" and the Island is "lost" somewhere in the Pacific Northwest, see it here...

The Blackwater Island Logging & Mining Co.

Reply 1
Eugene Griffin EGRX

@Michael and Steve G

Thank you. I started the coding and "GOOGLE"ing on Jan 5th. I am having fun. 

Quote:

 Do you expect that in the final result of your tests, the applicable MCU devices for on board locomotive control would fit within an HO loco or car

 If I keep looking for the perfect solution, nothing will get started. So for now it is full steam ahead with O scale.

C721AC2.jpeg 

This advertiser has a HO solution using the same family of MCU. So I am encourage, but I will not be looking into it until I complete this O scale project. Once completed, if the MCU fits then it's a matter of resizing the motor controller for the smaller HO scale load.

IMG_0540.jpg 

That's (DRV8871) a 3.6A max current drive for a DC brushed motor. I am so happy it comes on a breakout board.

Eugene

 

Reply 1
Neil Erickson NeilEr

Following

Thanks Gene!

Neil Erickson, Hawai’i 

My Blogs

Reply 1
filip timmerman

Question:

Hi Eugene,

Is this a stand alone (open ?) project or is / will this fit in with NMRA standards ?

Bon courage and good luck !

Cheers, Filip

Filip

Reply 1
Eugene Griffin EGRX

Hello Neil and Flip

Quote:

Is this a stand alone (open ?) project or is / will this fit in with NMRA standards ?

The relevant NMRA electrical standards that I can see deal with DCC. I do not need to use DCC, with O scale, making this a stand alone project for now. Does that mean never, no, but at the moment I don’t have a need.

Eugene

Reply 1
Eugene Griffin EGRX

Why use the older ESP8266?

Is it bad that I am asking myself questions?

With respect to the older ESP8266, I want to see how much this older slower MCU can do before it becomes unreliable/unresponsive. This should help establish a base line so I can select physically smaller MCUs of the same family.

After adding the motor control and verifying that it works, the ESP8266 will become a throttle and all remaining engine control development will be on the ESP32s.

Eugene

Reply 1
Eugene Griffin EGRX

Commands

Keep It Simple, Flexible and for now Not as efficient as it should be.

I would like to thank all those folks involved in the IEEE and the coders that implemented the standards  for making this project easier. 

I am a little embarrassed at my wasteful use of bits but so be it.

Command for light controls shall start with a L and will then have a secondary identifier.

LD1 - Light group, ditch light on

LD0 - Light group, ditch light off

could be expanded to

LD11 or LD10 for on and flashing or On and not flashing or LDF11,LDR11 for front and rear ditch light control.

LF0, LF1 Light group front facing light on/off.

LR0, LR1 Light group rear facing light on/off.

Command for Throttle controls shall start with a T,  T### throttle setting.

Command for Braking controls shall start with a B, B### Brake setting, not sure if I need more than on/off

Command for direction controls shall start with a D, D0,D1 Direction 1 forward, 0 Reverse.

Command for configuration settings shall start with a Z.

Eugene

Reply 1
Jim at BSME

Updates

Just wondering how the project is going and is this for a dead rail (or Power on Board) application?

Also I was wondering if you have had response issues with the http server? A friend was trying to use the http server to just send messages back and forth between two ESP-32s (I believe, could have been ESP-8266s) and had regular timeout issues.

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: Facebook, Instagram
Reply 1
jeffshultz

I don't know about this project....

...but Geoff Bunza has a homebuilt wi-fi throttle that I think is based on the same chip/board. 

https://forum.mrhmag.com/post/sma30-a-simplified-wifi-throttle-you-can-customize-12211948

orange70.jpg
Jeff Shultz - MRH Technical Assistant
DCC Features Matrix        My blog index
Superintendent, 2nd Division PNR, NMRA
Northwest Oregon/Southwest Washington

Reply 1
Jim at BSME

Different concept

@Jeff, this project and Geoff's are different concepts. Geoff's project which I am also following, gives you a wi-fi throttle connected to your DCC system via JMRI's wi-throttle intreface. This project is a direct wi-fi to the receiver in the engine, no DCC involved.

If you look at the picture here:  https://forum.mrhmag.com/post/diy-wifi-engine-control-project-12211875, and here:  https://forum.mrhmag.com/post/sma30-a-simplified-wifi-throttle-you-can-customize-12211948

you will note the different concepts.

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: Facebook, Instagram
Reply 1
BruceNscale

Thoughts and Options

Hi EGRX,

I completed a similar project using IR instead of WIFI. 

Here are the options I included:

Four channel capability

Momentum on/off

Minimum speed control to reduce "dead zone" in throttle

Maximum speed control to prevent grandchildren from racing trains to the floor

Pause/resume to stop and restart all trains if the phone rings/wife calls

Emergency stop all

LED feedback to indicate command received, in progress and completed

Good luck with your project, it can be a lot of fun.

ignature.jpg 

Happy Modeling, Bruce

Reply 1
theeren
Hi Eugene, 
I am trying to do this exact thing. Is there any code available?
Reply 1
Eugene Griffin EGRX
Hi Eugene, 
I am trying to do this exact thing. Is there any code available?
Hi theeren,
 
I am on a three-month work assignment and I am nowhere near the computer that has the code for this project. When I return, I will post what I have, unfortunately, that doesn't help you at the moment. 
 
Wow, it must have been the older site, I never saw the replies to the project and it has been 5 years. My apologies.
 
 

Thoughts and Options

Hi EGRX,

I completed a similar project using IR instead of WIFI. 

Here are the options I included:

Four channel capability

Momentum on/off

Minimum speed control to reduce "dead zone" in throttle

Maximum speed control to prevent grandchildren from racing trains to the floor

Pause/resume to stop and restart all trains if the phone rings/wife calls

Emergency stop all

LED feedback to indicate command received, in progress and completed

Good luck with your project, it can be a lot of fun.

 
Thank you, it was a fun project.
 
 

Different concept

@Jeff, this project and Geoff's are different concepts. Geoff's project which I am also following, gives you a wi-fi throttle connected to your DCC system via JMRI's wi-throttle intreface. This project is a direct wi-fi to the receiver in the engine, no DCC involved.

If you look at the picture here:  https://forum.mrhmag.com/post/diy-wifi-engine-control-project-12211875, and here:  https://forum.mrhmag.com/post/sma30-a-simplified-wifi-throttle-you-can-customize-12211948

you will note the different concepts.

 
Absoultely correct.
 
 

I don't know about this project....

...but Geoff Bunza has a homebuilt wi-fi throttle that I think is based on the same chip/board. 

https://forum.mrhmag.com/post/sma30-a-simplified-wifi-throttle-you-can-customize-12211948

 
And Geoff Bunza has been a great influence.
 
 

Updates

Just wondering how the project is going and is this for a dead rail (or Power on Board) application?

Also I was wondering if you have had response issues with the http server? A friend was trying to use the http server to just send messages back and forth between two ESP-32s (I believe, could have been ESP-8266s) and had regular timeout issues.

 
This control system was developed independent of the power source.  I used the ESP-32  and also experimented with the ESP-8266, no response issues were noticed.
Reply 0
Reply