Where I work we have semi-automatic machinery and a target run speed.
So I thought how could I build a timing device so that the operator can keep a consistent rate of running the machine as they are also the key person for keeping the speed of the whole production line.
With this in mind I originally started learning electronics and based my 1st prototype on a 555 chip with a decade counter. This was basically an adjustable LED flasher using a host of switches and resistors to be able to adjust the timing rate between 600-1200 an hour.
The 2nd prototype involved mounting this within a box (empty Ferrero rocher box) with one added adjustment of a rotary switch for adjusting the timing speed.
Both of these involved a lot of soldering and switches, plus they were fixed with no ability to easily adapt or modify them.
Around this time I started looking at microcontrollers for their ease of programing and adaptability plus I wanted to add a visual display for the timing rate and other features such as buttons and sound.
I am currently just finishing soldering this altogether ready to test on my Arduino as my 3rd prototype. It already woks setup on the breadboards which was immense fun and frustration at times (solving bugs) and so easy to adjust on the fly.
The programing of the Arduino took the longest as was adding routines and ensuring was running correctly. Having had learnt some C++ previously the programing was not overly difficult but was challenging especially when it didn't run as I thought I had programed it sometimes or did odd things. Things like a loop over running a byte value, or a loop with no exit. Was certainly valued experience and helpful in my programing skills, especially as I have already got a list on improving my sketch further.
The first prototype that I finally made failed, just wouldn't work and due to the compact nature of it was extremely difficult to re-solder and fault trace. I therefore decided on a larger one board layout and tried making it again. Sadly this failed also, and as I had used my breadboard version up as parts to assemble prototype I was unable to fault trace effectively.
I have rebuilt my breadboard version and am planning a third attempt to build a prototype but will not be done until I get some more board to mount it on. I have made a change in using a 4 digit 7-segment display instead of individual ones, so much easier to wire up. And found that on my fritzing layout I had wired up the buttons incorrectly which has now been amended.
Improvements have been added to the list and some been completed.
Step 1: Tools and Parts
1 x Arduino Uno
2 x 74HC595 shift registers
3 x 2222A NPN transistors
1 x buzzer/speaker
3 x 7 segment displays (3 digit 7-segment display better)
8 x LEDs (3 x red, 3 x yellow, 2 x green)
3 x tactile switches
resistors10k ohm x 1, 4k7 ohm x 3, 150 ohm x 8 (although I used one on my prototype board), 100 ohm x 1
male header pins
Breadboard or prototype board (depend what you want to mount it on)
Where to get parts
All the components I sourced from Ebay, the china superstore at £1 a go was excellent value. The only 2 parts I didn't get from china was the vero board and wire as cheaper here in the UK. Always have a look as often it cheaper to get 10x of one item for other projects especially transistors and shift registers. Often it was still under £2 for ten or 5.
Step 2: Testing
My first step in building this was using several breadboards and building up what I required.
I started with the shift registers and got those working as the are linked so that I only use 3 pins of the Arduino Uno. As one controls the 7-segment displays using multiplexing with the NPN transistors, this enables fast switching between the 3 segment displays tricking your eyes into thinking all 3 are on. The other controls the LEDs with a straight forward change.
Once I had these understood I then incorporated the buttons which do the 3 functions :-
- Change sound (2 beeps, 1 beep, Off, On)
- Enter Setup of rate
- Start/Stop running timing
Once you have entered setup their action changes to :-
- increment value by one
- decrease value by one
- move to next digit
There is a maximum value of 2990 that I have set that the unit will run at, as if faster it is going to be pretty hard to keep up with. A lower value I am planning on writing in is a planned improvement that I hope to do soon.
Finally I added a buzzer/speaker to the setup and got the sound running and able to turn it off.
Step 3: The Arduino Sketch
Although the Arduino is extremely versatile and can do a lot of different things, it is up to the user to be able to program these to make most use of it. My current version of the sketch is attached.
I have used software debounce instead of hardware debounce so fewer soldering and connections, so I can keep the package smaller. For those that are new to this sort of thing, debounce is where you counter the mechanical effects of a pressed button.
Debounce tutorial - An excellent article which made it all clear for me, many thanks
One thing I have tried doing is creating a function for the debouncing as the sketch is pretty long with all the debouncing code written in many times. So far the function is still in development.
The basic structure of the sketch is the main loop checks the three buttons and runs the leds if they are set to run. The 7-segment displays are constantly on and are called every time through the main loop. There are 2 functions, one for displaying the 7-segment displays which also updates the LED's, plus another one for setting the 7-segment displays.
I also plan on adding more to the setup routine so that all the LED's and segments plus sound are checked to begin with.
Uploaded latest version V2 25/10/2014
Step 4: Assembly
Above you can see the breadboard layout that I used a program called Fritzing to setup which was very easy to do. One draw back was that I should of done it in schematic view which would of been easier for when I was soldering. It is easy to use and very helpful.
For mine I used two shield sized prototype boards that had copper rings on one side as I was thinking of having them stacked up on the Arduino. One small annoyance was that the pins on one side did not line up that well with one side of the Arduino, so I had to remove one pin of my board and bend about 5 pins so it would sit on the Arduino. I am thinking about using some female header pins in between so it sits better and more clearance from all the pins and solder underneath.
The first layer consists of the shift registers and transistors plus the resistors. Originally I was going to use DIL sockets for the shift registers which I should of stuck with, but I thought it would be too high for the top layer.
The second layer has all the display and LEDs plus the buzzer and its resistor plus the buttons. Both boards proved to be a lot of soldering and used plenty up as I was soldering adjacent points across as wanted to limit the amount of wire connections. One solution I have thought of is to use pin headers or use ribbon cable to connect the two boards. This may of been easier also if I used a larger prototype board, but the main design was keeping it compact for a box.
It has been pretty tricky doing the soldering of the wires that join the two boards together, still have 16 to go as 8 for each shift register. I did reduce the amount of resistors for the LEDs as originally had 8 on the breadboard but only one on the prototype as only ever one led on.
Have included image of my second prototype attempt which I tried spacing out more on a single board. One thing I did do was use header pins so could easily change the wiring if need be.
Step 5: Further Development
Below is a current list of developments I plan to incorporate into my design (in no particular order).
- Design power circuit so can use just Arduino chip and mount all on prototype board reducing size.
- Add more to sketch setup so all LEDs and 7-segment displays checked plus sound
- Develop a debounce function
- Add another button so display is off and when pressed lights up for x amount of time
- Add lower timing limit (set at 400, done 15/10/2014)
- Add a sensor so can count time operator runs
- Once added counting sensor develop sketch so can display running rate as +/- amount
Any feedback or suggestions welcomed.
Had some further thoughts as to developing this.
- Use 4 digit 7-segment display so a zero is always displayed at end so number is correct. (done 29/9/2014)
- I play D&D so was going to write code so it can also be used as multi choice dice (D2-D100).
Step 6: Useful Links and Information
Through my learning of electronics and Arduino the following sites and books have been most helpful.
Arduino home page - Everything for Arduino great forum for all those questions and helpful community, tons of resources and info for all levels.
Electronics for dummies - Nice and simple introduction to electronics
Arduino Tools and techniques for engineering wizardry - still reading this and always on my desk when working on my Arduino.