Photon with l293d or l293ne

Hey guys! I am working on a dual motor shield for working with the photon at my robotics club and I keep on running into issue after issue… I was wondering if I could get some ideas from you guys? I had recently built a identical shield for the arduino nano without issues, I’d really like to add in wifi functionality with the photon but im having the following issues: too much current draw with the l293D (causes the photon to restart), Since the l293D wasn’t working I decided to try the l293NE (1A per channel rather than 600ma) but I am still drawing to much current from the photon as it dramatically dims and causes flickers with the onboard RGB led. My second problem is that for some reason the standard code and wiring setup that is used with arduino doesn’t work on the photon. Normally, I hook up the In pins of the l293 into digital pins, the enable (speed control) pins of the l293 into analog pins and then connect vcc 1 and vcc 2 to the battery power source. The only time that the motors will actually spin is when the speed and or digitial pins aren’t on/connected properly.

If you need more info let me know, any help is appreciated! Thanks guys! -Seth

Here’s the code for both arduino and the photon, although pins used will change depending on device…

    #define in1 D1
    #define in2 D2
    
    #define in3 D3
    #define in4 D4
    
    #define speed0 A4
    #define speed1 A5

void setup() {
    pinMode(in1,OUTPUT);
    pinMode(in2,OUTPUT);
    
    pinMode(in3,OUTPUT);
    pinMode(in4,OUTPUT);
    
    pinMode(speed0,OUTPUT);
    pinMode(speed1,OUTPUT);
}

void loop() {
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
    digitalWrite(in3,HIGH);
    digitalWrite(in4,LOW);

    analogWrite(speed0,255);
    analogWrite(speed1,255);
    delay(2000);
    analogWrite(speed0,0);
    analogWrite(speed1,0);
    
}

Could be a few things. maybe your power supply is not up to the challenge. Or maybe there is back emf causing the onboard regulator to flutter and fluctuate. Try adding some 0.1uf and 100uf caps to the power supply and maybe have a look at diodes to clamp the emf and some 0.1uf caps on the motor itself.

Motor controllers are tricky… and the motor you select will have a massive effect too.

I have 2 little slot car style motors that look nearly identical and one works perfect and the other is just far to noisey to work. Current draw on the noisey one is half that of the one that works perfectly.

For testing you could power the photon from USB and the motors from the batteries that should help too

Did you use the same power supply when you had the system working with an Arduino nano? If so, where exactly did you connect the vcc when you were running the system with the Photon?

When you moved from the I293D to the I293NE you need to add diodes. The D comes with buitin diodes while the NE doesn't.

Maybe you could also add some schematics of your full setup.

I figured you guys may want to know, I am using the Pololu micro-metal geared 50:1 HP motors, as well as the Pololu Zumo Chassis (Tank treads…). The motors can run on 3-9v, and run with no load 6V@120mA, stall 6V@1.6A.

Here are the links.


Above are the Fritzing breadboard designs. The Voltage regulator ( 7805 - 5V ) was originally in both designs but I realised that It was not needed for the Arduino nano. The same schematic was used for the l293ne since it has the same pinout.

I am worried that the batteries may not be enough of a supply since the first pcb I made (etched) with the Nano was having supply issues (Partly since I used the 7805 and I powered the motors from the 7805’s output…). When the robot stalled, the nano would sometimes lose so much current that it would restart. That was fixed by removing the 7805 and using the batteries to directly power the l293d.

Some of you mentioned diode use, I am not to familiar with that. From the looks of my results, I think that maybe the motor driver is pulling to much current from the digital pins of the photon core. Im not totally sure though. I’m not sure if it really matters or not, but I am using the motors bi-directionally with the gpios (you may have noticed that possibility in my code).

I may have failed to say that the led dimming/photon restart only happens under motor load, when I am holding the chassis in air and letting it run it works fine, but handles terribly when load is involved (That applies for both motor drivers).

If this schematics does show all the components you're using, then I'd say you're definetly missing some caps.

Alone the 7805 wants to be cap-backed (as @Hootie81 already pointed out) and with with heavier loads I'd even got one or two nodges (min. 100µF) up on the primary side.

And as for the clamping diodes:
If you have an inductive load (a coil or a motor) the current flowing through the wire builds up a magnetic field (which drives the motor in your case), but as soon as the voltage driving the current is cut of, the magnetic field starts collapsing which in turn induces a current in opposite direction of the previous current and building up a voltage that will even exceed the originally driving voltage (this principle is for example used in ignition coils in cars to produce the voltage to produce the spark on the spark plugs).
Since the resulting voltage may by far exceed the allowed max ratings of any component in your circuit, you need to take measures to get rid of this current/voltage.
And this is usually done with a clamping diode.

