Monday, April 9, 2012

7-Segment display, now on Teensy

Finally, after a few setbacks, I was finally able to play with Teensy and learn how to program it. Here's a few notes on that.

Looks like the numbering convention for the pins on an IC is as follows: Take the IC (or in this case the display) and with the top facing you and the notch on the left side, pin number 1 will be the one on the lower left corner and the numbers will increase to the right and then continue from the upper right corner to the left. I can't believe I did not know this.

Another thing I noticed is that not everything is low asserted like it was on the Spartan board, here only the segments and the cathodes for the colon and apostrophe are low asserted. Otherwise, the display works pretty much the same, with only one digit on at a time. Here's a little clip of the display slowed down:



I used C to program Teensy and by the way, it's super easy to download the program to it, once you have it setup just press one button and that's it. The finished product looks like this:


I must mention that I haven't made my code very portable, the digits are hard-coded but with a few tweaks it can take inputs. I'll add that to my to-do list and post it somewhere in here later.

I got the display from www.robotshop.com, they have the correct pinout but just in case:

1: Digit 1 -             16: B
2: Digit 2 -             15: G
3: D -                     14: A
4: Colon Anode -   13: C
5: E -                      12: Colon Cathode
6: Digit 3 -             11: F
7. Decimal Point - 10:Apostrophe Anode
8: Digit 4 -             9: Apostrophe Cathode

Teensy has ports of 8 bits each one, with each bit corresponding to one pin. The way I wired them was:

PORTB(0 to 7) : Segments A to G and decimal point.
PORTC(0 to 3): Digits 1 to 4.
PORTC(4 to 5): Colon and apostrophe cathodes.
PORTC(6 to 7): Colon and apostrophe anodes.

I have uploaded all the files HERE, feel free to take a look. I do not claim this is the best way to implement this simple display, I would actually be grateful if you leave a comment with a suggestion on  any clever way to do it better.

Wednesday, April 4, 2012

Defective display + noob = Waste of time

And add to that an old breadboard. I was very excited to do my first Teensy little project, just to learn how to use it, but nothing worked the way I was expecting. Only 2 segments were being displayed. At first I thought I had wired something wrong. I checked the pinout for the display. The vendor's webpage said that the manufacturer's documentation was wrong and provided the right one. And it still didn't work. I thought maybe I was reading it wrong, to be honest I did not know the convention for numbering pins on an IC. I just got confused.

Finally, I decided to just map every pin to a switch or button on the Spartan board (I even had to use a couple generic pins) and just see where it took me. After several minutes of trial and error I realized that the pinout from the vendor was right. At that point I was wiring everything the way I should. But some of the segments were still not turning on. So I tried the extra display I bought. Bingo! (kinda) All segments except one turned on! After checking the connections I suspected either a pin on Teensy or the breadboard to be the problem... And luckily it was just the breadboard.

It's going to be a little annoying having to use a separate breadboard for Teensy instead of using the one on the Spartan add-on board but I'm OK with that. So... I just have to make a few adjustments and I will post the seven segments display code now with Teensy here.