Author Topic: PreenFM2 SMD version  (Read 31631 times)

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2256
    • 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: 38
    • 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: 2256
    • 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

  • Sr. Member
  • ****
  • Posts: 383
    • 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: 28
    • 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: 38
    • 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

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: PreenFM2 SMD version
« Reply #36 on: November 24, 2017, 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: 38
    • View Profile
Re: PreenFM2 SMD version
« Reply #37 on: November 24, 2017, 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: 38
    • View Profile
Re: PCB ready
« Reply #38 on: November 24, 2017, 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.

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: PreenFM2 SMD version
« Reply #39 on: November 24, 2017, 10:47:49 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) .

ok, well if this works out ok, count me in!

matrix12x

  • Team Member
  • ***
  • Posts: 188
    • View Profile
Re: PreenFM2 SMD version
« Reply #40 on: November 24, 2017, 11:13:27 PM »
Count me in as well.

zelea2

  • Team member
  • *
  • Posts: 38
    • View Profile
Re: PreenFM2 SMD version - F1 firmware
« Reply #41 on: November 25, 2017, 02:35:20 AM »
I have finished a rough version of the STM32F103 firmware
If anyone wants to have a look it's here http://uglyduck.ath.cx/PreenFM2_SMD/SurfaceControl_F103.tar.gz

The processor sleeps most of the time, it's only awaken by the systick interrupt every milisecond or by a surface event or a SPI command. I have 5 encoders + 5 encoder switches + 7 switches so that's 17 and the processor only has 16 EXTI lines. So switch 6 has to be separately scanned every milisecond.

At the start a LED is flashed 6 times so you can see the processor is alive. A second LED near encoder5 shows the function of this encoder - if it's lit then the encoder acts as a global volume knob and doesn't generate a surface event. The volume is adjusted by the F1 alone.

Every time a surface event occurs the F1 raises an interrupt line. The main processor can read the entire surface status with two 16bit SPI transfers whenever it has time. Each encoder can memorize up to 7 steps. A second SPI interface controls the digital potentiometers. Both SPIs are at 2Mbit/s which is maximum for its internal 8MHz clock. All SPI transfers are handled by the DMA.

One command also allows the F4 just to read the switches status in real time (maybe useful to detect long-presses). I have so far 7 commands from F4 that I handle. Is there anything missing?

The volume scale is logarithmic. The F1 initializes the number of volume steps with a default value. The F4 can also change the number of steps. Each of the 4 audio channels have a maximum volume fixed at 255 at the start. The F4 can also change the top value for each channel at any time.  The global volume acts as a fraction of this top volume value.

I've split the flash memory in half and I'm using the last part to store some non-volatile local variables. So far I only have the current volume position and the volume number of steps.

For now I'm relying on the external caps for the debouncing but what I plan to do is to use all the available 4 timers in a round robin scheme  to start a one-shot count when a switch/encoder is pressed and ignore any following presses until the timers elapse. With 4 timers I can keep track of 4 simultaneously pressed switches/encoders.

Any suggestions are welcomed.

zelea2

  • Team member
  • *
  • Posts: 38
    • View Profile
Re: PreenFM2 SMD version - F1 firmware
« Reply #42 on: November 29, 2017, 01:05:26 AM »
I plan to use all the available 4 timers in a round robin scheme  to start a one-shot count when a switch/encoder is pressed and ignore any following presses until the timers elapse. With 4 timers I can keep track of 4 simultaneously pressed switches/encoders.

I've added the timer filtering and 2 new commands to interrogate the F1 firmware date/version and to get a configuration word which says how many audio channels are soldered on the board. Presumably the F1 will be only programmed once when the board is soldered so it makes sense to hold this configuration word.

The code can be compiled now with both CrossStudio and a makefile. I've briefly tested the code on one of those chinese STM32F103 boards and the surface controller code seems to work fine.

zelea2

  • Team member
  • *
  • Posts: 38
    • View Profile
Re: PCB ready
« Reply #43 on: January 07, 2018, 08:59:08 AM »
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.

After a quiet period I'm back. My boards arrived in the post 42 days after I've ordered them. I was hoping to get them before XMAS so I can do some work over the break but no luck. It took EasyEDA 25 days to manufacture them and another 17 days to get them shipped. This was the first time I've used them and I am not very happy about this delay. In the past I've used "ITEAD Studio" "Seeed Studio" and "Dirty PCBs" which were also cheap and I've received boards in about 3 weeks time instead of 6. This time I've cheapened  and got EasyEDA  as the first entry from  http://pcbshopper.com . Lesson learned not to use them again unless I don't care about the delivery time.

Anyways I have 10pcs now and by the end of this week I plan to solder and run my test programs on one. To test the functionality I will just use 4 encoders to generate sine waves with all the piano notes on all 4 output channels.

zelea2

  • Team member
  • *
  • Posts: 38
    • View Profile
Re: PCB ready
« Reply #44 on: January 13, 2018, 06:57:35 AM »
[Anyways I have 10pcs now and by the end of this week I plan to solder and run my test programs on one.

I've managed to solder 2 boards. On my first try each processor was working on the other board. Quickly traced this to a short and some passives soldered to one end only. Now I have both uP blinking LEDs on both boards but I haven't done any more testing.

Unfortunately I've over-estimated my soldering. It took me a total 6 hours to solder these 2 board (so 3h/board).
All the ICs went very fast, probably an hour for both boards. The switches, encoders and electrolytic  caps another half an hour. What's killing the rest of the time are the passives. There are 144 passives per board with 2 ends each ;-)  and you have to pay attention to all the different values. That comes to about 1 minute per passive.

With this time consuming experience in mind I probably won't solder anymore boards any time soon. I'll have to forget about all those 0603's first. For my future testing I won't need any more anyways.

The good news is that I haven't found anything wrong (yet) with my design like unmatched footprints or schematic faults. The next few days I'll prove all the audio chain and then I'll be ready to install the real software.

This is how I've spent my Friday evening and night ...