r/Nerf•
Darke

A little late to the party: My work in progress Rapidstrike

So I had been waiting on some arduino minis from Sparkfun to replace the one I burned out a few months ago, attempting this ammo counter mod for the Rapidstike. These arduinos took about a month to ship, which is really bizarre since the tracking showed the package sitting in a local post office for several weeks in a row.

Anyhow, the package came in a few days ago and I got my rapidstrike mostly up and running. Here's a picture of how it's looking thus far. The display is actually flush with the angled surface of the blaster there, but I haven't peeled off the protective plastic film yet.

Firing full auto is working well; it fires at ~500RPM with an 18 rnd magazine and at ~470 RPM with a 25 rnd magazine.

However, it's got a couple problems that I can't figure out.

The first of the problems: Some of the inputs seem to behave almost randomly when I am revving the flywheels. The magazine cycle button flips out and registers several presses per second (even though I'm not touching it), and the magazine sensor will occasionally read that it is depressed even when a magazine is inserted (maybe one time every second).

These two inputs are just spst switches that are hooked up to ground and the input pin, and I have the pullup resistor for the inputs enabled in the code.

I considered that maybe the batteries are struggling to put out enough power to the motors, and maybe that's screwing with the Arduino. However, I ruled that out because the Arduino is not turning off or resetting, and it's fully responsive to the inputs even after the inputs glitch and after the flywheels stop spinning. I am using 3x TEnergy 18650 Li-Ion cells in this blaster, if it matters.

I have no idea what could be causing this problem, and while it doesn't interfere with the operation of the blaster in full-auto, it fucks with the ammo readout while firing. I haven't encountered this problem in the previous 4 ammo counters I have built (3 of them were in flywheel blasters too, which makes this problem doubly bizarre).

The second of the problems: One of the goals for this mod is selective fire; I want to be able to switch between semiautomatic, 3-round-burst, and full-automatic firing modes. I implemented this in my Stampede mod by switching the motor using a spdt relay, and it worked perfectly. However, it's proving to be a pain to implement in the Rapidstrike. Switching the dart pusher motor using an N-Channel MOSFET is working fine, but when power to the dart pusher motor is cut, the dart pusher motor slows down gradually rather than slowing down quickly or stopping immediately. This means that anytime I release the trigger, the blaster will still fire ~3 more darts. I knew that this would happen, but I didn't think that it would be this severe.

How do I make the motor slow down faster, without using a motor controller board? I can't find any documentation on braking a DC motor anywhere. :/

tl;dr: I am having electronic problems with my Rapidstrike ammo counter mod. One is random input behaviors when the flywheels are spinning, and the other is the blaster shoots too damn fast and doesn't stop shooting immediately when I release the trigger. I would like help :)

Posted Sep 9, 2013, 5:21 AM UTC · edited

319
justusUMBC•

If I remember correctly, you brake a DC motor by shorting its terminals together

3
DarkeOP•

Since I'm currently using a N-Channel MOSFET as an spst switch to close the motor circuit to ground, does this mean I should find a spdt solution instead, to switch between ground and the other motor terminal?

My motor circuit currently looks similar to this: http://www.nerdkits.com/videos/motors_and_microcontrollers_101/finalcircuit.png

1
naazrael•

What about using a second MOSFET? Use a PMOS. Then it would be like a half H bridge.

2
[deleted]•

[deleted]

1
torukmakto4•

This is the solution used in airsoft. N-channel plus P-channel = MOSFET pack with active braking. You still only need one control lead and there is no need to have a SPDT switch on the trigger to get braking.

1
naazrael•

Yerp, just tie the gates together. Didn't know that about airsoft, haha. Makes sense.

1
DarkeOP•

I was considering a nonlatching SPDT relay to replace the current N-Channel MOSFET, actually. I'll look into using a P-Channel MOSFET.

[EDIT]: It's looking like I would need another element that can supply a high enough voltage to the gate. Otherwise, 5v from the Arduino won't be able to desaturate the P-Channel MOSFET, since the source would be +11.1v. Is this true?

1
justusUMBC•

Arduino stuff is a little out of my depth, but I know the motor braking switch on the jam door of the Stryfe is SPDT, it seems like that'd be best

1
[deleted]•

[deleted]

0
naazrael•

As for the other problem, perhaps you are experiencing noise coming from the motors going into your signal? Do you have an oscope available to you?

3
DarkeOP•

That's what I suspected it would be. Unfortunately, I don't have an oscope immediately available.

In the circuit, the sensors and all three of the motors share the same node that leads to ground.

1
naazrael•

That's fine, really. I assume you removed the inductors from the motors? First I would suggest strapping some caps across the motors to see if that rolls off the noise. Try 100nF ceramic caps, one might be enough, but don't be afraid to put some more in parallel.

If not, you may need to put back the inductors which block AC ripple.

3
DarkeOP•

I added three 0.1 uF capacitors to each motor in this fashion: http://letsmakerobots.com/files/userpics/u11554/motor.jpg

It helped a lot but didn't squash the problem completely, so I added some debouncing code for the two inputs (magazine and magazine mode) that would glitch, with a debouncing delay of 100ms.

No more glitching inputs. :)

