Dec 10, 2017
Downgraded to Arduinojson 5.13.3 and it now compiles OK!
So now onto the next hurdle..I have a keyestudio uno motor shield based on 298 chips with no current sense outputs..but i do have a couple of hall effect 30 amp current sensors from my rc modelling activities.
Where do you set the voltage corresponding to the current limit in the software?
I was thinking of a simple resistor and schottky diode 3.3v clamp to limit the input voltage and avoid blowing the socks off the esp32
Sent from my CLT-L29 using Tapatalk
The Arduino reference says there is a 10 bit A/D converter and it accepts 0 .. 5V input (-> 5V = value 1024).
To change to conversion back to real Amps I would adapt the routine CurrentMonitor::check() in CurrentMonitor.cpp . I guess the current limit is defined in MilliAmps in CurrentMonitor.h.
Hope this helps, can't check it myself ...
So the DCC++ controller is still running on an UNO or MEGA but communication is via ESP8288, right? I thought I could get rid of the UNO (PCB too big, insufficient resource) and run the controller code directly on a WEMOS D1.... which currently sits on my desk with a nice OLED display on. Need to check the code again ... or wait for the ESP32s to arrive.
Unfortunately that doesn't apply to the ESP32. The ESP32 has a pair of 12 bit ADCs as well, there is no CurrentMonitor.cpp/h files on the ESP32 as well.
The diode is not required as the L298 logic should be fed by the 5V or 3.3V pins on the ESP32 which is tolerant to both voltages on the analog input pins. The resistor though is going to be needed, check this post for a diagram showing how to wire this up. You will need to add this on pins #1 and #15 to utilize both channels on the L298 circuit. In addition to current sense a transistor is needed to split the signal from simply HIGH/LOW to HIGH/LOW and LOW/HIGH (inverted) for the IN1/IN2 pins. You can refer to the post linked above, specifically the RED board at the top and the transistor to the right of it.
In Config.h set the board type as ARDUINO_SHIELD and it will be automatically current limited to 2A per channel. This is the same chip as the Arduino shields but in a different packaging.
Unfortunately yes, the UNO/Mega provides the necessary hardware timers to generate the DCC signal to the track. The ESP8266 would only be able to generate one DCC signal as it has only one hardware timer and also has only one analog input. The majority of the ESP8266 boards on the market also do not expose enough pins as well, the WeMos D1 Mini is a great board and has a lot of potential for use since it does expose a few extra pins but is still unfortunately limited in scope due to analog input support. I have one of the WeMos D1 Mini boards, triple base and OLED shield sitting on my desk looking for a purpose still. They were part of my ESP8266/Mega solution that I was working on prior to moving over to the ESP32 as I was wanting to reduce the amount of electronics required for my setup.
Thanks for that ...I've looked at how the uno motor shield does it and also Dave Bodnar's design..which seems to have been copied from a very early arduino shield..got some 74hc00 ics so going to go that route
Thanks for your help
I'm having problems similar to several posts in this thread and have attempted to read most of it. I hope you'll forgive me if this is obvious and already answered but...
I'm attempting to use a HiLetGo ESP-WROOM Dev Board (see https://www.amazon.co.uk/HiLetgo-ES...?ie=UTF8&qid=1542920167&sr=8-9&keywords=esp32) to a standard Arduino Rev 3 Motor Shield. I think I've got all the connectors as required. The 5V link on the Motor Shield is cut; the Brake link is not (but nothing is connected to those pins on the board, so I've read this should be ok?)
The main problem is the motor keeps cutting out after random periods of time and restarting. If using the Serial Monitor on the iMac supplying the ESP's 3V power over USB, I often see the Overcurrent cleared message. Switching to an external 3V input, I see on the web page, <p2 PROG> then <p1 PROG> at the start and end of the power loss.
I've tried various different USB cables. (When I rigged up a Mega256/Motor Shield system some months ago, I found one USB cable was often giving Brown Outs... is this similar?)
Any thoughts, please?
2 minor questions: (a) What is the Disconnect toggle for on the main web page? (b)The speedometer dial often seems to be out of step with the value from the speed slider (and also sometimes briefly jerks to a random point and immediately switches back again, without any equivalent jerk in the <T> tracing values.) Does this indicate another problem?
Many thanks, Atani, for all the work you have obviously put into this. I'm really looking forward to getting my setup working without a glitch!
I think I've overcome the problem mentioned below, but don't know whether what I've done is correct or safe. Can someone advise please?
After reading earlier parts of this thread, I altered line 103 in MotorBoard.cpp to set the 3rd parameter (triggerMilliAmps) to 1500 rather than 980. The motor no longer cuts out. It's probably relevant that I'm running a G-Gauge loco which I assume is drawing more current than a typical HO or N gauge engine.
Is it safe to push the triggerMilliAmps up this high or am I likely to blow something? (As you can guess, I'm not particularly knowledgeable on electronics, just an ex-programmer experimenting now that I've retired...)
It should be safe to push to nearly 2000 as the Arduino motor boards can handle 2A per challenge from what I have seen. Other boards can go higher still.
You may want to consider an external booster if you are already approaching 1A, especially if that is on MAIN. The PROG track shouldn't ever use more than about 500mA IIRC from the NMRA specs. (I'll double check later).
As for the brake pin, it is probably fine to leave it in tact but if you experience any issues I'd suggest cut it.
The disconnect toggle on the webpage is to disconnect the connection from the browser to the base station. The speed dial and slider are a major pain and one if the reasons that the web interface got an overhaul as part of the development branch. As soon as I have a few bugs fixed and features stabilized a new release will be pushed out (lots of new features in addition to the new web interface).
Sent from my ONEPLUS A5010 using Tapatalk
Thanks for the prompt reply, Atani.
Can you also help me with my understanding of the impact of Outputs? I've previously rigged up an ESP32 to drive the 5 turnouts on my small layout, through my own simple web page where throwing a turnout causes a servo to slowly move it (through a coding loop and direct wiring from the ESP32 to the turnout servos). I'm not putting any DCC signal onto the rails and therefore don't need a decoder by each turnout. If I were to add each turnout as an Output on your system and extend the Outputs.cpp code to check for "throws" of these specific Outputs, such that I then move the servos in the same slow way, would this interfere with how the ESP32 is constantly pushing DCC throttle commands onto the rails?
[Low / No priority questions: Just out of interest, I had a quick look at the Development branch. Do the connections between the ESP Dev Board and Arduino Motor Shield need to change at all? And how does/will the throttle screen work when if I want to switch between several locos? I seemed to have to replace the one registered loco with another from scratch, but not be able to register several locos and easily switch from one to another?]
I can't think of any reason it should cause problems as long as the updates do not involve calls to functions like "delay()". The loop() function is used in the base station currently to time out events for various loco update packets (roughly every ~50ms) and polling inputs (S88 has very specific timing requirements).
I'm looking at another update soon that may remove some of the timing requirements for the loop() function as well, in fact doing away with it entirely! I'll share more on that later after I get it stable.
No changes in pins required. The majority of the changes are stability and functional changes at this point. Some new features are present but not stable and will not make the next release.
You would click on the "Acquire Locomotive" button and select a locomotive, the existing ones should remain active until you click on the "Release Locomotive" button. The list of locomotives that will show up in the popup are created via the locomotive roster (base station -> roster). In some cases the roster can be populated automatically via the programming track (still working on stability of this piece!) via the Identify function.
I've now managed to compile and run the software on my ESP32 (WEMOS LOLIN32 V1.0.0) . Besides of little issues in finding the correct libraries for the Arduino IDE the main problem was the CPU continuously resetting. Reason was the Brownout Detection that triggered in the moment WIFI was configured. Now I'm switching the detection off at the beginning of startup() and on again at the end. Now it runs !
The ESP32-Base-Station links in to my network and I can connect with a Web browser. Nice! The new problem I face is lots of <T....> commands reported when changing the loco speed (together with the <t...> commands that I am expecting to see. Did you ever observe similar behaviour?
I also made trials with Telenet connecting on port 2560: Sent our some <T ...> commands to define switches, but <T> reports only one switch definition back. I'll do some futher tests - at the time being I think this is not an issue...
The difference to the "original" Base-station I found so far is that the new version doesn't accept <Txx ....x> commands without a blank following the T.
Because I'm running RocRail to control my layout I'll have to check which syntax the interface sends and maybe adapt.
Looing forward your next release that you mention in the reply above
Which libraries were you having issues with? The only one I know of is ArduinoJson which the beta versions don't work with the web server (or other components for that matter).
This is typically a sign of a bad USB cable that is unable to provide the necessary power for the board to run WiFi.
<T...> is the response to <t...> so this is expected. If you are using the web based throttle the speed increments can cause a lot of these to be sent.
Double check in the web interface on the base station -> turnouts tab. It should show all turnouts that have been defined. Make sure to set unique IDs for each turnout otherwise it will update the existing one with the same ID.
Yes, this is a known difference and in all cases so far this hasn't been an issue, even JMRI has always sent <T XXXX> (same for any command really). Adding support for <TXXXX XXXX> can be done but hasn't been a huge priority. Feel free to open a tracking issue here so it doesn't get lost..
Just wanted to drop in and say I'm back at it again. Got a second loco wired for DCC and operating on my test track now, so it's time for the real fun to begin... Is S88 working ok on this project (not sure I ever saw if anyone has tested it yet)? My next step is getting some sensors on my test track to convey the positions of both locos and try to make them run together around the loop without hitting each other.
I'm also curious about the state of the built-in web page? Any updates for smaller screens yet? And what was required to change the loco numbers under the throttle? I think my current code may be too old for this feature.
S88 works quite well from what @NormHal has reported.
Take a look at the latest on the development branch, the entire UI has been changed and built with mobile devices in mind. There are a few features that are still needing some work but it is getting closer.
Awesome, thanks! I need to put together an arduino for S88 and get started testing different types of sensors then.
One issue with the development code... what's this Nextion library it is asking for, and is there a flag somewhere that I can disable it since I obviously don't have that hardware?
Comment it out in platformio.ini and don't enable the options in config.h. it isn't perfect with the custom libraries, something I'll be working on a bit more before releasing the next version
Sent from my ONEPLUS A5010 using Tapatalk
I'm not actually using platformio, I use the arduino IDE to compile from, and the include lines for NextionInterface.h seem to be scattered throughout the code. I thought commenting the include in DCCppESP32.cpp might suppress it, but apparently not.
Hmm, I'll check today and see if I can mask those includes. In the meantime you might be able to pull the NeoNextion library from my GitHub and it should work. The only references should be in DCCppESP32.cpp/h and NextionInterface.cpp/h files.
Sent from my ONEPLUS A5010 using Tapatalk