News:

SMF for DIYStompboxes.com!

Main Menu

Clocking on breadboard...

Started by Transmogrifox, March 10, 2006, 12:48:07 PM

Previous topic - Next topic

Transmogrifox

I have been doing most of my development on a breadboard with DIP packaged uC's.  For the slower clocks, like the 4MHz RC clock, and internal 8MHz clock, I have had no problems.

My quesion is this:  Have any of you tried to run a 40 MHz clock on a breadboard?  I know I could just try it and see what happens...but without out a scope it's hard to come to anything conclusive, thus it would add that question, "is it my code, or is it the hardware?".

I got the A/D converter working last night, and was able to write it straight through to the PWM register.  The problem with the 8 MHz clock and PIC is that the instruction clock is Fosc/4, and Fosc/4 is the clock that drives the PWM timer....so my maximum resolution at a PWM frequency above audio is 6 bits. 

Maybe I should look into the Atmel AVR's...
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

David

I'm running a MIDI bass pedal controller right now on a breadboard.  It's not using a 40 MHz clock, but a 20 MHz one.  Runs just fine.

Peter Snowberg

I've had serious problems with high speed circuits on breadboards. Sometimes you can just bend up the really sensitive pins and solder them directly. For instance, you can bend up the clock pins and solder them to a crystal piggybacking the chip.

Once you get beyond a few MHz you start to see transmission line effects and things like clock distribution can become a nightmare.

Minimize parasitic coupling to the clock lines and you should have no problem running a 40MHz microcontroller so long as everything 40MHz stays inside the chip. ;)
Eschew paradigm obfuscation

Transmogrifox

Thanks.  I'll give it a try and see how it ends up.  I want to try this digital EF at 6-bit resolution to see if it's ok.  Otherwise, I'm going to learn the 40-pin chip at 40MHz! Yeehaw
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

Transmogrifox

I was just doing some thinking...I can do the A/D conversion using 2 output pins:  One represents the upper nibble, the other is the lower nibble of a sample byte.

Here's how it works:
Let xn = [0  2]

Any 8-bit number is the following:

x1^0 + x2^1 + x3^2 + x4^3 + x5^4 + x6^5 + x7^6 + x8^7

Lower Nibble =
x1^0 + x2^1 + x3^2 + x4^3

Upper Nibble =

2^4 * (x1^0 + x2^1 + x3^2 + x4^3)

So upper nibble = 16 * (Lower Nibble)

The factor of 16 can be applied in hardware more compactly and easily than my 40-pin chip and crystal and capacitors can be used for a DIY project.

Now to convert this to analog:

let j be an integer ranging from 1 to ...

We set up a sample period that occupies 15 periods of time.

Bit0 is held for 1 period
Bit1 is held for 2 periods
Bit2 is held for 4 periods
Bit3 is held for 8 periods


If I'm not mistaken, this is similar to PCM type audio algorithm.  I am not familiar with PCM, but I gather that it must be something similar to this.  This is pretty much PWM spread piecewise accross the period.


On the PIC's 8MHz internal clock, I can set my output sample rate to 22.2kHz and have a total of 90 instruction cycles per sample.

Therefore, my code to do any processing (such as A/D conversion and peak detection) must be done without the use of subroutines or interrupts since I likely can't afford the extra overhead cycles.

I think what I must do is use the time during long segment (2^3 bittime) to do the ADC, set up the high nibble register and low nibble register, then end by shifting the 2^0 bits to their respective I/O pins. 

I'm trying to make a compact envelope follower, so the rest of the peak detection and averaging must be done in bits here and there wherever I have a spare instruction cycle in between...and hopefully the final output register will be set up before the next sample.

I'm still developing an envelope detection algorithm that is low in instruction cycles, yet similar to Harry Bissell's analog peak hold/reset circuit.

This post has kinda become my "think pad" so I can reference it later, though I hope it will inspire some others in some way.  I am yet to see how the challenge of cramming an envelope follower into an 8-pin PIC turns out.
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.