ESP32 Command Station

Atani Dec 10, 2017

  1. John Holdsworth

    John Holdsworth TrainBoard Member

    18
    3
    5
    OK I'll try that..thanks for your help
     
  2. John Holdsworth

    John Holdsworth TrainBoard Member

    18
    3
    5
    So i installed espjidf version 4.0.2..ran a idf.py fullclean...and it worked..or at least compiled!

    Thanks for helping me...it must be a pain dealing withe great unwashed like me..but i do really appreciate your helo

    Regards JH
     
    Atani likes this.
  3. John Holdsworth

    John Holdsworth TrainBoard Member

    18
    3
    5
    sorry some typos instead of espjidf esp-idf...and less important help intead of helo..sent from my phone...so always error strewn..thanks again
     
    Atani likes this.
  4. Guywire

    Guywire New Member

    8
    1
    2
    Can you explain where the 3 W 1.5 ohm resister goes (replacing the resistors on the board, in line with the programming track?)
    Also the only other schematic I've found for using the L298N board with DCC++ showed cutting the traces for 2 of the pins and then adding resistors, although the resistors shown didn't seem to match what was described. Is that not necessary for the sensing? - image here https://www.trainboard.com/highball...ject-documentation.130401/page-2#post-1140248

    I looked on the wiki's (I found 2 different ones, and the githubs) but I'm not seeing any other schematics or images, just this one here.

    I'd also like to just use the one L298N and not use the IBT_2 for the particular layout I'm working on, and I think that would work.

    thank you


     
  5. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    The L298D boards that you typically find, which look like the one in my image, do not have current-sensing available. However the L298D itself DOES provide the option. I can only assume they didn't include it because the resistors are so large.

    Basically what you want to do is lift up the last pin on each end of the chip. It's not easy because the pins are fairly heavy, but you can do it without destroying the board or the chip if you take it slowly. In my case I was only using one side of the chip, so I lifted up the pin on the far right and made my connections to the appropriate inputs and outputs for that side. Once you have the pin lifted out of the board, solder one side of the resistor to that pin. Connect the other side of the resistor to the current sense pin on the ESP32 (SVP or SVN). You do not need to reconnect anything back to the L298D circuit board. The 3W 1.5ohm resistor value was chosen to match the maximum current available through this board (probably around 2 amps), and change it to a voltage range that was acceptable to the ESP32. Other situations would call for a different resistor value, which is probably what you were finding.

    Hope that helps?

    [Edit] Sorry, I forgot to mention... if you want to only use the L298D board to run both the prog and ops tracks, perform the same operation to both sides of the chip (the far left and far right pins). Again, once you remove the pin from the board for either side of the chip, there is no need to make any other connections or changes to the circuit board. The resistor goes between that pin and the ESP32 input, nothing else.
     
  6. Guywire

    Guywire New Member

    8
    1
    2
    Thank you for the explanation! Just to clarify, the resistor you're describing goes between the L298D pin and the current sense (blue line) on the esp32, not on the progamming track line or those other resistors shown in your image?

     
  7. Atani

    Atani TrainBoard Member

    1,337
    1,047
    28
    I thought the R was used as a divider on the output with the ESP32 input being connected to the L298 where the R is connected with the other leg of the R to GND (where the L298 pin was originally connected).
     
  8. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    Ah crap, you're right. I looked back at it a little closer and I did in fact describe it wrong!

    OK so after you lift the L298D pins off the circuit board, one leg of the resistor goes to that pin, the other leg of the resistor goes back in the hole that the leg was previously in. So the resistor is now placed between the original hole in the circuit board and the leg of the L298D.

    The wire to the sense pin of the ESP32 is connected to the lifted leg of the L298D.

    Hope that makes more sense?
     
    Atani likes this.
  9. Guywire

    Guywire New Member

    8
    1
    2
    Ok, I'm following your connections now, I'm still unclear around the extremely different values used here instead of the arduino design shown here: https://www.trainboard.com/highball...ject-documentation.130401/page-2#post-1140248 (says 1/2 W 1.5k ohm but seems to show a 10k ohm in the photo)
    but I'm not that knowledgeable about resistor calculation.

    I don't seem to have the exact right resistors lying around, maybe I'll just solder some stuff together and see what happens. I do have the right components to make the transistor circuit on the motor inputs.

     
  10. Jimbo20

    Jimbo20 TrainBoard Member

    274
    176
    10
    The suggested 1.5k and 10k resistors are way off the correct value. The track current has to pass through that resistor, so anything higher than a couple of ohms and nothing would work!

    The original motor shield uses a 0.15 ohm resistor but also has an op-amp chip to amplify the voltage across it by a factor of about 11.

    To simplify the modification to modules that don't have current sensing circuitry the op-amp can be omitted, but the resistor has to be increased in value by about 11. The nearest standard value available to 11 x 0.15 (1.65 ohms) is 1.5 ohm. The disadvantage of not using the 0.15 ohm & op amp combo is that the higher value resistor causes the track voltage to fluctuate more (maybe by 2-3 volts) with varying track current demands, however this doesn't seem to adversely affect many layouts.
     
    Guywire likes this.
  11. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    I would expect fairly similar values, so I too am uncertain why the values in that other post are so extremely different. The other post is referring to an arduino setup instead of an ESP32, so it works with 5v values instead of 3.3V, but I still wouldn't expect a difference of more than about 50%? I confirmed again that the resistors I have here are 1.5 ohm. I have 1W and 3W versions of the same resistor, but I believe Atani specified the 3W resistor to handle the amount of power being sent to the track. Also I would assume that using a 1.5K resistor would significantly reduce the amount of power available on the rails, and I'm pretty sure that a small 1/2W resistor would fry itself if you had more than one loco on the tracks. (For reference, most of the locos I'm familiar with in HO scale pull at least 1/2W each.)

    You can create your own resistor pack by soldering multiple smaller resistors together in parallel. Basically if you connect two 1K 1/4W resistors in parallel, the result will be a 500 ohm 1/2W resistor (value is halved, wattage is doubled). Ten 1.5k 1/4W resistors should give you a 1.465 ohm 2.5W arrangement.
     
    Guywire likes this.
  12. Jimbo20

    Jimbo20 TrainBoard Member

    274
    176
    10
    I afraid the math is out there!

    Ten 1.5k resistors in parallel would give you 1500/10 = 150 ohms. You would need one thousand 1.5k resistors in parallel to give you 1.5 ohms!

    Note that if a loco was drawing 2 amps, the 1.5 ohm resistor would drop 3 volts and would therefore have to sink 2x3 = 6 watts, so even a 3 watt resistor would not be sufficient if you are continuously drawing the maximum the Motor board can provide.
     
    Last edited: Dec 17, 2020
  13. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    Gah! I was thinking each additional resistor cut the value in half, but yeah you're right, it's just a simple division. I'll just stop talking now...
     
  14. Guywire

    Guywire New Member

    8
    1
    2
    I have a pack of 1W 470 ohm resistors, so I'll put 3 in series and see if that works.
    Incidentally your image shows the program track, so for that there shouldn't be much current.

     
  15. Atani

    Atani TrainBoard Member

    1,337
    1,047
    28
    PROG will be limited to around 250mA. OPS will be limited to around 1.75A.
     
  16. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    Parallel, not series! If you put them in series then they add together (470*3=1410 ohms), without increasing the wattage.

    Right, in my setup I use the L298D for the programming track where only a single loco would ever be sitting at one time, and I use the BTS board (rated up to 43W) with a 4.5A power pack for my layout.
     
  17. Jimbo20

    Jimbo20 TrainBoard Member

    274
    176
    10
    three 470 ohm resistor in parallel would give a total of 156 ohms; far too high.

    You can't have a resistance of more than a few ohms or there wont be enough current to operate a loco!
     
  18. Guywire

    Guywire New Member

    8
    1
    2
    So if you look at the arduino R3 motor driver, which is what most people seem to use for dcc++, it looks from the schematic like it's using 10k resistors on the sense lines, if I'm reading this schematic correctly. Sense goes to A0 and A1. Also it looks like they're pretty low wattage.

    https://cdn-learn.adafruit.com/asse...afruit_products_mshieldv2schem.png?1396892649


     
  19. Atani

    Atani TrainBoard Member

    1,337
    1,047
    28
    This is *NOT* an Arduino R3 motor shield... Here is the correct schematic: https://www.arduino.cc/en/uploads/Main/arduino_MotorShield_Rev3-schematic.pdf. Note that it does use 10k R on the sense line but it is part of the op-amp portion of the circuit.
     
    Jimbo20 likes this.
  20. Jimbo20

    Jimbo20 TrainBoard Member

    274
    176
    10

Share This Page