Hardware Programming...for "Dumbasses"

Status
Not open for further replies.

j3

Ars Tribunus Militum
2,226
I figured "Dummies" and "Idiot's" are copywrighted...

ANYWAY, I want to talk a little bit about building your own hardware. I have taken an intro to electronic design (gates, registers, flip-flops, etc etc) course, but I would like to apply it to something beyond a breadboard.

I would like to do the (seemingly cliche) winamp-output-to-lights type of project.

But I have quite a few questions:

1) What do you "build" on? Like, I used a breadboard where I just had to plug wires from here to there. Do I look for something that has some kind of power input then a little board of holes? What is the amateur replacement for printed circuit boards?

2) Where do you get/research ICs? Radio Shack? It would be really cool to work with USB if the level of complexity isn't insane. I understand that it would be a lot more complicated than a little parallel-port connection, but it would be freakin COOL :)

3) Anyone interested in this project? What I am envisioing is a wall-sized copy of winamp's miniature frequency bar visualization (the little vertical bars in the main winamp window). I figure that if there are 8 horizontal bars (frequency ranges) and 8 vertical bars (intensity ranges) that would be 8 possible states (since lower squares are necessarily lit if higher squares are lit) for each freq range. I am guessing that USB communicates in some kind of packet. Therefore, it seems that it would be possible to send out packets every X interval which contain something like (4,5,3,2,1,1,2,4) to indicate the desired state of the eight bars. Each bar would have it's own eight-state controller which would recieve the relevent info from the USB decoder (no small chore, I'm sure) which would trigger the lights.

I know this is kind of scatterbrained, I will explain it more clearly if anyone is interested.

Thanks all,
j3
 
Hmm...what about using a P11 board? (annoying as all h-e-double hockey sticks to solder, but useful for some cool things once you're done).

I just finished a class where we were working with one with a Lattice programmable logic chip that we had to program using ABEL(aka the most godawful HDL of all time) and interfaced it through the parallel port. I've strickly never done what you're asking in particular, but I did just get finished making it generate a square wave of configurable frequency on one of the testpins and made an appropriate 2-column(hi-lo frequency) spectrum analyzer using some of the binary LED/LBDs. Our project also involved working with an IR receiver and television remote. We then hooked up a speaker to the testpin and have it so that pressing a button on the remote causes a tone to be played(we have it generating 15-notes...from C to C+2 octaves(?)) with the regular LED display showing which key on the remote was pressed, and the LBDs showing a spectrum analyzer reaction to the sound wave/tone, done entirely in hardware using a programmable chip with entirely too few global logic blocks. Wasn't too bad, actually...once my "pottnas" and I were properly able to latch and decode the remote control's pulses and figured out ABEL's cornball syntax with the synario package.

Now if I could just find somebody that's interested in a remote control piano with a spectrum analyzer. ;)
 

wb

Ars Legatus Legionis
25,208
Subscriptor
1) What do you "build" on? Like, I used a breadboard where I just had to plug wires from here to there. Do I look for something that has some kind of power input then a little board of holes? What is the amateur replacement for printed circuit boards?

For this kind of prototyping people generally use what are called (strangely enough) protoyping boards. They are basically circuit boards with no printing on them, that have a bunch of holes to place components. Unlike breadboards (which are very unreliable for any kind of digital circuit beyond turn-on-the-light) you need to use some mechanism both to hold the components in place, and wire the appropriate elements together. Typically people either solder wires, or use wirewrap. I would recommend wirewrap especially if you're starting out, because it's much easier to fix mistakes, and generally easier to mess with. If you're unfamiliar with wirewrap (which I gather you are) it's like a little inverse screwdriver that you use with a very thin gauge wire to wrap the wire around the pins very tightly. If done properly, this will make a strong, stable electrical connection as well as hold the component in place.

Jameco sells several products for making protoyping computer interfacing projects easier. In particular they make a couple of prototype boards with ISA or PCI card interfaces directly attached to one side. I've used these kinds of boards before to prototype stuff like sound or video cards, or use as a custom interface for other hardware I was building.This catalog page has a couple of such boards.


However, for the lights-flashing-to-winamp kind of project, you hardly need anything as complex as the above. All you really need to do for that kind of project (as well as many, many others) is to use a "standard" smallish prototyping board, and interface to the parallel or serial port on your PC. There is power (5V, some might have 12V) on the ports on the back of your computer which you can use to power your circuit.


2) Where do you get/research ICs? Radio Shack? It would be really cool to work with USB if the level of complexity isn't insane. I understand that it would be a lot more complicated than a little parallel-port connection, but it would be freakin COOL

