I'd be happy to look at it. It's not an error with the PSIM but
rather different scales for input and output.
For input, the range is 1024 steps over 10 volts, or 9.76 mV
increments.
For output, the range is 4096 steps over 10.666 volts, or 2.60 mV
increments.
Thus to pass an input to output, the scale factor is (10/1024)X
(4096/10.666) which is 3.75.
Thus to scale the input to output, it needs to be multiplied by
3.75, (not 4). I typically multiply by 15/4 to keep the math
integer based.
Note that 10.666 volts was chosen to calibrate to semitone voltages
which are increments of 83.33 mV, or 32 increments. Thus to
quantize to semitones, you simply zero the right 5 bits of the
output value.
I have a FAQ on my page which details a number of things I've
learned both with the PSIM and the AtomPro24 and 28. It's right
below the header for my DJB PSIM Programs on
http://www.modularsynthesis.com/modules/synthmodules/synthmodules.htm
In my quantizing (only) program, I did both the conversion and the
quantizing in the actual DAC output code. Zeroing the right 5 bits
is the same as dividing by 32 and then multiplying by 32.
Multiplying by 3.75 and dividing by 32 is the same as multiplying by
2 and dividing by 17 (ok, reasonably close). The code I used to
scale, quantize, and output J1 to the DAC is:
shiftout ser_data,clock,4,[((((in_j1*2)/17)*32)+49152)\16]
This keeps the code reasonably fast although I could have also
multiplied by 15/4 and zero'd the last 5 bits with code like:
shiftout ser_data,clock,4,[((((in_j1*15)/4)&$0FE0)+49152)\16]
I couldn't find the program you were referring to. Where is it?
Dave
--- In SynthModules@yahoogroups.com, "Gary Chang" <gchang@...> wrote:
>
> Dave,
>
> What seems like an eternity ago I mentioned that in a typical PSIM
> application such as gc-sah-sr-qua.bas, there was an discrepency
> between the input and the quantized voltage outputs when sending an
> already quantized voltage through the PSIM. You had commented on
the
> fact that there was an error on the perceived voltage range of the
> PSIM input, which is why the quantization error occurs.
>
> Does this conversation sound memerable to you, Dave? With Woody's
> permission, I would love to have you look at this program to see if
> you can correct this issue - otherwise, gc-sah-sr-qua.bas (stands
for
Show quoted textHide quoted text
> sample and hold - shift register - quantizer) is a really rockin
> version of a Serge Sual Analog Shift Register...!
>
> Gary
>