|HOME| |DIY FAQ| |GEO FAQ| |Debugging Page| |Links| |Schematics| |Wiki| |Layouts Gallery| |STORE|
|AMPAGE| |GEOFEX| |AMZ|

Welcome, Guest. Please login or register.
Did you miss your activation email?
October 24, 2014, 05:17:44 AM
971619 Posts in 103589 Topics by 33037 Members
Latest Member: Trevoga
Home Help Login Register
DIYstompboxes.com  |  DIY Stompboxes  |  Digital & DSP  |  PIC based divider?? 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: PIC based divider??  (Read 4787 times)
Jaicen_solo
Posts: 1152


PIC based divider??
« on: December 01, 2008, 03:45:52 PM »

Does anyone know of any projects that use a PIC mocrocontroller for dividing stuff?? I want a number of signals divided simultaneously, and I thought that rather than use six flip flops, a PIC might work better. Any ideas??
Logged
iaresee
Posts: 652


Ian C.


Re: PIC based divider??
« Reply #1 on: December 01, 2008, 10:00:35 PM »

As in you want one analog signal multiplexed to up to six outputs? That's not what a PIC does. You might be able to cook something like that up with a DSP PIC like the dsPIC. Something like a dsPIC33 has 21 programmable digital output pins. That'd work. You'd need a D/A for each line out. Sean C would know more though I bet.

