DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: ElectricDruid on May 13, 2009, 05:22:13 AM

Title: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on May 13, 2009, 05:22:13 AM
Hi All,
First post for me here. I'm a SynthDIY refugee.

Some time ago I did a voltage-controlled LFO project with a PIC 16F684. I put this online: http://www.electricdruid.com/index.php?page=projects.lfo9

Mostly I'd intended it as a modular synth module, but a few people wrote to me asking whether the chip would be usable as an LFO in effects circuits. They also asked whether it would be possible to add a Tap Tempo feature. Well, it's taken me ages, but I'm finally getting around to doing it. I've got a tap-tempo version of the above chip working on my breadboard already.

So what I'd like to know from everyone is "What features would you like to see on a LFO for effects use?". I'll try and include as many good ideas as I can.

Thanks,
Tom
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: kvb on May 13, 2009, 07:18:41 AM
multiple waveform output

are you going to be selling chips?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: RonaldB on May 13, 2009, 07:58:06 AM
Hi Tom,
Nice to see you here.

A feature that would be helpfull is a ramp up and down in time.
And subdivisions for the tap tempo time.

thanks, looking forward to this one.

Ronald
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on May 13, 2009, 09:14:59 AM
KVB,
I might sell chips if people are interested. I've occasionally sold programmed chips to people without PIC programmers in the past when they asked me.

When you say "Multiple waveform output", do you mean simultaneous outputs? Currently the chip has one output which can be any of 8 waveshapes (ramp up/down, triangle, sine, square, sweep, spike, and noise).

RonaldB,

Subdivisions of tempo? Ok, I'll make a note of that one...

T.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: moosapotamus on May 13, 2009, 10:53:21 AM
This sounds like a very cool idea. Agree, tempo subdivisions and multiple alternative waveforms would be great (sample & hold and/or random would be cool, too).

I don't recall ever hearing of a tap-tempo pedal that could do this, and it surely would be a challenge, but... How about a tap-pattern mode? IOW, maybe a rotary switch could be used to set the number of taps for the chip to accept as a pattern (ie- 3, 4, 5, 6, 7, 8 ). Now, suppose you set it to 5. Then, corresponding to the last five taps that you make, whatever timing differences you tapped in would be repeated. For example... 1 - - - 2 - - - 3 - 4 - 5. Actually, I guess if you set it to 5 you would probably have to tap 6 times in order to get the timing for going back to step 1 from step 5 in the pattern. Anyway... just a wacky thought.

What is the sweep waveform? Similar to ramp or saw?

What is the noise waveform... white, pink, etc.? Is there really any tempo associated with noise?

Any constraints on the duration of each tap or the number of taps needed to set or change the tempo? The more idiot-proof the better. :P

~ Charlie
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: moosapotamus on May 13, 2009, 10:56:56 AM
Quote from: moosapotamus on May 13, 2009, 10:53:21 AM
What is the sweep waveform? Similar to ramp or saw?

What is the noise waveform... white, pink, etc.? Is there really any tempo associated with noise?

Oh, okay... just looked at your web page. thx 8)

~ Charlie
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on May 13, 2009, 11:53:43 AM
Charlie,

The sweep waveform is essentially the bottom half of a sine wave, repeated. It's supposed to be a good waveshape for flangers as it doesn't loiter at the top of the range. I haven't tried it.

Your idea of tap-patterns is definitely possible. My biggest fear would be that it might get a bit unwieldy to use. I want to try and keep the controls as simple as possible. But not simpler.

Currently the chip is set up so it measures the time between two taps. E.g. First tap it starts counting, second tap it stops counting and sets the frequency. You can either count yourself in ("1", "2", "3"+press, "4"+press), or you can have two goes and press on each beat. It'll time between taps one and two, and then between three and four, and use the latest tempo.
This means that you can feed it 0-5V pulses from other equipment (an old drum machine or synth, for example) and it'll syncronise the LFO to the incoming pulses.

Does anyone really need multiple simultaneous outputs, or are people just interested in having a good range of waveforms available on a single output?
T.

Title: Re: Tap Tempo LFO with PIC 16F684
Post by: kvb on May 13, 2009, 12:51:37 PM
naw, I wasn't thinking that there would need to be multiple simultaneous outs.

But one more waveform idea is the opposite of what you said the sweep is - like a bunch of humps - this is good for filters and tremelo.

As far as buying a chip goes - it's either that or about two years of me trying by myself.

the sync function sounds good.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: moosapotamus on May 13, 2009, 01:07:27 PM
Yeah, that pattern idea just kind of jumped into my head while I was typing my other questions... probably a little bit over the top.

I think my only interest in having multiple outputs would be a dual LFO that would allow you to do things like adjust the phase relationship between the two continuously on the fly with a pot, and select the waveform for each of the two outputs independently, as well as the tempo subdivisions. Maybe that's a little over the top, too? But if it's not, I would definately line up to buy a few of those chips.

The sync function does sound useful. If I understand, the tempo gets continuously reset for every pair of taps? What happens if tapping manually and you tap in an odd number of taps?

~ Charlie

Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on May 13, 2009, 01:55:34 PM
Charlie,

"If I understand, the tempo gets continuously reset for every pair of taps?"
Yes, exactly.

"What happens if tapping manually and you tap in an odd number of taps?"
The chip will continue at the last known tempo whilst it waits for a second tap. If you tap again within 65 seconds, it sets the tempo based on that interval - hence it is possible to set extremely slow oscillations. This isn't a carefully designed limit - just a side effect of measuring milliseconds with a 16-bit variable (65535 mSecs). Perhaps it should be less.
If you wait longer than 65 seconds, it resets and ignores the "spare" tap.

BTW, KVB, I like the "humps" idea too. Thanks.
T.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: moosapotamus on May 13, 2009, 02:54:04 PM
Sounds great, T.

~ Charlie
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: RonaldB on May 14, 2009, 02:04:30 AM
Quote from: ElectricDruid on May 13, 2009, 09:14:59 AM
KVB,
I might sell chips if people are interested. I've occasionally sold programmed chips to people without PIC programmers in the past when they asked me.

When you say "Multiple waveform output", do you mean simultaneous outputs? Currently the chip has one output which can be any of 8 waveshapes (ramp up/down, triangle, sine, square, sweep, spike, and noise).

RonaldB,

Subdivisions of tempo? Ok, I'll make a note of that one...

T.

Yes Tom, subdivisions of what you tap. So you tap in 1/4 notes and get out 1/16 notes.

The subdivisions i would like are:
1/4
1/8
1/16
1/4*
1/8*
1/16*
1/4T
1/8T
1/16T

Just an example.

And i like the idea of Charlie about the Tap Pattern, I played with that to for a while on my arduino tap tempo controller.

best regards
Ronald
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: G. Hoffman on May 23, 2009, 06:28:49 PM
Quote from: ElectricDruid on May 13, 2009, 11:53:43 AM

Does anyone really need multiple simultaneous outputs, or are people just interested in having a good range of waveforms available on a single output?
T.





Actually, I would.  Not a whole bunch, but two outputs which could be variably out of phase with one another would be useful.  They don't need to have different waveforms, just the variable phase relationship.  180 degrees would be easy to do with an inverting buffer, which is PROBABLY the most useful phase relationship, but I think I'd like to have others available, if possible.  Alternatively, how about some way to sync two chips?  With a variable phase relationship, of course.

The other thing that I would find useful would be a rhythmic amplitude modulation, i.e., the ability to change the amplitude of every (variable number) wave.  So, for instance, every other wave has a higher amplitude, or every third wave has a lower amplitude.  Does that make any sense?

For what it's worth, I want to use this to drive a tremolo in a stereo tube guitar amp. 



Gabriel
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: sinisterguy on May 25, 2009, 08:20:04 PM
this is quite intriguing. I've been wanting to do something like this for a tremolo project as well. I do agree that subdivisions are a good idea though. the S&H feature could be cool for a tremolo too. or even having using the output as a controller for an expression pedal input. it could be like a diy empress tremolo on steroids  :icon_smile:
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: G. Hoffman on May 26, 2009, 06:39:12 PM
Quote from: sinisterguy on May 25, 2009, 08:20:04 PM
this is quite intriguing. I've been wanting to do something like this for a tremolo project as well. I do agree that subdivisions are a good idea though. the S&H feature could be cool for a tremolo too. or even having using the output as a controller for an expression pedal input. it could be like a diy empress tremolo on steroids  :icon_smile:

That's what I was thinking, but you could do some interesting Flange and Chorus effects with it too.



Gabriel
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on June 29, 2009, 03:10:20 AM
I figured I should put my post in this one too, both as a bump to generate more interest in it and to double the chances of you reading this:


If you ever spent the time to get this off the ground, you could seriously make alot of money with this. I'd be willing to pay up to $10 for one pre-programmed, seeing as the part itself costs a mere $1.40 on bulk on mouser. Although I would buy many more if they were around $7, which I think is very reasonable. That's still a 500% profit, for not much work at all, provided you have a interface and a code set up for transferring!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on June 29, 2009, 12:45:16 PM
This topic should be moved into the building your own stompbox forum, seeing as how it is meant for people who are not familiar with PICs. He is asking the community that has no experience with them what they would like to see in a preprogrammed chip that he could sell off to them.

In short, the target audience for the project & topic does not even venture into this forum.  :icon_rolleyes:
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Taylor on June 29, 2009, 08:49:38 PM
Quote from: JKowalski on June 29, 2009, 12:45:16 PM
This topic should be moved into the building your own stompbox forum, seeing as how it is meant for people who are not familiar with PICs. He is asking the community that has no experience with them what they would like to see in a preprogrammed chip that he could sell off to them.

In short, the target audience for the project & topic does not even venture into this forum.  :icon_rolleyes:

Agree. I am one of these people. I occasionally pop in here as part of my effort to know what I don't know - the first step in learning is learning what you need to learn.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: David on July 02, 2009, 08:41:53 AM
Druid:

What is the possibility of using this setup to determine a beats-per-minute count and send the count out serially?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jacobyjd on July 02, 2009, 09:10:19 AM
Just to chime in with others--if this ended up looking like a 1-stop shop, multi-shape LFO in a single-chip format w/ minimal external parts and tap tempo, I would absolutely be in for one. In fact, I would consider converting my pedalboard setup to use a remote LFO plugin, and I would keep the LFO in its own box with a tap switch. I would use the LFO to sync up multiple modulation pedals from a central point.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: David on July 02, 2009, 10:44:13 AM
Quote from: JKowalski on June 29, 2009, 12:45:16 PM
This topic should be moved into the building your own stompbox forum, seeing as how it is meant for people who are not familiar with PICs. He is asking the community that has no experience with them what they would like to see in a preprogrammed chip that he could sell off to them.

In short, the target audience for the project & topic does not even venture into this forum.  :icon_rolleyes:

Yes, they do.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: .Mike on July 02, 2009, 07:11:18 PM
Quote from: jacobyjd on July 02, 2009, 09:10:19 AM
Just to chime in with others--if this ended up looking like a 1-stop shop, multi-shape LFO in a single-chip format w/ minimal external parts and tap tempo, I would absolutely be in for one. In fact, I would consider converting my pedalboard setup to use a remote LFO plugin, and I would keep the LFO in its own box with a tap switch. I would use the LFO to sync up multiple modulation pedals from a central point.

You know, I was thinking about this, and I think it could be very cool. I'm building a multi-effects project, and having one LFO that controls multiple modulation effects would be great.

Someone earlier mentioned multiple LFO outputs and tempo divisions. I wonder if it would be feasible or useful to sort of combine the two. For example you could have one LFO going out to a tremolo at 100% speed, and another LFO going out to a phaser at 50% speed, and another going to a delay at 10% speed. The LFOs would be in sync with each other, just at different rates.

I suppose, though, it would be better to have a way to sync multiple LFO chips in terms of speed only, so you could use a different waveform or depth for each effect.

Could the tap-tempo VCLFOs simply be run in parallel, so that a single tap button changes the speed of multiple LFOs at the same time?

One of the LFO's inputs could be a tempo division CV, and all the other features (depth, waveform, wave distort) would be independent of the other LFO chips, and have their own potentiometers for adjustment. Of course, if you always wanted one of the characteristics to be synced with all LFOs-- waveform, for example-- you could just run the waveform CV to each LFO chip you want synced.

I bet that some pretty cool layers of effects could be built on that.

:)

Mike
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on July 09, 2009, 05:34:59 PM
Quote from: David on July 02, 2009, 10:44:13 AM
Quote from: JKowalski on June 29, 2009, 12:45:16 PM
This topic should be moved into the building your own stompbox forum, seeing as how it is meant for people who are not familiar with PICs. He is asking the community that has no experience with them what they would like to see in a preprogrammed chip that he could sell off to them.

In short, the target audience for the project & topic does not even venture into this forum.  :icon_rolleyes:

Yes, they do.

Well, there are exceptions. I meant the general population.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on July 19, 2009, 04:38:57 PM
Just found this thread because I was looking for a "tap tempo" square wave LFO with an option to set the duty cycle (wave distortion) in discrete steps that make "musical sense" like 50%, 33%, 25%.
This thread sort of covers it.

So it is basically the "Voltage Controlled LFO (VCLFO 9D)":
http://www.electricdruid.com/index.php?page=projects.lfo9
with added tab tempo control instead of the voltage control?

It would be nice to do it with an even simpler 8 pins PIC like: PIC12F629 or PIC12F675.
We probably only need up to 4 inputs (tap tempo, tempo division, duty cycle or wave distortion, wave-form selection) and the PWM-LFO output.
Title: Averaging circuitry of Boss DD5
Post by: brian.d.haber@gmail.com on September 04, 2009, 01:10:32 PM
Quote from: jacobyjd on July 02, 2009, 09:10:19 AM
I would use the LFO to sync up multiple modulation pedals from a central point.

I, too, have thought about that before (great idea!). How would you make it work with pedals that don't have tap tempo inputs?

