Photon not driving stepper correctly when powered via Vin, ok via USB

Hi,
I hope someone can help. I’ve a little project using my Photon to driver a stepper motor via a TB6600 stepper motor driver. Whilst the photon was powered from the PC USB port and the Stepper via an 18V 5A PSU everything worked great. I then wanted to use the single PSU to driver both the Stepper and the Photon. When I stepped the voltage down to the Photon (via multiple methods, which I’ll explain) the stepper motor no longer ran smoothly. I’m using the AccelStepper library and it just kept stopping and restarting as it tried to move.

I have tried:

With the voltage feeding into Vin on the Photon, all resulted in the same outcome, steppers not running correctly.

I checked powering the Photon via a small mains powered USB PSU and that worked fine.
I then purchased an Amazon Basics 12-24V Micro USB Car Charger. I fed the 18V into the input of the car charger and connected the MicroUSB to the Photon and it worked.

My conclusion thus far is that there is something odd going on when powering via Vin instead of the USB connection, but I don’t know what.

Whilst I can temporarily cannibalise the Car Charger PSU, the way I planned to mount the Photon in it’s enclosure it’s practical to be able to connect to the USB connection.

@martinrowan, the LM7805 requires a minimum of 2 volts above its regulated output to work. That means a minimum of 7 volts input. What voltage are you feeding it since you only mention “set with a higher voltage”?

The only difference via powering from Vin vs Vusb is that there is a protection diode between Vin and Vusb to prevent problems when you have power to both Vusb and Vin. If you feed 5V directly to Vin with a supply that can handle 500ma, then it should work.

As both the LM2596 were used ahead of the LM7805 I adjusted the input voltage until the output voltage (measured via my multi-meter) no longer increased. I did briefly check the what that was adjusted too and it was above 7V. However I was working on the assumption that the LM2596 was somehow unstable or injecting noise and so was applying extra regulation with the 7805, but it didn’t help.

The 7805 shouldn’t be needed IMHO, since the LM2596 board should be more than sufficient. I’m tempted to chop a USB cable up and connect it to the LM2596 to confirm that when the only thing different is the USB vs Vin as a the power source.

FWIW the Cheap Car charger is using a AX3050 Step-Down DC-DC Converter.

I’d read that the only difference was the protection diode, but for me that doesn’t seem to be the case as I can’t explain what I’m seeing otherwise.

EDIT: I guess one difference at the moment is that via USB the power is going via a 2m cable, vs a 10cm cable when used with any of the regulator boards.

@peekay123 I’ve just confirmed:
a) LM2596 with 2m long Micro USB cable -> Steppers work as expected
b) 12-24V Car Charger that worked with USB, when connected with 10cm wire to Vin, Steppers don’t work.

This suggests the cause is either the Photon and how it handles different power input sources, maybe different input impedance? Or that long cables are the factor here…

Any thoughts?

@martinrowan can you show a schematic of your wiring? I am trying to understand the power distribution and the grounding between the supply, the photon and the stepper.

Another thing to consider in this regard is the power quality (foremost stability and ripple - output impedance only to a lesser degree) of your car charger.
Charging battery driven devices and directly driving a microcontroler (with noisy loads) are two kettle of fish.


@peekay123 Here is a quick diagram of how things are connected. The input power is split at the barrel jack, feeding the TB6600 then on the various DC-DC buck converter boards I’ve tried.

@ScruffR I understand ripple/noise can be an issue, which is why I first started by adding a second stage 7805 circuit after the buck converter in the hope that with some additional filtering around the linear regulator it might fix things and point me in the right direction. The fact that the AX3050 car charger worked with USB cable but not when connected direct to Vin via a short cable and the LM2596 that didn’t work with Vin but does when using the 2m long USB cable, suggests to me this isn’t about noise as longer cables would likely have more noise.

Is this on the 5V rails meant to be a cap or a diode?
If it’s a diode, what is it for? Short the DC-DC converter when connected the wrong way round?
If it’s a cap the negative side should be on GND.

I’d add a few caps (47µF, 100nF & 10nF) on the rails.

1 Like

Have you tried this circuit without the diode?

@ScruffR Yes it was a polarity protection diode for when I had connectors on the board that weren’t polarised. They are now. So could be removed. @armor Yes I’ve tried without the diode, didn’t make a difference.

