electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Stickney Synthyards
BPM CLK oscillator upgrade
Post new topic   Reply to topic Moderators: PHOBoS
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
PHOBoS



Joined: Jan 14, 2010
Posts: 5591
Location: Moon Base
Audio files: 705

PostPosted: Fri Oct 18, 2019 12:01 pm    Post subject: BPM CLK oscillator upgrade Reply with quote  Mark this post and the followings unread

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.


BPM CLK oscillator - 01.jpg
 Description:
 Filesize:  104.11 KB
 Viewed:  387 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

BPM CLK oscillator - 01.jpg



BPM CLK oscillator - 02.jpg
 Description:
 Filesize:  157.67 KB
 Viewed:  398 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

BPM CLK oscillator - 02.jpg



BPM Oscillator outputs.gif
 Description:
 Filesize:  89.17 KB
 Viewed:  441 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

BPM Oscillator outputs.gif



_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
PHOBoS



Joined: Jan 14, 2010
Posts: 5591
Location: Moon Base
Audio files: 705

PostPosted: Wed Oct 23, 2019 3:29 pm    Post subject: Reply with quote  Mark this post and the followings unread

Instead of reprogramming the PIC I opted for using an arduino instead. I don't really know what code is in the PIC at the moment
and it would take a while to wrap my mind around it. I also find an Arduino much easier to work with and since that's what I've been
using lately it would get a bit confusing to switch back to another programming language (I use PIC basic for PICs). I also wanted
to get rid of the divider and 555's and the method of using a high frequency.

Besides having some problems with accuracy I also want some other divisions. Over the years that I used it I've mostly made use
of the x4 and x2 outputs and pretty much never the /2, /4 which I can easily do externally anyway. So Instead I think it's much more
useful to have some triplets (BPM x3, x6). I've also been thinking of making it adjustable per output and one idea involved pots/CV
but I wouldn't be able to fit that in and maybe another module would actually be more useful for that anyway.

I wrote some code and tested things connected on a breadboard and that seemed to be working. However the midi input misbehaved
once I soldered it together and put it in its housing. When I tested it I used my MIDI test board which uses a 6N137 optocoupler and the
BPM CLK oscillator uses a CNY17. This was working with the PIC though but just in case I replaced it with a 6N137. But that didn't work
either. Turned out that I had actually changed a small thing in the code and after fixing that the MIDI input worked as it should. doh

I did manage to fry 1 LED segment which I guess must have gotten shorted somehow Crying or Very sad luckely it is segment 'e' of the left display so
it is only visible with a tempo of 200BPM and up. I might even have a replacement for it, at least I know I have 1 green display somewhere
which might be the exact same one. I haven't been able to find it though.

Sofar everything seemed to be working but I did want to do an accuracy test which I did today. I let it control some drums and recorded
an hour of it to see how much it would drift. Well, a couple minutes would have been enough as it is clearly running a bit fast. Mad
I'll have to go over the code again as it is very well possible that I have a counter somewhere that is reset too soon. But I've also been
trying to find some info on the accuracy of the arduino itself and that worries me a bit. I think I will write some very simple code that
will give pulses at a fixed frequency and see how accurate that is. If that shows there is a problem I might be able to add some offset
somewhere in the code. Otherwise I might have to look into using some kind of external precision oscillator.


BPM CLK oscillator - 03.jpg
 Description:
 Filesize:  126.58 KB
 Viewed:  393 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

BPM CLK oscillator - 03.jpg



_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
PHOBoS



Joined: Jan 14, 2010
Posts: 5591
Location: Moon Base
Audio files: 705

PostPosted: Fri Oct 25, 2019 11:40 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Fri Oct 25, 2019 1:02 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
PHOBoS



Joined: Jan 14, 2010
Posts: 5591
Location: Moon Base
Audio files: 705

PostPosted: Fri Oct 25, 2019 1:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Fri Oct 25, 2019 3:18 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: PHOBoS
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Stickney Synthyards
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use