1
naazrael•

That is some fat debouncing delay haha.

1
torukmakto4•

What azrael said about the noise from those motors.

In RC, there are always some low value ceramic caps on motors, usually each terminal to ground. Nerf puts in suppression caps but they are tiny SMD parts, you probably don't have them anymore since they are on that stupid PCB on the rapidstrike, and I suspect running the motors at higher voltage saturates them anyway.

Other ideas, perhaps barking up the wrong tree:

  • Shield the wiring with grounded braid.

  • Is it possible to put a lower value pull up on the input to increase the current and make input more robust against noise?

  • Stock switches are terribad. I would bet they have a bunch of noise and multiple spikes when they turn on and off. Is there any debouncing of the inputs or could vibration and switch bounce be doing this?

And finally I would suspect the batteries. Cell holder? Have you tried a bigger battery pack, as in lower IR/more current capability?

1
DarkeOP•

I don't think it could be vibration. The one input that behaves the most sporadically is a tactile switch, like one of these. I've used these tactile switches before, in other flywheel blasters, and they performed well and exhibited negligible switch bounce and didn't react to vibration.

I'm not sure if it's the stock switches either. There are three stock switches that I am using: Magazine sensor, Dart Pusher sensor, and Trigger sensor. These are in the positions where the stock switches would otherwise be normally located. Of the stock switches that I'm using, only the magazine sensor exhibits the weird behavior. The Dart Pusher sensor is not double counting darts either, so there's negligible switch bounce on at least one of the stock switches.

There's presently no debouncing in the code, but it should be pretty easy to implement. All of the inputs, besides the dart-counting inputs, in my previous ammo counter builds were reliable enough that I didn't need debouncing. I frequently used stock switches for these too.

It is possible to eschew the internal pull-up resistors (20k ohm) in the Arduino, and use smaller ones. How small do you think these should be? 1k ohm?

I don't think that I can shield the wiring with a grounded braid, because of how little space there is in the Rapidstrike.

I'm going to add the caps to the motors first and see if that resolves the problem before trying these other solutions (besides debouncing in the code).

1
torukmakto4•

Yeah that doesn't sound like switches messing up.

About the pullups, I have never messed with arduino have zero idea of the specs, only seen reports of this kind of oversensitive input problem with those mosfets when people use too high a resistance to pull the gate down. Wouldn't it depend on power supply limitations and dissipated power on the resistor? 1k should be 5 mA and I would assume that is well within a safe current for the 5v rail, correct?

Another idea, I have heard people refer to the EMI/noise from overvolted/hard-running metal brush 130 motors as "horrendous" (due to all the brush arcing). Stock motors are metal brush, a rather current-hungry wind, and here are being thrashed with 11.1V so... Perhaps if you put carbon brushes in to cut that down... There is an ebay source of carbon brush 130s that can be scavved to upgrade a stock motor which was posted on the forum britnerf. I am going to be getting a bunch soon.

1
DarkeOP•

3x 0.1 uF caps on each motor + 100ms debouncing delay on the affected inputs fixed the problem.

2