I’ll try some filtering caps on the input power rails tonight (UK). I’ll also try with a shorter USB cable to see if length is some how a factor, or not.

1 Like

I had this with a electronic lock driver board - it worked fine when I opened 1 lock and 2 locks but then the 3rd lock didn’t work. It turned out there was insufficient power (current) when driving the locks and it sounds like when you start driving the stepper motors you get the same issue. The solution in my case was to buy a laptop charger type PSU which had sufficient power and some very big capacitors inside it. If your AC to 18V 5A supply works OK when just powering the stepper motors then why not have a AC:DC 5V supply just for the Photon? I have used PCB mounted Meanwell or XP Power packaged converters - they work fine.

1 Like

@armor The max current draw with both steppers running or halted is ~1A so there is plenty of headroom to be able to power the Photon from the single PSU. I’ve monitored voltage levels both at 18V and the 5V connections and don’t see any drop in voltage associated with drawing excess current from the PSU.
Sure I could use 2 x AC connections, but that’s not ideal and shouldn’t be necessary. Since all that would be doing is moving the 5V PSU from inside the project to a wall mounted PSU.
As I’ve demonstrated the 18VDC PSU with the 5V via the car charger microusb PSU and USB cable works.

So the problem remains driving this project via Vin rather than the actual power supplies themselves.

Sorry disagree - the problem is not driving a Photon via Vin - it is what you are feeding into Vin. It might also be the interaction of an inductive load like the stepper motor with your DC PSU. The quality of the Amazon basics AC:DC converter? Hence, my suggestion was to look at a dedicated PSU for the Photon or a better quality PSU for both - try RS Components or CPC since you are in the UK. Of course, putting some large capacitor across the Photon Vin and GND might also do it!

@armor The 18V PSU is a HP Laptop 18V 5A PSU so I’m pretty confident that’s fine as a source. Also the problem has persisted when using cheap amazon basics car charger psu, dedicated LM2596 board, dedicated XL4014 board and with a LM7805 added. All of these when going direct into Vin, have a problem, all of these going in via the MicroUSB input (longer cable) everything works.

I’ll see if I can hook up a scope and see any obvious noise.

@ScruffR I’ve added 47uf, 100nf & 10nf caps to the power rails. Problems still exists.

I then tried using the XL4014 with longer power cable between the output of the XL4014 and the Photon. With ~1m cable (XL4014 and Photon are in the same place, just longer wires) the problem goes away. I suspect I’m going to need to create try and create a low pass filter, so have ordered some inductors to create an LC network to try once they arrive.

Might be two problems involved if the cable length has an effect: the XL401(x) puts out a ~180khz PWM, which I can’t imagine the photon does well with if the breakout board doesn’t filter it properly. If I were selecting a cap for this I’d choose 4.7uF (near the output of the converter) instead of 47uF, but also you may be getting reflections of the pulses from the cable termination points.

A longer cable may either attenuate the waves, or may just be contributing its capacitance to filtering the signal. Can you scope the input to the photon or the output of the XL4014 board?

Page 4 of this document has a good starting point for filtering caps if you know what your noise looks like:
http://www.ti.com/lit/an/scaa048/scaa048.pdf

and here’s some graphs showing some attenuation across the ranges of caps:

Typical caps I see on the photon for filtering: 22uF in to the regulator, 0.1uF and 22uF coming out plus a 2.2uH inductor.
https://docs.particle.io/datasheets/wi-fi/photon-datasheet/#schematic-power

This is all really a guessing game without looking at it with a scope.

I’ve performed some single shot captures whilst the Stepper is being driven. The probe is connected on the circuit board hosting the Photon. The filtering caps I’ve previously mentioned are in place:

XL4014 - 10cm wire to Vin - NOT WORKING

XL4014 - 1.5m wire to USB - Working

XL4014 - 1m wire to Vin - Working

The spikes are present in all tests, but the baseline background ripple (~180KHz as @wileecoyoti suggested is the likely the PWM from the XL4014) is noticeably reduced in the tests with longer wires.

As noted in the datasheet the Photon already has it’s own power input filtering, but this doesn’t appear to be sufficient. I guess I ought to probe the 3v3 output since that’s the power being supplied to the controller and is the result of all the filtering off and on the module.

Thank you for the links, I’ll take a read review my current component value choices.

You are now allowed to upload more than two images.

Thanks @ScruffR I’ve edited the post and embedded the images.

1 Like