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.

Saturday, March 31, 2012

7 Segments display on my Spartan

I decided to start my VHDL review with the 7 segments display controller for the Spartan 3 FPGA Board. I have to admit that I cheated a little bit and reused most of the original code I used for my class. I just added a little extra functionality and comments to my code. Before I post the code, let's review the way this 4 digit display works.

Now, you may have thought there should be 7 signals to drive each of the 4 digits and 4 for each of the possible decimal points, a total of 32. However, there are only 12 signals that control the display: 7 for the segments, 1 for the decimal point and 4 to select which one of the 4 digits is active. This is a clever way to save 20 inputs and adds just very little difficulty to the implementation. Because of this, only one digit can be on at a time. So... how come we see all 4 on? It's just a matter of turning them on and off in a cycle so fast that the human eye won't notice when they're off. If we slow down the cycle enough we can see it:

Display slowed down using a 26 bit counter


The way I have adjusted the speed of the cycle is by making a counter large enough (16 bits for the final version) so that the 2 most significant bits take a while to change when the number is being increased by one every clock cycle. Those two bits are the select signals for the multiplexers that pick one of the digits and its value to display. I tried to see what happened if the counter was smaller and noticed that the digits started to get all blurred together. After fixing that, I took a picture of the working display:

"Finished product"



I almost forgot to mention: all the signals for the display are "Low asserted", which means that "ON" is 0 instead of 1 and "OFF" is 1 instead of 0.

Finally, HERE is the VHDL code and its corresponding .ucf file(the one that matches the signal names to on the code to the board signals.

Tuesday, March 27, 2012

Ready, set, go!

Today I finally got in the mail the equipment I am going to be using for my little beginner's projects and I am so excited!!! My school renewed some of the equipment in the digital lab and sold the old FPGA boards for a very tempting price and I couldn't resist. Here's what I got:


I had to get a power adapter for the board and a parallel port for my computer but I can start downloading my little baby steps now. I also got a little Teensy++ USB development board. That one I got because I was originally intending to use it for a project that a friend from business school asked me to joint but when the team decided to go on a different direction I was already very interested in learning how to use it so I bought it for myself. Here's a picture that shows how tiny and cool (at least for me) this thing is:



And finally, as I was browsing the web looking for projects I stumbled upon a little infrared remote and receiver and bought them as well. Yeah, I wish I were not a poor student, then I could buy more stuff I don't know how to use (yet). And yes, I also took a picture of that:


In the end, I still don't know what I am going to do with all this but in the meantime I will lean how to program Teensy, start reviewing my old Lab files to get my VHDL skills back and will be posting my progress regularly. Maybe I can come up with a larger project along the way. For now, it's time to go to bed.

Monday, March 26, 2012

Text in forms disappearing on Adobe Acrobat

I just ran into an interesting issue at work. User 1 sent a PDF form to User 2. When User 2 was done and sent it back, User 1 could not see the text entered in the form unless she clicked on the field and then it would only show that field.

Turns out that this is a know problem with PDF form filled on Mac OS X. Someone smarter than me made a fix, here it is:

Windows Vista (And I tried it on 7 and it works):


1. Download this script
2. Close Acrobat
3. According to your operating system, copy the downloaded script on the corresponding location:
  • Windows XP: 
         C:\Documents and Settings\USERNAME\Application Data\Adobe\Acrobat \9.0\JavaScripts

  • Windows Vista (And I tried it on 7 and it works): 
         C:\Users\USERNAME\AppData\Roaming\Adobe\Acrobat\9.0\JavaScripts

  • Mac OS X:
         /Users/USERNAME/Library/Application Support/Adobe/Acrobat/9.0_x86/JavaScripts

4. Open Acrobat
5. On the "Edit" Menu, click on "Fix Field Appearances". Done!

Note: The path is for Acrobat 9, but I tried it on Acrobat 10 and still works, at least on Windows 7.

Al credit goes to the smart dude who made the solution. Here's where I found it.

Sunday, March 25, 2012

Computacion con manzanitas

Estaba muy emocionando platicando con mi mujer acerca de mi primer y unico blog (este) y se nos ocurrio que  una seccion podria ser dedicada a compartir principios sencillitos de computacion para aquellos que tengan la curiosidad de aprender. A diferencia del resto del contenido este sera unicamente en EspaƱol, con el objetivo de que tanto mi mujer como otros que se sientan mas comodos en este idioma lo aprovechen mejor.

Dicho esto ahi van mis dos primeras grandes sugerencias para aprender a sacarle mas jugo a la computadora:

  1. No tengas miedo a descomponerla: Es casi imposible echar a perder la computadora simplemente moviendole a los programas y picandole por aqui y por alla. Aunque es posible dejar la computadora inutilizable por un rato y requieras la ayuda de alguien mas experimentado, solo el danio fisico puede llegar a ser irreparable. Mientras no la eches al agua o la agarres a martillazos todo estara bien.
  2. Siempre ten una copia de seguridad de tus archivos: Utiliza alguna memoria externa a la computadora para guardar un respaldo de tus archivos, de esta manera en caso de robo o perdida total de la informacion en la computadora no pierdas para siempre tus fotos, musica y documentos.

En el futuro publicare en este blog algunas "Definiciones marca Pey" para ayudar a entender esos conceptos que a primera vista se ven complicados. Solo es cosa de perderle el miedo y darse cuenta que es mas facil de lo que parece.

Friday, March 23, 2012

Dual boot Mac and domain logon problem

Yesterday something reminded me of a stupid problem I had last year. I am one of the administrators for a computer lab at school and during our big yearly re-image and update of he computers I noticed I was having problems logging in after putting them on the school's domain.

The problem was that after adding the computer to the domain on the Mac side, once I tried it to add it on Windows side the "link" would be messed up and since we were using a domain account to log in, we were stuck with just the local account.

The solution/workaround was to remove the workstation from the domain (both at the workstation and the Active directory Users and Computers list) and then add it on the Windows side FIRST and then on the Mac side.

I don't know if an update or the IT people have solved this little issue yet but I document it just in case anyone comes across something similar.

Thursday, March 22, 2012

Outdoors!!

So, I am taking and  outdoors recreation class (I needed something easy to balance my load this semester and that was the only thing I could get) and we went to a rope-climbing-course-thing-place. No mames! Now every single muscle in my body is sore. But it was awesome! I am starting to realize there is cool stuff outside of my cave (not that there is anything cool here anyway).

BTW, I had noticed it before, but today I found more evidence of my aversion to sunlight:


This picture was taken at noon. The door at the bottom is the bathroom, guess which one is La Cueva del Pey.

Wednesday, March 21, 2012

I have a midterm, I have a midterm...

Yeah, but it is easier to get distracted and start a blog that will probably die in 2 weeks. If you happen to be one of the < 10 people who will visit this blog, here's a few DISCLAIMERS:

  • This is my first blog ever, it was never intended to be a good blog, it's probably lame and I'm OK with it.
  • I'm Mexican: You will find Spanglish and/or Spanish. 
  • I used to be obsessed with spelling but I don't care about it or grammar anymore. (Pero nuunk boi a ezkribir asii, m kstra la gnte k lo haze!!!) 
  • No tengo "Enie" ni acentos en mi teclado y me da hueva solucionarlo.
  • I might (highly super most pinche likely) use inappropriate language 
I might add more to that list eventually.

And now, let's get started with this "blogging" thing.