Don't start out doing USB. Make sure you get a couple of projects under your belt first, as there are a couple of added complexities when designing interfaces that use serial communications, and although it's not so much harder than using other interfaces, it's enough of a step that I wouldn't recommend it to start out with.

Don't go to Radio Shack to research (and especially buy) ICs, because they have a crappy selection, and very high prices. Jameco will sell IC's at a fraction of what it costs to go to Rat Shack, and they're not particularly low-priced. To do general research on different ICs available, go to the manufacturer. Especially since you're a student. Most semiconductor manufacturers (e.g. Motorola, Texas Instruments) have very good academic-type programs. If you ask them for data books (say, for 7400 series logic devices) they will happily ship them to you for free. You can also get all of this information online, but I find it's easier to wade through if you have a dead-tree format to page through and make notes on. Furthermore, they will also usually send free samples, meaning if you only need one or two of that part, you can usually get it for free from the manufacturer as a sample.

3) Anyone interested in this project? What I am envisioing is a wall-sized copy of winamp's miniature frequency bar visualization (the little vertical bars in the main winamp window). I figure that if there are 8 horizontal bars (frequency ranges) and 8 vertical bars (intensity ranges) that would be 8 possible states (since lower squares are necessarily lit if higher squares are lit) for each freq range. I am guessing that USB communicates in some kind of packet. Therefore, it seems that it would be possible to send out packets every X interval which contain something like (4,5,3,2,1,1,2,4) to indicate the desired state of the eight bars. Each bar would have it's own eight-state controller which would recieve the relevent info from the USB decoder (no small chore, I'm sure) which would trigger the lights.

Hmm...well if you're really bent on doing USB stuff for your first project (which I strongly recommend against) you will need a USB transceiver (do a search) to understand what's being sent. I'm just thinking off the top of my head, but you could also do this with a parallel port interface using one wire for eacy frequency range, perhaps pulsing each line a given number of times to represent the intensity. This would be a piece of cake to do with basic logic devices.
 

j3

Ars Tribunus Militum
2,226
Thanks for the comments...

DigitalFury:
The link has a broken image, but I am going to look around a bit. I just finished a class on assembly for the 68HC11...small world. Your project sounds pretty cool with the remote and everything...I wish we did things that were that interesting. Good luck with the piano ;p

wb:
Great tips, "Jameco" was the easy name I couldn't think of.

I totally agree that USB is overkill/really complicated for this type of project. I have no concept, however, of how serial communication would work (using the serial or parallel port). If the host sends out "pulses" (I am assuming binary pulses) then what "collects" them on the other end? My initial thought is that this process must take time, but I counter that with thinking the time required is probably like 5ms. Can you explain a little of how such a system works? Lets assume that the host wants to send a ten (1010) down the pipe...how does it send it and how does the listening work?

The USB stuff is still tempting (I am reading up on beginning USB programming) but I might be compelled by serial/parallel if it is easy.

Thanks for the help,
j3
 

wb

Ars Legatus Legionis
25,208
Subscriptor
My initial thought is that this process must take time, but I counter that with thinking the time required is probably like 5ms. Can you explain a little of how such a system works? Lets assume that the host wants to send a ten (1010) down the pipe...how does it send it and how does the listening work?

Well, as I said, I hadn't really thought it through, but your typical bandwidth for a parallel port is going to be at least 200KB/s, which is more than fast enough to do what you want. The PC parallel port interface has more than just the data bits; there are pins for both sending and receiving 8 bits of data, as well as several control pins. I was thinking you could use the standard transmit sequence to clear and enable 4-bit counters on the other end to "collect" the number of pulses on each line, which would be used to determine the height of your bars.


Therefore, it seems that it would be possible to send out packets every X interval which contain something like (4,5,3,2,1,1,2,4) to indicate the desired state of the eight bars.

I think you mean the 4 would mean intensity "4" on the first bar. The way I would send the data on the parallel port would be kinda inverse of that. So, for the same states, you would send the following sequence on the parallel port:

code:<HR>
Code:
         bit #'s for each light
           high   low
pulse # |  7654 | 3210   |  hex value
-------------------------------------
   1    |  1111 | 1111   |    FF
------------------------------------- 
   2    |  1111 | 0011   |    F3
-------------------------------------
   3    |  1110 | 0001   |    E1
-------------------------------------
   4    |  1100 | 0000   |    C0
-------------------------------------
   5    |  0100 | 0000   |    40
-------------------------------------
   6    |  0000 | 0000   |    00
-------------------------------------
   7    |  0000 | 0000   |    00
-------------------------------------
   8    |  0000 | 0000   |    00
-------------------------------------
 total     4532   1124
 for
 each bit
(the state of each light at that instant)

EDIT1: added explanation of transmit sequence
EDIT2: whoops found a typo in the technical stuf

[This message was edited by wb on December 25, 2001 at 13:23.]
 
Post in the OH forum for help with hardware like this.

I don't have any trouble with basic digital circuits on a bread board. After that I generally go right to the etch my own step.

)If the host sends out "pulses" (I am assuming binary pulses) then what "collects" them on the other end?
UART - Universal Asynchronous Reciever Transmitter. You can get them dirt cheap. For RS-232 anyway. USB interface chips are like $12 and not for the beginner.
 

