Thunderborg high pitch noise

Hi, i'm using the thunderborg to power my LEGO power functions train. Its works perfectly however there is this high pitch noise coming from the motor. This occurs putting the motor in forward or reverse, when the motor is stationary there's no high pitch noise. I would presume this is due to PWM, is it possible to change the PWM frequency ?

piborg's picture

You are correct that the noise is probably caused by the PWM switching, which is at ~ 7.8 KHz.

Unfortunately the PWM frequency is programmed into the board and cannot be changed from the Raspberry Pi. This means that without the tools to re-program the ThunderBorg itself it is not really possible to change the output frequency.

Oh that's unfortunate, kinda hoped for an undocumented i2c command to change the frequency.

After some research it turns out that the LEGO's PWM controller functions at 1150Hz.

I would be presume the frequency is programmed in the PIC processor on the board, is it easy to hook up a PICkit on the Thunderborg ?

piborg's picture

Connecting a PICkit 2 or 3 to the ThunderBorg is fairly easy, in fact this is how we program the boards before testing :)

On the underside of the ThunderBorg near the middle there should be a row of five solder pads surrounded by a black rectangle. This is the programming connection.

In order to connect the PICkit you will need five pins inserted into the connector, starting with pin 1 (marked by a triangle). On the ThunderBorg you can insert these into those holes (pin 1 is square instead of round) and apply a slight pressure to hold the pins to the edge of each hole. Be careful to make sure the pins are pushed away from the DC/DC on the other side to avoid any accidental damage!

When programming the ThunderBorg we recommend it is entirely disconnected from both batteries / power and the Raspberry Pi to avoid any possible issues. The PICkit will need to supply 3.3V in order to program the board successfully.

Unfortunately changing the PWM frequency is a bit more tricky than simply setting a number. I have created a version with a small change which gets the frequency much closer to what the LEGO controller functions at, 1953 Hz. Hopefully this will be close enough to remove the unwanted noise for you.

I have attached the compiled .hex file, renamed as .txt. This should be the only file you need to reprogram the ThunderBorg for the lower PWM frequency. No code changes are needed on the Rapspberry Pi side :)

When using the PICkit programming software select Device Family > Midrange > 1.8V Min before trying to load the hex file. The checksum for the hex file should be 6A9D.

Thanks for the effort of building a version 1953Hz version of Thunderborg. I've flashed the 1953Hz version today, unfortunately it seems the LEGO power functions train motor makes a lot of PWM noise nevetheless. Because with a PWM frequency of 1953Hz its gets even worse. For now I've roll-backed the 7800hz version because its the least noticeable one.

I'm gonna try to get a hold on another LEGO train motor, because with the original LEGO controller @ 1150hz there is also some audible noise however not really disturbing. So maybe I've might just got a faulty motor.

For people who are interested I've attached close-up sound recordings of the original 1150Hz, 1953Hz and 7800Hz PWM control.

I've applied FFT transformation and analyzed the audio spectrum from my own audio samples and come to the following conclusion that:

- The original thunderborg creates a 7820Hz tone
- The modified 1953Hz Thunderborg creates a 1956Hz tone
- The original LEGO controller create multiples tones being 1125Hz and 2249Hz

Since the DC motor tone closely resembles the PWM frequency. I think we have to increase to frequency to in-audible levels. Since audible sound ranges between 20Hz-20.000Hz we have to get a PWM frequency greater than 20.000Hz.

So I've downloaded the PIC16F1828 datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/41419A.pdf). And on page 220 the different PWM frequencies are shown. Since we already have a 1953Hz and 7800Hz version of Thunderborg. I would presume that Fosc = 32Mhz, hence theoretically 31.25 kHz should be possible.

Is it possible you can provide me a version of Thunderborg with a 31.25 kHz PWM frequency ?

Images: 
piborg's picture

31.25 kHz is possible like you suspect and I have made a new version attached below for you to try.

Unfortunately there is a bit of a catch to going faster, the outputs are not as linear as the standard code so you may need to make some tweaks to the power settings you are using.

The differences are most obvious at lower positive values being too low and higher negative values being too high. This is due to limitations with the output control chips which cannot be fixed with a software change.

The checksum for the new version is 3007.

Subscribe to Comments for "Thunderborg high pitch noise"