Also, does anyone know if it is possible to make a chip that averages the time in between 4 taps (instead of just 2) to get a more accurate setting, a la the Boss DD5? This would help most with pedals that you want to sync to the BPM of a song that are continuously running (e.g. tremolo, phaser), and lag (or speed) further and further behind the beat as the song progresses. Its not so much of an issue with delay pedals, because the pedal goes off of the notes you play.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on September 05, 2009, 07:10:27 AM
Using 4 taps instead of 2 is just a matter of programming with a PIC.  ;)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: brian.d.haber@gmail.com on September 06, 2009, 01:21:26 PM
Quote from: flo on September 05, 2009, 07:10:27 AM
Using 4 taps instead of 2 is just a matter of programming with a PIC.  ;)

Thanks for the response. So, how exactly do you buy a generic PIC from Mouser and program it to perform a certain algorithm, such as the averaging 4 tap tempo inputs to set the tempo on a tremolo? Is there a common programming language to interface with the PICs (e.g. assembly language), and if so, how do you interface with it?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on September 06, 2009, 05:07:46 PM
There is a lot of information about programming PICs on the internet also for beginners. I suggest you search it.  ;)

Beginners checklist for PIC  Microcontrollers
http://www.piclist.com/techref/piclist/begin.htm

PIC Programming - Getting Started
http://www.mhennessy.f9.co.uk/pic/index.htm

But basically:

- Buy a PIC chip.
- Buy a PIC programmer. I got a clone of the MicroChip PicKit2 from ebay.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805
- Install the MicroChip MPLAB IDE.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&redirects=mplab
- Learn to program it using very simple examples and a language called "C" (or else Assembler but its more difficult).
http://www.nextdawn.nl/c-reference/index.php
http://www.nextdawn.nl/sub/c_language/index.php
- Write a program in MicroChip MPLAB IDE, preferably using an example project to get you going.
- Compile the program with the MicroChip MPLAB IDE into a binary file.
- Put the binary file into the PIC chip using the MicroChip MPLAB IDE.
- Put the PIC chip into the hardware you build.
- Test the functionality of the program running in the PIC.
- Fix bugs in the program in MicroChip MPLAB IDE.
- etc.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on December 04, 2009, 10:05:10 AM
Just a note to say that this isn't dead. After some nudging from elsewhere, I've gone back to this project and am getting close to having it finished off. Hopefully code and a datasheet will appear shortly on my website (http://www.electricdruid.com).

Thanks,
Tom
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Roy on December 04, 2009, 03:14:11 PM
That's very good news about tap-tempo development.

I found this thread after I mentioned elsewhere  http://www.diystompboxes.com/smfforum/index.php?topic=79078.msg666768 (http://www.diystompboxes.com/smfforum/index.php?topic=79078.msg666768) (Gristleizer PCB's) that a soft LFO might be worth pursuing, and then I found that it had already been done.

Does the tap-tempo input completely replace the frequency control? If it does, then you can't use the pot to nudge the frequency up or down, you have to re-tap it. And if it doesn't and there's still a frequency pot too, then there is the usual problem of editing an existing value when the pot's physical position doesn't match the setting. Either you do a Prophet-5 style edit from where you happen to be, or you use a rotary encoder and accept the finite steps which are larger than the smallest step on a pot.

I was thinking about the algorithm. Taps 'expire' after 65 seconds, which is an absolute age in messing around with things terms. Consider the situation where it is 64 seconds since the last tap. You tap twice. The first tap is paired with the ancient tap, setting the frequency to very-slow-indeed. The second tap is now taken as a new 'first' tap, so noted but not acted on. The net result is that the frequency is still very-slow-indeed. Now consider the situation where it is 66 seconds since the last (unpaired) tap. The first tap is noted, the second concludes the timing interval and the LFO is set to the tempo defined by those two new taps. That is very different behaviour, depending on stuff that happened ages ago.

Would it be better to not differentiate between 'first' and 'second' taps, and each time there is a tap, try to pair it with a preceeding tap and set frequency appropriately. If there is no preceeding tap within the last 65 seconds, note the new tap but do nothing to the frequency yet.

If you're really clean about never leaving an unpaired tap it would never be a problem. I know I'm not like that. I might tap it three times, five times, whatever, until it sounded right.

I can't pretend to speak from first hand experience, though. This is just conjecture. How does it pan out in practice?


Roy Gwinn
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on December 04, 2009, 06:44:20 PM
You've got it pretty much spot on, Roy. I had exactly the problem you describe, and a related issue which was that 1mS resolution wasn't really enough for the timing. So I've used the 19.5KHz sample interrupt to count instead. This means the counter counts 19500 per second instead of 1000. This improves the resolution and reduces the maximum 16-bit time to a bit over three seconds. This is slow enough for fairly slow tempos (20BPM or less) but isn't long to wait for a unpaired tap to 'expire'. It seems to work pretty well.

The tap tempo does completely replace the tempo cv input, yes, and that means that you can't use the knob to nudge a tapped tempo up or down a bit. If you twist the knob, the chip changes to the new tempo you just set with the knob. The most recent change wins.
It's simple to use. If you want a particularly frequency, set it with the knob; if you want a particular tempo, tap it with the button.

Finally, you're dead right about needing first and second taps too. That's exactly how I thought to do it too.
Great minds think alike, and fools never differ.
T.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Skruffyhound on December 05, 2009, 02:56:13 PM
Like I said in the other thread. I'm interested, if you are at a point where you want to start taking orders, I'm in for a few. How many depends on the final price. Thanks for doing this.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on December 08, 2009, 06:35:50 AM
I think I've finished! I've put details of my Tap Tempo LFO up online at:

http://www.electricdruid.com/index.php?page=projects.taplfo

There are example circuit diagrams, a datasheet, code, etc. Any questions, please ask.

I'll be trying to sort chips out soon, and if I can persuade Steve Daniels that this is a good idea, you might be able to buy programmed chips from Small Bear.

Thanks,
Tom
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: RonaldB on December 08, 2009, 07:15:27 AM
Looks good Tom, ;)

Thanks for making this avalible for everyone.

Ronald
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 08, 2009, 04:11:21 PM
I've been waiting for this for a long time. Thank you so much for finishing it up! This program, IMO, has the perfect array of features, all useful, in a good sized chip. You have done a wonderful job, and are very generous to offer all of this hard work freely to the community! I'm gonna test it out as soon as I can.

Many many many thanks for your efforts and generosity!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Processaurus on December 08, 2009, 09:08:34 PM
Very cool, thanks very much for putting this together, Tom.  Question, when, rythmically, does the new tempo come in once you've tapped?


Idea, to make inverted LFO's (for stereo effects and the like) one could probably just stick an inverter on the PWM output (with the inverter powered from the 5v), and then LP filter that just like the non inverted signal.  As you turn the depth down with the digital control, does the LFO remain biased at 2.5v?  If so, the digital depth knob would work fine for the inverted copy...


I got some PIC's to try your original VCLFO, but hadn't had a chance to try it yet, this is timely!  Awesome!

EDIT: reading answered my questions about hanging taps and interaction with the Tempo CV knob.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Processaurus on December 08, 2009, 09:16:55 PM
One last question, do you recall the cutoff frequency of the Bessel LPF?  I was thinking about trying the single opamp 3 pole filter that Boss uses (can't recall the actual name of the circuit).
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on December 09, 2009, 04:28:48 AM
Wow, that's great. Very well documented as well.

Thanks for this, now I have to figure out where I want to use it... :)

Potul
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on December 09, 2009, 05:14:48 AM
The bessel filter has a cutoff around 1KHz. It's a tradeoff between sharp edges on the ramp and square waves and better filtering. I chose 1KHz originally because it meant I could have a 1mS attack time for my PIC envelope generator. Since then, I've just reused it.

You could go lower for an LFO, I'd have thought. By all means experiment with different filters. The very first filter I used came from a Maplin ADA echo project from about 1984!

T.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on December 15, 2009, 06:18:24 PM
How hard would it be to use a small PIC instead (like a 8 pin PIC12F629 or PIC12F675) with just the basic in/out options (tap tempo in, PWM out and two other parameters like "waveform" and "level")?
Just state to use the other PIC device in the code, shuffle the "parameters" to the right hardware pins and re-compile?  ;D
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on December 17, 2009, 11:26:36 AM
Processaurus asked whether the LFO remains biased at 2.5V when you turn the depth down. Yes, it does, so your idea for inverting the waveform by inverting the PWM output would work exactly as you thought. Is it really much simpler than an inverting op-amp though?

Flo was asking about whether you could move the code to a 12Fxxx PIC. The 12F675 you mention has 4 A/D inputs, so that's good, but it doesn't have a PWM output module, so you wouldn't be able to get the output out of it without more substantial modifications and probably an external DAC or something. The killer might be program memory - the little 12F chips only have 1024 bytes, which isn't enough. It's not that the code is particularly long, but you need look-up tables for the control response and the waveforms, and those eat up some memory.

T.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on December 17, 2009, 03:41:11 PM
Thanks for the reply!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Processaurus on December 17, 2009, 11:22:12 PM
Quote from: ElectricDruid on December 17, 2009, 11:26:36 AM
Processaurus asked whether the LFO remains biased at 2.5V when you turn the depth down. Yes, it does, so your idea for inverting the waveform by inverting the PWM output would work exactly as you thought. Is it really much simpler than an inverting op-amp though?

Maybe not, I had just run into trouble in the past inverting analog LFO's with inverting opamps, from the DC bias being a little different or wandering as the depth knob was turned, so that there's a different DC value between the inverted and non inverted copies, that kind of thing, but those concerns might be out of place with this...  I was just excited because there was a bulletproof way to get the inverted copy without trimming anything, etc.

Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 29, 2009, 04:02:16 PM
Just wanted to note...


Your filter design in the application notes might put off some people who want a voltage output without a large number of parts.

A simple two pole low pass filter is all you really need, IMO.

2x 1k and 0.1uF cleaned up the output perfectly, great resolution across the waveforms and speeds. Practically zero trace of the high sampling frequency.  Going higher than that, the square wave/sawtooth cliffs/random jumps became a little curved but that doesn't strike me as bad in any way.

:icon_biggrin:
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on December 29, 2009, 09:58:25 PM
Quote from: JKowalski on December 29, 2009, 04:02:16 PM
A simple two pole low pass filter is all you really need, IMO. 2x 1k and 0.1uF cleaned up the output perfectly, ...
So you mean just two RC lowpass filters in series?
If not, do you have a schematic perhaps?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 29, 2009, 11:02:56 PM
Quote from: flo on December 29, 2009, 09:58:25 PM
Quote from: JKowalski on December 29, 2009, 04:02:16 PM
A simple two pole low pass filter is all you really need, IMO. 2x 1k and 0.1uF cleaned up the output perfectly, ...
So you mean just two RC lowpass filters in series?
If not, do you have a schematic perhaps?

Yeah, two passive lowpass RC filters.

Here's a scope view of the result:

(http://i45.tinypic.com/4kto5w.jpg)

The filter doesn't need to be very precise - with the sample rate at 20kHz and the LFO frequency range between <0.1Hz and 30Hz, you can get away with a pretty blunt filter. You just gotta make sure you don't start eliminating the sharper points of the wave (such as the square wave and sawtooth wave transistions) and the harmonics that lend the triangle and lump/sweep waveshapes their resolution. As you can see on the scope with 1k and 0.1uF, the sharp transistions are pretty much untouched by the filter - going any higher and you see a bit of sloping gradually start to come in to the 0-5 jumps.

The sample rate is something like.... 50dB down? Jump it to around 65 with another pole of you want... You'd have to see if it's good enough for the application... Make sure there's no bleed through but I think that it being at the total extreme of human hearing and the severe attenuation from the filter it won't be a problem.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on December 30, 2009, 09:16:53 AM
Nice picts, looks good!  8)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Processaurus on December 30, 2009, 10:21:55 AM
Nice waveforms! I bet in optical pedals, you could hook the PWM out right to the LED (if the PIC can supply the current, otherwise with a transistor driver), no filtering, because the response of LDRs is so slow it would filter out the jaggedies.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 30, 2009, 12:37:16 PM
Quote from: Processaurus on December 30, 2009, 10:21:55 AM
Nice waveforms! I bet in optical pedals, you could hook the PWM out right to the LED (if the PIC can supply the current, otherwise with a transistor driver), no filtering, because the response of LDRs is so slow it would filter out the jaggedies.

Oh definitely, I just cooked up an optical tap tremolo much like the one in the app notes Electric Druid provided. He discusses that option in the datasheet. Of course, optical kind of muddies up the waveforms a little bit (Turns the lump, sweep, sine, and triangle waves into something resembling the lump waveform, I scoped it using the LDR in a voltage divider) but it still works beautifully. In fact, since the LDR has a kind of exponential relationship, the volume sweep is probably much better for it because of how we hear exponentially anyways. If you looked at the sawtooths on my scope through the LDR/resistor voltage divider, it's a pretty good exponential curve. If you listen to the optical trem sawtooth sweep, it sounds pretty linear.

There's also the interesting effect where since the LED brightness is controlled not by the voltage/current but by the PWM, it is has a more linear brightness/LFO relationship, reducing distortion on that end. Also mentioned in the datasheet.


Finally just wanted to note that in the filter I was discussing, the bessel filter in the datasheet is a good option if you have room, I'm just saying that if you don't your not at loss. The two pole Bessel filter should provide about 100dB attenuation at the sample frequency, and it also buffers the output. There is one problem though, the first stage of the filter provides some measure of attenuation down to 30Hz... With my experience at the passive filter method, having the 6dB point at 1kHz (attenuation starting at 300Hz) is about the limit for keeping the waveforms nice and sharp. I would think the filter on your datasheet would be kind of brutal to the waveshapes coming out of the chip... It'd need to be scoped before decisions are made, though...
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: MoltenVoltage on December 30, 2009, 02:29:22 PM
Those waveforms look really good, but how do they scale?