Horatio

Ars Legatus Legionis
24,432
Moderator
You can create hardware on an Altera UP1 FPGA board. They're sold at some universities for about $150. It comes with a MAX7128 CPLD and a Flex10k20 FPGA, as well as VGA out, PS2 ports, etc. You program it in Altera MaxPlus2 which is included free in the package. I teach a digital hardware course that uses them, and they are quite user friendly.

DF: You learned on Abel-HDL too eh? Pity us :( I'm glad I switched to VHDL (which I also hate). Verilog.... so much better...
 

wb

Ars Legatus Legionis
25,208
Subscriptor
You can create hardware on an Altera UP1 FPGA board. They're sold at some universities for about $150. It comes with a MAX7128 CPLD and a Flex10k20 FPGA, as well as VGA out, PS2 ports, etc. You program it in Altera MaxPlus2 which is included free in the package. I teach a digital hardware course that uses them, and they are quite user friendly

I got Altera stuff (board, 2xFPGA, software) for free by requesting it from the manufacturer. Of course, this was while I was in school working on a design project. They did ship us two of their largest (at the time they had just started selling 10k250's in small quantities) FPGAs to prototype on worth about $300 each, since it was the only thing commericially available that we could use to protoype our microprocessor design in hardware without running into complex wiring problems.

Anyway, although I certainly agree that FPGAs and PLDs are very useful for designing certain types of hardware, I think for a lot of cases it's "missing the point" of digital circuit design. In a lot of ways it turns designing hardware into writing software, which is not always good, because beginners can't differentiate between a hardware description language and a "normal" programming language. I've worked on projects where the previous groups made grievous mistakes in the VHDL because they weren't "thinking hardware" and doing stuff that would work in software, but would never work in reality. I think if you're forced to first learn to design with non-programmable logic (with the exception of maybe ROMS) you can't make that kind of mistake, and then when you DO design stuff in VHDL maybe you'll have a better understanding of how things work as you're writing the code.


I just finished a class where we were working with one with a Lattice programmable logic chip that we had to program using ABEL(aka the most godawful HDL of all time) and interfaced it through the parallel port. I've strickly never done what you're asking in particular, but I did just get finished making it generate a square wave of configurable frequency on one of the testpins and made an appropriate 2-column(hi-lo frequency) spectrum analyzer using some of the binary LED/LBDs.

That sounds like a sophomore level course. You get to do much more interesting stuff later, assuming you stick with hardware stuff.


UART - Universal Asynchronous Reciever Transmitter. You can get them dirt cheap

A UART is a serial interface. Of course, one could add a UART to the project and use the serial port rather than the parallel port.

[This message was edited by wb on December 26, 2001 at 16:53.]

[This message was edited by wb on December 26, 2001 at 16:54.]
 

morpheus1981

Wise, Aged Ars Veteran
104
Why don't you go to your school library, and see if they have any books on microprocessor interfacing? Get one from around 1988. It stays away from VHDL, and sticks with generic plans for building computer modules. I had to learn 68HC11 in one of my classes, but afterwards we hardly used it. So I found a book on interfacing to the chip, and you can play around with things from there. Build your own RAMs, serial transfer controllers.... Anyways, it's just a place to go if you get bored.
 

Horatio

Ars Legatus Legionis
24,432
Moderator
Anyway, although I certainly agree that FPGAs and PLDs are very useful for designing certain types of hardware, I think for a lot of cases it's "missing the point" of digital circuit design. In a lot of ways it turns designing hardware into writing software, which is not always good, because beginners can't differentiate between a hardware description language and a "normal" programming language. I've worked on projects where the previous groups made grievous mistakes in the VHDL because they weren't "thinking hardware" and doing stuff that would work in software, but would never work in reality. I think if you're forced to first learn to design with non-programmable logic (with the exception of maybe ROMS) you can't make that kind of mistake, and then when you DO design stuff in VHDL maybe you'll have a better understanding of how things work as you're writing the code.
This is quite true. We do start our students out on discrete logic, then moving on to the graphic editor in MaxPlus to get a feel for component design. After that it's a mix of the graphic editor and VHDL. The biggest difficulty my students tend to have is that VHDL != C in that each process runs concurrently. They have some problems getting their heads around it (which explains their sub-50 final exam average :) )

Build your own RAMs, serial transfer controllers....
Hehe... start small. Building a DRAM controller was one of the most painful experiences of my life (along with my DMA controller, USB controller...)
 
That sounds like a sophomore level course. You get to do much more interesting stuff later, assuming you stick with hardware stuff.
Eh? Uh...No. That's a senior-level course, here....a sophomore level course is something like learning digital logic and basic combinational and sequential logic device structures in the first place. I would imagine you'd be hard pressed to find a program where you'd be doing what we did in anyone's second year of college...I mean, come on...using a dla to reverse engineer the signal pulses of a remote control, and devising an appropriate design with which to program a logic chip to decode and latch and uniquely identify said pulses in a noisy environment in a glitch free manner to use as input to a system that drives a display and interfaces a PC...heck, the timing and HDL issues alone are beyond what I could've done as a sophomore. And who said it was uninteresting? It was interesting(as were some of the other projects I didn't bother to mention)...I just said it was annoying because the crap was written in ABEL.
 

starkravenmad

Ars Centurion
386
Subscriptor++
I just finished a fourth-year electrical design course and did pretty much exactly what you are talking about. We decided to use MIDI as our interface since it runs somewhat slower than USB and is pretty well suited to turning things (be they notes or lights) on and off. We also built an analog-to-MIDI converter so that we could control our lights using a standard RCA audio input.

Our project was based on the PIC16F873 microcontroller, made by Microchip. There are a *ton* of resources on the net dealing with the MIDI and the PIC, and even more for the PIC in general. The PIC we used was about $15 and hardware programmers run from about $60 (from here) to $300 from Microchip. The assembly development environment is free from Microchip's website.

Since our project was microcontroller based, I was able to program a whackload of different visual effects, from a basic spectrum analyzer, to a light chaser, to all sorts of crazy combinations inbetween, entirely in software. The routines can be modified easily too, once we get bored of a certain pattern.

For (excellent) electronics information I would recommend ePanorma.net. They link out to literally thousands of good pages covering all sorts of projects. You can try Digikey for part datasheets, plus they are a better supplier of parts than Ratshack.

my $0.02

SRM
 

starkravenmad

Ars Centurion
386
Subscriptor++
A few more things after reading your question a little more closely...

(snip)
how does it send it and how does the listening work?

MIDI is a serial interface running at 31.25kHz, so each bit is 32us long. When we wanted to send a byte of data we did the following:

1) MIDI uses a low start bit so we sent that first, holding our ouput pin low for 32us.

