I’ve got a project where I want to count a signal from a shock sensor for a period of time.
The shock sensor will be connected to a pistol target so the signals will only be a couple every second.
Push a push button
delays 3 seconds
Outputs a signal to a piezo buzzer
starts 5 second timer
counts number of inputs from shock sensor (3volt signals that are sent from another circuit)
buzzes again at 5 seconds
outputs number of hits to lcd.
I’d sure appreciate it if someone would point me in the right direction.
Thanks guys
This is a pretty simple task for something like an Arduino.
I would buy:
Arduino http://www.sparkfun.com/products/10356
Serial LCD display http://www.sparkfun.com/products/9066
Pushbuttons http://www.sparkfun.com/products/9336
Buzzer http://www.sparkfun.com/products/7950
The only thing that worries me is your shock sensor input at 3V. In an ideal world, the signal would be enough to trip a 5V logic Arduino input, but in the real world it might have issues including noise. But nothing that some extra circuitry would not solve.
fll-freak:
But nothing that some extra circuitry would not solve.
Or using the analog input for the (assumed) digital 3V signal. Or perhaps a 3.3V version of an Arduino.
Or using the analog input for the (assumed) digital 3V signal. Or perhaps a 3.3V version of an Arduino.
I was assuming the pulses might be very small due to the nature of the system (bullet strike). As such, I figured the signal was attached to an interrupt line and would not be polled using digital or analog reads.
I like the idea of using the 3.3V Arduino. Changes the buy list a bit (finding all 3.3V parts), but does lower the risk on the interface.
Darn, I’ve already got sparkfuns Inventor kit with the arduino uno and I bought an LCD screen.
This is the circuit im using for the shock sensor.
http://electroschematics.com/6023/vibra … r-circuit/
It uses an NPN transistor to send a 3v signal from a button cell battery. Is there any way to make this work.
This should be pretty easy to get to work. Had you told us what you had in stock, we might have skipped the shopping list.
The circuit you point to uses a monostable one-shot to generate a single pulse for what might be lots of ringing after you smack the sensor. I was worried about this as you might have counted hundreds of hits for each bullet. There were ways to fix this in SW but this circuit (as long as C2 and R3 are properly sized) should solve that problem.
The next hurdle is the Arduino 5V power and the circuits 3V power. Pulling up the datasheet on the 74HC123 shows that it works to 7 volts. Not sure about the piezo element, but I would assume it is good to 5V. So a solution of just to replace the 3V coin cell with the Arduino’s 5V regulated supply.
The output of your circuit is just an open collector. This means it does not provide any voltage, all it can do is close a circuit to ground. So even if you decide to use the 3V coin cell, you are still ok. Just tie the “C” connector to a digital pin and the “E” to ground. Now you need to enable the internal pull up resistor on that digital pin to give you the pull up you need.
After this, its all just code…
The use of the 74HC123 already makes me wonder if the whole device might be done with just “555s” and discrete logic (if that can be found these days). One 1-shot sounds the buzzer and enables, for 5 secs (another 74HC123), a BCD counter. The counter input is the other 74HC123’s output and the outputs drives a 7 segment display. I’ve yet to figure out how to get the buzzer to go at the end but I’m sure it could be done. Not as fancy nor as versitile as using an Uno (which could also time the shots).
Thanks a ton for all of the advice guys!
Is there any projects similar available on-line that I could learn the programming concepts for this project?
All of this is a stretch for me, I’ve got some education in electronics (hardware) but the only programming I learned
was Visual Basic freshman year of college in 2005. I’m all for not needing to completely re-invent the wheel.
So what LCD display do you have? Based on that, you should be able to find lots of sample code to drive the LCD. The rest of the program is very simple. If you begged with sufficient humility (this is not a good way … viewtopic.php?f=14&t=31656&p=140653&hilit=money#p140620), someone here might write you a shell that you could tune.
sspbass:
Thanks a ton for all of the advice guys!
Is there any projects similar available on-line that I could learn the programming concepts for this project?
All of this is a stretch for me, I’ve got some education in electronics (hardware) but the only programming I learned
was Visual Basic freshman year of college in 2005. I’m all for not needing to completely re-invent the wheel.
Let me suggest that up front you simply make a list of what you want it to do and jot some ideas of what has to happen, step by step, to make those happen. For example your original list is a good one :
Push a push button
delays 3 seconds
Outputs a signal to a piezo buzzer
starts 5 second timer
counts number of inputs from shock sensor (3volt signals that are sent from another circuit)
buzzes again at 5 seconds
outputs number of hits to lcd
So let me ask a few questions based on my experiences. Do you want a fixed delay of 3 secs ? On my shot timer, there’s a random delay that goes from 3-5 secs (IIRC). That’s so I can’t fool myself and “time” my 1’st shot knowing when I pressed the “go” button. Do you also want to record the times of each hit (say yes), so your target is not only a counter but a timer ? Do you want some way to save the times/count for future review ? How will the times/count normally be cleared ? How long will the start buzzer sound for ? Do you want to be able to record a hit before it’s finished sounding ? (this has implications on how the software is written)
If you think some of the above are good ideas, don’t feel like you have to do it all at once. Rather just have some inkling of how you might do certain functions so the base software can be readily expanded to do them.
Out of curiousity … what’s the target ?
Awesome, I’ve got a gun guy on the line!
-The random time between 3-5 seconds is great, I just picked 3 to make it simpler for me.
-My ultimate goal is to have several settings. i.e. one setting counts the number of hits for an adjustable amount of time.
Another setting will time how long it takes to achieve an adjustable amount of hits.
I would also like to integrate multiple targets so I could compete with a friend on another target.
This is all pretty lofty which is why I wanted to start off with the simple functionality I stated above.
-Recording the time of each hit is great, I just didn’t know how to go about effectively displaying all that info.
-I figured that once the round was done it would display the corresponding info and pushing a button would reset it.
-I want the buzzer to go for approx 1-2 (how long is your shot timer?) seconds and I want the timer/counter to start as soon as the buzzer starts.
-The target is 3/8" steel mounted to an angle iron stand.
-On top of it all I would one day like to make the shock sensor mount to the target and wirelessly send signals to a shot timer type unit clipped to the shooters belt. For now I just want a prototype to see how cool it is.
In the spirit of complicating things beyond all reason …
Do you need to know which target was hit of just that a target was hit ? Some many years ago when I was doing a lot of bowling pin and plate shooting, I needed to have a better practice system, so I’m keen on this type of thing. I ended up with something different from your plan but I did have some thoughts on making it “better” (tying it into a PC). :mrgreen:
Starting off simple, it’s pretty easy to record all the shots and their times relative to the “go” with an Arduino. You could also set up the display to scroll though the shots and times, it’s what all the simple shot timers do. You just need to have buttons to command scrolling back and forth with. Your 15 character by 2 line display could do something like this :
Shot XX of NN
Time: TT.TT {alternately blinking with} Interval: tt.tt
Then scroll to the next shot times. Or something else.
Competing mano-a-mano shouldn’t be too hard either, just need to have 2 input pins on the Arduino which get measured and recorded, assuming any hit on any of your targets just gets counted as a hit. And same for the opponent. Your targets are wired in parallel and his are too (your existing hit detector works well for this). That is you don’t need to know that target #1 was hit a time T1 and target #2 at time T2 and … I have a plan to do this but it gets more complicated.
My timer beeps for under 1 sec. I’d guess 0.5 but that’s a guess. The thing is you want to be able to record a hit before the buzzer is done buzzing.
I guess I have always envisioned just one target per shooter but there’s no reason to limit it to one per shooter.
I can definitely see the benefit of know which target was hit and how many times since it could tell your weaknesses. i.e. not transitioning from one target to another very well. Perhaps its as simple as limiting it to the number of inputs available. Each target is an input, i.e. (I realize I’m using i.e. a lot) 4 inputs means 4 targets, the user can just determine if target 1 and 2 belong to the same shooter, if intervals are being recorded as well, the info shouldn’t matter to the Arduino. All that matters is that the user interprets the data according to how they were shooting.
sspbass:
Perhaps its as simple as limiting it to the number of inputs available. Each target is an input, i.e. (I realize I’m using i.e. a lot) 4 inputs means 4 targets, the user can just determine if target 1 and 2 belong to the same shooter, if intervals are being recorded as well the info shouldn’t matter to the Arduino. All that matters is that the user interprets the data according to how they were shooting.
Pretty much that’s it. You could dedicate some pins to Shooter A and some to Shooter B and have the Arduino keep track which are which when in “2 shooter mode” … or lump them all together in “Single shooter mode”. There’s lots of things you can do once you’ve got some “smarts” in the targets. I think an Arduino has a limited number of digital input pins that can also act as interrupt sources so in the above case I’d think the simplest thing to do would be to poll all the input pins every so often (1msec?) and see if a hit occured or not. If one did, save the pin/target number and the time. Also be sure not to re-record it as another hit for the next 2 or 3 polling periods. Buzz the buzzer as needed. The Arduino could have various “game” modes and be more than just a timer/recorder … but also act as a judge.
Imagine a shooter vs shooter course where each has 3-5 targets (constrained by available pins … at first. There are ways around this too) to clear. First to do so wins. Go button starts the buzzer and the race is on. When the Arduino detects all 3-5 of one set are hit, it buzzs and declares a winner. Hit times are saved for display. No need for a traditional stop plate. A time limit could be imposed as well, shooter with the most hits in that time wins (for the newbies). Lots of other simple games are also possible.
Too bad I suck at programming! haha
Whats the best resource for learning these specific concepts.
I made it half way through the book sparkfuns inventor kit came with.
It’s definitely interesting but there isn’t any of the concepts used that I need, unless I missed something.
Perhaps the Arduino tutorials page ???
http://arduino.cc/en/Tutorial/HomePage
You need to be able to read and set digital inputs and outputs, enable the internal pullup on the inputs. You need to understand a timer based interrupt (this is somewhat advanced) to be able to record a time, and be able to call the function millis(). Just these would allow you to read the “go” switch, delay some seconds, buzz a buzzer, and record number of hits and their times. To interface to the LCD you’ll need to understand serial communications and to interpret the LCD datasheet. I would actually do this last as you could use the PC-serial link to get all the other stuff working first. If i were an Ardnuio person, I’d have a whack at it. If I have nothign better to do tomorrow I may give is pseudo-whack, if you don’t mind half written code missing pieces to use as a starting place. An Arduino sketch is not that different from C programming.
Well I guess I better I get started then!
I’m reading a few tutorials about interrupts but it’s clear to me that I don’t have the proper foundation to apply the knowledge.
Would an external interrupt be used initially to start the process and the timer interrupts would take over after that to do the timing and counting operations? Is the portion that does the timing and counting all in a single timer interrupt?
I wish I could just find a good example online that I could modify to fit my needs without needing to re-write the entire thing.