From what I can read, the rates you have pictured are between 5 and 16 hz.

I suspect that at a sweep of 2 seconds (0.5 hz), they wouldn't be as smooth, but I could be wrong.  One big factor when using lookup tables for sine waves, is the number of data points in your table.

I also wonder whether any PWM filter responds consistently across the useful LFO range (let's say 10 hz [.1 seconds] to .01 hz [10 seconds]).
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on December 30, 2009, 06:36:16 PM
Another interesting LFO shape is the "hyper triangle" for slow phasers and flangers.
Are the "Sweep" & "Lump" meant for something that resembles a hypertriangled shape?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 30, 2009, 08:36:22 PM
Quote from: MoltenVoltage on December 30, 2009, 02:29:22 PM
Those waveforms look really good, but how do they scale?
From what I can read, the rates you have pictured are between 5 and 16 hz.
I suspect that at a sweep of 2 seconds (0.5 hz), they wouldn't be as smooth, but I could be wrong.  One big factor when using lookup tables for sine waves, is the number of data points in your table.
I also wonder whether any PWM filter responds consistently across the useful LFO range (let's say 10 hz [.1 seconds] to .01 hz [10 seconds]).

I only did the fast waveforms (it was probably like 8Hz not 5, my scope doesn't recognize frequencies below 10Hz it just says "<10Hz" :icon_eek:) because I was testing the filter, and the most ciritcal part of the filter was to eliminate the sample frequency without messing up the LFO harmonics and resolution.

They are quite smooth, way down to 0.5Hz. Around 0.3Hz or so is where it becomes very slightly noticable on the scope, and getting even more lower than that it might get noticable audibly (in the 10 second LFO rates...?)

My optical trem pedal with the chip is not handy right now, but I will break it out when it is, slow it wayyy down and report back. I'd have to build a voltage LFO controlled effect first to see how it fares in that regard with the slow speeds...

Quote from: flo on December 30, 2009, 06:36:16 PM
Another interesting LFO shape is the "hyper triangle" for slow phasers and flangers.
Are the "Sweep" & "Lump" meant for something that resembles a hypertriangled shape?


Yeah the sweep and lump ones are the hypertriangle shape, normal and inverted. I would say it IS a hypertriangle rather than just a resemblance - the "hypertraingles" I have see look just like that, one half triangle one have sine waveish.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: cloudscapes on December 30, 2009, 10:42:20 PM
speaking of waveshapes, say I want to create some of my own wavetables and I'm not terribly good at math. which software could I use to either import a wav or generate one on an easy-to-understand formula and convert it to a table of values?

I've already got tables for square, triangle, sine and saw, but I'm interested in making some of the funkier ones
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 31, 2009, 01:43:04 AM
Quote from: cloudscapes on December 30, 2009, 10:42:20 PM
speaking of waveshapes, say I want to create some of my own wavetables and I'm not terribly good at math. which software could I use to either import a wav or generate one on an easy-to-understand formula and convert it to a table of values?

I've already got tables for square, triangle, sine and saw, but I'm interested in making some of the funkier ones

Get a big sheet of graph paper and hand draw it out? It can't take tooooo long, right? Unless you have a zillion values. Besides, if the wave flips around then you only have to go through half of it  :icon_lol:

I can't think of any other way to do it without using math... I mean, for the computer to calculate the values on a curve you would need a mathematical formula for that line to give it first. To do what you want, you would need something that lets you draw out a curve and compute values on it and that sounds like a pretty specialized program with limited applications--the kind of thing your would make yourself for your own use.  :icon_neutral:

EDIT: Just an idea, if you have photoshop you could grid a square (with the PS grid overlay), draw out your waveshape with vector lines, and then use the ruler in photoshop with snap to measure all of the distances systematically on the line. Kind of the same thing as the pen and paper just on the computer instead which might make it a little easier on you.

For standard waves and whatever waves you can build with math, I would use a graphing calculator, draw it out, then hit the table function and read of all the values at each interval.


Just wondering, what kind of waves are you thinking about?

This chip has everything I would think you would ever need as far as waveforms - but the random waveform is not very useful for pedals, and maybe it could be replaced with something better. But I have been racking my brain trying to figure out what else would be worthwhile.

Triangle and sawtooth are faster calculated than looked up (as ED said on his site) so the only table you really need is the lump - because for the sweep, you just invert it, for the sine, you just double speed it and invert it on the second pass. I'm pretty sure thats how ED's chip does it but I would have to double check. That system I would think would give you nice resolution on all waves, and barely take up any space (just the hi res lump lookup table and that's it).

I suppose you could even only have HALF the lump wavetable, as you can read it forwards then backwards to give you the full waveform, and then etc.  :icon_lol:

Anyways the point of that was that if you think of any other kind of waveform that you think would be useful to have please share!


Quote from: JKowalski on December 30, 2009, 08:36:22 PM
My optical trem pedal with the chip is not handy right now, but I will break it out when it is, slow it wayyy down and report back. I'd have to build a voltage LFO controlled effect first to see how it fares in that regard with the slow speeds...

Just as a side note, I've played with the thing a ton recently and never had any scaling issues whatsoever while doing so. Couldn't hear anything in the slightest. I don't really use the super super super slow speeds, so I can't vouch for that at the moment, but I think theres a point where the speed is just not usable anymore and I think the chip doesn't become badly scaled before that point is reached.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Processaurus on December 31, 2009, 10:32:43 PM
Just had a thought, the pwm output could be a boon as far as interfacing with analog effects: with the pwm output, you could hook it directly (or through a logic buffer running at the effect's full supply voltage) to a 4066 for a pulse width controlled variable resistor, by putting the max resistance value you want across the switch.  For PWM'd pot, you could use a 4053 in a similar arrangement, tie identical resistors (both equal to the value of the pot) from the common to each throw.  Then filter the audio to get rid of the hi frequency artifacts at the end.

Provided the PWM'ing is fast enough to be filtered out without wrecking the audio, you could make a phaser with a jillion stages pretty easily, or replace a pot in any non LFO effect.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 01, 2010, 03:35:43 PM
Quote from: Processaurus on December 31, 2009, 10:32:43 PM
Just had a thought, the pwm output could be a boon as far as interfacing with analog effects: with the pwm output, you could hook it directly (or through a logic buffer running at the effect's full supply voltage) to a 4066 for a pulse width controlled variable resistor, by putting the max resistance value you want across the switch.  For PWM'd pot, you could use a 4053 in a similar arrangement, tie identical resistors (both equal to the value of the pot) from the common to each throw.  Then filter the audio to get rid of the hi frequency artifacts at the end.

Provided the PWM'ing is fast enough to be filtered out without wrecking the audio, you could make a phaser with a jillion stages pretty easily, or replace a pot in any non LFO effect.

Thats a neat thought!

You need a good sharp filter, though. 19kHz is on the very very edge of human hearing.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 01, 2010, 04:36:37 PM
Like in the MXR Envelope Filter:
http://www.tonepad.com/project.asp?id=4
http://www.generalguitargadgets.com/pdf/ggg_mxr_envelope_filter.pdf

Is the PWM frequency fixed to 19kHz because it is directly related to the clock frequency of the PIC, or can it be run even faster?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 01, 2010, 09:36:03 PM
Quote from: flo on January 01, 2010, 04:36:37 PM
Like in the MXR Envelope Filter:
http://www.tonepad.com/project.asp?id=4
http://www.generalguitargadgets.com/pdf/ggg_mxr_envelope_filter.pdf

Is the PWM frequency fixed to 19kHz because it is directly related to the clock frequency of the PIC, or can it be run even faster?

The PWM module on the PIC16F684 is limited to a 20kHz maximum sampling frequency, I suppose that's what stopped Electric Druid from going any further  :icon_eek:

He's also running the clock at it's limit too (20MHz)

Im starting to feel like I am him now! I think he's the sensible one here and is having a nice relaxing and/or fun holiday without thinking endlessly about electronics  :icon_lol:
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: MoltenVoltage on January 01, 2010, 10:47:03 PM
Quote from: JKowalski on January 01, 2010, 09:36:03 PM
The PWM module on the PIC16F684 is limited to a 20kHz maximum sampling frequency, I suppose that's what stopped Electric Druid from going any further  :icon_eek:

He's also running the clock at it's limit too (20MHz)

At 20MHz the PWM frequency can be as high as 208.3 kHz, but the resolution drops from 10 bits to 6.6 bits (don't ask me how they calculate 6.6 bits?!?)

See page 83:
http://ww1.microchip.com/downloads/en/DeviceDoc/41202F-print.pdf

You have to decide whether the higher frequency or sample rate is more accurate with your PWM filter by doing some experiments.

Quote from: JKowalski on January 01, 2010, 09:36:03 PM
Im starting to feel like I am him now! I think he's the sensible one here and is having a nice relaxing and/or fun holiday without thinking endlessly about electronics  :icon_lol:

Thinking endlessly about electronics IS relaxing!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 02, 2010, 02:59:15 AM
Quote from: MoltenVoltage on January 01, 2010, 10:47:03 PM
At 20MHz the PWM frequency can be as high as 208.3 kHz, but the resolution drops from 10 bits to 6.6 bits (don't ask me how they calculate 6.6 bits?!?)

Hahaha, that is quite interesting! They have a fancy log equation to calculate it, and for some reason they put 23 into it on that last one when complete bits can only be calculated using 2^n...? I do not know why.

Quote from: MoltenVoltage on January 01, 2010, 10:47:03 PM
Thinking endlessly about electronics IS relaxing!

I suppose it is! :icon_lol: I do catch myself daydreaming about them every day!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 03, 2010, 02:09:49 PM
Here's another version of the code edited to include a new feature, if anyone wants to use it:

RA2, or pin 8, the previously unused pin, now functions as a wave selection switch. When you bring pin 8 low, then the waveform changes to the next one. Attach a footswitch to this pin (just like the tap tempo) and you can cycle through all the different waveforms with your foot. The waveform selection potentiometer works as before. When you turn the wave knob, the wave changes to the value signified by the knob. If you ever hit the switch, the waveform goes to the next one over from the one selected by the knob. Keep hitting it and everytime it goes to the next one.

Here's (http://www.filedropper.com/taplfowaveswitch) a .rar file with the new ASM code and an assembled HEX file.



EDIT: Just realized it's my iconic 555th post! Hooray for timers!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 03, 2010, 04:24:49 PM
Cool new feature!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 07, 2010, 06:45:58 PM
Here
(http://www.filedropper.com/pic12f683taptempouc) is another "mod". I ported the basic tap tempo functions over to an 8-Pin uC, the PIC12F683. It's basically just to have tap tempo without the LFO portion of the chip. I am making a universal tap controller for all my TAPLFO pedals and I didn't want to waste space using a 14-pin chip loaded with features I did not need. It uses the internal 8mHz oscillator in the chip, no crystal.  It's rough right now, I am sure there are things I did not fully consider while porting as I did not design the chip and do not fully know all the bits of it. But it works perfectly to my eyes. And I am not to worried about building with it because it's so easy to reprogram and update it.



I was considering porting a stripped down LFO code to the PIC12F683 as well. I know this was asked earlier, and Electric Druid said no because program memory and the PWM module are necessities, but there are chips out there that do meet the needs - for example, the PIC12F683. It has the same PWM capabilities and the same amount of program memory as the PIC16F684! 4 A/D channels.

So, that makes 4 pins available (two for power, two for the 20mHz crystal). Now, two pins need to be the TAP INPUT and the LFO OUTPUT, so that leaves only 2 pins for CV controls... The level CV can be set at max and done analog style outside the chip, so that's not a priority...

Speed & Waveform?

Waveform & Multiplier?

Is this even worth doing, with the limited control capability? Anyone interested?




FINALLY I just want to thank Electric Druid again for this code. It is unbelievably useful, your generosity is astounding, and I have to say modifying your code and reading through it a hundred times has taught me a ton about PIC and asm. I think working backwards like this is one of the best ways to learn these kinds of things.  :icon_biggrin:



OH: And I thought I might as well post my first completed project with the TAPLFO chip on here. Tremolo, with tap sync jacks & the multiplier pot in the rear.

(http://i50.tinypic.com/28bcsrb.jpg)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 07, 2010, 07:24:42 PM
Wauw, you're really cookin'!  8)

Good find on the 8 pins PIC12F683. Should make a port to a small IC possible without large code changes I guess. "Just" change the ports/pins to use and the destination PIC library. ;)

If we have two controls left my current choice would be:
1) Waveform. Got to have it!
2) Speed, for a manual speed option (preferably by footpedal).
Closely followed indeed by:
3) Multiplier, for changing the rate in a "tempo related manner".

Imo, if this is made as simple (few options and thus few external hardware like pots) and small (8pins DIP) as possible, people will be more inclined to simply add it to a design or an existing build.

But as always having to choose which options to have and which to drop makes me want them all and needing the full 14 pins version. ;)  ::)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 07, 2010, 10:12:56 PM
Here (http://www.filedropper.com/pic12f683ttvclfob) is the TAPLFO on the PIC12F683.... Version "B". This one has the multiplier CV and the waveform CV. Version "A" will have the Tempo and Wave CV's.

Next one, maybe tomorrow. Doesn't take hardly any time at all.

Pinout for PIC12F683 TAPLFO Version "B":

1. V+
2 & 3. 20mHz Clock Crystal
4. Tap Input
5. PWM LFO Out
6. Waveform Select CV 0-5
7. Multiplier CV 0-3.75
8. V-

DOWNLOAD LINK (http://www.filedropper.com/pic12f683ttvclfob)



Pinout for PIC12F683 Tap Controller (Previous post):

1. V+
2. Tap Indicator LED
3. Clock Out
4. Tap Input
5. Unused
6. Multiplier CV 0-3.75
7. Tempo CV 0-5
8. V-

DOWNLOAD LINK (http://www.filedropper.com/pic12f683taptempouc)

I just want to use those crystal I/O pins so bad!  :icon_eek:

Am I putting out too many options?   :icon_lol:

Title: Re: Tap Tempo LFO with PIC 16F684
Post by: G. Hoffman on January 08, 2010, 02:49:18 AM
Quote from: JKowalski on January 07, 2010, 10:12:56 PM
Here (http://www.filedropper.com/pic12f683ttvclfob) is the TAPLFO on the PIC12F683.... Version "B". This one has the multiplier CV and the waveform CV. Version "A" will have the Tempo and Wave CV's.

Next one, maybe tomorrow. Doesn't take hardly any time at all.

Pinout for PIC12F683 TAPLFO Version "B":

1. V+
2 & 3. 20mHz Clock Crystal
4. Tap Input
5. PWM LFO Out
6. Waveform Select CV 0-5
7. Multiplier CV 0-3.75
8. V-

DOWNLOAD LINK (http://www.filedropper.com/pic12f683ttvclfob)



Pinout for PIC12F683 Tap Controller (Previous post):

1. V+
2. Tap Indicator LED
3. Clock Out
4. Tap Input
5. Unused
6. Multiplier CV 0-3.75
7. Tempo CV 0-5
8. V-

DOWNLOAD LINK (http://www.filedropper.com/pic12f683taptempouc)

I just want to use those crystal I/O pins so bad!  :icon_eek:

Am I putting out too many options?   :icon_lol:




None of your download links are working for me.  I just get a File Dropper home page.


Gabriel
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 08, 2010, 12:08:04 PM
Woops.

I don't host files very often. I guess filedropper doesn't keep the files very long

Here they are on MEGAUPLOAD for now, does anyone know a place to host small files for a long time, free?

TAP TEMPO uC (http://www.megaupload.com/?d=8OW6YQVN)

TAPLFO 8-PIN (http://www.megaupload.com/?d=Q000TK76)

TAPLFO 14-PIN WITH WAVESWITCH (http://www.megaupload.com/?d=8LJW9UEZ)

I was working on a website a while back maybe I should finish that up - hosting small files like these won't be a problem on it.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Skruffyhound on January 08, 2010, 07:47:58 PM
Thanks Chris, downloads working now.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: G. Hoffman on January 08, 2010, 09:47:39 PM
Quote from: JKowalski on January 08, 2010, 12:08:04 PM
Woops.

I don't host files very often. I guess filedropper doesn't keep the files very long

Here they are on MEGAUPLOAD for now, does anyone know a place to host small files for a long time, free?

TAP TEMPO uC (http://www.megaupload.com/?d=8OW6YQVN)

TAPLFO 8-PIN (http://www.megaupload.com/?d=Q000TK76)

TAPLFO 14-PIN WITH WAVESWITCH (http://www.megaupload.com/?d=8LJW9UEZ)

I was working on a website a while back maybe I should finish that up - hosting small files like these won't be a problem on it.

Thanks!

I'm working on some other stuff right now, but I want to have these when I get around to needing them.


Gabriel
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 09, 2010, 12:45:10 PM
Hmm the new download links on megaupload give me:
"The file you are trying to access is temporarily unavailable" :(

Edit:
After trying a few times and waiting a bit they became available again! :) Thanks!

Standing by for "version A" ... ;)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 09, 2010, 02:13:26 PM
Quote from: flo on January 09, 2010, 12:45:10 PM
Hmm the new download links on megaupload give me:
"The file you are trying to access is temporarily unavailable" :(

Edit:
After trying a few times and waiting a bit they became available again! :) Thanks!

Standing by for "version A" ... ;)


I will have my (barebones) website up today or tomorrow so we don't have to deal with all this.

Oh, and I nearly forgot about version A! I'll do that right now.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 09, 2010, 02:26:45 PM
Great!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 09, 2010, 11:30:26 PM
...Right after I spend the entire day cleaning the house  :icon_neutral:


Here it is.v

Pinout for PIC12F683 TAPLFO Version "A":

1. V+
2 & 3. 20mHz Clock Crystal
4. Tap Input
5. PWM LFO Out
6. Waveform Select CV 0-5
7. Tempo CV 0-5
8. V-

DOWNLOAD LINK (http://www.megaupload.com/?d=Q69X6VQQ)

My website should be up soon, its complete but my hosting service is giving me a 24-hour waiting period before I can work with it.

If you have any problems with the chips, tell me and I will fix it.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 10, 2010, 06:18:11 AM
Thanks!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 10, 2010, 05:37:53 PM
Alright, my website is up at strangedesigncs.heliohost.org (http://strangedesigncs.heliohost.org)

The downloads are up as well, except for the waveform select switch because I need to do a pinout diagram for it. That's my next thing on the list to do. It should be there in half an hour or so.  

EDIT: It's up.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Skruffyhound on January 10, 2010, 07:37:41 PM
Your site works fine for my mac.
I liked your art gallery, and nice tip on the vactrols. The clock on the home page is strangely pleasing.
Looking forward to pop by from time to time.
You are bookmarked :icon_biggrin:
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on January 11, 2010, 01:17:33 PM
Site looks great, I downloaded all the stuff again for the pinout images. Thanks again!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on January 13, 2010, 12:59:05 PM
Site does not work for me. Is it down?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: G. Hoffman on January 13, 2010, 07:20:51 PM
Quote from: potul on January 13, 2010, 12:59:05 PM
Site does not work for me. Is it down?

Just worked fine for me.


Gabriel
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on January 14, 2010, 04:27:04 AM
I realized today that the site is not working in my Google Chrome. If I use IE, everything is fine.

Regards,

Potul
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 14, 2010, 08:42:15 AM
Quote from: potul on January 14, 2010, 04:27:04 AM
I realized today that the site is not working in my Google Chrome. If I use IE, everything is fine.

Regards,

Potul

Huh, that's strange. I use Google chrome and every time I check it's up and running with no problems...?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on January 14, 2010, 09:57:12 AM
that's weird... Maybe related to the cache... don't worry.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 14, 2010, 04:41:25 PM
Alright, I hope you manage to figure it out!

I am working on putting the wave distort feature from the VCLFO into the TAP LFO chip right now. I have it basically finished, the pulse width CV is now the wave distort CV with duty cycle control of all the waveforms.

I am considering messing with the available waveforms.... For example, taking out of the noise source and replacing it with something different. My first thought was a 90 degree phase shifted sine wave - while this would have the same waveform as the other sine wave normally, it would 1. allow the waveform to be started at a different point in time relative to your tapping, and 2. offer new possiblities with the wave distort (it will distort differently then the other sine wave, see the first waveform in the table below)

Here's a table of what I was thinking (middle is standard wave, either side is different wave distort directions):
(http://i45.tinypic.com/28l9d7m.jpg)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on January 14, 2010, 06:37:43 PM
Wow, there's been a lot of really great work going on here! Well done!

JKowalkski, if you're still struggling with a place to host files, I'd be only too glad to put them up on a page of their own on my website. I think the various options and mods you've done are ace, and I'm particularly impressed you managed to get it into an 8-pin chip. I'd thought it couldn't be done, but I should have known better than to tell a PIC hacker that something's impossible!

I'd be very interested to see the schematic for your optical trem too. Did you have to alter the datasheet design much? Anything you learned that I should put it the next revision to save other people some messing about?

For the record, changing the waveshapes on the chip isn't that difficult, and I could post a version without the random wave (if that's the least useful) but with a "user-alterable" table. You *could* just about make up some numbers and type them in, but using your favourite programming or scripting language is the better option. I actually used PHP to generate the original sine table, but you could use Matlab/Octave, or C/C++ or your faourite graphic calculator or etc etc...basically anything that prints a list of numbers.

BTW, I *am* currently on holiday, but I haven't forgotten about sorting out programmed chips for those without the wherewithall/desire to program PICs.

Thanks everyone - it's great to see this chip "out in the wild"!

Tom
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 14, 2010, 07:47:25 PM
Quote from: ElectricDruid on January 14, 2010, 06:37:43 PM
Wow, there's been a lot of really great work going on here! Well done!

JKowalkski, if you're still struggling with a place to host files, I'd be only too glad to put them up on a page of their own on my website. I think the various options and mods you've done are ace, and I'm particularly impressed you managed to get it into an 8-pin chip. I'd thought it couldn't be done, but I should have known better than to tell a PIC hacker that something's impossible!

I'd be very interested to see the schematic for your optical trem too. Did you have to alter the datasheet design much? Anything you learned that I should put it the next revision to save other people some messing about?

For the record, changing the waveshapes on the chip isn't that difficult, and I could post a version without the random wave (if that's the least useful) but with a "user-alterable" table. You *could* just about make up some numbers and type them in, but using your favourite programming or scripting language is the better option. I actually used PHP to generate the original sine table, but you could use Matlab/Octave, or C/C++ or your faourite graphic calculator or etc etc...basically anything that prints a list of numbers.

BTW, I *am* currently on holiday, but I haven't forgotten about sorting out programmed chips for those without the wherewithall/desire to program PICs.

Thanks everyone - it's great to see this chip "out in the wild"!

Tom

You are back! Well, sort of  :icon_biggrin:

I managed to get a website up for my files, they are in a good place now. If you wanted to put them up on your site to I wouldn't mind, after all they are just basically modifications to your code!

My optical trem was basically the same as in your datasheet. The only real differences were putting a trimpot as the feedback resistor on the second op amp for volume adjustment, and an inverter chip for buffering LEDS, inverting the clock output, and buffering the sync out pins (not that they really needed it).

Oh, are you still planning on putting the wave distort feature back into the chip? I figured I was on a roll with the mods and might try doing it myself but I am sure you could end up with a much more refined code... My work is basically:

1. Try to figure out what it does and how
2. Cut and paste
3. Integrate
4. Troubleshoot

I managed to get the WD feature into the chip and working correctly with my blunt methods, but there are two things I still need to work out:

1. A way to get a good clock output from the chip (the wave distort duty cycles the clock output, so I need to find a way to keep it 50% and at the original speed, or ideally 2x the original speed for proper chip-to-chip syncing) I'm not entirely sure how to go about this yet... I was thinking flipping the clock output at the start of the phase accumulator part A, but then that would divide the speed by two and I'd rather multiply it by two...

2. How to get the random wave working correctly again (only works when the wave distort CV is at it's highest setting at the moment, haven't looked into it yet, but then again I might not use it anyways)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 14, 2010, 09:34:43 PM
Quote from: JKowalski on January 14, 2010, 07:47:25 PM
I managed to get the WD feature into the chip and working correctly with my blunt methods, but there are two things I still need to work out:

1. A way to get a good clock output from the chip (the wave distort duty cycles the clock output, so I need to find a way to keep it 50% and at the original speed, or ideally 2x the original speed for proper chip-to-chip syncing) I'm not entirely sure how to go about this yet... I was thinking flipping the clock output at the start of the phase accumulator part A, but then that would divide the speed by two and I'd rather multiply it by two...

2. How to get the random wave working correctly again (only works when the wave distort CV is at it's highest setting at the moment, haven't looked into it yet, but then again I might not use it anyways)

Nevermind I figured something out. I just ran a separate linear phase accumulator in parallel with the wave distort-able one and used that for 50% duty frequency increments. Using bit 6 instead of 7 of the phase accumulator gave my 2X the speed for the output as well (why on earth did I not think of that?) The random works fine now as well.

I guess I will package it up and put in on my site tomorrow afternoon.



One thing I think is really neat about digital effects is their versatility after they are built. For example, since the PIC is the controller for the tremolo pedal I made and all features of it come from the LFO section, I can build the pedal and make major changes in the way it works just by editing code and reprogramming the chip! I don't know why but that's fun  :icon_rolleyes:
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on January 16, 2010, 12:26:05 PM
tremolo comming soon. i will post here the final version too. here is the populated pcb:

(http://i381.photobucket.com/albums/oo251/expiredharmonix/tap_tempo_trem_pcb.jpg)

i can't find anybody who can write to the PIC... but searching :)
ElectricDruid and JKowalski... well... all i can say: thanks!
it was really nice from you to public the codes/schematics.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: G. Hoffman on January 18, 2010, 06:26:55 AM
Quote from: 3080 on January 16, 2010, 12:26:05 PM
i can't find anybody who can write to the PIC... but searching :)

There are a plethora (http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=Yq&q=diy+pic+programmer&aq=f&oq=&aqi=g3) of DIY PIC programmers out there, and the PICkit 3 isn't all THAT expensive, if you really feel like it and think you are going to want to do more with PICs. 


Gabriel
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on January 19, 2010, 05:31:56 AM
(http://i381.photobucket.com/albums/oo251/expiredharmonix/variable_square_wave.jpg)

working well :)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 21, 2010, 08:32:29 AM
Don't know if anyone was waiting for it but I uploaded the TAPLFO with the WAVE DISTORT feature (duty cycle for all waveforms) on my site a bit ago. 3080, your switching system will work the same with the wave distort. God idea!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on January 27, 2010, 01:48:16 PM
Another PWM output solution:

It's easy to change the 0-5V LFO output to any voltage range. For example, say you want a 0-9v Analog LFO output. You just put the PWM output into a CMOS buffer with 0/9v supply and filter the output of THAT. Now you have a 0-9v analog LFO after filtering. 5/-5v? Use a +5/-5 supply CMOS buffer (or anything very high gain)

If you want to get a... say 3-6V P-P LFO wave output, to get around the supply rail limitations for most op amp inputs (they cant go ALL the way to their supply rails) just put a potentiometer on the output of the CMOS buffer (or op amp) to divide the digital PWM signal down to the voltage range you need.

The PWM output is actually VERY versatile.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on February 06, 2010, 06:45:45 AM
(http://i381.photobucket.com/albums/oo251/expiredharmonix/tremolo.jpg)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on February 06, 2010, 11:41:47 AM
Looks awesome!  8) Any gutshots with that?  :)

Is that printed on transparant sheet or something?
Perhaps you can post the graphics because they look great!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: duffman0733 on February 07, 2010, 02:25:32 PM
where can we find the schematic for this pedal?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on February 07, 2010, 03:14:56 PM
Quote from: duffman0733 on February 07, 2010, 02:25:32 PM
where can we find the schematic for this pedal?

... maybe in a topic called Tap Tempo LFO with PIC 16F684  ::)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: mth5044 on February 07, 2010, 04:59:59 PM
Quote from: 3080 on February 06, 2010, 06:45:45 AM
(http://i381.photobucket.com/albums/oo251/expiredharmonix/tremolo.jpg)

THAT is cool!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on February 08, 2010, 12:48:16 PM
Quote from: JKowalski on January 27, 2010, 01:48:16 PM
Another PWM output solution:

It's easy to change the 0-5V LFO output to any voltage range. For example, say you want a 0-9v Analog LFO output. You just put the PWM output into a CMOS buffer with 0/9v supply and filter the output of THAT. Now you have a 0-9v analog LFO after filtering. 5/-5v? Use a +5/-5 supply CMOS buffer (or anything very high gain)

If you want to get a... say 3-6V P-P LFO wave output, to get around the supply rail limitations for most op amp inputs (they cant go ALL the way to their supply rails) just put a potentiometer on the output of the CMOS buffer (or op amp) to divide the digital PWM signal down to the voltage range you need.

The PWM output is actually VERY versatile.

which CMOS you prefer?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on February 08, 2010, 12:57:17 PM
Quote from: 3080 on February 08, 2010, 12:48:16 PM
Quote from: JKowalski on January 27, 2010, 01:48:16 PM
Another PWM output solution:

It's easy to change the 0-5V LFO output to any voltage range. For example, say you want a 0-9v Analog LFO output. You just put the PWM output into a CMOS buffer with 0/9v supply and filter the output of THAT. Now you have a 0-9v analog LFO after filtering. 5/-5v? Use a +5/-5 supply CMOS buffer (or anything very high gain)

If you want to get a... say 3-6V P-P LFO wave output, to get around the supply rail limitations for most op amp inputs (they cant go ALL the way to their supply rails) just put a potentiometer on the output of the CMOS buffer (or op amp) to divide the digital PWM signal down to the voltage range you need.

The PWM output is actually VERY versatile.

which CMOS you prefer?

Well it doesn't even have to be CMOS, just anything that can buffer a digital signal. It just has to be able to trigger on the 0-5V PWM and output a x-yV digital signal. I prefer CMOS digital chips because they are simple to use and they waste less power then other methods. Any ol' chip under the sun that can do the above (logic gates, inverters, digital buffers) would be usable. You just got to make sure the supply voltage ratings aren't exceeded.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on February 08, 2010, 01:01:32 PM
Quote from: JKowalski on February 08, 2010, 12:57:17 PM
Quote from: 3080 on February 08, 2010, 12:48:16 PM
Quote from: JKowalski on January 27, 2010, 01:48:16 PM
Another PWM output solution:

It's easy to change the 0-5V LFO output to any voltage range. For example, say you want a 0-9v Analog LFO output. You just put the PWM output into a CMOS buffer with 0/9v supply and filter the output of THAT. Now you have a 0-9v analog LFO after filtering. 5/-5v? Use a +5/-5 supply CMOS buffer (or anything very high gain)

If you want to get a... say 3-6V P-P LFO wave output, to get around the supply rail limitations for most op amp inputs (they cant go ALL the way to their supply rails) just put a potentiometer on the output of the CMOS buffer (or op amp) to divide the digital PWM signal down to the voltage range you need.

The PWM output is actually VERY versatile.

which CMOS you prefer?

Well it doesn't even have to be CMOS, just anything that can buffer a digital signal. It just has to be able to trigger on the 0-5V PWM and output a x-yV digital signal. I prefer CMOS digital chips because they are simple to use and they waste less power then other methods. Any ol' chip under the sun that can do the above (logic gates, inverters, digital buffers, hell even flip flops) would be usable. You just got to make sure the supply voltage ratings aren't exceeded.

i will try it with 40106...
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on February 08, 2010, 01:03:19 PM
Quote from: 3080 on February 08, 2010, 01:01:32 PM
Quote from: JKowalski on February 08, 2010, 12:57:17 PM
Quote from: 3080 on February 08, 2010, 12:48:16 PM
Quote from: JKowalski on January 27, 2010, 01:48:16 PM
Another PWM output solution:

It's easy to change the 0-5V LFO output to any voltage range. For example, say you want a 0-9v Analog LFO output. You just put the PWM output into a CMOS buffer with 0/9v supply and filter the output of THAT. Now you have a 0-9v analog LFO after filtering. 5/-5v? Use a +5/-5 supply CMOS buffer (or anything very high gain)

If you want to get a... say 3-6V P-P LFO wave output, to get around the supply rail limitations for most op amp inputs (they cant go ALL the way to their supply rails) just put a potentiometer on the output of the CMOS buffer (or op amp) to divide the digital PWM signal down to the voltage range you need.

The PWM output is actually VERY versatile.

which CMOS you prefer?

Well it doesn't even have to be CMOS, just anything that can buffer a digital signal. It just has to be able to trigger on the 0-5V PWM and output a x-yV digital signal. I prefer CMOS digital chips because they are simple to use and they waste less power then other methods. Any ol' chip under the sun that can do the above (logic gates, inverters, digital buffers, hell even flip flops) would be usable. You just got to make sure the supply voltage ratings aren't exceeded.

i will try it with 40106...

That will work perfectly. Just remember though when you invert the PWM signal you invert the LFO, so if you want it back to the original you have to invert it again somewhere down the line. Or you can just use two inverters in series.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on February 08, 2010, 01:51:33 PM
Quote from: JKowalski on February 08, 2010, 01:03:19 PM
Quote from: 3080 on February 08, 2010, 01:01:32 PM
Quote from: JKowalski on February 08, 2010, 12:57:17 PM
Quote from: 3080 on February 08, 2010, 12:48:16 PM
Quote from: JKowalski on January 27, 2010, 01:48:16 PM
Another PWM output solution:

It's easy to change the 0-5V LFO output to any voltage range. For example, say you want a 0-9v Analog LFO output. You just put the PWM output into a CMOS buffer with 0/9v supply and filter the output of THAT. Now you have a 0-9v analog LFO after filtering. 5/-5v? Use a +5/-5 supply CMOS buffer (or anything very high gain)

If you want to get a... say 3-6V P-P LFO wave output, to get around the supply rail limitations for most op amp inputs (they cant go ALL the way to their supply rails) just put a potentiometer on the output of the CMOS buffer (or op amp) to divide the digital PWM signal down to the voltage range you need.

The PWM output is actually VERY versatile.

which CMOS you prefer?

Well it doesn't even have to be CMOS, just anything that can buffer a digital signal. It just has to be able to trigger on the 0-5V PWM and output a x-yV digital signal. I prefer CMOS digital chips because they are simple to use and they waste less power then other methods. Any ol' chip under the sun that can do the above (logic gates, inverters, digital buffers, hell even flip flops) would be usable. You just got to make sure the supply voltage ratings aren't exceeded.

i will try it with 40106...

That will work perfectly. Just remember though when you invert the PWM signal you invert the LFO, so if you want it back to the original you have to invert it again somewhere down the line. Or you can just use two inverters in series.

The VCLFO's Level control is working the same az the TAPLFO's?
If yes... then I need to invert it...
I'm going to do a phaser with this LFO... and I wanna add Start and Stop pots (something like on the new EHX Polyphase)...
So if it works az the TAPLFO's, then I will invert the PWM, and the Level pot will be the Stop...
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: 3080 on February 10, 2010, 07:13:41 AM
Quote from: 3080 on February 06, 2010, 06:45:45 AM
(http://i381.photobucket.com/albums/oo251/expiredharmonix/tremolo.jpg)

again...
(http://i381.photobucket.com/albums/oo251/expiredharmonix/schematic/variable_square_wave.jpg)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: bunnycat on February 25, 2010, 09:12:41 PM
Would somebody mind posting their schematic / pcb for this if they have it?  The ones that were previously posted seem to have disappeared.  I'd love to learn PIC programming and this seems like a great project!!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Taylor on February 25, 2010, 09:23:09 PM
If you look here:

http://www.diystompboxes.com/smfforum/index.php?topic=80407.120

a PCB will be available in a couple of weeks. It's a tap tempo trem, but if you just want a tap tempo LFO, the PCB can be used for that as well.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: flo on February 28, 2010, 08:17:22 AM
Quote from: bunnycat on February 25, 2010, 09:12:41 PM
Would somebody mind posting their schematic / pcb for this if they have it?  The ones that were previously posted seem to have disappeared.  I'd love to learn PIC programming and this seems like a great project!!
See also:
Tap Tempo LFO (TAPLFO V2) - electricdruid
http://www.electricdruid.com/index.php?page=projects.taplfo
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on November 15, 2010, 02:52:47 AM
I don't really want resurrect a dead topic but I have a question about this tap tempo chip. Does the clock output pin output the LFO frequency before or after the multiplier? I tried wading through the assembly code but that stuff is so far from C I don't know what I am looking at half the time. The reason I ask is because I am trying to send the clock output steps to a decade counter as a sequencer, but I want the counter steps to be the slowest base frequency of the LFO chip before and regardless of the multiplier. (so for 1 step on the decade counter the LFO goes (1 x multiplier) number of steps or output waveform periods).

And if it is post multiplier, how do I go about changing it?     
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: cloudscapes on November 15, 2010, 07:23:16 AM
Quote from: jakefuzz on November 15, 2010, 02:52:47 AM
I don't really want resurrect a dead topic but I have a question about this tap tempo chip. Does the clock output pin output the LFO frequency before or after the multiplier? I tried wading through the assembly code but that stuff is so far from C I don't know what I am looking at half the time. The reason I ask is because I am trying to send the clock output steps to a decade counter as a sequencer, but I want the counter steps to be the slowest base frequency of the LFO chip before and regardless of the multiplier. (so for 1 step on the decade counter the LFO goes (1 x multiplier) number of steps or output waveform periods).

And if it is post multiplier, how do I go about changing it?     

I dont think it outputs a clock signal. I think it outputs PWM (which is basically varying voltage). Not totally sure, though. I've not tried it.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: nelson on November 15, 2010, 08:11:13 AM
Quote from: jakefuzz on November 15, 2010, 02:52:47 AM
I don't really want resurrect a dead topic but I have a question about this tap tempo chip. Does the clock output pin output the LFO frequency before or after the multiplier? I tried wading through the assembly code but that stuff is so far from C I don't know what I am looking at half the time. The reason I ask is because I am trying to send the clock output steps to a decade counter as a sequencer, but I want the counter steps to be the slowest base frequency of the LFO chip before and regardless of the multiplier. (so for 1 step on the decade counter the LFO goes (1 x multiplier) number of steps or output waveform periods).

And if it is post multiplier, how do I go about changing it?     

If it does, you can always just tie the multiplier switch to also select pins on another decade counter, aswell as control the multiplier. Dividing it down by however much it is multiplied, to get back to 1x.

Breadboard the circuit and see!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on November 15, 2010, 11:29:50 AM
Quote from: jakefuzz on November 15, 2010, 02:52:47 AM
I don't really want resurrect a dead topic but I have a question about this tap tempo chip. Does the clock output pin output the LFO frequency before or after the multiplier? I tried wading through the assembly code but that stuff is so far from C I don't know what I am looking at half the time. The reason I ask is because I am trying to send the clock output steps to a decade counter as a sequencer, but I want the counter steps to be the slowest base frequency of the LFO chip before and regardless of the multiplier. (so for 1 step on the decade counter the LFO goes (1 x multiplier) number of steps or output waveform periods).

And if it is post multiplier, how do I go about changing it?      

The clock output is after the multiplier.

You can change the base multiplication (i.e. half or double or triple etc. the clock frequency compared to the PWM) of the clock output by changing one 6-bit number in the code. I found this useful to link multiple chips together, since the clock output needs to be 2x speed to clock another chip at the same frequency since the tap timer only reads negative going edges. (the act of reading a square wave as a tap tempo input acts like a frequency divider)

It's been a while since I have worked with the code but I can think of two things you can do.

1. Set up another phase accumulator, this one using RAW_INC instead of FREQ_INC. RAW_INC is the tap tempo frequency before multiplication. Toggle the clock based on this counter.

2. Depending on the multiplier setting, adjust the bit that the clock output toggles on. For example, if the multiplier is set to 2, toggle the clock every 2nd full cycle of the clock. If set to 0.5, toggle every half cycle. You'd have to set up come sort of counter, so that you can count how many clock cycles have passed.

The way the chip works when tapped in a very general sense is:

Tap input -> calculate timing interval in RAW_INC -> send to multiplication code and output to FREQ_INC

A timer runs in the background as the phase accumulator. This timer:

Adds current FREQ_INC to phase accumulator -> If bit 7 is on (end of phase accumulator cycle) toggle clock out
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on November 15, 2010, 01:50:56 PM
Okay so for the first method. Just changing the phase clock variable, or do I have to change the phase variable as well because the clock output looks like it is evaluated from the phase clock variable.

; Increment the Clock Phase Accumulator (Provides non-distorted phase location)
IncrementPhaseClock:
   movfw   RAW_INC_LO   ; Add FREQ_INC_LO to PHASE_LO
   addwf   PHASE_LO_CLOCK, f
   
   movfw   FREQ_INC_MID   ; Add FREQ_INC_MID to PHASE_MID
   skpnc
   incfsz   FREQ_INC_MID, w
   addwf   PHASE_MID_CLOCK, f

   movfw   RAW_INC_HI   ; Add FREQ_INC_HI to PHASE_HI
   skpnc
   incfsz   RAW_INC_HI, w
   addwf   PHASE_HI_CLOCK, f
   
   ; If carry is set here, the Phase Accumulator has overflowed
   skpnc
   bsf   SEGMENT_END

; Deal with the Clock Output
   btfss   PHASE_HI_CLOCK, 7
   bsf   CLOCK_OUT      ; Glitch-free squarewave output
   btfsc   PHASE_HI_CLOCK, 7   ; Bit sets frequency multiple (below)
   bcf   CLOCK_OUT

; Bit 7=x1, Bit 6=x2, Bit 5=x4, and so on
; Use Bit6 for synching other TAPLFO chips since it measures the time between
; two pulses,  ; The output will also need inverting if it is to be used directly.

Can I do this and leave the rest of the phase accumulator intact? There is no RAW_INC_MID variable so I could probably just get rid of that central portion (and maybe even PHASE_MID_CLOCK). Also I just changed the phase clock increment routine, if I add a separate section to it preserving the old variable additions wont it add RAW_INC and FREQ_INC to the phase clock variable? I doesn't seem like the phase clock variable is used anywhere else so omitting the FREQ_INC additions wont change anything else but the clock output.

Nelson: interesting, I figured it would be only a few lines of code to change to get the clock output correct as opposed to adding more decade counters.

One more question, If I want to change the multipliers from (0.5, 1, 2, 3, 4...) to (1,2,3,4,6,8,16) Where 1 is the base frequency (RAW I guess) do I change the multiplier tables?

GetMultiplier:
        movwf   WAVETEMP
        movlw   HIGH MultiplierTable
        movwf   PCLATH
        movfw   WAVETEMP
        addlw   LOW MultiplierTable
        btfsc   CARRY
        incf   PCLATH, f
        movwf   PCL

MultiplierTable:
   retlw   D'1'   ; 1/2 note
   retlw   D'2'   ; 1/4 note
   retlw   D'3'   ; 1/4 note triplet
   retlw   D'4'   ; 1/8th note
   retlw   D'6'   ; 1/8th note triplet
   retlw   D'8'   ; 1/16th note
   retlw   D'2'   ; +2 dummy values for the top of the scale
   retlw   D'2'

I know for the majority of tremolo applications the latter multiples would seem redundant, but I wont lie, I am trying to build something that works like a Goatkeeper trem and for this the 1/2 multiple would be pointless and it would be nice to extend the range. 
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on November 15, 2010, 06:18:06 PM
Ahhh, you know what, I am just going to use two divide by N chips (CD4018b) and a CD4011 to divide the existing output signal, this way I don't need to change any of the multipliers or the clock output and I can do hardware debugging rather than fiddle around with a language I don't know. Nelson has the right idea, but tying the pins together on a decade counter will limit the amount of denominators I can get out of a single CD4017 with minimal hardware. The best I can do is a 2P8T rotary switch for multipliers and one pole is going to changing the multiplier CV, that means I only have one pole to change the frequency divider for the sequencer clock.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on November 18, 2010, 12:25:09 PM
Quote from: jakefuzz on November 15, 2010, 06:18:06 PM
Ahhh, you know what, I am just going to use two divide by N chips (CD4018b) and a CD4011 to divide the existing output signal, this way I don't need to change any of the multipliers or the clock output and I can do hardware debugging rather than fiddle around with a language I don't know. Nelson has the right idea, but tying the pins together on a decade counter will limit the amount of denominators I can get out of a single CD4017 with minimal hardware. The best I can do is a 2P8T rotary switch for multipliers and one pole is going to changing the multiplier CV, that means I only have one pole to change the frequency divider for the sequencer clock.

I can try to work something quick out for you if you'd like.

If you describe exactly what you are trying to make the chip do - what features you need/don't need. 

I'm working on a project that I might decide to start selling in pedal form (with permission from Tom), based on a modified version of this chip. If uses the PIC18F1320. It's basically the TAPLFO chip with a display output, 8 standard waveforms and then a switch to select 8 additional waveforms in memory - these waveforms can be customized, in the style of Cloudscape's tremolo design (where you draw out a waveshape with a knob). Also, the chip runs at 40mHz, enabling 10-bit PWM at 39kHz. I might fiddle with the tempo calculation to include averaging... Hardware multiplier simplifies the code a bit, too. If I complete this, I'll definitely post the code for you guys to play with as well. And if you guys think of anything interesting to add to the chip I am all ears!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 04, 2010, 12:38:12 AM
Sorry its been a while since i've visited. I am trying to make a goatkeeper like tremolo, essentially a sequenced tremolo with different waveforms. The problem with the current program is that to correctly sequence the counter clock (CD4017) you need the lowest frequency multiple (before it gets multiplied) as an output pin. I have been testing and experimenting with the code for the last couple of days, I have been able to add x5 and x16 multipliers and a post-multiplier clock pin out (instead of the next multiplier pin input).

The hardware design I am currently looking to build will send the pre-clock output (called half notes in the documentation) into the clock input pin of a CD4017 set up like a Zvex sequencer, these sequenced 5 volt pulses will run into a series of rotary switches (8 in total, one for each step of the sequence) and these will individually trigger the multiplier CV to whatever value is selected via the user on the rotary switches. So the multiplier will show a different value for each step of the sequence very similar to the goatkeeper.

I have also added a switchable NAND gate to the design in case the user wants to do a 90 degree phase shift on the clock output wave (mainly because the sine and triangle waveforms start high, but I thought it would also bee a cool feature to have)
Also unlike the goatkeeper the sequencer pulses and the post clock output are put through two quad AND gate chips to control each step led, showing the final frequency at the indicator for each step.



The problems I have been having so far:

I set up the phase_inc_clock timer to use the raw_inc increment rather than the freq_inc (post multiplier) increment, this makes the clock output independent of what multiplier is selected. The problem now is that clock out is about 100 times faster than the output waveform (at the lowest multiplier setting). I have tried everything I can think of to get the clock frequency back to the pwm waveform output frequency, no luck on this front.

The second issue is that the phases of the clock out and the waveform output are out of sync. I cannot see any defined relationship between the two and they start at different places almost every test run. For the post multiplier clock I was able to sync up the phases perfectly by triggering the clock output on a high 7th bit of the phase_hi variable rather than the phase_clock_hi variable. Works great, but the process to get here indicates that when I finally get the pre clock output working it wont likely be in phase with the wafeform output.   



I know it is kind of tough to explain, but I am confident if I can get the clock output to do what I want this would be a great design. Came up with the idea when someone asked about a diy goatkeeper over at the madbean pedals forum. If anyone else can figure this out that would be awesome, i will be working on it until I get it (no matter how long that takes!). I can draw up some paint pictures of the phase issue if anyone wants, i know that helps me to see what is going on. 
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 04, 2010, 12:48:07 AM
That custom waveshape idea is awesome by the way. The new goatkeepers do that too I think, very, very cool. I would be very interested in that code.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 04, 2010, 04:54:59 PM
and if you don't mind me asking, how are you implementing hardware multiplication? Is it some sort of return loop to the microcontroller? or are you using a whole external clock section?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 05, 2010, 02:36:33 AM
   movlw   D'128'   
   movwf   TEMP2
   movfw   PHASE_HI
   subwf   TEMP2, w      
   btfsc           ZEROBIT      
   incf           PHASE2_COUNT, f
   movfw   MULTIPLIER
   subwf   PHASE2_COUNT, w   
   btfsc       ZEROBIT   
   bsf      CLOCK_OUT
   btfss           ZEROBIT
   bcf       CLOCK_OUT   
   btfsc           ZEROBIT
   clrf           PHASE2_COUNT

Ahh, why doesn't it work!!!!  >:(  This should count the number of times the output wave passes 1 whole cycle (PHASE_HI = 128) then compare that to the multiplier, when they are equal the clock will trigger high. Am I a retard cause this seems like it would work. It just gives me some funky random sputtering when the multiplier is set above 2.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on December 05, 2010, 04:25:49 AM
Quote from: jakefuzz on December 04, 2010, 04:54:59 PM
and if you don't mind me asking, how are you implementing hardware multiplication? Is it some sort of return loop to the microcontroller? or are you using a whole external clock section?

The PIC18F series includes a hardware 8x8 bit -> 16 bit multiplier. This is used as another instruction, MULLW, MULWF. It's like the SUB and ADD instructions you are used to. The output is put into a special register for the low and high bytes.
Quote from: jakefuzz on December 05, 2010, 02:36:33 AM
   movlw   D'128'   
   movwf   TEMP2
   movfw   PHASE_HI
   subwf   TEMP2, w      
   btfsc           ZEROBIT      
   incf           PHASE2_COUNT, f
   movfw   MULTIPLIER
   subwf   PHASE2_COUNT, w   
   btfsc       ZEROBIT   
   bsf      CLOCK_OUT
   btfss           ZEROBIT
   bcf       CLOCK_OUT   
   btfsc           ZEROBIT
   clrf           PHASE2_COUNT

Ahh, why doesn't it work!!!!  >:(  This should count the number of times the output wave passes 1 whole cycle (PHASE_HI = 128) then compare that to the multiplier, when they are equal the clock will trigger high. Am I a retard cause this seems like it would work. It just gives me some funky random sputtering when the multiplier is set above 2.


I will have to check it out (and your previous message) tomorrow but I can tell you that you can count the wave cycles simply just by checking the high bit of the phase accumulator (when this bit is set, then the clock equals it's maximum value). The Clock_Out uses this method to trigger. Maybe simplifying will fix something.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 05, 2010, 02:41:51 PM
Yeah, take your time, I have finals like a madman for the next couple of days. The way I understand (which very well may be incorrect) is that the phase accumulator high bit goes high when it reaches 1/2 of the cycle (=128) then it stays high until the remaining 1/2 cycle runs out (128-255). I just want it to increment my counter once for every one of these cycle changes so I evaluated just when the phase accumulator was at 128, I think if I triggered my counter from the high bit of the phase accumulator my counter would increment for every cycle in the last half of the phase accumulator (128-255) and trigger the clock far too many times. Sorry if my logic is just completely off about the way this works, this is like my crash course in assembly language programming.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 05, 2010, 09:52:10 PM
I got it to work using the raw_inc method (your first suggestion). Tom pointed out that raw_inc was 128 times faster than it should be so I bit shifted raw inc 7 times and it works!

I knew the phases wouldn't be in sync which is definitely a deal breaker for this method. Also the frequencies are just slightly off and over time will shift phases another big problem. I think the best method is to reference the wave directly, that way error wont accumulate in the phases.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: jakefuzz on December 07, 2010, 10:27:21 PM
got it to finally work correctly using the following code! after a week of testing everything  :D

IncrementPhaseClock:


   btfsc   PHASE_HI, 7         ;Checking to see if the wave is onto the second half
   goto   skipper            ;if it is not then skip the increment section
   btfsc   OLD_COUNT, 0      ;if it is then check to see if there was a change from first to second half
   incf   PHASE3_COUNT, f      ;if there is a change increment the counter
   
   skipper:

   btfsc   PHASE_HI, 7         ;check the wave if it is the second half
   bsf      OLD_COUNT, 0      ;if it is set OLD_COUNT bit zero high
   btfss   PHASE_HI, 7         ;check the wave if it is the first half
   bcf      OLD_COUNT, 0      ;if it is set OLD_COUNT   bit zero low
   
   movfw   PHASE3_COUNT      
   subwf   MULTIPLIER, w      ;check if the cycle counter has reached the multiplier value
   btfsc   ZEROBIT            ;it has
   bsf      CLOCK_OUT         ;so turn on the clock
   btfsc   ZEROBIT            
   clrf   PHASE3_COUNT      ;also clear the counter to start over at this point
   
   btfss   PHASE_HI, 7         ;the wave is back to the first half so clear the clock
   bcf      CLOCK_OUT         ;this will make less than 50% duty cycle clock pulses, but it is the leading edge that counts (literally!)
   
   movfw   PHASE3_COUNT      
   addlw   D'127'            ;this section checks to see if the cycle counter has become larger than the multiplier
   movwf   BRAIN            ;this case will happen if the multiplier cv is rapidly changed
   movfw   MULTIPLIER         ;if it is larger then the counter needs to be reset
   subwf   BRAIN, f         ;if the counter isnt reset the counter will count to 255 until it resets itself
   btfsc   BRAIN, 7         ;which for out purposes (instant multiplier response) is not good
   clrf   PHASE3_COUNT


I think the multiplier change, reset section can be made better, but it all works! yay. now to make the triangle and sine waves start low b/c my clock invert function isn't going to work with a non 50% duty cycle clock. Thanks for all the help guys!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: orangeshasta on May 04, 2011, 09:36:58 PM
Hi all,

Sorry for reviving an old thread, but I've got a question.  I've ported a basic version of this assembly code over to C (using the CCS compiler, it's what I know) for the purposes of making a tremolo pedal.  I'm still using the 16F684; and the only potentiometers that I have implemented are frequency and duty cycle (although I do have different waveforms hardcoded for now).  My pins are different, but that shouldn't be an issue.

Anyway, things are working pretty well all-in-all, with one exception: the duty cycle control has an effect on the frequency of the LFO.  I've tried all sorts of things to figure out how to fix this, but haven't come up with anything.  Anyone have any ideas?  I'll put a copy of my code below:


#include <16f684.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOPROTECT                //Code not protected from reading

#use delay(clock=20M,xtal=20M)

/*********************************************
/  Declare pin defines
/*********************************************/
#define PIN_SPEED_CTRL PIN_C0
#define PIN_DUTY_CTRL PIN_C1
#define PIN_MULT_CTRL PIN_C2
#define PIN_DEPTH_CTRL PIN_C3
#define PIN_SHAPE_CTRL PIN_C4 //Damn, need to change to an analog pin
#define PIN_TEMPO PIN_A2

/*********************************************
/  Declare global variables
/*********************************************/

int1 calc_next_pwm=0, time_to_read_adcs=0;

//Half sine wave lookup table
//Actually a cosine table because it starts
//with max value.
static const unsigned int8 halfsine_table[256] = {
255, 255, 255, 255, 255, 255, 255, 255,
254, 254, 254, 254, 254, 253, 253, 253,
253, 252, 252, 252, 251, 251, 250, 250,
249, 249, 249, 248, 248, 247, 246, 246,
245, 245, 244, 243, 243, 242, 241, 241,
240, 239, 238, 238, 237, 236, 235, 234,
233, 233, 232, 231, 230, 229, 228, 227,
226, 225, 224, 223, 222, 221, 220, 219,
218, 216, 215, 214, 213, 212, 211, 209,
208, 207, 206, 205, 203, 202, 201, 199,
198, 197, 195, 194, 193, 191, 190, 189,
187, 186, 185, 183, 182, 180, 179, 177,
176, 175, 173, 172, 170, 169, 167, 166,
164, 163, 161, 160, 158, 157, 155, 154,
152, 150, 149, 147, 146, 144, 143, 141,
140, 138, 137, 135, 133, 132, 130, 129,
127, 126, 124, 122, 121, 119, 118, 116,
115, 113, 111, 110, 108, 107, 105, 104,
102, 101, 99, 98, 96, 95, 93, 92,
90, 89, 87, 86, 84, 83, 81, 80,
78, 77, 75, 74, 73, 71, 70, 68,
67, 66, 64, 63, 62, 60, 59, 58,
56, 55, 54, 52, 51, 50, 49, 47,
46, 45, 44, 43, 41, 40, 39, 38,
37, 36, 35, 34, 33, 32, 31, 30,
29, 28, 27, 26, 25, 24, 23, 22,
21, 20, 19, 19, 18, 17, 16, 15,
15, 14, 13, 13, 12, 11, 11, 10,
9, 9, 8, 8, 7, 7, 6, 6,
5, 5, 4, 4, 4, 3, 3, 3,
2, 2, 2, 2, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0
};

//This is to convert from an 8-bit A/D value into a 16-bit freq_inc value
//Provides a logarithmic response to the FREQ control using a linear pot
static const unsigned int16 freq_table[256] = {
0x0016, 0x0016, 0x0016, 0x0017, 0x0017, 0x0018, 0x0018, 0x0019,
0x001A, 0x001A, 0x001B, 0x001B, 0x001C, 0x001D, 0x001D, 0x001E,
0x001E, 0x001F, 0x0020, 0x0020, 0x0021, 0x0022, 0x0023, 0x0023,
0x0024, 0x0025, 0x0026, 0x0027, 0x0027, 0x0028, 0x0029, 0x002A,
0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032,
0x0033, 0x0034, 0x0035, 0x0037, 0x0038, 0x0039, 0x003A, 0x003C,
0x003D, 0x003E, 0x0040, 0x0041, 0x0042, 0x0044, 0x0045, 0x0047,
0x0048, 0x004A, 0x004C, 0x004D, 0x004F, 0x0051, 0x0052, 0x0054,
0x0056, 0x0058, 0x005A, 0x005C, 0x005E, 0x0060, 0x0062, 0x0064,
0x0066, 0x0069, 0x006B, 0x006D, 0x0070, 0x0072, 0x0075, 0x0077,
0x007A, 0x007C, 0x007F, 0x0082, 0x0085, 0x0088, 0x008B, 0x008E,
0x0091, 0x0094, 0x0097, 0x009A, 0x009E, 0x00A1, 0x00A5, 0x00A8,
0x00AC, 0x00B0, 0x00B4, 0x00B8, 0x00BC, 0x00C0, 0x00C4, 0x00C8,
0x00CD, 0x00D1, 0x00D6, 0x00DA, 0x00DF, 0x00E4, 0x00E9, 0x00EE,
0x00F3, 0x00F9, 0x00FE, 0x0104, 0x0109, 0x010F, 0x0115, 0x011B,
0x0121, 0x0128, 0x012E, 0x0135, 0x013C, 0x0142, 0x014A, 0x0151,
0x0158, 0x0160, 0x0167, 0x016F, 0x0177, 0x0180, 0x0188, 0x0190,
0x0199, 0x01A2, 0x01AB, 0x01B5, 0x01BE, 0x01C8, 0x01D2, 0x01DC,
0x01E7, 0x01F1, 0x01FC, 0x0207, 0x0213, 0x021E, 0x022A, 0x0236,
0x0243, 0x024F, 0x025C, 0x026A, 0x0277, 0x0285, 0x0293, 0x02A2,
0x02B0, 0x02BF, 0x02CF, 0x02DF, 0x02EF, 0x02FF, 0x0310, 0x0321,
0x0333, 0x0344, 0x0357, 0x0369, 0x037D, 0x0390, 0x03A4, 0x03B9,
0x03CD, 0x03E3, 0x03F8, 0x040F, 0x0425, 0x043D, 0x0454, 0x046D,
0x0486, 0x049F, 0x04B9, 0x04D3, 0x04EE, 0x050A, 0x0526, 0x0543,
0x0561, 0x057F, 0x059E, 0x05BD, 0x05DD, 0x05FE, 0x0620, 0x0642,
0x0665, 0x0689, 0x06AE, 0x06D3, 0x06F9, 0x0720, 0x0748, 0x0771,
0x079B, 0x07C5, 0x07F1, 0x081E, 0x084B, 0x0879, 0x08A9, 0x08DA,
0x090B, 0x093E, 0x0972, 0x09A7, 0x09DD, 0x0A14, 0x0A4C, 0x0A86,
0x0AC0, 0x0AFD, 0x0B3B, 0x0B7A, 0x0BBA, 0x0BFC, 0x0C3F, 0x0C84,
0x0CCA, 0x0D12, 0x0D5B, 0x0DA6, 0x0DF2, 0x0E41, 0x0E91, 0x0EE2,
0x0F36, 0x0F8B, 0x0FE2, 0x103B, 0x1096, 0x10F3, 0x1152, 0x11B3,
0x1216, 0x127C, 0x12E3, 0x134D, 0x13B9, 0x1428, 0x1499, 0x150C
};

#int_TIMER1
void  TIMER1_ISR(void)
{
clear_interrupt(INT_TIMER1);
time_to_read_adcs = 1;
}

// PWM timer interrupt
// Do calculations in the main loop to keep interrupt short
#int_TIMER2
void  TIMER2_isr(void)
{
clear_interrupt(INT_TIMER2);
calc_next_pwm = 1;
}

#int_EXT
void  EXT_isr(void)
{

}

void main()
{
int8 eightbit, lookup;
int8 wavetype=4;
int32 phase=0;
int32 freq_32,phase_inc_a,phase_inc_b;
int16 pwm_duty=0;

int8 freq_cv=1, dist_cv=128; // Placeholder for frequency and distortion potentiometers
// Keep dist between 4 and 252 for best results.  128 is zero dist.
int8 freq_mul=8;
int16 freq_16;

int32 num_samples, num_a, num_b;

setup_adc_ports(sAN4|sAN5|sAN6|sAN7|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_wdt(WDT_OFF);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
//setup_timer_2(T2_DIV_BY_4,127,1); // PWM Freq. of 19.5 kHz //Prescaler of 127 limits pwm output to 8 bit
setup_timer_2(T2_DIV_BY_1,255,1); // PWM Freq. of 19.5 kHz
setup_ccp1(CCP_PWM);
set_pwm1_duty(0);

enable_interrupts(INT_TIMER1);
enable_interrupts(INT_TIMER2);
//enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
//set_pwm1_duty(duty);
   while(TRUE)
   {
if(calc_next_pwm)
{
if(bit_test(phase,23)) // 24-bit phase accumulator - check to see which half of waveform we're on
phase = (phase + phase_inc_b) % 16777216; // Limit phase to 24-bit
else
phase = (phase + phase_inc_a) % 16777216; // Limit phase to 24-bit

switch(wavetype)
{
case 0: // Sine
eightbit = make8((phase >> 15),0); // MSB indicates which half of the wave, only take bits 16-23
// Eightbit is used to index into LUT
lookup = halfsine_table[eightbit];
if(bit_test(phase,23)) // If we're on second half of wave
lookup ^= 255; // Invert the lookup value using XOR
pwm_duty = (int16) lookup * 4; // Level control, set at max for now
break;
case 1: // Ramp up
eightbit = make8((phase >> 16),0);
pwm_duty = (int16) eightbit * 4; // Level control, set at max for now
break;
case 2: // Ramp down
eightbit = make8((phase >> 16),0);
pwm_duty = (int16) (255 - eightbit) * 4; // Level control, set at max for now
break;
case 3: // Square
if(bit_test(phase,23)) // If we're on second half of wave
pwm_duty = 0;
else
pwm_duty = (int16) 255 * 4; // Level control, set at max for now
break;
case 4: // Triangle
eightbit = make8((phase >> 15),0); // MSB indicates which half of the wave, only take bits 16-23
if(!bit_test(phase,23)) // If we're on second half of wave
pwm_duty = (int16) eightbit * 4; // Level control, set at max for now
else
pwm_duty = (int16) (255 - eightbit) * 4; // Level control, set at max for now
break;
}

set_pwm1_duty(pwm_duty); // This doesn't take effect until PWM timer overflow
calc_next_pwm = 0;
}
else if(time_to_read_adcs)
{
set_adc_channel(4);
freq_cv = read_adc();
set_adc_channel(5);
dist_cv = read_adc(); // Duty
freq_16 = freq_table[freq_cv] * 2; // Gets screwy at high values of freq_cv (>~210)
//freq_16 *= freq_mul; // Fixed by converting to int32 at mul. step
//freq_32 = (int32) freq_16 << 7;
freq_32 = (int32) freq_16 * freq_mul;
num_samples = 16777216 / freq_32;
freq_32 = freq_32 << 7; // Multiply by 128

if(dist_cv == 0)
phase_inc_a = freq_32; // Prevent divide-by-zero
else
phase_inc_a = freq_32 / dist_cv; // First half of wave, divide by dist value

if(dist_cv == 255)
phase_inc_b = freq_32; // Prevent divide-by-zero
else
phase_inc_b = freq_32 / (255 - dist_cv); // Second half of wave, divide by inverse

time_to_read_adcs = 0;
}
   }
}


Thanks in advance!

-Bob
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on May 05, 2011, 04:01:42 AM
I guess that when you talk about duty cycle you refer to the phase distortion, right?  If done correctly, the phase distortion should not affect your overall frequency.
I've quickly reviewed your code and I can't find anything obviously wrong. The only thing I would maybe do differently is  instead of:

phase_inc_b = freq_32 / (255 - dist_cv);   // Second half of wave, divide by inverse

I would:

phase_inc_b = freq_32 / (256 - dist_cv);   // Second half of wave, divide by inverse

To ensure that with dist_cv=128 you get an undistorted wave.

(I think this can have as well some impact to the total freq)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: orangeshasta on May 05, 2011, 09:19:32 AM
Hi, thanks for the response!

Yes, when I say "duty cycle" it's the phase distortion I'm referring to.

As for this:
phase_inc_b = freq_32 / (255 - dist_cv);   // Second half of wave, divide by inverse

My reasoning for doing it like that was to make sure that it compiled to an 8-bit subtraction rather than a 16-bit.  Just trying to save a couple cycles where I can; although to be honest, I've never checked the assembler output to see if it makes much difference.

Anyway I just tried using 256 there instead of 255, and there's no appreciable change to the fact that adjusting the phase distortion/duty cycle changes my frequency.  Any other ideas, anyone?

Thanks again!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on May 05, 2011, 12:49:31 PM
I don't see anything else that could be wrong.... Does it happen with all wave shapes?

I would try to debug in mplab sim and verify why the frequency changes.... A change in frequency when applying phase distortion seems to indicate there is an issue with the calculation of phase_inc_a and phase_inc_b. If they are correctly calculated, the total cycle should not change.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: swinginguitar on May 05, 2011, 04:59:13 PM
I posted some questions like this over in the stompbox forum concerning the PIC tap LFO, but thought i'd move it over here to get a better shot at some feedback.

1) when using this code/PIC for tap tremolo, how do I select an LED and LDR for the output? Does the color/value matter?

2) what board should i get for flashing the PIC? Is there just a simple (read: cheap) USB interface out there that is recommended?

3) In general terms,  how are the various waveforms generated by the PIC? How does the waveform selector vary the waveform?

4) would it be more/less advantageous to hook this up to a digital pot rather than the LDR for modulating volume?

5) slightly off topic, but could a microcontroller be employed for channel switching (either in an amp/preamp or "multichannel pedal")? What other components would be needed?

Title: Re: Tap Tempo LFO with PIC 16F684
Post by: orangeshasta on May 06, 2011, 11:07:01 AM
Hi Potul,

Yes, it happens with all wave shapes, so at least it's consistent.  That's a good idea using MPLAB sim; I'm used to using a debugger, but the 16F684 doesn't support one.  That sounds like a good alternative.  I'll play around with that this weekend.


Hi Swinginguitar,

1) I'm using a Silonex NSL-32 (http://www.silonex.com/audiohm/index.html), available from either Allied or Newark.  It's nice because the LED and LDR are packaged into one sealed package.

2) At home, I use a PicKit 2 for programming.  It's made by Microchip, is relatively inexpensive, and supports most of the PIC line.

3) In general terms, the PIC varies the duty cycle of its PWM output proportionally with the shape of the desired waveform.  To get the waveform from that signal, all you have to do is feed the PWM through a low-pass filter.  This is basically the same way that class-D amplifiers work.  Wikipedia has a great article on pulse-width modulation that explains the principle pretty well; also check out their article on Direct Digital Synthesis.

4) Personal preference, I guess - though I think you'd get a smoother output from the LDR.

5) Not sure exactly what you mean, but you could either use a microcontroller with some relays (higher fidelity, lower durability), or use an analog multiplexer IC like the 4051: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-2057-5-ND
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Hides-His-Eyes on May 06, 2011, 03:21:39 PM
The filter required to get a 'smooth' output using PWM without an opto is large. Could it be simplified with an inductor?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on May 07, 2011, 02:50:54 AM
Quote from: orangeshasta on May 06, 2011, 11:07:01 AM

3) In general terms, the PIC varies the duty cycle of its PWM output proportionally with the shape of the desired waveform.  To get the waveform from that signal, all you have to do is feed the PWM through a low-pass filter.  This is basically the same way that class-D amplifiers work.  Wikipedia has a great article on pulse-width modulation that explains the principle pretty well; also check out their article on Direct Digital Synthesis.


The DDS article in Electricdruid's web site is a great article to understand how to generate different waveforms using lookup tables. Algo the phase distortion explantion is a good read.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: JKowalski on May 07, 2011, 03:26:09 AM
Quote from: Hides-His-Eyes on May 06, 2011, 03:21:39 PM
The filter required to get a 'smooth' output using PWM without an opto is large. Could it be simplified with an inductor?

You can simplify it, but inductors are not needed.

Someone earlier PM'd me about doing some things with a TAPLFO chip, so I drew this up (i mentioned the inverter trick earlier in the topic)

This method gets around the difficulty in using non-rail-to-rail op amps to play with 0-5 volt signals... The circuit in ED's datasheet is made for synth things where bipolar supplies are common and the output signal whould be +/- 5v. The one below is made for single supply power and to give you a LFO around 4.5V.

(http://img545.imageshack.us/img545/6189/pwmforguy.png)

Basically, the 0-5 volt input to the inverters will trigger a 0-9V output. If you divide this output down to the 4.5V Vref, you can get any amplitude PWM signal based around 4.5V. Sticking a filter onto this is easy.This will give you a 2-7V LFO waveform (2.5V peak centered around 4.5V) which was application specific for him. To change the max P-P voltage simply adjust the voltage divider (27k/30k) ratio.

If you have a spare op-amp in the circuit this is very easy to implement. And inverters are always useful!

The roll-off is pretty sharp. He tried it and said it works well. The only problem he had with it was ticking on sharp transistion waveforms (square, sawtooth). This is typical for those waveforms in any scenario and to fix that you could bypass the power rails better, lower the frequency cutoff a bit to smooth the sharp transistions (which also improves HF attenuation), etc.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Hides-His-Eyes on May 07, 2011, 03:32:51 AM
Oh wow, thank you. :)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: orangeshasta on May 11, 2011, 09:19:07 PM
Hi all again,

I finally got a chance to figure out MPLAB sim, so that I could check that all my math was executing properly.  As far as I can tell, none of my math operations are doing anything unexpected.  Anyone have any other ideas?  To anyone who's used ElectricDruid or JKowalski's code, is the frequency even supposed to stay constant when changing phase distortion?

Any and all ideas would be appreciated, I'm starting to get frustrated!  ???
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on May 12, 2011, 04:54:33 AM
Have you checked the values of inc_a and inc_b in MPLAB? You should verify they stay correct when changing phase.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: orangeshasta on May 13, 2011, 11:39:11 AM
Yup, they stay correct...maybe there's something wrong with my overall method?  I thought I copied the method from ElectricDruid's assembly code (and excellent website) almost exactly, but maybe I'm wrong.  One difference I know of is that I don't increment the phase and set the PWM at the interrupt level, to keep my interrupts short.  I wouldn't think that would make much difference though...
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: orangeshasta on May 19, 2011, 08:27:39 PM
Hi all one more time,

Not sure if anyone is curious; but I figured out my problem.  Turns out all my calculations WERE correct - it was simply an ADC problem.  I neglected to add a delay after changing ADC channels, so the reading of the freq_cv value was actually being affected by the reading of the previous dist_cv value.  Once I added a delay of about 25uS (just like ElectricDruid does in his assembly code), it works like a charm.

Thanks to potul for the help - if you hadn't reminded me about the MPLAB SIM, I never would have figured that out!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: potul on May 20, 2011, 01:55:41 AM
I'm happy to see you solved the issue.... those ADC problems are usually hard to troubleshoot.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: swinginguitar on June 29, 2011, 02:50:42 PM
Reviving this thread to ask a question after looking at the code a little more:

what does 9177280/mSecs represent in this line?:

; Do a calculation of 9177280/mSecs to find required RAW_INC
call   TempoCalculation

Also, what is this?:

; Set up limits for the Tempo CV
   ; Set Upper limit
   ; hi = tempo cv + 4
   ; addlw 255-Hi
   movlw   D'4'
   addwf   TEMPO_CV, w
   movwf   TEMPO_UPPER
   comf   TEMPO_UPPER, f   ; Turn Hi into 255-Hi

   ; Set lower limit
   ; lo = tempo_cv -4
   ; addlw   (Hi-lo)+1
   ; Note that this always gives me 9, since hi-lo cancels
   ; the tempo cv.
   movlw   D'9'
   movwf   TEMPO_LOWER
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on October 19, 2011, 02:30:34 PM
Quote from: swinginguitar on June 29, 2011, 02:50:42 PM
Reviving this thread to ask a question after looking at the code a little more:

what does 9177280/mSecs represent in this line?:

; Do a calculation of 9177280/mSecs to find required RAW_INC
call   TempoCalculation

Aha! Now this I *do* know!

The tempo is calculated by using a timer to measure the time between two taps. This time (in milliseconds) is then used to calculate the increment that the LFO would have to use to generate the same frequency. Since the phase accumulator is 24-bit (e.g. 16777215 max value) and the output sample rate is 19.5KHz, and the RAW_INC base rate is actually 1/2 the real tempo (to avoid fractions in the multipliers), the magic number needed comes out at 9177280.


Quote from: swinginguitar on June 29, 2011, 02:50:42 PM
Also, what is this?:

; Set up limits for the Tempo CV
   ; Set Upper limit
   ; hi = tempo cv + 4
   ; addlw 255-Hi
   movlw   D'4'
   addwf   TEMPO_CV, w
   movwf   TEMPO_UPPER
   comf   TEMPO_UPPER, f   ; Turn Hi into 255-Hi

   ; Set lower limit
   ; lo = tempo_cv -4
   ; addlw   (Hi-lo)+1
   ; Note that this always gives me 9, since hi-lo cancels
   ; the tempo cv.
   movlw   D'9'
   movwf   TEMPO_LOWER

This is because the tempo can be set by either taps on the tap tempo button or by twisting the tempo knob. In the case that the tempo has just been set by the tap tempo button, we don't want the next reading from the ADC for the tempo knob to change the setting, *unless the knob has moved*. So we set up a couple of upper and lower limits, and if the ADC reading goes outside of those, then we reckon the knob has been moved, and the tempo knob position sets the tempo. If it wasn't done like this, a little tiny bit of noise in the ADC results (which there always is) would reset the tapped tempo to whatever the current knob position is.

Hope this helps - if you've got more questions about the magic number, PM me and I'll dig out the notes I made about it.
Tom
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: frequencycentral on January 19, 2012, 03:42:51 PM
Woot! Just got my first TAPLFO2 going. This will become part of my modular synth. Now I'm working  on a second version with CV inputs and attenuators for Tempo, Waveform, Multiplier and Wave Distortion.

Thanks Tom for a really great project!

(http://dl.dropbox.com/u/967492/ED%20VCLFO/Proto.jpg)

Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Bunyaman on February 07, 2012, 03:44:36 PM
Hey men! Does anyone have a PCB of this LFO without tremolo module (Sprint layout or other soft, or just a picture). I want to use it in other effects(delays, tromolos,phasers,  etc). I will be grateful!
Just a week ago, thought about TAP TEMPO, when suddenly I found this super project. Author, RESCECT!

p.s. Sorry for my english, if it not quite correct, I`m from Ukraine :)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: .Mike on February 07, 2012, 05:46:08 PM
I think my PIC Tremolo that uses Tom's VCLFO is the closest you are going to get. You can easily remove the tremolo components.

The VCLFO came before the TAPLFO. They are very similar.

You will only have to do minimal modifications to the schematic, since the datasheet TAPLFO tremolo circuit is based on my drawing.

http://www.diystompboxes.com/smfforum/index.php?topic=77471.0

Good luck! :)

Mike
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Bunyaman on February 08, 2012, 12:28:48 AM
Thanks Mike! This is what I need:)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Bunyaman on May 22, 2012, 06:33:52 PM
Men, does anyone tried to use this LFO with others effects(not tremolo)? I would like to use this in MXR phase 90. Is it possible? I don`t understand how to connect LFO to JFET pins(Gate, Source)
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on July 02, 2012, 05:13:08 AM
Quote from: Bunyaman on May 22, 2012, 06:33:52 PM
Men, does anyone tried to use this LFO with others effects(not tremolo)? I would like to use this in MXR phase 90. Is it possible? I don`t understand how to connect LFO to JFET pins(Gate, Source)

You need to use a PWM filter like in the datasheet to turn the LFO's output (a PWM pulse train) back into an analog LFO signal. At the bare minimum, this can be a passive RC filter. There's a design for this minimal filter in the LoopEnv datasheet on my website:

http://www.electricdruid.net/datasheets/LOOPENV1Datasheet.pdf

Once you've filtered the PWM signal, it's the same as any other LFO. From the minimal filter, you'll get a signal from 0V to 5V.

The nice thing about the Tap Tremolo circuit is that the vactrol's LDR response is so slow that no further filtering is required. This simplifies the circuit, which is part of what makes it appealing to do.

HTH,
Tom


Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Hoffmann on December 25, 2012, 11:22:38 AM
Hi!
I want to make a DIY pwm phaser (something similar to ASMOP phaser). Does someone have 39kHz (9-bit) asm (or hex) version of Electrodruids taplfo?
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Yonatan on February 24, 2013, 05:39:40 AM
This project looks way cool.  Can anyone tell me if buying a pre-programmed TAPLFO chip is equivalent to taking the HEX code from the Synth DIY site and flashing it to a bare PIC?  I'm NOT trying to save money, as I'm sure that buying a pre-programmed chip is cheaper than buying a PIC programmer :),  it just looks like a really interesting learning project.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: slacker on February 24, 2013, 10:49:30 AM
Yes, buying the TAPLFO chip gives you the same thing as downloading the code and flashing your own.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: midwayfair on March 12, 2013, 08:52:35 AM
Do the voltage dividers for the pin controls simply provide a ratio, or is their value important? For instance, could I use a 100K or the depth and have it function similarly?

I'm considering using dual concentric pots to simplify the control panel in something, but I have ONE control in the pedal I'm making that isn't 10K. Most inconvenient!
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: ElectricDruid on March 12, 2013, 03:10:35 PM
Quote from: midwayfair on March 12, 2013, 08:52:35 AM
Do the voltage dividers for the pin controls simply provide a ratio, or is their value important? For instance, could I use a 100K or the depth and have it function similarly?

I'm considering using dual concentric pots to simplify the control panel in something, but I have ONE control in the pedal I'm making that isn't 10K. Most inconvenient!

They simply provide a ratio. I've used 100K pots, 47K pots, and 10K pots without incident. Since the voltage is being fed to a ADC and charges a small cap in the ADC, you're not supposed to use high impedance outputs (the cap will take too long to charge, affecting the measured voltage) - so perhaps 1M pots wouldn't be a great idea.

T.
Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Mbas974 on December 26, 2013, 04:52:52 PM
ElectricDruid, this project is amazing !!

Is there a way to buy this chip in Europe (otherwise I'll go with smallbear) ?

Also, one thing I like to have implemented on a tremolo pedal, using this concept, is the make PWM duty cycle variable with a Pot
http://arduino.cc/en/Tutorial/PWM

Thanks for your replay.



Title: Re: Tap Tempo LFO with PIC 16F684
Post by: Brian_L on April 14, 2014, 04:50:13 PM
Quote from: jakefuzz on December 07, 2010, 10:27:21 PM
got it to finally work correctly using the following code! after a week of testing everything  :D

IncrementPhaseClock:


   btfsc   PHASE_HI, 7         ;Checking to see if the wave is onto the second half
   goto   skipper            ;if it is not then skip the increment section
   btfsc   OLD_COUNT, 0      ;if it is then check to see if there was a change from first to second half
   incf   PHASE3_COUNT, f      ;if there is a change increment the counter
   
   skipper:

   btfsc   PHASE_HI, 7         ;check the wave if it is the second half
   bsf      OLD_COUNT, 0      ;if it is set OLD_COUNT bit zero high
   btfss   PHASE_HI, 7         ;check the wave if it is the first half
   bcf      OLD_COUNT, 0      ;if it is set OLD_COUNT   bit zero low
   
   movfw   PHASE3_COUNT      
   subwf   MULTIPLIER, w      ;check if the cycle counter has reached the multiplier value
   btfsc   ZEROBIT            ;it has
   bsf      CLOCK_OUT         ;so turn on the clock
   btfsc   ZEROBIT            
   clrf   PHASE3_COUNT      ;also clear the counter to start over at this point
   
   btfss   PHASE_HI, 7         ;the wave is back to the first half so clear the clock
   bcf      CLOCK_OUT         ;this will make less than 50% duty cycle clock pulses, but it is the leading edge that counts (literally!)
   
   movfw   PHASE3_COUNT      
   addlw   D'127'            ;this section checks to see if the cycle counter has become larger than the multiplier
   movwf   BRAIN            ;this case will happen if the multiplier cv is rapidly changed
   movfw   MULTIPLIER         ;if it is larger then the counter needs to be reset
   subwf   BRAIN, f         ;if the counter isnt reset the counter will count to 255 until it resets itself
   btfsc   BRAIN, 7         ;which for out purposes (instant multiplier response) is not good
   clrf   PHASE3_COUNT


I think the multiplier change, reset section can be made better, but it all works! yay. now to make the triangle and sine waves start low b/c my clock invert function isn't going to work with a non 50% duty cycle clock. Thanks for all the help guys!

I hate to bump such an old thread, but this is exactly what I'm trying to do. I need the clock out to be pre multiplier, so I can sync 2 chips and set the multiplier independently. I tried using this code but I then don't get anything out of the clock pin at all. Any suggestions of what else I may need to change or add to get this code to work?
Thanks.