2) We set or clear the output pin for 32us for each bit.

3) MIDI requires a high stop bit so we held the output high until we wanted to send another bit.

On the receiving end whenever we were ready for data we watched our input pin and waited until it dropped (i.e. the beginning of a start bit). We then wait for 48us (16+32) and read the input pin. You wait 1 1/2 cycles to ensure that you sample from the center of the data bit and don't catch any edges. Once we'd read 8 bits we we could go on to process the data. Another (probably more ideal) approach would be to use an interrupt driven system so that whenever a start bit was detected the main program would be interrupted and the input data would be processed and stored in a buffer. Since MIDI was about 32x slower than the PIC, however, we didn't really need to bother.

Also, note that some models of PICs have a ton of built in functions, like ADCs, UARTs, PWM controllers, SPI and/or I^2C modules. They are very versatile and could probably accomplish most of what you need to do with a minimum amount of electronics. (The tradeoff of course is having to write a bunch of assembly, but this is the programming forum, right ;))

SRM
 

wb

Ars Legatus Legionis
25,208
Subscriptor
Eh? Uh...No. That's a senior-level course, here....a sophomore level course is something like learning digital logic and basic combinational and sequential logic device structures in the first place. I would imagine you'd be hard pressed to find a program where you'd be doing what we did in anyone's second year of college...I mean, come on...using a dla to reverse engineer the signal pulses of a remote control, and devising an appropriate design with which to program a logic chip to decode and latch and uniquely identify said pulses in a noisy environment in a glitch free manner to use as input to a system that drives a display and interfaces a PC...heck, the timing and HDL issues alone are beyond what I could've done as a sophomore. And who said it was uninteresting? It was interesting(as were some of the other projects I didn't bother to mention)...I just said it was annoying because the crap was written in ABEL.

