What I do own is a half-assed ballistic timer and a triggering oscilloscope. Here you can see the parallax USB oscilloscope. They're about $100 and probably one of the best buys a home electrical engineer can make.
I've got it hooked up to some infrared sensors (shown in the next pic). When the beam is broken the sensor makes a pulse that the scope can pick up. Setting up the scope every time, however, is kind of a bitch. There's a lot of clicking and getting things just right. When you're tuning an electromagnetic rifle, you'll need to take many shots in succession and this will slow you down.
My solution was to hack a microcontroller into doing it for me instead. The microcontroller also watches the sensors but it resets every time it sees a new round go through so there's not re-setting. And instead of having a nifty, highly accurate but click-drag heavy way of finding the distances between the pulses the microcontroller just counts off in binary on the lights that come mounted on it by default. All lights on means it's ready and waiting for a shot.
I didn't try real hard to calibrate it but the pulses come out to about 1ms per binary digit. When the gun is firing at full speed I'll have to reduce the wait time.
Here's the code:
#include
void wait(int a, int b)
{
int i,j;
for(i = 0; i < a; i++)
for(j = 0; j < b; j++)
}
void count()
{
int time;
TRISC = 0xFF;
TRISD = 0x00;
PORTD = 0xFF;
//Check portc 0 going to high
//Check portc 1 going to high
//Show elapsed time
while(1==1)
{
if( (PORTC & 0b00000001) > 0)
{
PORTD = 0b11001100;
time = 0;
while( (PORTC & 0b00000010) == 0)
{
wait(0x01,0x2F);
time++;
}
PORTD = time;
wait(0xFF,0xFF);
}
}
}
void main()
{
//testPortC();
count();
}
No comments:
Post a Comment