You could use a PIC to handle the control line selection logic on an analog mulitplexer like perhaps an ADG1407 (I don't know how well that would work with audio) or to even drive the selects on a series of logic-controlled relays like a 4066 (see: http://www.geocities.com/thetonegod/switches/switches.html). The PIC-controlling-relays is essentiall what things like the Musicom EFX switcher are built around.
« Last Edit: December 01, 2008, 10:02:47 PM by iaresee » Logged
snap
Posts: 360


Re: PIC based divider??
« Reply #2 on: December 02, 2008, 02:27:05 AM »

or is it for a hex pickup to achieve polyphonic octave down?
Logged
iaresee
Posts: 652


Ian C.


Re: PIC based divider??
« Reply #3 on: December 02, 2008, 10:21:17 AM »

or is it for a hex pickup to achieve polyphonic octave down?
But why would he need to split the signal from a hexaphonic pickup? It's already divided in to one signal per string.
Logged
Jaicen_solo
Posts: 1152


Re: PIC based divider??
« Reply #4 on: December 03, 2008, 06:20:01 AM »

It is indeed for a hex pickup! I want six flip flop dividers, nothing fancy!
Logged
flo
Posts: 415


Re: PIC based divider??
« Reply #5 on: December 03, 2008, 07:04:34 AM »

If you give the PIC a "nice" digital (0V-5V) signal it will do a division (octave down) quite happily for you.
More interesting imo would be to put the 6 analog signals on the analog inputs of a PIC, use a (multiplexed) onboard AD, and let the PIC do the pitch tracking / extracting the fundamental freq. Dividing it for an octave down would then be a trivial extra. That would drastically reduce the amount of (analog) circuitry around the PIC.
Logged

Jaicen_solo
Posts: 1152


Re: PIC based divider??
« Reply #6 on: December 03, 2008, 07:09:36 AM »

Sounds great, let me know when you have it working! Wink

Hehe, seriously though, i've seen a PIC based pitch to MIDI project, but nothing thats really playable.
I've no doubt that one of the more powerful micros might be able to handle pitch detection and division, but i've no idea how to do so.

EDIT: Right now, all I'm looking for is exactly what you describe, a set of six 0-5v flip flops. Any ideas how to achieve that??
On the other hand, I'm happy to help with a pitch detector project, I can burn PIC's and proto stuff, but programming is not my thing Wink
« Last Edit: December 03, 2008, 07:12:02 AM by Jaicen_solo » Logged
flo
Posts: 415


Re: PIC based divider??
« Reply #7 on: December 03, 2008, 06:20:09 PM »

Sorry, currently I only know of the general capabilities of the PICs. I'm a programmer but not versed yet in PIC programming. I'm going to learn it but that will take me some time in the new year.

Another member here, Andre (http://www.diystompboxes.com/smfforum/index.php?action=profile;u=4087), has used the very simple 8-pins 12F675 PIC to divide one input digital signal (like a clock signal) and outputting the divided signal again. Perhaps he's willing to share his PIC "divider" program.
Probably, when the input signal changes state, this generates an interrupt in the PIC. The PIC interrupt handler then toggles the state of a boolean variable which is then set onto the output.
Also, you need to search for a larger PIC that can handle 6 inputs, instead of only one, that can each interrupt the PIC.

So you are planning to make 6 pitch tracking circuits that convert the 6 analog signals into "clean" digital clock-like signals? If you are going into all that trouble why not also add some flip-flop chips to to the division for you instead of a PIC? (just curious)
Logged

ElectricDruid
Posts: 136


Tom W.


WWW
Re: PIC based divider??
« Reply #8 on: May 14, 2009, 09:27:30 AM »

It could be done with a PIC, but to be honest there isn't much point. If you want 6 flip-flops in a single chip, you should do a search for "hex flip flop" and you'll find something like the 74HC174. This is a standard logic chip and costs pennies.

Save the PIC for something more complicated.

T.
Logged
Jaicen_solo
Posts: 1152


Re: PIC based divider??
« Reply #9 on: August 23, 2009, 02:52:12 PM »

Thanks for that dude, I haven't checked this thread for ages, but that looks like exactly what I need.
Logged
Transmogrifox
Posts: 1234


WWW
Re: PIC based divider??
« Reply #10 on: August 25, 2009, 04:28:11 PM »

...However, if you use a PIC in the project, then you have a chance to do more complicated stuff down the road if you ever get up to speed with the programming, or find a guru buddy to do it, or download some source code of the web....lots of options if you use a PIC instead of a Hex flipflop.

On the PIC, just write a routine that is like this:
test input pin 1 for rising edge
if rising edge is true
      toggle output pin 1

test input pin 2....
and so on.

If you're still interested in doing it with a PIC, you'll have to spend some time in the datasheet to determine what set of commands will do this.

With a PIC, further down the road you can do multiple frequency shifts, and even add harmonics if you like.

If you're not interested in getting into PIC programming, then you'd just as well stick with the easy hex flipflop chip.


Logged

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.
WLS
Posts: 216


My Pt-80


Re: PIC based divider??
« Reply #11 on: September 21, 2009, 03:37:24 PM »

...
Something like a dsPIC33 has 21 programmable digital output pins. That'd work. You'd need a D/A for each line out.
...

I'm just getting into this area, but could you just run the digital signal through a PWM to get the anolog outputs needed? Elemenating the need for costly DAC's.


Bill


Logged

Since I've breadboarded it I can only blame myself.

But It's Just A Chip!
Transmogrifox
Posts: 1234


WWW
Re: PIC based divider??
« Reply #12 on: September 23, 2009, 07:43:59 PM »

...
Something like a dsPIC33 has 21 programmable digital output pins. That'd work. You'd need a D/A for each line out.
...

I'm just getting into this area, but could you just run the digital signal through a PWM to get the anolog outputs needed? Elemenating the need for costly DAC's.


Bill




You can do this.  The limitation is clock speed.  For example, if you want 16 bit resolution PWM at 41.4kHz sample rate, then you need to be able to modulate the pulse width in 1/[41.4k*(2^16)] second increments.  This comes out to 368 nanoseconds.  This means you need a 2.7GHz clock, minimum.  Since a processor probably can't do this with one instruction, and that instruction cycles take multiple clock cycles, this implies the need for a 10GHz clock to do this on one pin.

So, before I look dumb, this can be done with reasonable clock speeds using multiple pins.  Let's use two pins.  Viewing these as a pair of 8-bit registers, we can represent 16-bit audio with two pins.  This requires an 81ns clock, which is quite reasonable.  We could probably get an acceptable sample rate with a dsPIC clocked at 40MHz.   Because of the way the PWM registers work, I think you can get the pulse turned on and off within a clock cycle, but almost certainly an instruction cycle.

If a clock cycle, you can get a 25 ns pulse width, otherwise it will be 100ns.  In both cases a 41.4k sample rate is possible.  The "high" byte represents numbers up to 2^16, while the low byte represents numbers up to 2^8.  One needs to apply a 1/256 resistor divider to the low byte pin and add to the high byte pin in hardware.

Now to make an A/D converter out of this, you feed the output of the D/A into one side of a comparator, and the audio signal into the other side.  You then set up a control scheme to cause the output of the D/A converter to track the audio input; for example:
if inputbit=1
increment PWMoutputreg
else
decrement PWMoutputreg

Of course, this implemented exactly would require too much CPU to keep up, so one would have to apply some algorithms for quickly resolving the value.  This is as though we're implementing a unity gain op amp with digital innards, where we harvest the digital representation every 1/(sampling_frequency). 

I think some PIC chips have comparator registers built-in.  This would reduce external circuitry to resistors and capacitors.  You may want to apply an active filter for anti-aliasing.  A passive filter may end up needing a cut-off frequency below what's acceptable for getting adequate rejection at fs/2.
Logged

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.
WLS
Posts: 216


My Pt-80


Re: PIC based divider??
« Reply #13 on: September 25, 2009, 10:27:49 PM »

... 
I think some PIC chips have comparator registers built-in.  This would reduce external circuitry to resistors and capacitors.  You may want to apply an active filter for anti-aliasing.  A passive filter may end up needing a cut-off frequency below what's acceptable for getting adequate rejection at fs/2.

Yes, their are a lot of pics out their with built in comparators and mostly all the avrs form the datasheets I've looked at. Most of them also have the adc's already their too.

Not wanting to Hi-Jack the thread I will say no more, but I do thank you for your in depth discussion on the role that the PWM can take in providing analog to digital and digital to analog conversion.


Bill

Logged

Since I've breadboarded it I can only blame myself.

But It's Just A Chip!
Pages: [1] Go Up Print 
« previous next »
Jump to: