Author Topic: PreenFM2 SMD version  (Read 456 times)

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 1228
    • View Profile
Re: PreenFM2 SMD version
« Reply #30 on: November 20, 2017, 09:07:35 PM »
I have a few issues to clarify:
- what is the crystal you are using for the F4? I've put a 12MHz one, it needs to be a divisor of 48MHz because of the USB

I also use a 12Mhz on the preenF405.

- right now I've connected Channel1 Left/Right to one stereo jack AF1 and Channel2 Left/Right to AF2
  would it be better to have Channel1 connected to both AF1/AF2 tips and Channel2 connected to both AF1/AF2 rings? This second configuration will allow the use of only one PCM5102 and allow the use on mono cables as before.

With solution1 mono cable will be possible but we'll need 2 PCM5102 even for 2 mono channels, right ?
So the difference is small, i don't have a strong opinion.

- because I'm mixing the 2 lefts and the 2 rights for the headphones amp there is a small (-43dB) signal crosstalk between the before mentioned channels. If one doesn't want this if should replace R30/R38 with 0 ohm resistors and not solder the TDA2822M and its capacitors.

- a very important issue is the output sample frequency. The PCM5102 has its own PLL which locks to the WS signal. If the F4 isn't able to provide a constant stream of data this might be a problem. The F4 can also generate instead the system clock and send it to PCM5102 (just 2 extra pins of F4).
- there is an error between the desired sample rate and what the F4 can provide with the current crystal - for example instead of 44KHz the real audio frequency is 43.4KHz (an error of 1.35%). A 6% error is already a semitone. I haven't studied yet the current firmware - is the software able to compensate for this? what is the sampling rate you are using now?

I don't know the PCM5102 so i don't know what is best for it.

Sample rates are here :
https://github.com/Ixox/preenfm2/blob/master/src/synth/Common.h#L43
I have a firmware (with o suffix) which overclock the F4 to 192Mhz which allows a higher sample rate.

With the current firmware the F4 has to feed 4 DACs so there is an interuption 4 times per sample to deal with DACs :
https://github.com/Ixox/preenfm2/blob/master/src/PreenFM_init.c#L182
https://github.com/Ixox/preenfm2/blob/master/src/PreenFM_irq.c#L164

This interuption takes the sample data from a 192 samples buffer that is constantly fill  by  synth.buildNewSampleBlock() :
https://github.com/Ixox/preenfm2/blob/master/src/PreenFM.cpp#L52



- 24 and 32 bit samples need to be loaded in the SPI data register twice because that's only 16bit wide in I2S mode so the best way would be to DMA the data from the memory and let the MCU do something else in this time

Yes, would be nice.

zelea2

  • Team member
  • *
  • Posts: 19
    • View Profile
Re: PreenFM2 SMD version
« Reply #31 on: November 21, 2017, 01:45:25 AM »
With solution1 mono cable will be possible but we'll need 2 PCM5102 even for 2 mono channels, right ?
So the difference is small, i don't have a strong opinion.

True, but I'm leaning more to second case because then you can stop one PCM5102, save some power and CPU cycles.
The PCM5102 shuts the audio channel down when it detects several consecutive samples of 0 on both channels.
I'll probably split the SoftMute signal to each PCM5102 to have extra control. The XSMT input also monitors the 5V supply
through the R35/R37 divider and shuts the audio down when the 5V supply drops. This will prevent pop noises at power-down or power loss.

I don't know the PCM5102 so i don't know what is best for it.

Sample rates are here :
https://github.com/Ixox/preenfm2/blob/master/src/synth/Common.h#L43
I have a firmware (with o suffix) which overclock the F4 to 192Mhz which allows a higher sample rate.

Thanks for all the clarifications.

The reason I'd rather not send I2S MCK clocks to PCM5102 is to reduce EMI (those clocks are 256*fs so 11MHz traces on the board).
If the PCM5102 doesn't detect a system clock then it switches to its internal PLL which samples the BCK frequency and generates internal clocks for its miniDSP.
It is not clear from the documentation how wide is the capture range of this PLL but it will definitely work for standard sampling frequencies like 32, 44.1, 48KHz etc.

The F4 has its own PLL for the I2S interfaces and those can be configured with very fine grain to almost any sample rate with less than 1% error.

With the PCM5102 we don't need interrupts to send the samples; each time a couple of new samples become available we test the DMA in progress bit and if it's not set we just configure a new DMA transfer over all available samples. Another way of doing this is to get a interrupt at the end of a DMA transfer and set a new one with the available samples.

Is there any reason you've chosen a non standard sampling rate? Instead of 42031.52 (1142 ticks) you could have gone for 44117.65 with 1088 systicks.
In any case 42KHz is just 5% away from 44.1KHz so I expect the internal PCM5102 PLL to lock.

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 1228
    • View Profile
Re: PreenFM2 SMD version
« Reply #32 on: November 22, 2017, 09:00:02 PM »
Is there any reason you've chosen a non standard sampling rate? Instead of 42031.52 (1142 ticks) you could have gone for 44117.65 with 1088 systicks.
In any case 42KHz is just 5% away from 44.1KHz so I expect the internal PCM5102 PLL to lock.

It's only a performance reason.
With those sample rates, the CPU is close to 100% in worse case scenario (full polyphony with the most demanding FM algo, FX, arpeggiator..).

lokki

  • Team Member
  • ***
  • Posts: 161
    • View Profile
Re: PreenFM2 SMD version
« Reply #33 on: November 23, 2017, 09:00:18 AM »
since a lot of cpu will be saved by the extra controller that handles encoder etc. 44.1khz seems doable...

norbim1

  • Team member
  • *
  • Posts: 27
    • View Profile
Re: PreenFM2 SMD version
« Reply #34 on: November 23, 2017, 03:09:57 PM »
Hi,
My fork on STM32F4Discovery uses 48k sampling rate with overclocked firmware. It runs without problem, since the I2S DMA also spares some CPU load. See my fork on Github. Actually the F4Discovery uses CS43L22 dac chip, but the I2S code part could be reused for PCM5102 too.

http://ixox.fr/forum/index.php?topic=63425.msg64969#msg64969

zelea2

  • Team member
  • *
  • Posts: 19
    • View Profile
PCB ready
« Reply #35 on: November 23, 2017, 11:44:02 PM »
I've added capacitors to all encoders and switches to eliminate contact debouncing in hardware rather than software. Also one pull-down resistor on pin D2 which is not currently used will be able to distinguish this board from stock (enable port D clock, input with pull-up D2, after 1ms read pin2: 1-stock 0-mine, disable port D clock).

The board is now finished and I've published the Gerbers and all the design files. I'll send it tomorrow to be manufactured and maybe I'll even get a black Friday deal.

I can now turn my attention to firmware until the boards arrive in 3 weeks time.

lokki

  • Team Member
  • ***
  • Posts: 161
    • View Profile
Re: PreenFM2 SMD version
« Reply #36 on: Today at 10:51:01 AM »
great! please post all updates...
one question, when one would want to build this, without smd soldering experience, would you sell preassembled boards with the stm32's on and burned firmware for the stm32f1? or what is the plan?

cheers

zelea2

  • Team member
  • *
  • Posts: 19
    • View Profile
Re: PreenFM2 SMD version
« Reply #37 on: Today at 05:44:27 PM »
one question, when one would want to build this, without smd soldering experience, would you sell preassembled boards with the stm32's on and burned firmware for the stm32f1? or what is the plan?

I might sell 1-3 of the 5 units I'll build presuming everything works fine and I haven't made any mistakes but don't count on me for getting into manufacturing these units.

People are soldering SMD parts all the time, it's not an impossible task. These are actually easy to solder SMD packages.
My only goal is to make this SMD version work and then publish all the files and firmware modifications so anyone can build them (or even start selling pre-soldered kits if they want to) .

zelea2

  • Team member
  • *
  • Posts: 19
    • View Profile
Re: PCB ready
« Reply #38 on: Today at 08:36:12 PM »
I'll send it tomorrow to be manufactured and maybe I'll even get a black Friday deal.

I did get an great deal. 37$ delivered for 10 PCB (green mask only). I could have got a stainless steel stencil for just another 13$. Crazy prices from EasyEDA.