Monday
Jun252012

What my bench looks like after a little work

I’m frequently accused of being a neat freak. I clean my bench (in my living room) every day. But no matter what I do this is what it looks like after just a couple hours of working on a project. In this case, I was just messing around doing realtime DSP on an FPGA.

My Bench

Thursday
Jun142012

Television + FPGA + Verilog

I love when people share their code on the internet, but have a complaint: short, obscure variable names. Also, a lack of whitespace. Most engineers aren’t the best at documentation, myself included. But I try my best to make my code very readable. It can be a pain type out 20 character variable names, but that’s where code completion, along with regular expressions and find & replace come in.

Surprisingly, unreadable code recently led me to do something I don’t often do: start from scratch. I was looking for a Verilog module to generate an NTSC signal, which is the analog television standard in North America and a few other places. There were plenty of VHDL snippets out there, and one or two Verilog, but I couldn’t make heads or tails of what the author was doing with it. So I got on Google and and found just about every document I could on the NTSC standard until it finally sunk in. I was just starting to get the hang of Verilog before I started this project, but having to go from timing specifications to an FPGA (Field Programmable Gate Array) really made it all sink in. The irony is that I really didn’t even want to generate a TV signal. I wanted to output video from my prototyping board to a VGA display, but I don’t have one. Normally they’re a dime a dozen on trash days here in NYC, until I needed one. But, I do have a small TV a neighbor threw out a few months ago.

So here I’m sharing my project. At the heart is a file named interlaced_ntsc.v, which generates 3 bit monochrome video signal. There’s one bit of code I borrowed, another file named 8x16_font_rom.v. It’s just a pixel lookup table for all the ASCII characters. Making a font rom is tedious, so I don’t feel bad about using that. The top project file is top_ntsc.v. It’s included only as reference to complete working project. You don’t need to use it unless you’re new to FPGA’s or Verilog.

Here’s the instantiation template for my NTSC code. There’s a few signals not listed, which are only needed for debugging with an oscilloscope. They’re documented in the code.

interlaced_ntsc.v instantiation template

interlaced_ntsc instance_name (                
    .clk( clk ),                              // input: 50 MHz clock input     
    .pixel_data( pixel_data ),                // input: brightness of pixel 0..5
    .pixel_y( pixel_y ),                      // output: current pixel's y coordinate (row number)
    .pixel_x( pixel_x ),                      // output: current pixel's x coordinate
    .pixel_is_visible( pixel_is_visible ),    // output: high when not a sync signal, but not necessarily visible on the screen
    .ntsc_out( ntsc_out )                     // output: the TV signal, fed to a 3 bit r2r DAC
    );                                   

The 50 MHz clock requirement is baked into the code right now. I’m trying to figure a way to improve that. If you need to use a different clock, adjust the timing constants in interlaced_ntsc.v. They’re pretty obvious.

That’s it. I’m the first one to admit that I’m frequently a hypocrite, so if there’s something you don’t understand, or needs more comments, please let me know. And if you see a way to improve it, definitely leave a comment.

Source Code

Monday
Mar262012

CR2450 Coin Cell Charger

This project was mainly a way for me to learn Altium Designer. It started out with me just messing around, but slowly a nice looking board started to emerge. So, I sent the design off to Gold Phoenix and got back 90 boards. It’s a charger for a single CR2450 (LIR2450 to be exact) coin cell. CR normally applies to primary cells (non-rechargeable). I’m guessing LIR stands for Lithium Ion Rechargeable. I bought a few of these cells from SparkFun a while back, but never really used them because I didn’t have a convenient way to charge them. Sparkfun sells a single-cell lithium charger based of the MAX1555 IC, but that chip has been hard to source lately. Regardless, its charging current is too high for this 110 mAH cell, and their board requires another daughterboard to hold the coin cell.

SchematicThis board is based around the MCP73832, which contains all the logic and active devices to charge a single lithium ion/polymer cell. It has multiple charge modes, including constant current which does the bulk of charging. R3 sets the constant current. I chose a resistance of 20k ohms, to get a constant current of 50 mA; that’s about the max charging current one should charge a 110 mAH battery at.

Purchase

Right now I’m only selling bare-boards, $5 each including shipping in North America. If there’s enough interest, I’ll sell fully populated boards. Email me to purchase one.

Downloads