FAQ & Terms of UseFAQ & Terms Of Use   Wiggler RadioMW Radio   Muff Wiggler TwitterTwitter   Support the site @ PatreonPatreon 
 SearchSearch   RegisterSign up   Log inLog in 

software-based fine tuning the CV DAC
MUFF WIGGLER Forum Index -> nw2s  
Author software-based fine tuning the CV DAC
This may be one of the more mundane updates that I'm working on for 1.1, but it's important nonetheless (for a few reasons).

With 16 channels of output, only a single offset pot, and sooo many gain adjustment pots, it's really impossible to get a 'b in perfect tune. And if you're a perfectionist like me, you'll spend way too much time tweaking those pots.

Now, once you get them close enough (within 50mV), there is a way to fine tune it in software! In my example, for a +/- 10V model (which are particularly hard to tune due to the gain staging) I can get each of the 16 channels to have a perfect zero point and to have an average 40mV improvement at the far end of the scale - down to within 0.1% !!

I haven't tested the +/- 5V version, but I expect it will be a even better since the tuning for that one is a bit easier and generally ends up closer to the mark to begin with.

When the software is done, I'll provide a spreadsheet like this that will let you run through the tuning sequence and provide some values that you can plug in.

Right now, the code looks like this, but I'll add it to the JSON config (Oh, i haven't mentioned that before have I?) that lives on the SD card.


bool b::softTune = true;
int16_t b::offset[16] = {-5, -2, -1, -3, -5, -6, -4, -6, -5, -5, -3, -4, -7, -5, -5, -8};
int32_t b::scale[16] = {1002, 1004, 1003, 1003, 1004, 998, 989, 998, 1000, 994, 991, 999, 1003, 1001, 1004, 1009};

This will do a few things...

1. It will allow you to adjust the tuning more regularly without having to remove the 'b from your rack. Once it's basically in tune, you can continue to adjust in a config file.

2. It will allow me to simplify future iterations of the 'b by using a fixed resistor bias and gain network... I'm trying to get the 'b to be a lot cheaper to make as I get more software for it, it will have applications for non-Arduino hackers more and more.

3. If I ever, say, wanted to build a successor to the 'b that, for instance, used an SMT, 16-channel, 16 bit, buffered output, bipolar +/- 10V DAC, then this would use the same code to tune since they don't have any external tuning circuitry at all.

I will do the same for the ADC input which already uses a fixed gain network, but with an adjustable bias.

It's funny, I was thinking of something like this.
A code for recording b's output on b's input and generate offset arrays to correct the ouput.

Yeah, I think we spoke about that possibility.

I think the biggest problem with that would be the noise on the input side. There's clearly a significant amount of noise - far more than the mV or so of non-linearities of the DAC.

This makes sense since the DACs are relatively high-quality dedicated ICs whereas the ADC (there's really only one) on the Due is a crude device embedded with a boatload of noisy digital components. The next iteration will certainly use a dedicated ADC to help reduce that noise.

Anyway, it's working and the code is in the 1.1 branch and you can get it really close if you first do the spreadsheet and the make any further enhancements by hand.

I've also added into this configuration file a way for you to define some other system configurations. You can specify if your device is a high-gain or low-gain model so that we can remove that information from the code and *.b files. You can also specify a brightness level of the CV LEDs.

Will get the spreadsheet and docs up soon.

Documentation created and the spreadsheet is downloadable here:

Note that at this point, you'll need to be running the 1.1 unstable branch code to get this feature, but it does work with either compiled or scripted programs.

Is there a simple way one might be able to have both branches installed in order to test out new features in the unstable one but revert to the stable one if there is a problem?
The arduino IDE doesn't make it easy, but it's possible.

You can use the git command line to do it, but once you start using git for more than cloning and an occasional check-in, I prefer to use a program called SmartGit ( It's java-based, multi-platform, and makes it easy to switch between remote branches.

Arduino will recompile everything from scratch every time you want to upload, so in theory it works great. In practice, sometimes it doesn't see that you've switched branches so the old stuff gets "stuck" - If that happens, I have a workaround for you, but it works for most folk.

That should get you a little further, let me know if it's not clear...

Thanks. I haven't been using version control software with Arduino at all. Just saving incremental versions, comparing files with DiffMerge. I downloaded Smartgit and I'm looking into hosting services. I'm not quite sure how to set it up yet but researching. For your tutorials it might be good to cover more of the supporting software like this, including recommendations like you mentioned.

Back on topic, I have been noticing non-linearity in the analog outs. On my current sketch I've got an array of 120 values to calibrate one particular out. There probably isn't anything wrong with it, I just need the accuracy. I'm hoping your tuning feature will get things close enough in most cases. It would be great to have more calibration points if needed though.
MUFF WIGGLER Forum Index -> nw2s  
Page 1 of 1
Powered by phpBB © phpBB Group