No offense intended. It wasn't clear to me that reverse engineering the remote control signals was part of the project, and I did plenty of HDL stuff my sophomore year. However, I was in some kinda special design course where I ended up doing 3 times the normal workload. I didn't know that before I signed up, but I'm glad I did it anyway.

I didn't mean to disparage your project as "uninteresting." Did you do any other projects? I did some really cool projects my junior and senior years, and saw a couple of other projects that looked really fun. One group made a hovering platform (a 1 foot square platform with propellers on each corner) that was probably the coolest-looking project I saw, although the actual design work wasn't terribly complex.
 
A UART is a serial interface.
Yes...
I have no concept, however, of how serial communication would work (using the serial or parallel port).
You addressed the parallel port, I the serial. He can look up about UARTs once he knows what he's looking for.
a fourth-year electrical design course and did pretty much exactly what you are talking about.
If you used a PIC you were doing software. wb did hardware.

wb, the counter idea is intriguing. As you say, up to the counters is trivial. What I'm wondering is what you'd do after that. How are you going to decode the binary to drive the display? Best thing I can think of at the moment is latching the output while it counts the next cycle. Then feed that to a PROM to decode the display. While programming a PROM is easy too, I figure it's beyond what he wants to get into to start.

I was thinking it would be easier to use a 3 to 8 decoder to select one of eight latches. Use one of the control lines to select between the decoder (address) and the latches (data). That'd give basically direct access to each LED. The display could then easily be used to display anything one could think of. Apart from having to be ambitious with the soldering iron it could also be expanded.

