1. The Forum Rules have undergone some minor changes and updates.  Please take the time to read them; it will only take a couple of minutes of your time. By doing so, you lessen the chance of incurring the wrath of the moderation team or making yourself look foolish to other members.

    90% of users posting adverts in the Sales forums need to be reminded to read the rules as their posts are wrong.  This is unnecessarily time-consuming and will no longer happen - if your advert doesn't follow the Sales Rules it will be deleted and you'll have to start all over again.

    To close this box once you've read it (and the Rules), click on the X in the top right-hand corner.

    Thank you.

    AGF Staff



    Dismiss Notice
  2. A reminder of one of the Forum Rules:

    'Behaviour

    Do not make inappropriate or offensive posts - including threats, harassment, swearing, prejudice, defamation, deliberate insults or name-calling, other negative remarks about this forum, its moderators and administrators or your fellow members. Even if this is just your own personal opinion, RESPECT YOUR FELLOW MEMBERS.'

    There have been changes made to our censoring software in an attempt to help with this growing problem.

    Click the X in the top-right-hand corner to dismiss this notice.
    Dismiss Notice
  3. Dear members,

    Our membership (like our country) consists of people from all walks of life; different in far more ways than can be listed here and each with a different view based on their experience of life - regardless of their colour, religion or cultural heritage. Every single person in the UK has been born of mixed race – we are a multi-coloured and multi-cultural country.

    As many of you are aware there are a handful of individuals amongst this membership that persist in making provocative, inflammatory, racist and otherwise offensive comments. This has been happening across the forum to a certain degree but is most especially prevalent in the Adult section.

    The moderation team has tried to stay on top of this, however unfortunately because of the ‘offensive’ nature of much of its content we don’t monitor the Adult section quite as much as perhaps we should. As a result much of this behaviour has gone unnoticed unless it has been reported to us. While the team always intended to take a "light touch" approach to the Adult section it would seem that some people aren’t quite adult enough to be left unmonitored after all.

    This behaviour is, and always has been against Forum Rules as well as the specific stipulations of the Adults forum and it will no longer be tolerated. We feel it's time to draw a line in the sand and as such from this point onward offenders will receive an immediate and permanent ban from the forum.

    In order for us to achieve our goal of restoring the forum to the friendly and tolerant place it once was, we ask that ALL members be mindful of the content they post and help us to stop unacceptable behaviour by using the 'Report' tool at the bottom of any offending post - the results of which can be seen only by Admin/Moderators.

    You should all receive a copy of this message by PM. 

    To close this message box, click on the 'X' in the top-right-hand corner.

    Dismiss Notice
  4. PLEASE READ
    You are breaking the forum rules if there is no comment on a sales or wanted thread by either the buyer or seller. 
    Or regarding to members manufacturing things stating something is going to be discussed and initiated through pm.
    I.e. 
    A buyer in manufactured section hi I’m interested in some work by you pm incoming.
    Or seller in a wanted add, hi I can do that for you pm incoming regarding it.
    Or a normal sale, hi I want to buy your item
    If a manufacturer gets asked privately about a sale they should say to the prospective buyer please comment on my thread to adhere to forum rules.
    Dismiss Notice
  5. Hotmail block emails from us entering your inbox. Unless you can setup a safe sender you will not get activation emails from the forum. Please use an alternative provider or complain to Hotmail.
    Hotmail addresses include.

    @Hotmail.co.uk @Hotmail.com @outlook.com @Live.com
    Dismiss Notice

A home-made device to measure springer recoil

