Rumble support?

(William) #1

Has anyone thought about adding rumble support? Gonna pick up some of these and see if I can add them in the library

1 Like
(Scott) #2

How much current do these things draw? It may be taxing on the Arduboy’s tiny battery.

#3

Item discription says 80mA @ 3V

(Kevin) #4

Should work just fine! Using them a lot will drain the battery but just a few taps here and there won’t be a problem. I don’t know if back emf would be a concern potentially? Current limiting resistors in series could help this and zener diodes would be a better protection.

1 Like
(Shawn) #5

A simple base resistor, npn transistor, and protection diode across the rumble motor is all that would be necessary to drive it and protect the io pin controlling it.

(Scott) #6

What I was concerned about was the battey’s internal resistance. When the motor runs, the heavy current causes the battery voltage to droop. When this happens with a somewhat low battery, even for a short time, it will cause the game to fail long before any other game not using rumble would continue to run.

You touched on this problem (somewhat incorrectly) in another topic:

(Kevin) #7

I bet it will work, try it out!

(William) #8

So, very similar to this? How would I figure out the transistor base resistor value at r2?
I usually use motor drivers :sweat:

(Scott) #9

It would depend on the DC gain (hFE) and base-emitter saturation voltage (VBE(sat)) of the transistor you choose, the voltage you’re driving the resistor at, and the current that the motor draws in the circuit with the transistor collector-emitter saturated.

That said, I’d try 200 or 220 ohms for a typical general purpose or switching NPN transistor (such as 2N2222 or 2N3904).

1 Like
(Shawn) #10


Anything under 1K for the base resistor or near enough is a good place to start if you are using a jelly bean small signal transistor like a 3904, 2222 or 4401. The exact resistance isn’t critical since we are just driving the transistor into saturation.

1 Like
(William) #11

Still waiting on the motors from Amazon. Somehow they got lost. First time that’s happened to me with Amazon.
Check out my new rig while we wait ;).

(William) #12

I couldnt get the transistor circuit working for the life of me, so I just hooked up a resistor for testing and called it a day. If I wanted to add a struct to the Arduboy2 library, where would I even put it?

(Pharap) #13

It depends on what you’re thinking of doing exactly and/or why you want to do it.

(William) #14

Well I want to pull up pin 3 as output, and then define the struct so that I can call Arduboy.Rumble and take in parameters for how long in ms, and what strength up to 255.
So arduboy.rumble(2000, 255);

(Pharap) #15

Shouldn’t that be a function rather than a struct then?
Though it would probably need some state for the timing I suppose…

Either way you may as well just put it in a separate header,
assuming it doesn’t actually need access to Arduboy2's internals.

struct ArduboyRumble
{
	// Sets up the rumble extension
	static void begin()
	{
		// Pull up pin 3
	}

	// Performs a timed rumble
	static void rumble(uint16_t milliseconds, uint8_t strength)
	{
		// Implement rumble code
	}

	// Performs an indefinite rumble
	static void rumble(uint8_t strength)
	{
		// Implement rumble code
	}
	
	// Stops an indefinite rumble (and possibly a timed rumble?)
	static void stopRumble()
	{
		// Implement rumble code
	}
};

Which could be used as:

#include <Arduboy2.h>
#include "ArduboyRumble.h"

Arduboy2 arduboy;

void setup()
{
	arduboy.begin();
	ArduboyRumble::begin();
}

void loop()
{
	if(!arduboy.nextFrame())
		return;

	arduboy.pollButtons();

	if(arduboy.justPressed(A_BUTTON))
	{		
		ArduboyRumble::rumble(2000, 255);
	}
	
	arduboy.clear();
	arduboy.println(F("Hello World"));
	arduboy.display();
}

2 Likes
(William) #16

Well damn, just do the whole thing lol. Idk why I didn’t just think of having it’s own header. Too much solder in the brain, ha.
But, yeah, looks good, exactly where I was going with it. Thanks

1 Like
(Stephane Hockenhull) #17

I’d put a low ohm resistor in series with the motor on the VCC side with a decoupling capacitor right after the resistor to handle the launching power draw spike and limit the pull on the battery.

Untitled

I’m not sure how big of a capacitor would be needed (as big as would fit).
Once started the motor can keep going with the lower voltage provided by the resistor.

That would allow the battery to drain further before the sudden motor draw causes a brown-out crash.

Actually I wouldn’t be surprised if the whole thing crashed on a full charge without the resistor and decoupling capacitor.

It’s 80mA when it’s running. The starting current is much, much larger.

(Stephane Hockenhull) #18

Also on the software side for the same physical reason if you PWM it you still need to give it a long starting pulse.
How long depends on the motor & weight. 67.5ms to 125ms starting pulse would be a good range to experiment with.

You can scale that starting pulse with the intended final PWM intensity but you still need a longer starting pulse to launch the motor.

_------------_-_-_-_-_-
 | starting |  PWM    |

And might need to give a bit of time for the capacitor to recharge after stopping the motor but that depends on how quickly the motor stops.
If it free-wheels a lot after cutting power you won’t need any recharge time. It’s own leftover inertia would be enough to restart and the capacitor would recharge at a faster rate than the motor stops.

(Shawn) #19

I was thinking the OP was opting for something like a phone vibrating motor which really only needs ~2-3V and 10-15mA (on par with an led in terms of power draw). In the past I’ve even directly driven such motors from I/O pins with a flyback diode of course. So long as you drive at a low enough duty (<50% or so) and high enough frequency (upper 100’s Hz to kHz range), a series current limiting resistor shouldn’t be necessary as average current will be much lower than peak current (and having enough decoupling capacitance across the supply rail near the motor will take the brunt of providing instantaneous current when necessary, shielding the battery from inefficient power extraction due to impulse current drawn causing the battery’s internal resistance to sag the output voltage).

1 Like