• How accurate can these IR proximity sensors be? My desire is to use them inside a Nerf dart clip/magazine to calculate remaining ammunition based on how full the clip is. Will these be accurate enough? Is there a better way to do this? (Keep in mind the clip must somehow electrically connect to the blaster)

    Nerf Clips/Magazines look like this Note: This clip is modified with a rail to allow for non-Nerf (Stefan) darts to be used

  • The IR proximity sensors have a very 'switchy' behavior: on or off... You may be more successful with a ultrasonic sensor. Size of the magazine and the fact that it is a 'closed environment' (with lots of wall reflections) may pose extra challenges. Other measurements could be implemented by placing a 'resistor-band' (heavy computer magnet tape) inside the magazin body and a wiper to the moving part. Placing the ends to 3.6 and 0 V and reading the wiper's voltage with an analog read will do a good job. A cross cut could look like this:

    .----------------------------.
    | .------------------------. |
    | |                        | |
    | |                        | | spring pushed part
    | |                        | |
    | |                        | |
    |  -----------|------------- | wiper on the spring pushed plunger
    | -------     W    -------   | regular tape taping...       
    |     ----------------       | ...resistive tape to case side
    .____________________________.
    

    You can use the spring as the 'wire' from the wiper to the wire you connect to the analog input to avoid having moving wires in the box interferring with the spring: solder the wiper to the moving end of the spring and the wire to the fixed one at the bottom of the clip. The regular tape works also as an insulator and distancer so that only the wiper touches the resistor tape and not the metallic - conducting - spring. You may anyway have a tight situation with the tapes taking up some space as well.

  • I'm afraid the TRCT5000 probably won't be great for that - as @allObjects says it's very much on/off.

    Another option I've come across recently is actually to use a magnetometer. If you put a neodynium magnet on the plunger that pushes the nerf darts up (I guess there is one?) and position the magnetometer correctly then you should be able to measure the direction of the magnet - and so work out where the plunger is.

    It'd need some experimentation, but the magnet itself should be so much stronger than the earth's magnetic field that the angle of the nerf gun won't really matter.

  • I think the Hall Effect sensor is probably the best suggestion so far as the IR solutions (even the Sharp GP2Y0A41SK0F) would probably get blocked or interfered with by the walls or the spring. However @allObjects 's resistive tape idea is also good. Thanks for your replies.

    P.S Nice to see your back Gordon, hope you had a nice time.

  • What would suit this application better, HMC5883 or A3144 ?

  • @Ducky, I'm not sure you want to go for a 'switchy' Hall Effect sensor... you will end up with practically the same behavior as with the IR proximity sensor. There are various Hall Effect sensors. Of course, the most used ones are the switching ones. They have usually Schmitt Trigger behavior / built in, and some they go even further and require a polarity change to switch to the other state. Therefore, you have to find a Hall Effect sensor that just measures the intensity of the magnetic field (see this intro]). You need something like Honewell SS49/SS19 Series with 5v, GND, and Hall Voltage out. Hall Voltage is related to the intensity of the magnetic field.

  • Ah, I was under the impression Switchy Hall Effect sensors were Magnetic read switches, my bad xD, Would the HMC5883 work for this application though?

  • HMC5883 provides you with the angles relative to the magnetic field vector... For example, a regular compas shows you the deviation from north, so does of the sensor when z perpendicular to the magnetic field vector. When you tilt, you get different values for xy and non-zero for z. As you will become aware when reading the Erdmagnetfeld wiki entry, the calculations it becomes quite complex depending where you measure because the field is heavily 'bent'. The compas sensor tells you only which direction to the magnetic field vector you are heading. I do not know how they exactly work, but they could include 3 orthogonally oriented hall sensors... (Magnetometer and Erdmagnetfeld). You may give it a try, but I doubt that it works well enough, because I'm not sure if a neodine can create a far enough reaching field of strength that the earth's field does not really matter. How much (inch / mm) does the plunger in the clip travel? This site may be of some help. I still believe that a resistive technique is the most affordable and still accurate enough approach.

    If you want to get down to a 1/100 inch/ 3/100 mm, you can 'hack' a cheap ($10..$20 for 4..6 inch 10..15 cm) digital caliper made of metal or composite material... and most of them have even some kind of serial interface. If you can 'hack' the built-in chip ('s scaling factor - may be through the serial interface), you can even modify the displayed value to match the number of rounds left!... ;) - let me know how far you get with that... we could ask the manufacturer to add a third setting: inch/mm/rounds :||


    3 Attachments

    • DC0.png
    • DC1.png
    • DC2.png
  • Where could I source some resistive strip? Ebay? Or perhaps some paper with HB pencil Led could work. I also thought of the caliper but it is too expensive to apply to multiple clips at £10 a clip. Even if all these ideas fail I guess I could resort to assuming the clip is full and counting down after one is fired, although id like absolute measurement.

  • What about measuring the electrical resistance of the spring? It may require some amplification. Assuming it is metal.

  • @cwilt: With a general 10-7 OhmMeter resistance of steel, it is quite a challenge to confidently detect a delta of almost nothing... copensating for environmental effects may even be a bigger hurdle (as it is also for a magnetic solution). The initial value and variation of magnetic field of a neodyn is 7+ orders easier... Btw, resistance vs tension was tried but failed, succeded capacitive (with telescopic coil spring). Capacitve could a solution (see bottom of the post).

    Back to @Gordon's suggested magnet field solution:

    Assuming, @Ducky's average magentic field from the earth is about 0.000'048T or 0.48Gauss (see text and chart and calculated); electromagnetic field intensity measurement unit conversions: 1 T(esla) = 10'000 G(auss).

    Assuming the plunger moves 4 inches, the magnetic field of an axially (+-y) magnetized neodyn 42 disk of 1/4" (0.25) thickness and 1/2" (0.5) " diameter varies with a 4" plunger movement:

    with y=0 for:

    x=0.50" to 4.50" from _490.8G to 0.6G --- ~ ratio 1:820```

    
    with x=0 for
    

    y=0.125" to 4.125" from 4674.3G to to 1.5G --- ~ ratio 1:3100```

    y=0.750" to 4.750" from _218.5G to to 1.0G --- ~ ratio 1:220```

    (calculated, calculator courtesy of K&J Magnetic Inc. based on their product).

    Arrangments starting farther away from the magnet are easier to measure (may be...see next paragraph)... Courtesy Honeywell Solid State Sensors SS49/SS19 Series Analog Position Sensors: Hall Effect sensor's data sheet(s) and magnetoresistive-hall-effect-application­s applications notes should be able tell. Wether the placement with magnet in the plunger and sensor at the bottom of the clip or vice-versa has to be figured out experimentally, as well as what the effect of the most-likely steel spring has.

    With the earth magnetism taken into account, things look pretty bleak for distances of 4":
    Earth magnetism by itself reaches 30% to 50% of the magnet's magnetism for x=0 and varying y. The setup with y=0 and x varying becomes a no-option... :(

    Conclusion: Measuring over a distance of 4" is a challenge... a complicated calculation with a x,y,z device to compensate for the (locally known) x,y,z components of the earth magnetism may work, though.

    Alternatives:

    • Choosing a measurable setup - shorter distance - may give accurate feedback only for the last 50% of remaining rounds
    • Measure from 'both ends' with sensor in plunger and magnet axially to plunger moving direction half way
    • Fix multi-magnet and moving single sensor arrangement
    • Sngle movig magnet and fix multi-sensor arrangement

    A optical - reflecting - solution:
    With not too much in rounds in the clip, a multi-IR-proxymity-sensor as a binary encoder (in the plunger with non/reflection on the clip inside-wall may work...

    A mechanical-optical solution:
    Attach a non-transparent tape with as many wholes as rounds to the plunger, let it pull through the bottom of the clip throught the slit of a IR sensor... The tape could roll onto a spring loaded drum (spring much weaker than the plunger spring).

    A laser solution:
    Hack a "Laser Measuring Tape" --- expensive and may-be bulky...

    A mechanical-resistive solution:
    Get a sliding/linear potentiometer and connect the plunger to the slider... If the slide is two short, creat some 'linear-planetary' reduction (cogwheel on the slider, one cogbar attached to the plunger, one to the clip (clip may end up longer)

    The capacitive solution:

    • place a wired, rectangular shaped alu foil piece on one of the wider sides of the plunger
    • place a wired, isosceles triangle shaped foil on the inside wall facing the foiled plunger side of the clip with the triangle's base at the bottom of the clip and cover it with an insulating foil (tape). The capacity between the wires will decrease with the rounds remaining in the clip. Make sure the distance between the foild plunger side and the foiled clip side are constant (by adding something that 'presses' the plunger against the foild clip side... The cpacity vs position could be a very interesing graph, because the spring - electrically connected to the plunger foil - (and the rounds) may influence the measurment positively. The capacity iself and its change though is very low as well and could be difficult to measure.

    Btw, how many rounds are in a clip, and how much moves the plunger? kind-a got it a bit better: @Ducky, is that what you are talking about?

    @Ducky, thanks for challenge!

  • Having seen the modifications, this is a possible solution:

    • drill a whole through the guiding tube in the plunger
    • place a IR gap sensor (or split proximity sensor) into the plunger 'watching the whole'
    • drill (18) holes thorough the guiding rod/tube fixed in the clip with distance of round diameter and first whole half round diameter below then the position of the plunger's hole with empty clip
    • count the on/offs the IR gap sensor makes - low when plunger and a guid whole align
    • use setWatch's debounce to manage jitter

    The drawback of this solution are the moving wires... 3 of them... so I'm thinking...

  • An electro-mechanical solution:

    • wired guiding tube has 18, eaquidistant (= round diameter) perpendicular valleys on the back - depth is about 1-1/2 the wall size of the tube, so they cut through the wall and are like oval shaped holes (see notes)
    • the colar tube has one (1) perpendicular valley at the back as well with the depth that its 'valley floor' is flush with the 'valley floors' of the guiding tube
    • a wired smaller tube or rod is placed/glued into the guding tube so that it is insulated from it (see notes)
    • a contact (blade) spring is soldered to the collar tube with a smooth ---u- shaped end over the cut-out (or 'hacked'/repurposed relais spring contact that you 'weaken' by hammering)

    When the collar is moving up and down the guide, the spring's contact portion falls into the valleys of the guiding tube and contacts the inner tube/rod creating pulses ou watch. Again, use options {edge:"both", repeat:true, debounce:aLot } to handle the behavior.

    Notes:

    • For insulation of the inner rod/tube, take a dummy/throw later away rod/tube as inner rod/tube, put it into a thin drinking straw or shrinked rings of thin shrink tube around it and have it inserted when grinding the 18 valleys. Grinding the guiding tube valleys to a depth hat the inner rod/tube has shallow valleys guarantee solid contacts later on.
    • Make the valleys/cut-outs in the guiding tube with a fine grinder of a rotary tool and smoothen the rims.
    • Polish the guiding tube with polisgh cloth (1200+) so the collar and spring move easily up and down.

    Whit this solution, you still have no absolute measurment. A manual preset is required (or loading while connected). The enhancement: use just pieces of tube/rod for the inner rod at the contact/valley locations and solder resistors between them. This will give you the abslute measurement. You use a setWatch for the event that triggers a fast seqence of analogue reads to handle the 'noise'. You can get rid of the count, or keep it and use it as a cross-check if count has been preset manually. For sequncing and powering and measuring, check out Resistive Touchscreen directly (no touch controller). Sequence looks like:

    • resistance/resistors chain's one side is grounded, other side is open
    • setWatch is setup on falling edge with no repeat and internal pull-up and debounce (resistance/resistor chain's total resistance has to be 'low' compared to pull-up resistor, pull-up o 30..50k, total resistance - when using 3.6 V power on it - should be about 2..3K to create good edges)
    • contact/touch is caught by the setWatch (falling, no repeat), and triggers the next 4 items
    • power is applied at the open end of the resistance/resistors for the measurement
    • flurry of measurements - analog reads - is taken for later calculation of the most-likely value (position/number of rounds)
    • power is disconnected from resistance/resistors
    • setWach is setup on rising edge with no-repeat and internal pull-up and debounce
    • unconnect/untouch is caught by the setWach (rising, no repeat) and performs next 2 things
    • process the the measurments (calculate the most-likely value and 'communicate' it
    • start over with the sequence with the 2nd item

    Note: setWatch and analog read use the same pin... internal pullup can stay on, because you have to calibrate anyway (of course, precision resistors <=1% are 'useful', since you want to use multiple clips with the same calibration).

    Btw, I still belive that there is a simple ultra-sonic or simple IR solution: simple because it would most-likely not need a modification of the clip and could be installed in the gun. Take a look at this overview, where minimum distance is very small and maximum distance includes the plunger moving distance, and resolution is less than (half) the diameter of a round... STMicroelectronics VL6180X Proximity and ambient light sensing (ALS) module and AN4545 Application note VL6180X, Sharp GP2Y0A41SK0F GP2Y0A51SK0F Analog IR Distance Sensor, Vishay VCNL4000 Fully Integrated Proximity and Ambient Light Sensor with Infrared Emitter and I2C Interface, BaxBotix Ultrasonic Sensors.

  • Well, I'd have said the HMC5883 should work fine. It'd be worth some experimenting.

    The digital caliper is an interesting idea - it might also be possible to create your own 'digital linear encoder'... Basically a PCB with a pattern of conductive areas:

     # # # # # # # #
      ##  ##  ##  ##
        ####    ####
            ########
    

    You could hack something out of a bit of protoboard, or could even use black markings and those IR reflectance sensors.

    Then you just read the 4 'bits' and you have the distance in binary.

  • @allObjects Thanks for your wounder full suggestions.

    Btw, how many rounds are in a clip, and how much moves the plunger?

    You can get 6, 12, 15(Chinese knock-off only), 18 and 25, 35 round drums which work on rotation. The distance of the plunger in the clip depend on the capacity of the magazine

    @Ducky, is that what you are talking about?

    I used that image as it was the only picture of inside a Nerf clip I could find. They usually don't come with the rail inside, the dart takes up all the space.

  • Yet another method would be to mount two switches to the pusher and glue some slight ridges to the side of the mag. These ridges would trigger the switches when they passed by, you'd need two switches to tell the direction, more or less ammo, this is like a simple caliper on a large scale just counting known distances.

    However with this approach (and the calipers, or anything not absolute un-like distance or resistance) you'd need to keep something powered to keep track of the current state of the clip to then add or subtract from. This is not ideal but I guess I could use the spare RAM inside a DS1307 to keep time and store current clip info. I say DS1307 because they come on modules that have a 3v battery on them to keep memory even when the blasters batteries are taken out. However yet another problem popped into my mind after I'd already written most of this, with any non-absolute method the blaster would loose track if you swapped magazines when the current mag is not empty, or if the next mag is not full etc...

  • You could use the binary pattern approach I suggested above, but with micro switches and holes drilled into the slide or ridges added?

  • Ah yes, it appears I didn't read it properly

  • Hmm, now another conundrum, how to elegantly electrically connect it to the blaster body reliably ?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Counting Nerf Darts Inside the Clip (Hall Effect, Restive strip, Digital Calipars)

Posted by Avatar for MrTimcakes @MrTimcakes

Actions