Introducing DCC++ ---a complete open-source DCC station and interface

Gregg Aug 25, 2015

  1. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave,

    Great stuff, I presume you can now see commands at the other end? Just a one wire connection should do it, same as your IR throttle. No need to up the logic voltage from the 3.3v.
    It requires stepping down though when we want stuff back on the return line i.e Arduino 5v >3.3v.

    Steve
     
    Scott Eric Catalano likes this.
  2. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave,

    This is my set up on the return serial line

    Stratergy #2: Zener diode with about 250 ohm resistor as in the description has been working best for me.

    http://jamesreubenknowles.com/level-shifting-stragety-experments-1741

    And when you need to connect the return line, create a common ground between both the ESP and Arduino. Ground the zener to that. Odd things happen if you dont.

    Steve.
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  3. DJ79

    DJ79 TrainBoard Member

    36
    25
    14
    Hey, Steve, here is an idea for you: if you look at TwinDad's code for WiThrottle protocol on the Arduino, you'll find that it isn't much more complicated than what you've done here. If I remember correctly, he has two nested switch statements instead of only one here. The difference is that it uses vanilla TCP instead of WebSockets, but I'm assuming the ESP8266 Arduino libraries can work with TCP just as easily. That way we can directly connect with WiThrottle or EngineDriver cell phone throttles (in addition to the web interface you're developing), all without needing a computer, and these are fully mature apps that support consists, turnouts, routes, and everything. Then in the next stage, if there's interest, I'd be willing to port the main DCC++ base station code to the ESP8266, so that we don't even need the separate Arduino and we can have the entire system running on a $3 chip plus a $10-$12 motor driver. Think about that!
     
    Scott Eric Catalano likes this.
  4. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    I am seeing commands on the terminal - what I don't understand is where you put in a locomotive's address (ie loco 1935) - the cab comes through but how does the controller know what loco is what cab?
    Perhaps I am missing something but when I did the wireless throttle that I built I send something like <t1 1935 44 1> -- I don't see that coming out on the terminal.
    thanks
    dave
     
    Scott Eric Catalano likes this.
  5. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    DJ79

    I like where you're coming from, and indeed after seeing your earlier post I went off to do some digging on DMA.

    Wow, I guess you know of CNLohr. If not here's the clip I came across,

    .

    This chip is mind blowing !!

    I know of Twindads efforts to port WiThrottle, and once went looking for the code, but couldn't find it that particular day. Anyway my esp's had just landed so off I went on my own journey.
    My only reservation with WiThrottle is that its an App and not cross platform albeit able to use TCP directly. So I came upon the cross platform solution when I discovered websockets. I think both technologies are worth seeing through.
    Give everyone more choice I say. And got one up on the corporations, this revolution will see some bloody noses before we're through.

    I sure admire your knowledge to take on something like porting Base Station to ESP, you're way in front of a noob like me.

    Oh, the esp does invisible TCP by default, without any programming. I did tests with a phone TCP app and the text just flows straight through on serial.

    Regards

    Steve.
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  6. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave

    There is a box above each slider for the loco address.

    Steve.
     
    Scott Eric Catalano likes this.
  7. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    The box labeled CAB # ?? I didn't think that was the loco ID - my error. I thought I tried changing that and didn't see it in the terminal - will look it over more carefully tomorrow.
    thanks
    dave
     
  8. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave

    Thats the one. Type in and hit return confirmation should appear in the console output. You can change the label in the html if you like :)

    S
     
    Scott Eric Catalano likes this.
  9. DJ79

    DJ79 TrainBoard Member

    36
    25
    14
    Steve, that video is amazing. Thanks. I've been doing programming since C64 days (and ZX Spectrum and Amstrad CPC, too -- I'm sure you're familiar with those), but this is a great time to jump right in, probably the most exciting time in computing since the 80's, if not even more. That said, my hobby time is quite limited, and I already have a Digitrax system, so I'm involved here just for the pure fun of it.
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  10. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    I thought so too.

    Another idea I played with, was porting Gregg's Controller app to mobile. It's pretty comprehensive and written in Java.
    Would need some work doing the mobile sizing thing. Possible? I don't know, I'm no coder that's for sure. There is an Andriod dev plug in for Processing now though.
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  11. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    The only coding I ever did was BASIC at school in the Seventies. I missed out on the Spectrum et al as we couldn't afford it. I can do CNC g Code though it's part of my job :)

    I agree its a very exciting time to be alive. I can find my way around a Windows machine though as I've had everything from Win 3.1

    Is this for real? More fun with phones and ESP.

     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  12. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - I think I have an idea of why I was confused - the two throttles appear to act differently to loco numbers and neither like large, 4 digit numbers.
    If I enter 12 into one and 21 into the other the first sends a 2 (<t1 2 72 0> and the second is correct (<t2 21 82 0>)
    Larger loco numbers give erroneous results, too -
    Do you observe the same thing?
    thanks!
    dave
     
    Scott Eric Catalano likes this.
  13. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dave,

    I'm on to that right now. It sounds like you found a bug that should be easy to sort.

    Bear with me

    Steve.
     
    Scott Eric Catalano likes this.
  14. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dave,

    This from post #934

    And while you're in there, I found a bug earlier. Scroll back up to the script functions section looking for this

    }

    function Cabmod1() {
    var text = document.getElementById('Cab1').value;
    var toSend = "CAB1" + text;
    connection.send(toSend);

    In your version it says "CAB" just add the 1 as above. Save and exit you're done.




    I think your problem is right there. If you're sending a text that omits the 1, then the esp will hack off the first digit of your cab #.

    This is because the program is looking for content after the first 4 characters. A simple html edit there. Hope that gets you going.

    Steve.
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  15. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    On the larger numbers thing.

    I've not done any testing. Also not sure of the format the Base Station wants to see. Maybe you could clarify.

    Steve.
     
    Scott Eric Catalano likes this.
  16. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - I made that change a few days ago but inadvertently loaded the original file.....
    In any event, I made the change but still have an issue - when I enter loco number 1234 I get <t1 210 69 0> on both throttles - not the 1234 that I would expect.
    Thoughts?

    dave
     
    Scott Eric Catalano likes this.
  17. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    OK thanks for the report, let me do a few tests.

    Steve.
     
    Scott Eric Catalano likes this.
  18. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave,

    Excellent bug find.

    And today I learned a bit more about memory.

    The problem occurs once you go over 255 so the answer is to assign more more space in EEPROM I hope.

    I'll expand the current assignments and see if that does a fix.

    Thanks.

    Steve.
     
    Scott Eric Catalano likes this.
  19. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave,

    Nope, it's a little more complex than that. Will have do a bit of an overhaul, but you're safe on values up to 255.

    Steve
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.
  20. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Silly question - Deleted
     
    Last edited: Mar 12, 2016
    Scott Eric Catalano likes this.

Share This Page