Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - zelea2

Pages: [1] 2
PreenFM2 / Re: PreenFM2 SMD version
« on: Today at 07:56:38 AM »
After another 10 hours of coding I want to report some good progress:

I've got the inter processor communication working. This was tricky because the F4 is the SPI master and the F1 raises an interrupt wire when any of the switches or encoders change state. For the F4 this transfer is transparent, everything is done by the DMA at both ends and after the 32bit transfer it can process the new input whenever it likes. There are also some commands which change parameters like the max volume and interrogation commands like the firmware version. So the F1 must start a DMA receive but if a key/encoder is pressed it must abort the current DMA (because the first word is already loaded in the SPI register) and start a new one with the new info. This allows the information exchange in just one 32bit transfer.

My encoders can send +/- 7 steps but regardless of how fast I turn them the max was +/- 2 steps. Also the detection algorithm for the encoders should be improved (now I'm basing this on just one sample) because I get the occasional step in the opposite direction.

Also my note generation works. I get sine waves on all outputs but I have a horrible super-imposed noise in my headphone amplifier. I have to admit that I haven't put a scope yet on my boards and my only detection method was a pair of headphones. I can also hear the microcontroller running in my headphones so this is bad. I hope that the only culprit is the headphones amp which was a bit of an afterthought. This is powered by the general 5V line and connected to the digital ground (instead of the analog ground as the rest of the audio path) while it has a 39db gain! I might have to scrap this and use only the jack outputs.

The wave generation is using 48KHz sample rate on all 4 channels and all transfers are DMA. I get a half way transfer interrupt and I'm filling the other half of the buffer based on a precomputed sine wave table and the desired frequency.

What's not working is the digital volume (haven't investigated why), haven't checked the purity of the sine waves with a scope and I get a very rare hangup of the surface processor so there's still a bug in there. Another bug is also lurking in my F4 code which manifest itself only when I'm compiling as a release, the debug version works fine. So programming still required.

All in all I'm very pleased so far because all the audio chains are working at least up the output of the DACs and the processor spends most of the time sleeping in the main loop.

PreenFM2 / VolcaFM as development platform for PreenFM
« on: January 16, 2018, 08:48:33 AM »
I am in the process of adding note velocity on my VolcaFM and while I was reversing the schematics I couldn't stop noticing similarities with a PreenFM2.
MIDI Keys Velocity for Korg VolcaFM

Both devices use an ARM Cortex-M4 so the PreenFM2 firmware could be ported (in theory) to a VolcaFM. Of course the original code will be lost
forever. The Volca uses a companion processor to read the touch keys and the protocol could be quickly reversed by hooking a logic analyzer on the SPI connector. The Volca doesn't have a nice screen, only a 9x7-segment display and neither it has the USB connectivity or pen drive interface. Instead is has a stereo 24-bit DAC.

What do you think; is it worth the effort to port this firmware to a Volca?
The Volca's firmware can be updated via an audio file played from the computer. I'll have a look in the future to see if that can be reversed so we could save the original firmware. Or maybe they've forgotten to fuse protect their Spansion FM4 processor.

PreenFM2 / Re: PreenFM2 SMD version
« on: January 16, 2018, 08:31:59 AM »
I haven't done any more testing but I've taken some pictures of the soldered boards. A few things I've noticed: the buttons caps that I have are way too low (they dont reach the screen base). Only one DIN connector fits comfortably at the back; a second will have to have its pins trimmed to fit in the back. but I have 2 more so I think I'll put all the DIN5 connectors on the sides.
The boards are still covered in flux; I haven't cleaned them yet.

PreenFM2 / Re: PCB ready
« 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 ...

PreenFM2 / Re: PCB ready
« 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 . 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.

PreenFM2 / Re: PreenFM2 SMD version - F1 firmware
« 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.

PreenFM2 / Re: PreenFM2 SMD version - F1 firmware
« 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

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.

PreenFM2 / Re: PCB ready
« 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.

PreenFM2 / Re: PreenFM2 SMD version
« 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) .

PreenFM2 / PCB ready
« 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.

PreenFM2 / Re: PreenFM2 SMD version
« 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 :
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.

PreenFM2 / Re: PreenFM2 SMD version
« on: November 20, 2017, 08:11:05 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

- 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.

- 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?

- 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

PreenFM2 / Re: PreenFM2 SMD version
« on: November 20, 2017, 07:29:05 PM »
And you will solder all these SMD components by hand ?  :o

Well, yes, about an hour of work per board. The LQFP and TSSOP chips have .5 and .65mm pitches and those are the easiest to solder. The secret is the flux that I'm using which is almost liquid and I'm using lots of it. I usually solder a whole row of pins with one touch of the iron. The most annoying parts are the 0603 because I'll have to pick each with the tweezer, solder one end, then apply flux to all passives, solder the other end and then come back and touch the first end again.

It works but i read from several olde display manual that we should avoid sending 3.3v data to a 5v powered display.
Do you think it would be better to convert the LCD_* lines to 5v (with a 5v inverter or anything else)?

There's no need for level translating the display. The HD44780 equivalent chip is itself powered at a lower voltage and we are not reading from the display so all the F4 connections to the display are outputs. It will only stress the F4 clamp diodes if we would need to interface an output signal which is higher than 3.6V.

PreenFM2 / Re: PreenFM2 SMD version
« on: November 20, 2017, 08:41:00 AM »
I've placed all components manually and trial-routed the board with some huge vias. It has routed to 100% in less than a minute. For the final board I need to write all kind of rules, change widths, add planes etc.

If you spot any kind of error in the schematic or in the placement please let me know in the following days.

PreenFM2 / Re: PreenFM2 SMD version
« on: November 19, 2017, 07:27:13 PM »
Is there still the JMP3 to flash the STM32F4 through USB ?
Will the STM32F1 flashing require the ST-LINK programmer ?

Would be great to have also a led for the STM32F1, so that we can make it blink a little when the board is switched on to check it's correctly flashed and working.

The jumper is J2 in my design.
Yes, the F4 can be programmed via USB or via SWD and F1 only via SWD.
I'll add a SMD LED to F1.

Pages: [1] 2