So I’ve got a new job.
I work remotely as a Sales-Technician – I take technical support calls for a private company and sell technical service to customers so that I can remotely access and fix their computers. My job’s current focus is taking sales calls and there are certain metrics that must be met to be in good standing. One of those metrics is the close rate, or percentage of sales made out of sales calls answered.
This is great, and I love it so far. One issue I came across was keeping track of my calls and sales for my own records. The supervisors keep track of the stats and issue reports a few times a week as needed, although I like to keep track of my stats in real time. The job is heavy on multitasking, and while having two customers chatting with you, remotely accessing their computer and supervisors asking you questions via chat, it’s easy to forget a tally mark on my spreadsheet on screen that’s minimized in the corner somewhere.
The Sales Counter
I’ll be honest – I just really wanted to build something using big clicky tactile classic arcade buttons like these, and then finally the sales counter idea came up. The idea was to build a fun device that I could mash big arcade buttons every time I answered a sales call, and/or made a sale. This device would display the number of calls vs. the number of sales and possibly also the actual close percentage. One further thought was to have it play some little beepy tune every time a sale was made but what I had thought up so far was already a challenge.
It sounded fun to use. For the first time in a while it was a project that was both challenging to me and actually had a purpose other than sitting on my shelf wasting space.
From the beginning, this project was more about the challenge of teaching myself how to use all of the different components and putting them all together in one functional system.
Things I knew how to do before the project:
- Prototype something in Arduino and transfer it to an ATTiny chip
- How to use buttons, switches, and other various basic electronic components
- Fit a lot of things in a small space
- Display a digit on a single 7-Segment LED Display (directly to Arduino, using all the pins)
Things I didn’t know how to do before the project:
- Use a shift register
- Program an Arduino to use a shift register as multiple digital outputs
- Use a 4-digit, 7-segment display multiplexed
- Program a microcontroller to use multiplexed 7-segment display
- Arduino multitasking – (performing separate functions at the same time and not using the Arduino delay(); function.)
Most of the project was a mystery at the beginning, although I knew that the knowledge on how to use these components were readily available online.
The goal was to create a device which had a small footprint on my desktop. It would have two buttons, each used to increment the display/counter each time a call was answered or a sale was made. A large LED display would display (up to two digits each) the amount of calls and the amount of sales made. A third function would switch the display from the actual count to a percentage using a decimal and also be sturdy enough to withstand me mashing the buttons.
Preparation and Design
I ordered all the necessary parts for this project from Sparkfun Electronics. They were the easiest to order from and the selection was cut and dry, I knew also that their support community would help if I needed any, and the staff is friendly!
I already had all the other parts on hand like an Arduino with a proto-shield, a handful of ATTiny85 chips, and various passive components.
I had originally intended on having three separate LED displays (one 4-digit for percentage, and two other separate 2-digits for the calls/sales counters) but this was going to come out very wonky, complicated and taken more space.
A big part of this design was that It needed to be small. I didn’t want something large and in the way on my desk that would kill the fun. Also, I really don’t like installing an Ardunio into a semi-finished project/prototype. It’s just silly and large – so I opted to just prototype on the Arduino and port the program to an ATTiny85
Research online showed that I could have 8, 16, 24, etc. digital outputs using the 74HC595 8-bit shift register and only use three pins on the Arduino. I knew that if this was possible on the Arduino using it’s IDE, then It had to be possible on an ATTiny85 which I have worked with on a previous project. I would program and prototype on the Arduino, and then port everything to the ATTiny while using the Arduino IDE that I was familiar with. I was cutting it close though, the ATTiny85 has (theoretically) 6 digital I/O pins, but one was the RESET pin. I found online that it was possible to set this pin as a digital I/O using the proper tools (high-voltage serial programmer) although I was only using an Arduino as an ISP.
I needed an enclosure. Where do you go when you need something cheap, and sometimes still works so that you can rip it apart? The local thrift store.
That’s where I found this:
A crappy old digital clock from the 80′s. (this is someone elses’ image, but it’s the exact same clock). I said hey, that’s got a 4-digit 7-segment display, and isn’t huge – so that will work.
Holy crap – I actually found datasheets for the chip inside it and the display. I don’t have the pictures at the moment, but you’re not missing much. The inside is a couple PCBs, one having a handful of passive components and a large DIP Texas Instruments general-purpose digital alarm clock chip.
Well, I wanted to use the display that came with the clock but for this being the beginning of the project, it was a bit overwhelming to figure it out without even really having a concrete understanding of how to even multiplex, or how this type of display works. When sticking it on a breadboard and poking it with some probes, It seemed to have a very strange type of multiplexing that only lit certain digits at certain times since this was meant to be a cheap clock. It also wouldn’t work with my project since this is a 12-hr format clock which means they were to cheap to include all the segments for the first digit. (i.e, the clock’s first digit will only display the number one and nothing higher)
But the enclosure was nice. It had plenty of space on top for my big buttons, the LED display I ordered from Sparkfun fit perfectly in the old display’s place, and the whole thing wasn’t giant.
The first thing I needed to do was learn how to use a shift-register. This was needed to be able to multi-plex the display and only use 3 digital I/O pins on my microcontroller. This was important since I didn’t plan on using the Ardunio in the final project, I needed to use the ATTiny85.
I did a lot of research and could hardly find anything that involved exactly what I had planned. Almost nothing online involved driving a 4-digit 7-segment display fully multiplexed. This display only has 12 pins.
I found an excellent resource for the basics of 8-bit registers on a bildr blog page: Can you move over? The 74HC595 8 bit shift register
Sparkfun has their own tutorial video by Nick Poole which demonstrates what a shift-register is: Sparkfun Shift Registers
These resources were extremely useful in learning the basics but the challenge was to translate the basics of a shift register to how it can be useful for controlling an LED display. I learned that here: Getting Started with Ardunio – Chapter tweleve – tronixstuff Mr. John Boxall starts off this post by talking about exactly what I’m doing. (everything minus the DS1307 Timer and the rotary encoder.). This image alone is what really got me started:
Credit: John Boxall, tronixstuff.wordpress.com
This shows how the 8 segments (decimal point) can all be individually controlled, by cycling through the common cathodes quickly. It’s Multiplexing!
From electronicsblog.net, I was able to find some useful code to help address the individual digits and mix this all in with the registers and multiplexing: Arduino 4 digits 7 segments LED countdown timer with buzzer. I didn’t need the buzzer part, but what I used was the functions related to controlling the individual digits during each cathode-cycle.
Here’s the code I strung together to display a bunch of zeros on the display: show_digits_zero.ino (it’s a txt file).
Put Things Together
Here we have the fully functional LED display + Arduino + shift registers displaying some test numbers.
errm, I apologize, this schematic is incorrect as there are supposed to be resistors between the registers and the LED display… see final schematic.
The three SPST buttons are the controls for the counter. Sales and Calls are the big arcade buttons that will be mashed to increment the amount of sales and calls. A third SPST will switch the counter between two modes: percent mode and regular mode. Percent mode does what it says, and turns on the decimal point, and shows the current close rate percentage. For this function, I decided to use the snooze button which was already present on the clock enclosure. So I’d be salvaging part of the clock’s PCB buttons.
Porting to ATTiny85
The challenges I came across are common that anyone doing this would encounter, I will detail this adventure later in another post in the future (this might turn into a link to that post one day).
The main issue I had with porting everything over was the fiasco with the RESET pin. While only using the Arduino as ISP, the RESET pin on the ATTiny is necessary to re-burn the chip. Many resources online indicated that it’s possible to program and re-program the chip without the RESET pin, but a high-voltage programmer was needed (not arduino as ISP). I could do it using only Arduino, but there was a risk. User Panici on this thread reveals a way to use the Arduino to re-burn the bootloader to use pin PB5 on the ATTiny as an I/O, but it would be a one-shot chance. Once the fuse is set, and the code is loaded, there’s no going back unless you have a HVSP (which DIY versions exist but this was easier).
Basically, I had to get my code working to test (minus the percent mode button, since that used the RESET pin) and once everything worked, I just had to hope the the percent button would work after porting over.
Well, the first attempt failed. And for obvious reasons. If you look in the thread linked above, I copied the exact command that was there without changing the reference for the hex file. So I pretty much burned a blank program to the chip and (for now) bricked it.
The next attempt worked, got the program over, and PB5 (reset) as the percent mode button worked! No turning back now, the chip is programmed and set. Anything else I wanted to change would need a new chip or a HVSP.
Here I have a second breadboard with just the ATtiny85, and it’s driving the registers and LEDs. If you look closely, the Arduino is present but disconnected. You can also see that it’s currently in percent mode displaying “60.00″ which would be 60.00%
Moving from Breadboard to Perfboard
Here’s the space I had to work with:
Now to solder everything to it’s final resting place, and add a LM7805 5v Regulator:
Then shove it all in and add a 9v battery!
Yeah, the numbers turned out red instead of blue – that’s because the window on the clock had a red tint to it. Really wanted blue, but I’ll have to settle until I can maybe make a new window from acrylic or something.
So here’s how it works
So with reference to the photo below, it shows “0602″. Which, I know they’re not really separated but it’s going to have to do. The two digits on the left “06″ represent the number of calls answered and the green button on the left increments this number. The two digits on the right “02″ represent the number of sales made and the green button on the right increments this number.
When pressing the “Snooze button” (the long button on the left side), the counter switches to ‘percent mode’ which displays the current close percentage. This is simiply the number of sales made divided by the number of calls taken then multiplied by 100. The result is “33.33″ or 33.33%
When the percentage is 100%, the decimal moves over to the right to display “100.0″ or 100%. I didn’t program this thing to display anything over 100% as it wasn’t needed and not likely that I’ll make more sales than amount of calls taken.
On The Job Testing
After finalizing it, I used it for a few days on the job to see how it worked:
Well, about half way through my first shift, my 9v battery died. I didn’t really put any thought into how much power this thing consumes with the super bright blue LED’s and the ATTiny85. Moving forward, I decided that no matter what numbers I came up with, even if it meant replacing a 9v every 1-2 months, I didn’t want to spend the money.
Further, I really didn’t need to have the device be super portable, so finding a stable power source sounded like an OK idea. I decided to replace the 9v battery pigtails with an old USB cable so that I can use the 5v from my computer. Works perfectly and no extra cost necessary.
The window on the clock is tinted red. My super awesome bright LED display is blue. This combination makes it very difficult to see my display when other lights are on in the room. You can even see it from the pictures above how hard it is to see. If i turn my second desk lamp on then forget it. I was thinking the original red tinted window would be okay but it turns out that it’s not so I might have to change it out or find a way to make it less red.
Video coming soon