Best box of parts to ever grace my work bench.
Category Archives: Code
Tweaking the 128×32 LEDDMD Verilog
There was a few problems with the code for the 128×32 LEDDMD. Every so often there was flickering at random spots on the screen. This was because of the way the display memory was updated. I already fixed it by putting a dummy state at the end of the display memory update. Doing so actually increased the speed that data could be sent to the FPGA. There is no waiting between the Latch pulls.
The last problem is that there is some slight ghosting on the screen. Due to the way the screen updates it looks like the Column data is updating slightly before the rows are updated. Because of this you get a ghost effect on the opposite side of the screen that is up one row.
I think the reason why is because there is a slight delay in the rows caused by the decoders. The current plan of attack is to buffer the Column data a couple cycles before outputting.
LEDDMD 128×32 Complete
So I finally finished the prototype of the 128 x 32 Light Emitting Diode Dot Matrix Display V1.0 (LEDDMD). The protocol to write to the display is almost exactly like a shift register. There is a clock, latch, and data lines. It works in either 1 bit mode or 8 bit mode data line modes.
In 1 bit mode there is only 1 data line and in 8 bit mode this is 8 data lines. 8 bit mode enables you to clock in an entire byte of data at a time speeding up the transfer process by a factor of 8. In either mode you can do animations smoothly. All processing of the data is done on the microcontroller. The Display stores the data and takes care of running the display.
The bulk of the hardware is in the FPGA. I am using a Cyclone II EP2C8Q208C8N FPGA breakout board. There are some darlington transistor arrays that sink the current from a single row. To expand the I/O of the FPGA some decoders are used.
Here are the links to all the code:
FPGA:
Main Routine
Memory
Propeller:
Transmission Protocol and Test
LM3S1968: 74HCT595 Shift Registers
For one of my up coming Labs for EE445L I am going to need to expand the I/O of the LM3S1968. I am using the 74HCT595 much like on my pinball machine. One 74HCT595 allows you to turn 3 output pins into 8 output pins. They can be daisy chained so you can have any multiple of 8 output pins for those 3 original output pins.
In this demo I have 3 74HCT595 chips wired up. Instead of using the SSIO ports on the LM3S1968 I bit banged the port. SSIO is built in hardware that does serial communication. I decided to not use is for the 74HCT595′s because I am going to use it in controlling a DAC.
The code is fairly module and easy to change to different ports and pins.
Link to the code.
MSP-430: IEEE CS Competition – Knock Knock Security System
Matt and I won a TI sponsored Launchpad programming contest that was held by the IEEE CS here at The University of Texas at Austin.
Here is the link for the details. In case the IEEE site goes down here is a screen cap of the page.
My partner Matt on left. Parker (me) grinning like a fool on the right. I did the majority of the programming and design work where Matt debugged my code as I wrote it saving allot of time.
The idea was to create a simple secret knock security system that could record a knock “pattern” and then only unlock a door when the pattern was repeated. Only three hours where given for the competition and we where the only ones to finish everything in that time slot. They extended the contest another hour to permit more teams to finish. More details about the contest can be had by downloading the packet they gave us.
Code
main.c
The code is a bit rough around the edges and the bulk of the program happens in the timer interrupt (which is a no no) but for only 3 hours to solve, design, program, and debug a solution; sloppy code is a bit expected.
Points where awarded based on a few areas.
Points:
Your solution will be graded and scored on the following categorizes
1) Time it took for your team to create the solution and produce a working
prototype to the Company.
a. Every 1 min is -1 pts
b. Ex: if you finish in 1:30 in you will get -90 points
2) Working prototype: after you submit your prototype to the company,
Quality Control will take it into their lab and run test on your system. Their
test will not exceed the specified requirements and each test you pass you
will get +10 points to your score. (MAX 80pts)
3) Documentation: As in any real project you should keep a good record on
how you came up with your idea for your solution. This is to keep the
company safe from legal problems, have a record of our intellectual
property.
a. Submit your code
b. Submit any notes
c. Document any resources for the internet
d. Instruction Manual
Our legal team at the company will take a look over and award points
(MAX 10pts)
4) Creativeness of the solution: When you submit your solution to the
company, your manager will take a peek at your solution. If you solved it in
a new and ‘creative’ way, this many include additional functionality, more
efficient algorithms, or intuitive (easy to use) interface. (MAX 30pts)
5) Cost: The Company does have a parts store. You will be able to buy extra
parts such as button kits and if you burn out your chip you can buy a new
one.
Help:
If you get stuck we do have an internal consulting group which will help you but
for a cost of 2pts per 1 min. This is not for questions about the contest or
questions about the problem; this is for help solving the problem.
We scored 65 points where the nearest team behind us only scored 22 points. We dominated the competition. The judges loved the simple interface and the admin password setup. The code was fairly changeable so you can adjust the precision of the knock (humans are not robots) and how long the passwords are. Teams that did finish had no where near the feature set our solution had.
This contest made me wonder if GPA should even be a consideration for companies like Texas Instruments in hiring. I have a 2.8 GPA and have a hard time realizing that I actually had the lowest GPA out of the entire contestants and I completely schooled everyone that had 4.0 GPAs. I think this goes to show that theoretical knowledge != practical knowledge. Hey maybe since Texas Instruments sponsored this event I could possibly get a career out of it?
To anyone out there hiring an embedded systems engineer and want a motivated worker that will tackle projects with all of his might? Hire me!
All PDS V1.1 are sold out!
Sorry for the lack of updates. My last semester is starting to heat up with labs.
I am currently in a TI sponsored MSP-430 Launch Pad competition. Free Microcontrollers and getting to talk to and work with the industry leaders. Will be a good experience. Ends today at 2:00PM so I will post again afterwards.
The PDS V1.1 prototype has sold out completely. I hope I start hearing back from the testers soon on how well it is working.
Bitmap Converter Code
This is the code I talked about earlier. Just rips the bottom 2 bits out of a 4-bit bitmap to make a 2-bit bitmap. So to use this you make a 4-bit bitmap with grayscale. Black, 50% Gray, 25% Gray, White. Paint is where I made the bitmaps. It must be 128×32. The program doesn’t do any checks on this, its fairly stupid.
#include <stdio.h>
void main(void)
{
char str[80];
char nstr[80];
int image[2048];
int ripped[1024];
int flipped[1024];
int i,j;
int header_junk;
FILE *fp, *nfp;
printf("4-Bit BMP File Name? : ");
gets(str);
printf("Opening File. : %s\n",str);
fp = fopen(str, "r");
if (fp == NULL)
{
fprintf(stderr, "File Can Not Be Opened.\n");
exit(1);
}
printf("File Opened Successful!\n");
printf("2-Bit DMD File Name? (format XXX.DMD) : ");
gets(nstr);
printf("\nCreating New File Named: %s.dmd\n",str);
nfp = fopen(nstr, "w");
printf("Reading Header.\n");
for( i = 0 ; i < 118 ; i++)
{
header_junk = fgetc (fp);
printf("0x%.2X ", header_junk);
}
printf("\nHeader Ripped.\n");
printf("Reading Image Data\n");
for( i = 0 ; i < 2048 ; i ++)
{
image[i] = fgetc (fp);
printf("0x%.2X ", image[i]);
}
printf("\nRipping bits out and Rotating!\n");
for( i = 0 ; i < 1024 ; i ++)
{
ripped[i] = (((image[2*i] & 0x80))| ((image[2*i] & 0x40)) | ((image[2*i] & 0x08)<<2) | ((image[2*i] & 0x04)<<2) | ((image[2*i+1] & 0x80) >> 4) | ((image[2*i+1] & 0x40) >> 4) | ((image[2*i+1] & 0x08) >>2) | ((image[2*i+1] & 0x04) >>2));
printf("0x%.2X ", ripped[i]);
}
printf("\nFlipping Image.\n");
for( j = 0 ; j < 32 ; j ++)
{
for( i = 0 ; i < 32 ; i++)
{
flipped [(992-(32*j))+i] = ripped[(32*j)+i];
}
}
printf("\nWriting To New File\n");
for( i = 0 ; i < 1024 ; i++)
{
fputc(flipped[i],nfp);
printf("0x%.2X ", flipped[i]);
}
fclose(nfp);
fclose(fp);
printf("\nDone!\n");
printf("Press Any Key To Quit...");
gets(str);
exit(1);
}
128×32 DMD Update
The verilog code is almost fully debugged. The demo code that will run on a Parallax Propeller is in the works. Right now the demo is fairly basic. Today I wrote a C program that takes a 4-bit bitmap image and strips out the header and and converts it to a 2-bit image. It then reorientates the data so the image is “correct”. Bitmap images data reads the image from bottom left to top right. This is essentially backwards. So the program corrects this which means less work for the microcontroller and faster transmission of pixels.
The Forums…..They are ALIVE!
I finally got a forums on the site running. Uses phpBB with a modified theme. It will probably slowly change over the next couple days as I add features and fine tune the layout.
The main point for the forums will be sharing projects and ideas with fellow people that enjoy creating and making great things. It will also be a support area for my future products like Tommy and the PDS.
How far down the logic hole are you willing to go?
So I think I have been bitten by the FPGA bug. I ordered the DE0 board from Altera this morning. Should arrive by this weekend. I have been thinking of doing a “begineer series” on FPGAs much like how the Arduino introduces people into the world of microcontrollers. Would people be interested in that?


