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.

1 comment:

  1. Ese Pey por fin lo hiciste me da gusto, felicidades amigo y no se ve tan mal.

    Oye escribe algo sobre los Hackers de Mac y de Google Chrome

    ReplyDelete