Custom motor to replace fan

I am trying to replace the fan motor with a more powerful motor. The motor says it operates at 4.5-9V DC. However, when I plug into the spot where the fan was, the motor does not spin. The motor does react to the calibration by turning a single click, like a momentary twitch, and then doesn’t move. I tried editing the config to increase the pwm Hz and initial duty cycle, but nothing really changed. How can I get this motor to work?

Thanks in advance

Hi @evanattessel, welcome!

What current does the motor need? Can you share its datasheet?

Do you hear any noise from the motor when it’s stalling like this?

Thank you for the quick response!

Here is the motor: DC Toy / Hobby Motor - 130 Size : ID 711 : Adafruit Industries, Unique & fun DIY electronics and kits
which says: Loaded Current: 250 mA max

I don’t hear any noise when it’s stalling. The way I’ve been testing it is to start stirring calibration, in case that’s helpful.

Hm, the motor looks okay. Try starting the calibration with a higher DC:

pio calibrations run --device stirring --min-dc 80 --max-dc 100

Does that work?

For some reason, my pioreactor doesn’t recognize the calibrations command.

pioreactor@pioreactor01:~ $ pio calibrations run --device stirring --min-dc 80 --max-dc 100
Usage: pio [OPTIONS] COMMAND [ARGS]…
Try ‘pio --help’ for help.

Error: No such command ‘calibrations’.
pioreactor@pioreactor01:~ $ pio --help
Usage: pio [OPTIONS] COMMAND [ARGS]…

Execute commands on this Pioreactor.

Configuration available: /home/pioreactor/.pioreactor/config.ini

See full documentation: Command line interface | Pioreactor Docs

Report errors or feedback: GitHub · Where software is built

Options:
–help Show this message and exit.

Commands:
blink blink LED
cache manage the local caches
db access the database’s CLI
kill kill job(s)
log logs a message from the CLI
logs show recent logs
mqtt tail MQTT
update update software for the app and UI
update-settings update settings on a running job
version print the Pioreactor software version
plugins manage plugins
run run a job
workers manage workers

Do I need to update it?

Ah, we changed the calibrations command line interface last patch. Feel free to update whenever. Instead, try this:

pio run stirring_calibration --min-dc 80 --max-dc 100

It did the same twitch that I was getting before, but then the ssh connection breaks inexplicably:

pioreactor@pioreactor01:~ $ pio run stirring_calibration --min-dc 80 --max-dc 100
2025-01-30T02:20:37+0000 INFO [stirring_calibration] Starting stirring calibration.
2025-01-30T02:20:37+0000 DEBUG [stirring] Init.
2025-01-30T02:20:37+0000 DEBUG [stirring] Operating without RPM feedback loop.
2025-01-30T02:20:37+0000 WARNING [PWM@GPIO-17] Setting a PWM to a very high frequency with software. Did you mean to use a hardware PWM?
2025-01-30T02:20:37+0000 DEBUG [PWM@GPIO-17] Initialized GPIO-17 using software-timing, initial frequency = 5000.0 hz.
2025-01-30T02:20:37+0000 DEBUG [stirring] Running continuously through OD readings.
client_loop: send disconnect: Broken pipe

Hm, that’s interesting. Did the Pioreactor brown out? (Do you need to power-cycle it to access it again?) Here’s a few things to try:

  • double check your wiring for a short between the + and -
  • reduce the pwm_hz in the config to 250.
  • try slightly smaller values:
 pio run stirring_calibration --min-dc 75 --max-dc 95

Otherwise I’ll have to think more about this!

I’m pretty sure there isn’t a short.
I reduced the pwm_hz to 250.
I tried the smaller value you suggested, but the result is still the same.
After the twitch, it disconnects and after a minute or so I see the blue light come back on. I think you’re right that it’s browning out, but I’m not sure why.

I tried running it again with the motor disconnected and it did not brown out.
I tried connecting it to a different motor of the same type and it browned out (wanted to make sure there wasn’t a short in that specific motor).

Also, I just realized that I accidentally sent you the wrong motor. It’s this one, which looks pretty similar but just in case: Amazon.com: Topoox 6 Pack DC 1.5-3V 15000RPM Mini Electric Motor for DIY Toys, Science Experiments : Toys & Games

Thank you for your continued help! I really appreciate it.