Discussion in 'Anything Airgun Related' started by loki_79, Aug 31, 2014.

  1. loki_79

    loki_79 Donator

    Messages:
    279
    Likes Received:
    54
    Location:
    Oxford
    I have recently made a little device that is capable of measuring three-axis acceleration profiles of anything (but intended for springers) using off the shelf parts for under £50 . There are limitations, but I think it will prove a useful tool to anyone who is interested in quantifying the result of any tuning efforts on recoil characteristics. I have been planning to make something like this for a while, but finally got around to it following a few discussions that were prompted by Cloverleaf's thread the other week about piston fit vs power.

    The following is mostly about the assembly of the device, and only intended for people who are interested in building one for themselves. Of course it may be of interest to others, and I would welcome any input on possible improvements or requirements, but it has ended up fairly lengthy! (You have been warned..)

    Some of you may be aware of the Arduino electronics platform - these are a range of easy to program electronics devices for the hobbyist. They have recently introduced an ARM processor based board [http://arduino.cc/en/Main/arduinoBoardDue] which has significant improvements in most areas compared to the previous PIC based devices. Including a higher processing speed (84 MHz), more RAM (96 kB) and it also runs at 3.3V, making it simple to interface with 3.3V electronics chips and components that are unable to tolerate 5V signals and therefore require level-shifting.
    View attachment 102869

    There are really only two vital components to make a functioning device: an Arduino Due board (from £20 to £40) and an accelerometer (£25). In the most simple case, that is all you need, plus a few lengths of wire and a USB lead. The collected data is sent to a computer by a serial connection over USB. If you want to make it portable so that you can capture data without a PC/Laptop in the vicinity, then you will also need a 9V battery and a lead to connect it. On my test device I have included a small OLED screen (£10) to display current status, etc, but this is by no means required. You could also easily output data via bluetooth, or write to an SD card.

    After a bit of research, the accelerometer that I chose was this one:
    http://uk.farnell.com/analog-devices/eval-adxl335z/adxl335-accel-3-axis-eval-board/dp/1699046
    The main criteria for selection were:
    1) It must be 3-axis, enabling the measurement of any out of plane motion, e.g. muzzle flip.
    2) It must be analogue output, so that the sample rate was not limited by the chip.
    3) It must be able to measure the high accelerations involoved in spring powered air rifles (250g was the highest 3-axis analogue device that I could find).

    If you want to buy an official Arduino Due (and get everything from one place) then Farnell is as good a place as any:
    http://uk.farnell.com/arduino/a000062/at91sam3x8e-arduino-due-dev-board/dp/2250861
    They are now selling it for only £32.94 (it was £40 when I last looked). However, because Arduino is open source, there are a lot of cheap chinese clones around (I paid £18 for mine on ebay from Hobby Components). The build quality is nowhere near as good as the offical ones, but still perfectly functional. Although I now wonder if the official version would produce measurements with less noise.

    There are 6 pins on the accelerometer board, 5 of which must be wired up to the Due as follows:
    ST <-> N/C
    VS <-> +3.3V
    X <-> A0
    Y <-> A1
    Z <-> A2
    GND <-> GND

    The Arduino program that I have written to read the values is:
    Code:
    #define array_size 22500
    #define target_frequency 22.5 //kHz
    
    double period;
    unsigned int i;
    unsigned int start_time;
    unsigned int stop_time;
    unsigned short int mask, x, y, z;
    unsigned int array[array_size];
    int incomingByte;
    bool dataAvailable;
    
    void setup()
    {
      mask = 1023; //0000001111111111 (only need 10-bits)
      period = 1000.0/target_frequency;
      analogReadResolution(10);
      dataAvailable = false;
      for(i=0;i<array_size;i++){
        array[i] = 0;
      }
     
      Serial.begin(115200);  // PC Serial
    //  Serial3.begin(115200); // BlueTooth
    }
    
    void loop()
    {
      // see if there's incoming serial data:
      if (Serial.available() > 0) {
        // read the oldest byte in the serial buffer:
        incomingByte = Serial.read();
    
        if (incomingByte == 'R') {
          Serial.println("READING DATA...");
          start_time = micros();
          for(i=0;i<array_size;i++){
            x = analogRead(A0);
            y = analogRead(A1);
            z = analogRead(A2);
            // pack three 10-bit values into 32-bit structure
            array[i] = (mask&x)<<20 | (mask&y)<<10 | (mask&z);
    
            while(1)
            {// wait for period to achieve target frequecy
              if(start_time+(i*period) <= micros()) break;
            }
          }
          stop_time = micros();
          Serial.print("Total collection time: ");
          Serial.print((double)(stop_time-start_time)/1000.0);
          Serial.println(" ms");
          Serial.print("Data collection frequency: ");
          Serial.print(1000.0/((double)(stop_time-start_time)/array_size));
          Serial.println(" kHz");
          dataAvailable = true;
        }
    
        if (dataAvailable && incomingByte == 'V') {
          double delta = (double)(stop_time-start_time)/(double)array_size;
          Serial.println("Time[us], X, Y, Z");
          for(i=0;i<array_size;i++) {
            Serial.print(i*delta);
            Serial.print(", ");
            Serial.print(mask&(array[i]>>20));
            Serial.print(", ");
            Serial.print(mask&(array[i]>>10));
            Serial.print(", ");
            Serial.println(mask&array[i]);
          }
          dataAvailable = false;
        }
      }
    }
    
    There is one significant limitation to this system. Because the available RAM is limited (96kB in total for the program) data cannot be collected and stored indefinitely. In fact, for the example 22.5kHz collection frequency, data can only be collected for one second. The maximum collection frequency is about 80kHz (limited by the speed of the ADC converter in the Due), but that of course reduces the collection time to a brief 280ms.

    The maximum collection duration could be increased by reducing the resolution to 8-bits (instead of 10). As it stands, I have packed the three 10-bit integers into 30-bits of a 32-bit value. Three single 8-bit chars would only occupy 24-bits of memory, so the collection period is extended by 33% to 1.33 seconds. I don't think this is worth the factor of 4 reduction in resolution, although there is a fair amount of noise on the 10-bit value so it is not a simple decision. Of course, the collection period can also be extended by reducing the collection frequency. At 11.25kHz the collection time would be two seconds, and so on.

    You may be thinking: why not write the data out as it is collected, then we can record indefinitely? The answer to this is that the write speed to any other device is significantly lower than writing directly to RAM. There is certainly no way that it can be written over serial in that time, or to the internal flash memory of the Due (I have tested both). There are a few promising leads in articles such as this [http://forum.dev.arduino.cc/index.php?topic=86880.0], and I have an SD card module on order to test this, but I think it is still reasonable to use the device as it currently is.

    The way I propose to do this is to either:
    1) After initiation by a button or serial command, an LED will blink three times, before turning solid for the duration of the collection time. It would then require the user to watch the LED and fire the rifle when it stops flashing. I think it should be easily possible to complete the trigger pull and shot cycle within a second for most people with a bit of concentration.
    2) Initiate the collection using a pressure pad/switch between the finger and the trigger of the air rifle. This could possibly be triggered to soon if you were to squeeze the trigger gently (as you should), but I think it should work.

    I've done a test by flicking the sensor fairly hard with my finger, and the raw results measured at 22.5 kHz for the three axis are shown here:
    View attachment 102912

    I have not done much in the way of processing any of the data yet. The accelerometer outputs a voltage between 0 and 3.3V for accelerations of +/- 250g. This is converted by the ADC to a 10-bit value (0-1023). So zero acceleration gives a value of around 512, with positive accelerations giving a value above that and negative below with a resolution of about 0.5g per step. For the sort of accelerations involved, I think the offset due to gravity of 1g is probably negligible, indeed the measurement noise is on this kind of scale anyway.

    The only thing left to do is to actually mount the accelerometer onto the gun. I am planning to make a dovetail mount by machining the top of an existing mount down as much as possible, then drilling and tapping a few holes in it. I'm sure it could also be done 'combro' style with a load of insulation tape, but I think analysis will be easier if the orientation is rigidly fixed and known.

    Well done if you got this far! I don't have a lot of free time (with a young family), so proper analysis of the results and any further hardware development is likely to be sporadic. I'll update this thread when there is more to report, and will be glad to assist anyone who is interested in developing a similar device for themselves!

    [Edit: all the forum links and attachments on old posts seem to be broken..]
     
    Last edited: Jul 29, 2020
  2. Pidlar

    Pidlar Big Poster

    Messages:
    3,653
    Likes Received:
    699
    Location:
    Kingwinford
    Excellect idea.I like to use Jim Tylers method of a pen against the butt resting on a piece of paper.Not as cool or accurate but a good comparative source.
    Thanks for sharing,
    Stu.
     
  3. Jackroadkill

    Jackroadkill Donator

    Messages:
    16,782
    Likes Received:
    152
    Location:
    Drenewydd, Powys, Cymru
    That is fantastic; can you make me one?!
     
  4. Titchgamer

    Titchgamer Honorary Member

    Messages:
    16,965
    Likes Received:
    388
    Location:
    Telford
    Looks interesting, Ile be waiting in anticipation :)
     
  5. Pidlar

    Pidlar Big Poster

    Messages:
    3,653
    Likes Received:
    699
    Location:
    Kingwinford
    Yes mate,i have some pens and paper here,what colour pen would you like?
     
  6. Ganton Gunner

    Ganton Gunner Super Duper Moderator Staff Member Mod/Admin

    Messages:
    13,862
    Likes Received:
    104,375
    Location:
    Ganton scarborough
    can you supply a felt tip version so I can see the line clearer ?
     
  7. trumpetier

    trumpetier Major Poster

    Messages:
    8,132
    Likes Received:
    7,294
    Location:
    middlesbrough
    my head hurts :eek:.....very clever stuff, but i will take the pen option ;)......well done loki
     
    Last edited: Aug 31, 2014
  8. Jackroadkill

    Jackroadkill Donator

    Messages:
    16,782
    Likes Received:
    152
    Location:
    Drenewydd, Powys, Cymru
    A quote from the Hitch-hiker's Guide To The Galaxy springs to mind here, Stu...

    "Nobody likes a smartarse".
     
  9. loki_79

    loki_79 Donator

    Messages:
    279
    Likes Received:
    54
    Location:
    Oxford
    Once I've actually taken a measurement from a rifle, so that I am sure it can produce useful results, I'd be happy to make one up for you. However, there really isn't much to it, just buy the bits off the shelf, connect the wires (you don't even need to solder them), upload that program and it is ready to go!

    Thanks to everyone for the enthusiastic replies!
     
  10. cloverleaf

    cloverleaf Honorary Member

    Messages:
    23,400
    Likes Received:
    35,939
    Location:
    Oxfordshire
    As discussed via PM, good work - very impressive :cool:
     
  11. Barni

    Barni Donator

    Messages:
    569
    Likes Received:
    1
    Location:
    Northants
    Very clever stuff indeed. Would one of those raspberry modules be able to work in the same kind of way ?

    Keep up the good work :)
     
  12. loki_79

    loki_79 Donator

    Messages:
    279
    Likes Received:
    54
    Location:
    Oxford
    You could certainly do something similar with a raspberry pi, and it has a lot more RAM so would be superior in that regard. However, I don't think it actually has onboard ADC capabilities (I'm prepared to be corrected on that), since it is really just a mini PC running linux. Lots of people seem to make and sell inexpensive ADC modules, such as this one: [https://www.abelectronics.co.uk/pro...---Raspberry-Pi-Analogue-to-Digital-converter], but the collection rate with that is painfully slow at just 240 Hz.
     
  13. Bemused

    Bemused Engaging Member

    Messages:
    438
    Likes Received:
    4
    Location:
    Stoke
    Would you not only have to do a data write for the maximum accelerometers axis values hence plenty of onboard logging capability. IE dont write the lesser values.
     
  14. loki_79

    loki_79 Donator

    Messages:
    279
    Likes Received:
    54
    Location:
    Oxford
    You could do that for a simple peak acceleration measurement, but I wanted to produce a plot of acceleration over time to identify other recoil characteristics.
     
  15. Bemused

    Bemused Engaging Member

    Messages:
    438
    Likes Received:
    4
    Location:
    Stoke
    What about a simple python script on a Rpi to take the data from an Arduino, give a small portable package with a sizable amount of logs.
     
  16. Bemused

    Bemused Engaging Member

    Messages:
    438
    Likes Received:
    4
    Location:
    Stoke
    Yes I had not realised you needed the whole plot, may be use an I/O pin to select peak for in-field and curve for workshop logging. Use both methods? Just thowing a random thought into the pot here.
     
  17. Dag

    Dag Pro Poster

    Messages:
    6,500
    Likes Received:
    3,584
    Location:
    Nr Leatherhead, Surrey
    Ah! But do we know it's more accurate? It's sounds very technical but Tylers pen might just have been better.;)
    Dag
     
  18. Bemused

    Bemused Engaging Member

    Messages:
    438
    Likes Received:
    4
    Location:
    Stoke
    You have a neat idea, looks like fun.
    I quite like bodging myself. There is an Arduino buried in here !
     
  19. loki_79

    loki_79 Donator

    Messages:
    279
    Likes Received:
    54
    Location:
    Oxford
    That does work (essentially the same as streaming the data to a PC over serial), but is limited to the data transfer rate. The maximum serial baud rate for the Arduino is stated as 115200 bits per second, but that is only 14400 Bytes per second. For the three axis data, you need 3 bytes for 8-bit resolution, or 4 bytes for 10-bit resolution, which means a maximum measurement rate of 3.6kHz (not including the overheads of serial communication).

    There are a few reports of faster baud rates being achieved with both platforms:
    http://forum.arduino.cc/index.php?topic=21497.0
    http://raspberrypi.stackexchange.co...ated-at-more-than-115200-baud-rate-i-e-230400
    but it is still not really fast enough, and could be subject to instability and data loss.

    There is also the possibility of using another protocol such as I2C or SPI to transfer the data, but that is currently a bit outside my comfort zone and requires a PC to be present. The only thing I am holding out hope for, is that I may be able to use existing libraries to write to an SD card module via SPI at a sufficient rate: http://forum.arduino.cc/index.php?topic=235805.0
     
  20. loki_79

    loki_79 Donator

    Messages:
    279
    Likes Received:
    54
    Location:
    Oxford
    That looks awesome, what does it do!?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice