trinket M0 power limitation?

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

trinket M0 power limitation?

Post by smcculley »

I created a project to replenish the bubble solution in my bubble maker for Halloween. I'm using a water level sensor to trigger a pump when the level falls below the threshold. The pump is a 3v submersible https://www.adafruit.com/product/4547 and I am using a TIP120 to power the pump from 2x AA batteries.

Everything worked as expected on an ItsyBitsy.m4, but that was overkill for this usage. When I moved to the trinket.m0, it works fine on the bench (with an LED in place of the motor). When I replace it with a motor that is not under load (just moving some water, not bubble solution, no 1-meter hose) is works for a bit, then the trinket reboots. Maybe a load issue? But the TIP120 should be handling that...

When I hook up the motor directly to the batteries, it seems over powered. So, I changed out the DigitalIO to pmw, figuring I would have a little more control over the power consumption. And, I did! At a 50% duty cycle, the motor runs fine. But, there is not enough power behind it to move the liquid. If I increase to about 60% duty cycle, It can move a little liquid, but eventually the trinket.m0 reboots.

I swapped out the TIP120, I swapped out the motor, and I still get the same.

I verified my circuit, and it seems okay.

Is there some sort of power limitation I am running into? Shouldn't this be a non-issue because of the TIP-120?

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: trinket M0 power limitation?

Post by adafruit_support_bill »

Can you post a photo or diagram of the circuit you are using?

User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

Re: trinket M0 power limitation?

Post by smcculley »

Screen Shot 2022-10-03 at 18.56.59.png
Screen Shot 2022-10-03 at 18.56.59.png (57.25 KiB) Viewed 230 times
Trinket is powered by USB, motor is powered by 2x AA batteries.

User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

Re: trinket M0 power limitation?

Post by smcculley »

Here is the code.

Code: Select all

import time
import board
import pwmio

from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn

sensor_enable = DigitalInOut(board.D2) # Pin to power on the sensor
sensor_enable.switch_to_output()
sensor_level = AnalogIn(board.A0) # Pin to read the sensor

pump = DigitalInOut(board.D4)  # Pin to control the pump
pump.direction = Direction.OUTPUT
pump.value = False # start with the pump turned off

pwmpump = pwmio.PWMOut(board.A2, frequency=25000, duty_cycle=0)

## use pwm pump?
PWM_PUMP = True
#PWM_DUTY = 32768  # 50% duty cycle -- not enough to pump
#PWM_DUTY = 40960  # 62.5% duty cycle
PWM_DUTY = 49152  # 75% duty cycle
#PWM_DUTY = 52428  # 80% duty cycle -- trinket reboots after 15-20 seconds


## reading interval
INTERVAL = 5

## liquid Level
FULL = 20000

def pump_on():

    if PWM_PUMP == True:
        pwmpump.duty_cycle = PWM_DUTY
        print("pwmpump @", PWM_DUTY, ", ", end = '')
    else:
        print("pump on, ", end = '')
        pump.value = True

def pump_off():
    print("pump off")
    if PWM_PUMP == True:
        pwmpump.duty_cycle = 0
    else:
        pump.value = False

def sensor_on():
    print("sensor on, ", end = '')
    sensor_enable.value = True

def sensor_off():
    print("sensor off")
    sensor_enable.value = False

def get_level():
    sensor_on()
    time.sleep(0.25) # Warm up time
    level = sensor_level.value
    print(level, ", ", end = '')
    sensor_off()
    return level

def fill_tank():
    print("    ==Filling Tank==")
    wlsv = get_level() # Water Level Sensor Value
    while wlsv < FULL:
        pump_on()
        time.sleep(01.00) # Pump for a second before checking the level
        wlsv = get_level()

    print("    ==Tank is Full==")
    pump_off()
    sensor_off()

##
## START HERE
##
print("\nTank Monitor\n")
print("Sensor will take a reading every", INTERVAL, "seconds and will\nturn on the pump when the level dips below", FULL,"\n")

while True:
    water_level = get_level()
    if water_level < FULL:
        fill_tank()
    print("    ==sleep== ", INTERVAL)
    time.sleep(INTERVAL)


User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: trinket M0 power limitation?

Post by adafruit_support_bill »

What is powering the Trinket?

Assuming that the Trinket is being powered independently of the motor, that would rule out a 'brownout' due to current demand from the motor. Other possible causes would be interference from motor brush noise.

https://learn.adafruit.com/adafruit-mot ... rduino/faq

User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

Re: trinket M0 power limitation?

Post by smcculley »

Trinket is powered by USB. So, the batteries are supposed to be separate for the motor only. I'm wondering if maybe the 1k resister is too much between the trinket and the transistor, as this a 3v3, and maybe the circuit I looked at is for 5v? Also, I just ordered a new supply of TIP-120's. Maybe the old ones I had laying around are faulty.

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: trinket M0 power limitation?

Post by adafruit_support_bill »

Too much resistance on the base of the TIP120 would just reduce power to the motor - which does not appear to be the issue here. And you have separate power supplies for the motor and Trinket which should avoid any brownout conditions due to motor current demand.

The other common issue with brushed DC motors is brush noise. This can couple back to the processor via the ground wire - or even inductively through the air. Brush noise has been known to cause processors to reset.

Brush noise is best suppressed at the source. See the link in my previous post showing capacitors added to the motor. You can also try to minimize inductive coupling by shielding and/or routing motor wires well away from other circuitry.

User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

Re: trinket M0 power limitation?

Post by smcculley »

Brush noise! We might be on to something here. I'll do some reading up on it and see if I can add to minimize the noise.

User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

Re: trinket M0 power limitation?

Post by smcculley »

Doesn't look like this pump will let me attach the caps directly because of the plastic case. Installing caps on the circuit board won't fix it, according to the articles I read. So, it might be time to switch to a different pump.

User avatar
smcculley
 
Posts: 191
Joined: Mon Sep 03, 2012 10:40 pm

Re: trinket M0 power limitation?

Post by smcculley »

Swapped out the 3v cheapo water pump for a 12v peristaltic pump and it work 100%. Its a brushed motor too, so I added the .1uf caps as suggested. The trinket.m0 is happy, and my Halloween is moving forward!

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: trinket M0 power limitation?

Post by adafruit_support_bill »

Good to hear! Thanks for the follow-up.

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”