Here was the result with the motor connected:
pioreactor@pioreactor01:~ $ pio run stirring_calibration --min-dc 75 --max-dc 95
2025-01-30T03:17:52+0000 INFO [stirring_calibration] Starting stirring calibration.
2025-01-30T03:17:52+0000 DEBUG [stirring] Init.
2025-01-30T03:17:52+0000 DEBUG [stirring] Operating without RPM feedback loop.
2025-01-30T03:17:52+0000 DEBUG [PWM@GPIO-17] Initialized GPIO-17 using software-timing, initial frequency = 250.0 hz.
2025-01-30T03:17:52+0000 DEBUG [stirring] Running continuously through OD readings.
client_loop: send disconnect: Broken pipe

So a brown can occur if the motor is drawing too much current. This is possible (but I would find that surprising).

As another test, can you try lower the dcs:

 pio run stirring_calibration --min-dc 25 --max-dc 50

Does it still brown out?

I tried even lower than that and still get a brown out:

pioreactor@pioreactor01:~ $ pio run stirring_calibration --min-dc 20 --max-dc 25
2025-01-30T03:31:13+0000 INFO [stirring_calibration] Starting stirring calibration.
2025-01-30T03:31:13+0000 DEBUG [stirring] Init.
2025-01-30T03:31:13+0000 DEBUG [stirring] Operating without RPM feedback loop.
2025-01-30T03:31:13+0000 DEBUG [PWM@GPIO-17] Initialized GPIO-17 using software-timing, initial frequency = 250.0 hz.
2025-01-30T03:31:13+0000 DEBUG [stirring] Running continuously through OD readings.
client_loop: send disconnect: Broken pipe

hmmm! That’s weird! The motor would need to be drawing a lot of current to brown out, or a short is happening.

And you’re confident there’s not a short in the connector assembly? No connector / stray wires are touching?

The only way there could be a short is if I connected the motor incorrectly. When the motor is disconnected, it doesn’t brown out. I only get a brown out when the motor is connected.

Right, so I’m thinking there could be a short in here:

Can you unplug it and give it an inspection? (I’m guessing this is from the original fan?) It’s possible something has come loose / strayed.

Yes, the cable was from the original fan. I should clarify that when I ran it without the motor connected, the cable was still connected. This tells me that it’s specifically the motor-to-cable connection that would be causing the short, if that is indeed what is happening.

Smart. Okay I’m a bit stumped! Let me talk to my team and see.

We’ll purchase that same pump and try, too.

I have an interesting clue! I have attached two videos with sound here: https://imgur.com/a/KWmXPuK

I found that if I start the calibration before the motor is connected, and then connect the motor, it will run just fine (first video). You can hear the motor running loudly after I connect it to the pi.

Conversely, if I connect the motor first and then start the calibration, it twitches and browns out. If you listen carefully, you can hear me hit the space bar and then a faint noise as the motor twitches for a moment.

I’m not sure why the order seems to matter, but it seems like a helpful clue. Some ideas: there is a power spike at the beginning, there is a short in the motor at the beginning that my weak connection is avoiding, or there is a near the point of contact. The last one seems unlikely to me. I tested several different motors of this type to make sure it was not a defect in a specific motor.

Another clue is that the trick of connecting the motor after starting the calibration only works when the heating PCB is disconnected. This makes it seem even more likely that the pi is running out of power.

So the default stirring works by providing a “kick” of power at 100% DC for a brief moment - this behaviour helps our start spinning the fan. This kick would happen at the start of the script. This could be causing the pump to draw too much power.

Try the following:

  1. open up the Python shell with: python3
  2. Run the following:
    from pioreactor.utils.pwm import PWM
    pwm = PWM(17, 250) # GPIO pin, hz
    pwm.start(0)
    
    
    pwm.change_duty_cycle(25) # try increasing values in the python shell
    # eventually I suspect you'll hit a brown out?
    
    pwm.clean_up()
    

If the initial kick is the problem, we can solve this by modifying the stirring start-up routine.

That kind of worked! It still tops out much slower than the top speed I saw in the test above (connecting the motor after starting the stirring calibration, video 1).

I tested duty cycles from 1 to 8 in steps of 1, and it browns out at pwm.change_duty_cycle(8).

It seems like the initial kick is not the only issue. I’d expect to be able to slowly ramp it up to the maximum speed I’ve observed in the previous test.

Is there any way to increase the power to the motor? Or will I need to give the motor an external power source?

Are you currently using a ~2.5A power supply? Can you check what the label on it says?