Author |
Message |
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Fri Oct 18, 2019 12:01 pm Post subject:
BPM CLK oscillator upgrade |
|
|
A while ago I build a master CLK oscillator that can be set to a certain tempo. It has 5 trigger outputs: /4, /2, x1, x2, x4
and a sync/reset button. The manual BPM control is actually it's secondary function but I ended up using that most of the time.
It's primary function is to convert a MIDI clock signal to the 5 trigger outputs. The reason behind building it is that I wanted
a CLK oscillator with a TAP function. I have a Pioneer EFX 500 which has an excellent TAP function (as well as a manual setting)
and it also happens to have a MIDI output. So I decided to make use of that instead of making something completely from scratch.
It uses a PIC and the MIDI conversion is mostly based on some code I found online. It sends out a much higher frequency,
probably using a hardware PWM output, which gets divided down by a binary counter. It has a 555 in monostable mode for
each output to create short trigger pulses and it also inverts the outputs from the divider (555 triggers on a high to low transition)
which makes it much more useful for music. (especially drums)
Since the timing is based on a crystal it is very stable and therefor I usually use it as my main CLK oscillator. However, it is
not very accurate. This isn't really a problem most of the time but if I record something and I want to add some things to it
later (using ACID) it can be quite tricky to find the correct BPM setting. So, time for an upgrade to see if I can fix that.
more info about that later but here are some photos and a schematic of the current divider/trigger section.
Description: |
|
Filesize: |
104.11 KB |
Viewed: |
387 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Filesize: |
157.67 KB |
Viewed: |
398 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Filesize: |
89.17 KB |
Viewed: |
441 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
_________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Fri Oct 25, 2019 11:40 am Post subject:
|
|
|
PHOBoS wrote: | I think I will write some very simple code that will give pulses at a fixed frequency and see how accurate that is. |
I did a test with this:
Code: | void loop() {
unsigned long start_micros = micros();
unsigned long next_micros = 250000;
while(1) {
if (micros() >= (start_micros + next_micros)) {
bitWrite(PORTB,2, !bitRead(PORTB,2));
start_micros += next_micros;
}
}
} |
Which is also running too fast. It's almost in sync with my previous test just a tiny bit faster.
Not sure if that has to do with my code or if it might be temperature related.
I think I might test what I get out of the Pioneer EFX500.
It can be adjusted to 1/10th of a BPM so I expect it is pretty accurate but I never really tested it. _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Fri Oct 25, 2019 1:02 pm Post subject:
|
|
|
Hmm .. judging the image two posts up the thing seems to have an xtal .. it should be pretty accurate with that with a pretty good temperature stability too .. how large is your deviation? and also .. how stable is it?
I would have expected it to be a silly tiny pico amount to be slow .. due to having to start the micro timer again .. would be better to have a free running timer generate interrupts and act on those ...
but ...
since it is too fast, either the main clock is off .. as said odd .. but are you sure the xtal is actually used? ... or the internal calculation for the micro seconds is off .. you have the code for the micro stuff I assume?
When it is stable .. but off only .. you could compensate in code ... and also that would suggest an xtal to be used.
Anyway .. you can easily test temperature stability with a hairdryer or a paint striper ... and cold spray for lower temps. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Fri Oct 25, 2019 1:49 pm Post subject:
|
|
|
The xtal is used for USB, the main microprocessor itself actually runs on a ceramic resonator which is a lot less stable.
Quote: | due to having to start the micro timer again .. would be better to have a free running timer generate interrupts and act on those ... |
If I understood correctly that is what the micro() timer does,. it runs nonstop in the background and you can get a value from it (which doesn't effect it).
Resolution is 4uS btw, so it increases every 4uS not every uS but in this case that shouldn't matter. there is some info about it here
https://www.arduino.cc/reference/en/language/functions/time/micros/ but that doesn't tell you much more.
Quote: | When it is stable .. but off only .. you could compensate in code ... |
yeah, that was what I was thinking although it would get quite tricky but I am not so sure now how stable it is.
I'll see if I can do some tests with temperature variations.
hmm can't seem to take screenshots but it is quite off, to the point that after a couple beats it is audible. _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube Last edited by PHOBoS on Fri Oct 25, 2019 3:45 pm; edited 1 time in total |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Fri Oct 25, 2019 3:18 pm Post subject:
|
|
|
From that manual I reach the same conclusion you did .. it being running all the time .. except for that overflow ... it's a bit of a toy thing eh ... anyway better check temperature stability first .. and then back to the PIC I guess ... _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
|