Chromatic A/D conversions for 16-bit systems

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Joe., lisa, luketeaford, Kent

Post Reply
johnstilton
Common Wiggler
Posts: 67
Joined: Tue Oct 09, 2018 10:31 am
Location: West Chicago

Chromatic A/D conversions for 16-bit systems

Post by johnstilton » Fri Mar 20, 2020 8:36 am

Hallo,

I'm just doing some simple maths about converting the 1V/octave standard to digital values and just want to shoot this past y'all just to make sure that I am not fundamentally off base.



a 16-bit diginal register would be the 0 to 10V equivalent of 0 to 32,767 bits

1V/octave would scale down to .083 volts per half step on a western chromatic scale. IS this correct?

So the maths would be that rounding to the nearest whole number (because it is digital) that every chromatic half step would be the digital equivalent of an integer 273 ?

Thanks all.

User avatar
guest
Super Deluxe Wiggler
Posts: 4010
Joined: Mon Aug 19, 2013 11:49 am

Re: Chromatic A/D conversions for 16-bit systems

Post by guest » Fri Mar 20, 2020 8:51 am

16b is either 32k or 64k, depending upon signed or unsigned integers. typically unsigned is used with DACs, so the 64k value is the better one here (the actual number of steps in the DAC). if you want 12 notes/octave times 10 octaves, thats 120 notes into your 64k, or 546bits/note. so the 273 is correct for 32k (which is fine to use if you dont have a 16b DAC).
openmusiclabs.com

johnstilton
Common Wiggler
Posts: 67
Joined: Tue Oct 09, 2018 10:31 am
Location: West Chicago

Re: Chromatic A/D conversions for 16-bit systems

Post by johnstilton » Fri Mar 20, 2020 9:00 am

yup, the DAC specs of the module i have is -10/10V = -32,768/32,768

thanks for the peer review!

User avatar
guest
Super Deluxe Wiggler
Posts: 4010
Joined: Mon Aug 19, 2013 11:49 am

Re: Chromatic A/D conversions for 16-bit systems

Post by guest » Fri Mar 20, 2020 9:08 am

ok, so you can use either value. i would reccomend using the 546 value, and then adding a DC offset to make up for the negative values on the DAC. or, what might give you a bit more accuracy, is to only use the middle 80%-90% of the range, and change your analog scaling factor. most DACs have a bit of error at the top and bottom, in particular audio DACs. this is why THD is often spec'd for a smaller portion of the range. if you used 512 it would make the math pretty easy!
openmusiclabs.com

User avatar
EATyourGUITAR
has no life
Posts: 4062
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Chromatic A/D conversions for 16-bit systems

Post by EATyourGUITAR » Fri Mar 20, 2020 1:20 pm

johnstilton wrote:
Fri Mar 20, 2020 8:36 am
a 16-bit diginal register would be the 0 to 10V equivalent of 0 to 32,767 bits
32,767 bits is 4KB, you can write a book with that. you can store any number between 0 and (2^32,767)-1. 16 bits is how many bits? 16 bits. if you want to know what 2^16 is in base 10 you can use a calculator for that. also, the voltage does not affect the number of bits you have in 16bit, only the size of the steps measured in volts. (2^n)/(v2-v1) = step size in volts. as v gets bigger, step size increases, therefor precision decreases.
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

johnstilton
Common Wiggler
Posts: 67
Joined: Tue Oct 09, 2018 10:31 am
Location: West Chicago

Re: Chromatic A/D conversions for 16-bit systems

Post by johnstilton » Tue Mar 31, 2020 11:50 am

So for the three people here who would be curious and know RSLogix I devised some code that quantizes an integer to the chronatic scale:

I'm Dividing an integer (N7:0) by 273 moving the quotient in S:14 into N7:3 and the remainderin S:13 into N7:2. The quotient in N7:3 I then multiply it by 273 again and put the result in N7:4. The remainder in N7:2 I compare against 137 uning the GRT and if true I ADD 273 to N7:7:4

BST DIV N7:0 273 N7:1 NXB MOV S:13 N7:2 NXB MOV S:14 N7:3 NXB MUL N7:3 273 N7:4 NXB GRT N7:2 137 ADD 273 N7:4 BND

And then I shared this in an Allen Bradley Forum and a much smarter user offered to use the compute command and use the truncate command as part of the expression:

CPT Output "TRN ((Input / 273.0) +0.5) * 273"

U nfortunately Truncate is not available in 500 , only in ControlLogix

They also pointed out that in Excel the equivalent expression would be ROUND(Input / 273, 0) * 273

I love forums.

tele_player
Common Wiggler
Posts: 60
Joined: Fri Feb 15, 2019 10:50 am
Location: Sacramento

Re: Chromatic A/D conversions for 16-bit systems

Post by tele_player » Tue Mar 31, 2020 11:59 am

EATyourGUITAR wrote:
Fri Mar 20, 2020 1:20 pm
32,767 bits is 4KB, you can write a book with that.
If you are suggesting that a book could be stored in 4KB, I would agree - but only if the book is very, very short.

nigel
Veteran Wiggler
Posts: 634
Joined: Wed Jan 16, 2013 6:49 am
Location: Melbourne, Australia

Re: Chromatic A/D conversions for 16-bit systems

Post by nigel » Tue Mar 31, 2020 5:27 pm

johnstilton wrote:
Fri Mar 20, 2020 8:36 am
a 16-bit diginal register would be the 0 to 10V equivalent of 0 to 32,767 bits

1V/octave would scale down to .083 volts per half step on a western chromatic scale. IS this correct?

So the maths would be that rounding to the nearest whole number (because it is digital) that every chromatic half step would be the digital equivalent of an integer 273 ?
Only if you use the output of the D/A directly. If you're going to add some analog adjustment (or maybe if you need to, depending on the specs of the device), then you can scale the voltage up a little and use a 256 count per semitone, for example.

Post Reply

Return to “Music Tech DIY”