Why?
Upgrading the scale lights to be able to deliver a turbine feeling has been on my list for quite some time. I experimented with putting a speaker in a 600-size heli; the results were awesome. So I wanted to try this when combining my open OpenScale 200 frame with the Bo 105 fuselage. I bought a DFPlayer mini and some small speakers off Amazon but did not manage to add thatto the scale lights.
Initial experiments
I prepared two files for the turbine sound:
- turbine spool-up, with 15 min of turbine looping
- turbine power down
I copied these files to an SD card and put them into the DFPlayer. The DFPlayer was connected to my PC via an FT232 USB/Uart dongle. I wanted to make sense of the commands first and get the player working standalone, before starting the integration.
It took me quite some time to get the checksums working. This is what I came up with:
PLAYBACK = 0x0D
VOLUME_SET = 0x10
PAUSE = 0x0E
PLAY_TRACK = 0x03
STOP = 0x16
CMD_INDEX = 3
def calcChecksum(data):
checksum = 0
for i in range(1, 7):
checksum += data[i]
checksum = 1 + (0xFFFF - checksum)
data[7] = checksum >> 8
data[8] = checksum & 0xFF
return data
#start with track 1 --> startup and loop
_dataBuffer = [0x7E, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xEF]
checksum = 0
_dataBuffer[CMD_INDEX] = PLAY_TRACK
_dataBuffer = calcChecksum(_dataBuffer)
The corresponding code in C looks like this:
static void CalcChecksum(uint8_t* buf){
uint16_t checksum = 0;
for(uint8_t i = 1; i <= 7; i++){
checksum += buf[i];
}
checksum = 1 + (0xFFFF - checksum);
buf[7] = checksum >> 8;
buf[8] = checksum & 0xFF;
}
static void PlayPowerUpAndLoop(void){
uint8_t data[] = {0x7E, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0xEF};
CalcChecksum(data);
HAL_UART_Transmit(&huart1, data, sizeof(data), 100);
}
Finding a free pin
When designing the Scallights V2, I thought it might interface with a receiver directly. After getting deeper into Rotorflight, I have decided to use UART 2 (backside of PCB) to interface with a flight controller. So the USART 1 TX pin for the Spektrum satellite became obsolete. My first plan was to use a timer to generate the UART sequence via DMA and an according sequence for the compare match values. I figured that the STM32L031 can switch RX/TX pins (as most STM32 do!), so I chose that way.
Finding a free pin
After finishing all the preparation work, I set up the DFPlayer and connected it to my Scalelights debug setup. While doing that I noticed that the current consumption is above 500mA while blasting at full power.
Next steps
Nex I am going to integrate the speakers into the Bo 105 fuselage. I need to find a nice sport near the center of gravity. Additionally, I need to keep in mind that the module will draw something in the region of 500mA, so the BEC for the servos needs to be strong enough. Maybe another power source needs to be added for the sound module. This will enhance the scale experience and I guess the fuselage will amplify the sound by quite a bit.