Jump to content


Justin Andrews

Member Since 05 May 2016
Offline Last Active Apr 08 2018 03:57 PM

Posts I've Made

In Topic: OpenChrony - open source, DIY chronograph

08 April 2018 - 12:40 PM

Hi. I noted that in your source code you are using a while loop with a digitalRead.

While this will work, you can optimise your code, as the while and especially the digitalRead are quite slow.
For a faster more accurate reading I recommend setting up Pin Interrupts, known as an ISR (Interrupt Service Requests) these interrupts can be raised internally in the Atmel AVR processor independent of code execution. On the arduino you can access these using the attachInterrupt() function.
( https://www.arduino....ttachinterrupt/ )

I have written my own chrony code in the past.
My Chrono code is below. I've bolded the interrupt parts/

 

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// If using software SPI (the default case):
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


// -------------------------------------------------------------------
// Interrupt Service Variables

const byte interruptPin1 = 3;
const byte interruptPin2 = 2;

volatile bool m_pin1_active = false;
volatile bool m_pin2_active = false;
volatile float m_time1 = 0;
volatile float m_time2 = 0;


// -------------------------------------------------------------------
// Variables

// distance between sensors = 170mm or 6.69291 inches
// distance between sensors 557742.5

unsigned long m_distance = 557742; // distance between sensors in inches

int m_numTimings = 0;

float m_fps[10];
float m_currentFPS = 0;
float m_avgFPS = 0;
float m_lowFPS = 99999.0;
float m_highFPS = 0;
float m_totalFPS = 0;

static String m_stringCurrent = "Current: ";
static String m_stringFPS = " FPS";
static String m_stringHi = "Hi:";
static String m_stringLow = ": Low:";
static String m_stringAvg = "Average: ";

// -------------------------------------------------------------------
// Interrupt Service Functions

void Pin1_ISR()
{
  m_pin1_active = true;
  m_time1 = micros();
}


void Pin2_ISR()
{
  m_pin2_active = true;
  m_time2 = micros();
}


// -------------------------------------------------------------------


void displayText( String string, int x, int y, int textSize = 1, int stride = 6)
{
  int textCursor = x;

  for ( int i = 0; i < string.length(); ++i)
  {
    display.drawChar(textCursor, y, string[i], WHITE, BLACK, textSize);
    textCursor += stride;
  }
}

void setup()
{

  // put your setup code here, to run once:
  Serial.begin(9600);
  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC);
 

  pinMode(interruptPin1, INPUT_PULLUP);
  pinMode(interruptPin2, INPUT_PULLUP);
  attachInterrupt( digitalPinToInterrupt(interruptPin1), Pin1_ISR, RISING );
  attachInterrupt( digitalPinToInterrupt(interruptPin2), Pin2_ISR, RISING );


  display.clearDisplay();

  pinMode(A0, INPUT);
}

void checkISRPins()
{
   if( m_pin1_active && m_pin2_active )
  {
    
    if( m_time2 > m_time1)
    {
      float timeDiff;
      timeDiff = m_time2 - m_time1;

      float fps = m_distance / timeDiff;

      m_currentFPS = fps;
      
      m_numTimings++;

      if( m_currentFPS < m_lowFPS )
      {
        m_lowFPS = m_currentFPS;
      }
      if( m_currentFPS > m_highFPS )
      {
        m_highFPS = m_currentFPS;
      }

      m_totalFPS += m_currentFPS;
 
      m_avgFPS = m_totalFPS / m_numTimings;

    }
    // reset ISR variables
    m_pin1_active = false;
    m_pin2_active = false;
    m_time1 = 0.0f;
    m_time2 = 0.0f;
  }
}

void displayResults()
{
     display.clearDisplay();
    
    String outString = "";

    outString = m_stringCurrent + m_currentFPS + m_stringFPS;   
    displayText(outString, 1, 1 );

    outString = m_stringAvg +  m_avgFPS + m_stringFPS;
    displayText(outString, 1, 11);

    outString = m_stringHi +  m_highFPS + m_stringLow + m_lowFPS;
    displayText(outString, 1, 21);
 
    display.display();  
}

void loop()
{
  checkISRPins();
  displayResults();
  delay(100);
}
 


In Topic: Muzzle loading 17th Century Pistol

22 June 2017 - 04:59 AM

 

Ok, thats really cool, I don't get what you mean by dead space in laser printing is usually free though.

 

When talking about SLS 3D printing, you normally pay by the Cubic Centimeter / inch, or for a portion of the machines space. So any voids in your print you are still paying for, if you can put another object in that space, you are essentially getting that part free (or more to the point, you are already paying for that space so putting something in it is just sensible) The only condition is you need to get the part out, so it cannot be an enclosed void. 
 