If you have a look at the datasheet of your L293NE you will see where to put the diode (page 2)

Or where the L293D has got the in-built ones (page 4)

Actually the motor driver is there to decouple the motors from the digital pins. The dimming you see will most likely be due to the supply voltage dropping.
With a stall current rating of 1.6A per motor your AAAs might be a bit too weedy - even with massive caps to buffer peak loads.

1 Like

Crap, I just realised I chose the wrong battery to use in the fritzing diagram… I am actually using 4x AA batteries

ScruffR, What you do ? Use the l293D since there are built in diodes or go with the L293Ne for the potential of high stall current, and if you were to go with the l293Ne what diodes would you recommend? I am currently trying to learn electronic design but I as using The Art of Electronics (1st Edition), which is a bit old fashioned. I really appreciate the help. I am more of a coder, and trying to get this figured out has been a headache for me. I actually host a robotics club for local homeschoolers, they are new to programming (I have to teach) which can be a challenge but I think it will be easier when they actually have hardware to test with.

Also, for the 7805, should I be worried about having exact caps? I have a few .22uF and .1uFs around. I will test it, but I thought I would ask so I dont make a dumb mistake.

So It appears that the caps fixed the flickering LED. I set the RGB LED to a non-pulsing color so that I could verify that it works, and it does! I used a .22uF from input to ground and a .100nf (same as a .1uf right?) from ground to output of the 7805. The only remaining issue I seem to have is that when the system is under load it barely runs. I thought it may be the need for newer batteries but still the same lack of power. I think that the motors actually ran way faster before, but still had little load support. Maybe consider using a different battery? like a pair of li-ion packets ? (they are usually 3.7v so I think I would need to step up the voltage).

@digitalblueeye, I believe you have a supply current and voltage issue. The 7805 needs a minimum 7V input to regulate correctly. You may want to consider a buck/boost regulator for the 5V to the Photon. It will also help with voltage drop due to motor turn on.

1 Like

Nope - try not to drop the leading zero, this will show why not :wink:
0.100nF = 0.1nF and not 0.1µF, but 100nF would be 0.1µF. But I guess your .100nf were meant to be 100nF, right?
For the bigger of the caps, as said, I'd even go for a much bigger than 0.33µF.
And - as Paul said - go for juicier batteries.

And as for the diodes, there is usually no need to guess. Just make it a habit to look up the datasheets of all the components you're using (especially for the first time).
In there you'll most likely find suggestions for all the required external components too - and you'll learn a lot about the components too.
e.g. the 7V min supply which Paul pointed out for the 7805 would be mentioned in there as well.

1 Like

Okay, Will do. Despite the length and bore of reading most datasheets I have been trying to do so. Does anyone have any recommendations for bigger batteries in a similar form factor? I am going to try using a 5V step down/step up voltage regulator as peekay123 recommended. Possibly integrate it on the final PCB (I’m making them at home) so that it fits together better. Thanks guys!

My favorite parts are for remote control toys. I use a 3S battery for most of my projects with motors (11.1v) They start from $5 so it’s cheaper than buying 4x AA from the local store. The charger is a little more expensive but even then it’s not too bad.

For power regulators I use a BEC or UBEC… they are small and light and totally self contained and designed to work with radio equipment so fairly noise free.

Have you had a look at pre-made motor driver circuits? There are a few on eBay that are pretty cheap and have diodes pre-installed

1 Like

I prefer to do something custom since the form factor is so small, and the bot being used by lesser-skilled members of my robotics team, It may be harder to damage. The bot doesnt have an enclosure of any sort to in order to keep weight low

I think the biggest issue is the I need a good, portable power source that fits on the bot or has a form factor equal to or smaller than 4X AA batteries.

Lipo batteries for RC helicopters… a 2S or 3S would be perfect… designed to run 2 high power motors and enough juice to lot the helicopter off the ground for 10mins…
Something like this
http://m.banggood.com/7_4V-1200mAh-25-C-Lipo-Battery-For-Wltoys-A949-A979-RC-Car-p-921149.html

1 Like

I will be looking into those for sure!

Most are just a few mm to big. wouldnt taking two 3.7v lipo packets and connection them in series (pos to neg) work the same way? I would just have to figure out a safe way to charge them.