DCC++ EX Arduino Mega + FunduMoto Motor Shield issue

grbba May 14, 2020

  1. grbba

    grbba TrainBoard Member

    13
    3
    4
    Hello,

    I am a bit at a loss now with my setup as of Diagnostics mode the programming part should work as the two LED's are flashing but the main track LED's aren't lighting up/flashing at all either when sending <1> and afterwards a <D>.

    The motor shield is this one : https://protosupplies.com/product/l298p-motor-driver-shield/ and the site has some decent description with a test sketch.

    I loaded the sketch from the above site and tested both motors which work properly so the shield should be ok.

    The shield is installed on top of a Arduino Mega, the Mega and the shield having each its own DC power in and the link downwards to the Mega is disabled.

    I did look up everything and "think" that the original Arduino motor shield and this one should be pin compatible. I say 'think' because as i can't get any LED's flashing on the motor shield for the main track so there must be some pin issues i guess.

    I put a wire between pins 2 and 13 as outlined for having a Motor shield on top of the Mega and if i pull the wire the flashing actually stops so the LED's blinking are for the Programming track and the main shows no sign.

    If you have any ideas what i do wrong or how o test further i would be grateful.

    //

    Edit: Since i posted this first I loaded BaseStation Classic to see what happens and its the same behavior.
     
    Last edited: May 14, 2020
  2. grbba

    grbba TrainBoard Member

    13
    3
    4
    Again me,

    as I couldn't let go I finally got it working by changing in DCCpp.h SIGNAL_ENABLE_PIN_MAIN ( i tested this in the classic version )

    ...
    #if MOTOR_SHIELD_TYPE == 0

    #define MOTOR_SHIELD_NAME "ARDUINO MOTOR SHIELD"

    #define SIGNAL_ENABLE_PIN_MAIN was 3 now 10
    #define SIGNAL_ENABLE_PIN_PROG 11

    #define CURRENT_MONITOR_PIN_MAIN A0
    #define CURRENT_MONITOR_PIN_PROG A1

    #define DIRECTION_MOTOR_CHANNEL_PIN_A 12
    #define DIRECTION_MOTOR_CHANNEL_PIN_B 13
    ...

    now all LED's are flashing in Diagnostic Mode as they should :)

    I will refrain from posting until I really have no ideas anymore what to test and try out. It should have been obvious from the doc on the shield above where the PWM pins given are 10 and 11!
     
    Atani likes this.
  3. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    you will need a jumper between 2 and 13 and 3 and 10. Be sure to remove the "OPT" jumper so the voltage on the shield does not get fed to the Mega as well.

    I'm not certain this is usable though since it does not expose the current sense pins of the L298 chip.
     
  4. grbba

    grbba TrainBoard Member

    13
    3
    4
    Thanks a lot for the reply and indeed i didn't check if the board has actually A0 and A1 as outputs :( my fault.

    Actually I am waiting for two of the LMD18200t motor drivers ordered from China since a while to do the Locoduino build. But as this takes a long time and looking at the current situation I have no idea if they will ever arrive ... So I ordered this one quite cheap to try things out a bit more. Maybe it will do something ...

    The OPT jumper has been removed indeed.

    Two more questions though.

    1) I have to put a jumper between 3 and 10 in addition to my code change or leave the SIGNAL_ENABLE_PIN_MAIN at 3 as before ?
    2) Second Can I add, just like in the locoduino build a current sensor and hook this up to A0 ? Something like the ACS712 5A ?

    Thanks a lot
    //
     
  5. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    The jumper will only be needed if you do not make the code change you have made.

    It should work for temporary usage but I wouldn't recommend it on the layout as the only place to put the ACS712 that will reliably detect current draw will be on the motor supply input to the shield which would be for both A and B outputs. So you will only be able to detect the current sense for both outputs and either the MAIN or PROG track will not have current sense support.

    Now, you could add current sense to the board itself if you are willing to modify the shield. The modifications would involve the L298 pins 2 and 19 (sense pins) adding a resistor and wire to A0/A1. It is not going to be an easy mod on the shield but would avoid the need for having the ACS712 cover both A and B outputs.
     
  6. grbba

    grbba TrainBoard Member

    13
    3
    4
    Hello, thanks for the reply

    ok understood

    So i may try this for the time being just to see as i don't need main and programming at the same time for now

    That is something i would like to try :) what resistor in Ohms i would have to pop in ?. One for each pin between 2 and A0and one between 19 and A1 i assume.


    So far i just tried it with my 80's loco which i equipped with a LENZ Standard V2 decoder and when reading CV from JRMI the motor makes some small moves but i end u with an error 308 in JRMI and a -1 in the serial console of JRMI. My assumption is that this id due to the lack of current sensing.

    //
     
  7. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    Yes, I would suggest a very low ohm resistor, the Arduino motor shield uses 0R15. I used the same on my PCB, I forget if it is a 1/4W or 1/2W. I would err on the higher side on the wattage.

    The circuit would be something like 2 -> A0 and 2 -> GND. The wire to A0 would be connected where pin 2 and the R are soldered. Similarly for pin 19 and A1.

    Yup, no current sense input from the h-bridge will result in a failed read.
     
  8. grbba

    grbba TrainBoard Member

    13
    3
    4
    Hello,

    I got finally hold of the ACS712 for measuring current and hooked it up to the mega/fun dû moto combo but send the measurement to an uno to see what’s happening. Trying to read a CV triggers the loco and I get reads from 300 up to 800mA when the loco reacts. ( 16v are fed into the fundumoto as I am on H0 scale ).

    So the question is now where in the DCC EX code base do I have to make the adaptations of any for the ACS712 ? The values I get are calculated taking into consideration that the ACS712 has 0 at 2.5v and I do some calibration first to get rid of the noise as much as I can.

    Thanks for your help
    //


    Envoyé de mon iPhone en utilisant Tapatalk
     
  9. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    DCC++EX will need a couple areas to be tweaked...

    you will need to add another define for ACS712 in this section and adjust the ack point here.
     
  10. grbba

    grbba TrainBoard Member

    13
    3
    4
    Just an update on my efforts to figure out what is going on with this shield.

    As I couldn’t get anywhere I ordered an original Arduino motor shield to get a reference system working to be sure that all other components are ok. So yes this is all ok now including the loco I added a DCC decoder. This way I figured out that actually pin A1 on my Mega is defunct... and had to remap A1 to A2.

    By further investigating the ACS712 I found out that the noise level is more or less 150mA all the time but by adding a 470nF capacitor I should be able to get this down to about 30mA at the cost of lower frequency of measurements ( somewhere at 1 or 2 / mSec ). Once that one has arrived and soldered on I will test again.

    If that doesn’t work I will then start hacking the motor shield.
    All have a nice day


    Envoyé de mon iPhone en utilisant Tapatalk
     
    FlightRisk likes this.
  11. Venari

    Venari New Member

    3
    0
    1
    How far have you got? :)

    I've just received a pair of the FunduMoto motor shields to go with some cheap MEGA2560s. I do want the current sense to work, so I'm considering the resistor hack...

    OK, so I'm not the most experienced in electronics, but I do like to confirm my sources. I'm not sure it's as simple as this.

    https://www.arduino.cc/en/uploads/Main/arduino_MotorShield_Rev3-schematic.pdf

    The R3 schematic shows the resistor from pin2, that going to ground, and then pin 2 going though an opamp circuit (see bottom right) before going to A0 (or SNS0).

    Also, a close look at the FunduMoto confirms that pin 2 and pin 19 are grounded (to the same track as pins 1 and 20) so you'd have to unsolder the leg from the board and lift it.

    It ain't rocket science, I guess, but it looks like a bit more surgery than first thought to get it to have the same function as the Arduino design.
     
    Last edited: Jul 28, 2020
  12. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    Not quite. The resistor (1/2W or higher!) will go between the L298 pin and GND and add a jumper from the same pin to A0 or A1.
     
  13. Venari

    Venari New Member

    3
    0
    1
    Thank you @Atani , looks like you caught my earlier edit. Yes, I understand what you've suggested, and it matches the Arduino Motor Shield... but the opamp circuits included in the R3 Motor Shield appear to ramp up the voltage by 11, which suggests it could be putting 22v onto the analog pins (which doesn't seem right.)

    Your further study and advice much appreciated!
     
  14. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    You might be right on that, I haven't used the Fundomoto shields and instead opted for ones that offered the correct analog signals by default...
     
  15. Venari

    Venari New Member

    3
    0
    1
    Very sensible. :D I've just ordered a pukka Arduino R3 Motor Shield. My knock-off Mega tests AOK using Gregg's advice, so I shall wait until Friday to play trains!
     

Share This Page