DCC++ EX Arduino Mega + FunduMoto Motor Shield issue

grbba May 14, 2020

  1. grbba

    grbba TrainBoard Member

    13
    3
    2
    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
    2
    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,103
    667
    22
    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
    2
    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,103
    667
    22
    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
    2
    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,103
    667
    22
    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
    2
    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,103
    667
    22
    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
    2
    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.

Share This Page