I am sure I have annoyed several people with my posts about trying to standardize the method of current sensing for a wide range of MD boards. does anybody think there is a need for it? I mean, we only need two types of current sensing. one for the program track that is sensitive to small changes to read in CV values, and one for the main track that can handle larger amounts of current from a wide range of DCC accessories. I have heard from some of you, but I was wondering what people have used that works good, and is independent of the MD board. in other words, not a feature of the MD. personally, I have tried a ACS712-30A, with no success. but that is all I have on hand right now. I have on order a 5A split core coil sensor, a 20A split core coil sensor, 15ohm 30W shunt resistors, and a pair of ACS712-5A sensors. Mainly I am browsing ebay for common sensors to experiment with. ~Travis
I am playing around with the idea of using a software gain to boost the readings from a shunt resistor. the intent is so that the current reading is closer to 1023 when full scale for the power source. so if you have a 2A MD board, and a 15ohm shunt resistor, then: (Math check please!) 2 / 15 = 0.13333333333333333333333333333333 volts on the sense tap at full scale. now, with a 10-bit ADC on the Arduino, we have 5 / 1024 = 0.0048828125 volts per ADC step. so that figures to about 27 ADC steps for full scale current. kind of weak when reporting the current used as a scale of 0 to 1023. so to figure the gain to get full scale to read as 1023, we divide 1023 by 27 and get about 38. so with the shunt resistor specified, we multiply the analogRead() result by 38, and when we draw 2 amps, the result will read 1023, and on JMRI it should report as 100%. Now the CURRENT_SAMPLE_MAX (CurrentMonitor.h) will have to be reset to a higher value, but less than 1023. am I on the right track? or have I made a math error? this is just for testing my theory, as I am not yet sure what current sensor I will use. right now I have a 8ohm resistor that I am playing with, but it produces a higher full scale voltage @ 0.25V. though it barely tickles the meter in JMRI. hence why I am playing with software gain. ~Travis
Just be careful using the Arduino at either ends of the limits it's capable of......accuracy suffers at the low and high limits, so I'd reccomend that you shoot for a voltage closer to the upper middle part of the range, say 800 out of 1023.
I found this to be interesting. https://openenergymonitor.org/emon/buildingblocks/dc-shunt the circuit shown could be built fairly easily, I think, and the shunt resistor can be changed out. there would have to be some calibration variables depending on the shunt used. could be a viable method. ~Travis
Something of interest. with the 15ohm resistor I have on order, I could still use it. if I change the analog reference voltage, as per: https://www.arduino.cc/en/Reference/AnalogReference I could set it to INTERNAL1V1, for a reference of 1.1V. that changes the low voltage precision to be far more sensitive. so, altering the math in reply #2, the full scale volts remains the same, but rather than 5/1023, we use 1.1/1023 = 0.0010752688172043010752688172043V per ADC step. so that's... Hmm, only 124 ADC steps full scale... and my 8 ohm I have would only be about 233 ADC steps for full scale. Hmm... I will keep playing with ideas. the circuit in reply #5, above is looking better and better, pending arrival of my other current sensors. ~Travis
Maybe you should try adopt this module which is used for current measuring at quadcopters: http://www.aliexpress.com/item/Cons..._1&btsid=30e27c5d-08c0-44dc-891c-5008b736a5d0
I already have the 180A version, but found that it wasn't sensitive enough. it does work happily in my 12V universal power source to monitor higher current usage though. good thought though, as it is based on a shunt resistor. I will play around with it though and see if I can boost the gain a bit. maybe it will work for the main track. ~Travis
hello Travis, how about this ? http://wiki.rocrail.net/doku.php?id=mgv93-en It's a simple reliable circuit. The outputs can be connected to an Arduino directly. http://wiki.rocrail.net/doku.php?id=schweineschnaeuzchen:arduino Don't know, if you know the software "rocrail". It's a dutch/german open-source project - supporting dcc++ ! http://wiki.rocrail.net/doku.php?id=dccpp:dccpp-en greetings from good old germany, Martin
Hello Martin, that is certainly an option for train detection, but my intent is a current sensor to monitor current usage on the main and programming tracks. this needs an analog output current sensor. though as I have said in another thread (Motor Shields, reply #256) I am now using the BTS7960 based motor drivers for both main and programming tracks. and with just a small alteration of the code, I can even read CV values on the programming track with this motor driver board. the board has built in current monitoring, and so far it works great. For train detection though, rather than current-based train detection, I am experimenting with using Hall-Effect sensors (A3144) mounted under the track, and small thin magnets mounted under the locomotive, and the last car in the train. though I still await shipment of the sensors from China. Current-based train detection is tried-and-true, and I may use it as a fall-back. as for rocrail, I have not used it, but I have downloaded it, and plan to test it out later. ~Travis
What are you guys using for re-settable short circuit protection with a base station stack? ...if anything.
Travis Can you give me some more info on your use of BTS7960 based motor driver shields for current sensing …. What are you using to see the readouts and what code changes did you have to make? …. BTW … based on your discussion in another post, I too still ride (at 79) but then again I owned several motorcycle dealerships in another lifetime Steve F
sorry for the late reply, i have been setting up my own personal web server, and it has been a little more demanding than i originally thought (dang hack attempts). I have been away from DCC++ for a while now so it may be a bit before i round up the code changes. as for readouts, i am unsure what you are referring to, unless you mean the current being used. i just used the stock JMRI current monitor. if i recall, it displays either the raw ADC output (0 to 1023), or the percentage of utilization. as for the code changes, i think the key change i can think of is that i changed: Code: #define ACK_SAMPLE_THRESHOLD 30 in PacketRegister.h (near the top) to: Code: #define ACK_SAMPLE_THRESHOLD 3 why i did this is because the maximum registered current for the BTS7960 is about 43A, where the current level the code was originally designed for is much lower. so for the code to register an ACK (for reading CVs), it has to expect a lower number. I was never happy with the way JMRI displayed current, but maybe that is a future fix. currently, my train set is carefully boxed up while i attempt to reclaim space (and my mind). As for riding my motorcycle, i "still ride" because i am not as... how can i put this, chronologically affected . but i do love my 88 Goldwing. ~Travis