• 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.

About

Avatar for allObjects @allObjects started