ESP32 Command Station

Atani Dec 10, 2017

  1. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    Don't know why I didn't think of this sooner, but since the ESP is plugged into my Pi through the USB port, I loaded up python so I can remotely flash new code directly from the Pi and not have to unplug everything each time. That'll make life easier... :)

    OK so it looks like the math is working now. From the same bulb:
    [MotorBoard.cpp:77] check(): [MAIN] Overcurrent detected 42989.50 mA

    Now obviously my little automotive bulb isn't really pulling almost 43A, so I think some adjustment needs to be made. I believe the BTS board puts out a 0-5V signal on the current sense line, while the ESP only takes an input of 1.1V. I know adc1_config_channel_atten() exists, but not sure it can adjust far enough to work with a 5v signal? I'll poke around this morning and see what I can figure out.
     
    Scott Eric Catalano likes this.
  2. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    The bulb is acting as a short across the rails. The esp is receiving nearly 5v from the BTS board on analog. I did not notice any difference of 5v vs 1.1v. The attenuation is set currently to allow higher voltages than 1.1v and seems to be working in all cases I have tried.

    Does the bulb light up when you connect it?

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  3. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    Yeah the bulb lights up briefly, then the ESP goes into fault and shuts down track power.

    I was trying to play with resistive loads. Have a 270 ohm (confirmed with the color bands and the meter) 1/2W resistor which at 16.4v should provide about 0.061A of current draw. I used it in series with my meter, and only see about 0.006A. So I started dropping lower. Went all the way down to a 10 ohm resistor and did not see any change anywhere, and no heat in the resistor itself. I didn't think AC would act any differently to a resistor which is essentially shorted across the tracks. And I'm also somewhat uncertain about the light bulb... I thought the whole point of it was to create a high resistive load across the tracks?
     
    Scott Eric Catalano likes this.
  4. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    If you set a resistor across the rails you should see a spike in power draw. Try a 10k ohm 1/2W. That is what a typical resistance wheel set uses. It is also what most block detectors use as "occupied". Another good test is a coin placed on the rails. That should be detected as a short and the power should get cut. With a resistor though it should only show as power draw and power should remain on.

    The theory behind the auto bulb is similar to a circuit breaker and as a visual indicator of a short. The theory is the bulb will light up and draw the power away from the rails before damage can occur to the decoders. At least that is how I understand it. How are you wiring it to the rails?

    It is also highly likely that he esp is detecting the short fast than the bulb can light up. The short detection is done approximately every 250ms. This can be made to check sooner and in all actuality probably should be half that.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  5. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    Oh the bulb does flash before track power is cut. It puts out enough heat in that moment that I feel it on my hand. The wiring is just across the rails, in series with my meter so I can see how much current is drawn. And of course after it goes into fault I can see the results on the serial console. However with the resistors I never see anything on the serial output. Is there an easy change I could make in the code to continually display the current on the main track only while I'm testing through this? Or maybe just throw it up on the top line of the display instead of the version number?

    I only have a few 1/2W resistors here, but I do have a huge pile of 1/4W. Also I have that digital red/blue panel meter soldered in line withe the 16V power supply so I can see some of what is going on, but none of this shows any change on that display. I was hoping to be able to put a resistor in place, measure a known current draw with the meter, and try to compare that with what the ESP is calculating so I could see if any adjustments were needed.

    Regarding the attenuation -- the only place I see adc1_config_channel_atten used in the code is in MotorBoard.cpp, and the atten is set to zero there. Was there an update to another file that I missed which is supposed to change this for the BTS board?

    [UPDATE] I must have popped a fuse in the meter. I checked again just putting the 270 ohm resistor directly across the tracks, and yeah that draws some current! The panel meter suggests I'm pulling around 0.06A as expected, but the ESP display is reading around 2.6A, so there's definitely a problem there. Just to confirm, I am feeding both of the current sense lines from the BTS board directly in to SVP. I wonder if I should only connect one of those outputs instead of both?
     
    Last edited: Feb 4, 2018
    Scott Eric Catalano likes this.
  6. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    The oled or LCD display should have the draw displayed periodically on the bottom line. You can add code to motorboard.cpp in the check method to display it on console.

    A resistor across the rails will only show some power draw. It won't show as a short. You can pull up the webpage and go to the status page and it should show the draw every approx 20sec as it refreshes.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  7. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Your thinking is correct; A 10 ohm resistor should get very hot (or burn out!), as with 16v on the track it will need to dissipate over 25 watts. I don't think your power was on - or you burnt out the resistor.
     
    Scott Eric Catalano likes this.
  8. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    Also the attenuation is the same for all boards. The settings don't seem to alter the behavior of the esp except to set the scaling factors. We don't need or want scaling on the values.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  9. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    @Jimbo20 -- yes absolutely! Which is why it surprised me that even with such a low resistor I wasn't seeing anything. And unfortunately I just checked the meter fuses and they are both just fine, so I really don't understand why I'm not showing any draw through the meter. I tried reading from both the 650mA jack and the 10A jack, and I show nothing. But at least the 270 resistor directly on the tracks reacts like I was expecting so that's something.

    @Atani -- I know that directly shorting the tracks will register as a fault and shut down power, but now I'm trying to get a known load across the tracks to compare the actually current draw to what the ESP is measuring. In case you missed the edit on my last post, when shorting the 270 resistor across the tracks the panel meter suggests I'm pulling around 0.06A as expected (according to the red/blue panel meter), but the ESP display is reading around 2.6A, so there's definitely a problem there. Just to confirm, I am feeding both of the current sense lines from the BTS board directly in to SVP. I wonder if I should only connect one of those outputs instead of both? And the reason I wanted the current draw shown full-time on the screen for testing is that because of the rotating display it takes several seconds to get back and show the current being detected at the moment -- I was hoping for a real-time always-on display that I could add just for testing this particular setup.

    As a side note, on my greenhouse project I made a small routine that performs a horizontal scroll of information, pixel by pixel. Makes for a nice smooth display of a lot of information, but unfortunately due to limits in the ssd1306 library the text cannot be longer than 256 pixels in width. I'm looking into a solution for the length limit, but wondered if you would be interested in adding this for that bottom line of text? It works by calling the update from the main loop every 20mS, so I don't know if this would affect the DCC timing.
     
    Scott Eric Catalano likes this.
  10. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    You can modify the bottom line display to always show the current draw by breaking up the switch statement so that it always falls into the power section. Then it would update every roughly half second.

    Something does sound off somewhere as the current draw calculation is done based on what the BTS board sends as the current draw. It could be the two pins combined causing a double read but I am not certain. If you only do one pin does it change the reading?

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  11. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    Reading only from L_IS I get "Overcurrent detected 5007.57 mA". Reading only from R_IS it doesn't seem to sense anything at all. When they're both plugged in to SVP then there are no faults and it gives a reading when I put the resistor across the tracks.
     
    Scott Eric Catalano likes this.
  12. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    Ok so sounds like progress of some sort. It sounds like there is a dead short somewhere though. The resistor is not causing the short as it is no different than a decoder really.

    For your meter, you are only doing one side of the rails, right?

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  13. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    My multimeter seems to be having trouble with current so I'm not using it for now. The red/blue panel meter is wiring in line with the 16V power supply input -- I don't expect a lot of accuracy from it, but it at least shows me close enough to tell when something is happening. My test loco with the arduino is sitting on the track and pulling about 0.04A, then when I put the resistor across the tracks the panel meter goes up to 0.10A WIth a 270 ohm resistor across 16.4V I should be drawing 0.0607A, so those reading appear to be just right.

    On the other hand, what's shown on the ESP display is giving me a headache. At times it will display 0.04A, then go back to zero. When I put the resistor across the rails it usually shows between 2.5 and 2.9A, not enough to put the track into fault mode, but certainly much different than the actual reading. And there have been a couple times when the reading drops back to zero, even though the panel meter still shows 0.10A.

    Also of note, the idea to connect both of the IS outputs together came from the trainelectronics site schematics. He just connects both IS lines directly together and it seems like that worked fine for him. I have to wonder since we're flipping the output direction, is it possible one of the IS lines puts out a negative voltage? I might have to add the ssd1306 library to my bridge check program and see what specific readings I am getting from SVP.

    Doing some experiments with the greenhouse monitor as well today. This is the first time I took the ESP32 out to the greenhouse and plugged it in. Wow the wifi on these little chips is really good! My AP is in the basement, on the opposite side of the house, about 75-100 ft away from where the ESP is sitting, but I'm still getting around a -75dB signal strength and it connects and sends data within just a few seconds. So I doubt anyone will have troubles using these on their locomotives. [EDIT] Ack I had that backwards, was thinking the higher dB was stronger when it's actually weaker. The signal strength seems to hover between -70 to -80dB but it's having no trouble sending the regular data updates to the server. What's even more impressive is that when I checked on my phone, there are 18 other access points detected from that location, and yet it's still staying connected to me.
     
    Last edited: Feb 4, 2018
    Scott Eric Catalano likes this.
  14. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    OK I set up the display in my bridge test script, have it flipping the power direction once every 5 seconds, and I believe there's a problem. When I read from R_IS, I get a value when the PWM line is high, and zero when the line is low. When I connect L_IS, I expect to see values when PWM is low, but instead I always get a zero. I tried swapping wires in case I had another bad jumper, but I can't get any reading out of that side. I'm going to inspect the soldering on the bridge to see if I can spot any issues there.

    I also notices when both IS lines are connected it cuts the ADC value in half. Makes me wonder if L_IS is grounded out somewhere. On the working channel, I'm seeing a raw value in the upper 400's for 0.04A, and adding the resistor gives me values of almost 900. Considering I'm in 12-bit ADC mode with an upper limit of 4095, I still think there needs to be some scaling of the input... however I'll wait and try to get L_IS working first to see if I get the same values on both channels before I mess with the circuit.
     
    Scott Eric Catalano likes this.
  15. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    A bit more info... I pull the IS wires from the breadboard and measured their values directly to ground. For the base load of 0.04mA on the track, R_IS reads 185mV while L_IS only reads 0.54mV. And I think I found a problem on the board...

    https://s3-ap-southeast-1.amazonaws.com/a2.datacaciques.com/wm/NDAy/804967351/2499910382.JPG

    Going by that picture, all eight of the surface-mount resistors should be 103 (10k). On my board, going from the top, I have 103 103 303 303 103 103 303 303. Can anyone else with this board confirm what resistors they actually have? Also what is odd is that I cannot read the resistance of any of the 303 resistors, but all of the 103s measure within tolerance of 10k. I get the feeling someone loaded a parts tray with the wrong values...
     
    Scott Eric Catalano likes this.
  16. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    I sent off an email to the seller, and in the meantime also placed an order for a second BTS board from a different seller, which will unfortunately take 2-3 weeks to get here. In the meantime would you be interested in adding another board combination to your code? This one could be entertaining. :)

    https://www.ebay.com/itm/291966896712
    https://www.ebay.com/itm/272651205707
    The H-bridge here is an A310, and switches up to 5A of power (but without any heatsinks, I wouldn't count on it!). The separate current sensor board uses an ACS712 and is also capable of handling up to 5A. The difference is that this board measures positive and negative current, so the base zero value is approximately half of Vcc. I just hooked it up with no connections for the track current. When Vcc is 3.286v then the sense pin reads 1.588v. When Vcc is 4.80v then the sense pin rests at 2.391v. So it is just slightly under 1/2 of Vcc. Unfortunately plugging the sense pin into the ESP just gives me a flat value of 4095 at both voltages, so I'm not sure if I need to do something different here.

    If you're willing to add the code for it, I'll get it hooked up
     
    Scott Eric Catalano likes this.
  17. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    Acs712 boards work well for pure DC but require a but more work for DCC. The 12bit adc might work for it, I know the 10bit adc on Arduino is not precise enough.

    As for another motor board, sure we can add them but I will need one to test with so we can make sure it all works.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  18. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    14
    OK it was worth a shot. I actually have these boards on hand now so I wouldn't have to wait for the new BTS board to ship. Ah well I think the BTS is working well enough to actually put a signal on the track, so I'll get back building an accessory decoder while I wait for the seller response and shipment of the second board.
     
    Scott Eric Catalano likes this.
  19. Atani

    Atani TrainBoard Member

    1,470
    1,769
    37
    I also have a bunch of the acs boards. I will try and use them again but a current transformer works a bit better and with a bit less power loss.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  20. mijnmodelbaan

    mijnmodelbaan New Member

    7
    5
    4
    According to this schematics https://o.lnwfile.com/_/o/_raw/iv/cz/gu.jpg they all should be 103. But it might not be a problem as it looks like the 303's are all on the left side of the schematics and functioning as pull-down resistors for the driver. It might even be a good thing as you're drawing less current via the ESP outputs (well not you, the BTS's).
     
    Scott Eric Catalano likes this.

Share This Page