j3, still here? You sure you want to solder all those LEDs? I think if you do a parallel port one you can tack the circuit to the backside of a UART. They just take the serial data and convert it to parallel. There's more parts and the program is a little more difficult but the idea is the same. Once you get serial to work you can get a USB chip for $5 that replaces the UART and presto! You have USB. That's the theory anyway. FTDI has a chip that comes with free com port emulator drivers. You use the same program as with the UART, only address a virtual com port.

Each step is progressively more difficult but not terrribly so. Beyond Logic looks like a really good site. They tell about parallel, serial, USB, and other stuff. The USB section tells a little about the FTDI chip too. I found the site through this site which has some other parallel port projects. And of course everything starts with Google.

Looks like you'll have to repost to get an interested programmer. If they aren't familiar with WinAmp they can start with this tutorial. Follow the link there to NullSoft and pick up the free SDK. WinAmp returns the spectrum data in an array of Bytes so it should be easy to code.

If you want to stay inhouse you could build a CPUmeter. Several people here have built them, see this thread. The software is free and it's a really easy circuit to build. The latest incarnation is here. Just take some of the "improvements" with a grain of salt.
It just happens that in this case the chip isolates the power enough that you can get away with a non switching supply but not a switching one.
Maybe some of you guys could weigh in on that last thread. Ars is too good a site to not have the record set straight.
 

wb

Ars Legatus Legionis
25,208
Subscriptor
wb, the counter idea is intriguing. As you say, up to the counters is trivial. What I'm wondering is what you'd do after that. How are you going to decode the binary to drive the display? Best thing I can think of at the moment is latching the output while it counts the next cycle. Then feed that to a PROM to decode the display. While programming a PROM is easy too, I figure it's beyond what he wants to get into to start.

I wasn't thinking of anything that complex. Actually, I had in mind a 7447 (7-segment display driver) and a part I've seen around that is like a 7-segment display but is a bar (or matrix?) of "dot" LEDs instead of the figure eight, but is addressable in the same way. I guess you'd need latches, too, or else the displays would keep "counting up" every time you updated the numbers.

Something kinda like this I guess, but I had something slightly different in mind.
 

j3

Ars Tribunus Militum
2,226
Hey all,
Thanks for all the posts. Construction in my area has killed my internet connection. I am actually at a party right now (being the proverbial "pooper," I suppose) and just wanted to take a minute to drop in. I quickly read through the responses and it seems there is quite a bit of secondary reading I will need to do. I wasn't intending to get into programmable circuits, but from your ideas it seems it will be necessary. On the software side, I am better on those skills than my hardware, so I will definitly look into that winamp tutorial. I will look at the other cited resources as soon as I can this weekend, hoping that my internet connection comes back up.

As always, thanks,
j3
 
I wasn't intending to get into programmable circuits, but from your ideas it seems it will be necessary.
I disagree. You want to hook up a boat load of LEDs. Most things are only going to have 20 to 32 outputs. You'll still need to do addressing and stuff. It'd be a software project to practice interfacing microcontrollers together. If you want to learn hardware and not programming then I think you can do it direct. The basic circuit is really simple, just a lot of repitition. I wonder how they do those moving light signs.

wb, work with the 7447? Interesting. Can't figure what it be. Can you describe it more?
 

wb

Ars Legatus Legionis
25,208
Subscriptor
wb, work with the 7447? Interesting. Can't figure what it be. Can you describe it more?

It was a "bar" of LEDs, or maybe a matrix (I can't remember exactly if it was just one bar, or a series of them all on one part, because the project I saw had several) where each column was addressed just like a 7447 (i.e. BCD) but would simply turn on that number of LEDs on the bar. The reasonI remember the 7447 stuff so well is because we were talking about what a pain in the ass it is to address a matrix display for that kind of task, and they happened to find this part in a catalog somewhere, which made things about 10x easier for that particular project (it was practically all built using 74 series logic as a requirement of the class).
 
Status
Not open for further replies.