That worked, thanks
 
These are the stats:
Outer Diameter (Do) (mm) ...22.00
Wire Diameter (d) (mm) ...2.01
Free Length (L) (mm) ...199.9
Solid Height, Approx (mm)... 40.9
Spring Rate (N/mm) ...0.9
Load Length (L1) (mm) ...55.6
Load at L1 (N) ...132.6
 
Fun fact: The OD and wire diameter are basically the same as a Mcmaster 9637k26 spring. It's only 8inches long ([[[[k26]]]] is 11in or ~280mm) but the spring rate syncs up with an 8inch length of [[[[k26]]]] as well.

The solid height of D22790 seems a bit shorter though. I think [[[[k26]]]] has 3.09 coils per inch; it seems your spring has more like 2.6 per inch or 1 per cm.

There is a higher rated version, try entering D12790, and looking at the Load at L1, 160N variant.
I tried using this version in my first version of the barrel. It was a touch overrated for the internals I'd made. It shattered the (high tensile) screws holding the compression chamber together and I ended up firing out both the HIR ball AND the piston down the garden!

Is the [k26] more like this D12840 spring perhaps?
If so, thats quite interesting, as thats the spring I use in my Muskets.
 


In Topic: Muzzle loading 17th Century Pistol

21 June 2017 - 04:40 AM


Ah, would that be the red dot under the hammer?


Correct! :)
 

I see, thank you very much.  Is it possible to make them actuate at the same time, or would that be too much work for too little reward?


I tune the catch screw so as to get them to actuate pretty much at the same time, one of my ideas for the catch screw is to not use a single screw but to use two parts. The first part is a long 1/2 inch long grub screw, the second part is a brass hexagonal stand off. The grub screw is screwed into the catch itself, and the stand off into the other end of the grub screw. You can then alter the length of the catch screw by turning the stand off. This in effect alters the point at where the catch releases in relation to the pull of the trigger. Use a bit of threadlock paste to stop the brass stand off turning to easily.

A nylon stand off would probably work better than a brass one (as it would be harder to rotate) that's not something I've tested yet. It's something I keep meaning to drop into some dead space in the next batch of laser 3d printed parts (dead space in laser printing is usually free, so I usually fill it with something)


In Topic: Muzzle loading 17th Century Pistol

20 June 2017 - 05:27 AM

By the way the link to your spring doesn't work.

 

Thanks, if I click that link, it does'nt work, if I copy it and open a new window, it does work. Clearly Voodoo at work.
Try using this link https://www.assocspring.co.uk, and then entering D22790 as the search term on the company's front page. (box titled "search our site")
 

 

Close, but no. The spark would be created when the flint strikes the steel frizzen; the pan underneath holds the powder and catches the spark.

 I don't see a flint, so I'm guessing it doesn't spark.

Indeed you are correct, no flint, no spark, instead it's adapted to fire off a toy cap instead . That way it makes a nice bang when fired.

 

 

That's awesome!  I don't quite fully understand how it primes and fires though.  I understand that it uses the ramrod to push back the piston, but does the hammer have to be cocked in order for the catch to work?  

 

Also, does it spark when the hammer strikes the pan(I think thats what its called)?

The hammer does not have to be cocked, in order for the catch to work. 
It's a little complicated to explain in words, so I'll post a CAD drawing of the internals, suffice to say, they are side by side mechanisms, in that the trigger activates both the hammer and the catch at the same time.

So in the picture the trigger (brown) is pulled, which lifts the sear (red) and pushes one end of the catch transfer bar (blue) down
The sear as it lifts disengages the tumbler (green) dropping the hammer,

at the same time the transfer bar rotates around its axle, and pushes the catch (purple) up.

So while the hammer position has not effect on the catch, this is how both are activated at (almost) the same time by the trigger.
 


In Topic: Muzzle loading 17th Century Pistol

19 June 2017 - 06:51 AM

I must make a video of it firing :)
First I'll need to make a new one, as the one above is on loan to the chap who sells my muskets.

The mechanism is pretty simple, I use this spring https://www.assocspr...und-wire/D22790
with a *tiny* metal rainbow catch (I tried plastic, but the forces are way high and not much plastic to hold them, so it wears out too quickly)
(UK nerf builders, take note, the above company is *awesome* for springs)

As the compression chamber is the same diameter as the barrel, I have to keep the barrel very short, only 50mm.

To prime it, you use a ramrod down the barrel to push down and lock the pistol (this is intentional as these are replicas of black powder muzzle loading pistol)
then you pop the HIR into the barrel which has a 21mm choke in the barrel to hold the ball. The choke also acts as the end of the compression chamber, which is why you can see the heavy duty black screws in the barrel securing the choke from being displaced when the piston hits it.