ByPS128 / Arduino-Aliens-M41A-Rifle

Light and Sound module for M41A rifle from Aliens movie, based on Arduino
MIT License
2 stars 0 forks source link

Issue with getting sounds to play #2

Closed PeteODDShop closed 5 months ago

PeteODDShop commented 5 months ago

Hi @ByPS128 First of all, thank you so much for putting this amazing project together!

I'm currently putting together a prototype of the board, just wanting to use a single button for pulse rifle fire as a test. However, I am having issues getting the sound to play when I press the A2 trigger button (the ammo counter works as expected).

20240616_132151

I have verified that the DF player works and the sounds are played if I trigger IO pins on the DF module. I have followed your instructions on the directory for the sounds.

SD Card Directory

I am stumped on what else to try so I hope you can help!

Thanks again for this amazing project!

ByPS128 commented 5 months ago

Hi, I'm glad you were inspired by my project. There are an incredibly large number of DF Player clones. I bought 8 of them from 8 different stores for testing purposes and each one is different in some way. I would put it down to the chip version. It is possible that it will take more time to initialize, for example, or take larger pauses between commands.

Start by uncommenting the directive in the DFPlayer.h file on line 7: #define _DEBUG. Here direct link to that line: https://github.com/ByPS128/Arduino-Aliens-M41A-Riffle/blob/a8250e9c2921058aded1581b83136675a5db8e98/src/M41A/DFPlay.h#L7

Upload the program to the arduino and then connect to the arduino's serial line by activating Serial Monitor. This is done with the icon on the top right. image

The arduino will reboot and the bottom of the Arduino IDE will start listing what the application is currently doing. Most of the information is from the DF Player. Without a doubt, the communication with the DF Player is the most sensitive part of the whole assembly.

` Booting..

sending:7E FF 6 C 0 0 0 FE EF EF CMD_RESET Sent.

received: FF sending:7E FF 6 3F 0 0 2 FE BA EF CMD_INIT: 2 Sent.

received: 7E FF 6 3F 0 0 2 FE BA EF CMD_INIT: 2

sending:7E FF 6 6 0 0 A FE EB EF CMD_SET_VOLUME 10 Sent.

DFPlayer ready M41A player ready received: 7E FF 6 3F 0 0 2 FE BA EF CMD_INIT: 2

sending:7E FF 6 6 0 0 A FE EB EF CMD_SET_VOLUME 10 Sent.

sending:7E FF 6 F 0 1 C FE DF EF CMD_SET_PLAY_FOLDER_FILE folder: 1, file: 12 Sent.

received: 7E FF 6 3D 0 0 9 FE B5 EF Playback finished, file: 9 received: 7E FF 6 3D 0 0 9 FE B5 EF Playback finished, file: 9 `

This is what communication looks like with DF Player, which works well. Try to compare the outputs. Or if they differ, put your output here.

The following constants are in the DFPlay.h file: static const int DFPLAYER_RESET_TIME = 1000; static const int DFPLAYER_INIT_TIME = 500;

You can try experimenting with their values. The values are in milliseconds.

There are more options to play around with, but let's start with the dump ;)

A little tip, if you have the serial monitor on and want to re-upload a new version. you need to deactivate the serial monitor first. I often forget this and the upload fails afterwards.

ByPS128 commented 5 months ago

These are the chips I had the opportunity to test. What's yours?

This is amazing and absolutely the best. Chip: TD5580A image

Also great. Chip: GD3200D image

Also great. Chip: A823A799755 image

I have received several versions with this chip and it is the worst option you can buy: MH2024K-24SS - realy BAD. image

PeteODDShop commented 5 months ago

Hi @ByPS128 Thanks for responding so quickly!

I took onboard what you mentioned about bad DFPlayer Mini clones so I got DFR0299 especially for this one. 2020_0102_055521_002

Definitely something wrong with the fire button is pressed as per monitor output below; `

Booting..

sending:7E FF 6 C 0 0 0 FE EF EF CMD_RESET Sent.

sending:7E FF 6 3F 0 0 2 FE BA EF CMD_INIT: 2 Sent.

sending:7E FF 6 6 0 0 16 FE DF EF CMD_SET_VOLUME 22 Sent.

DFPlayer ready M41A player ready

sending:7E FF 6 6 0 0 16 FE DF EF CMD_SET_VOLUME 22 Sent.

sending:7E FF 6 F 0 1 C FE DF EF CMD_SET_PLAY_FOLDER_FILE folder: 1, file: 12 Sent.

sending:7E FF 6 F 0 1 2 FE E9 EF CMD_SET_PLAY_FOLDER_FILE folder: 1, file: 2 Sent.

sending:7E FF 6 16 0 0 1 FE E4 EF Unknown command: 16, params: 1 Sent.

PeteODDShop commented 5 months ago

Just tested a DFplayer Mini with Chip: TD5580A and I'm getting the same result.

PeteODDShop commented 5 months ago

Ah, this is embarrassing.

The Tx and Rx were incorrect on my board D:

ByPS128 commented 5 months ago

Ah, this is embarrassing.

The Tx and Rx were incorrect on my board D:

No problem, I'll be happy to help if possible. I see you have the original ;) I couldn't find it here.

So the problem was caused by the Rx and Tx wiring. can you confirm? You see, I wouldn't even have thought that they designed the board differently. So does this mean that your sound module is already working and button presses are playing sounds?

PeteODDShop commented 5 months ago

I can confirm it was the D2 and D3 pins on the arduino nano

src/M41A/AppConstants.h static constexpr uint8_t PIN_MP3_TX = 2; // Connects to module's RX static constexpr uint8_t PIN_MP3_RX = 3; // Connects to module's TX

But unless I'm reading the Kicad schematic incorrectly, it shows that the DFplayer's RX pin connected to D3 and this is what I followed.

kicad

I hope my mistake can help others not make the same one!

Thanks @ByPS128 for the support! I will keep building and let you know how it goes :D

ByPS128 commented 5 months ago

Oh, my God, you're right, I drew it wrong on the schematic. I'm looking at the breadboard of the prototype wiring and it's really like that. I'm ashamed, such a schoolboy mistake. I'm sure you spent hours looking for it. Thanks for finding the mistake. I need to get new close-up glasses :D I'm sorry. I'll fix the schematic tomorrow and post it here. Be sure to let me know how you get on with the implementation. Fingers crossed.

ByPS128 commented 5 months ago

Corrected i KiCAD files, pdf, svg and readme.md files also. image

PeteODDShop commented 5 months ago

Thanks again for your help @ByPS128 Will keep you updated on the build :)

ByPS128 commented 5 months ago

Closing as solved.

PeteODDShop commented 5 months ago

Hi @ByPS128 Just a quick update on the build. The 3d print I have was never designed for internals so it's a bit of a squeeze.

https://youtu.be/PtkeMC004Nk

ByPS128 commented 5 months ago

Hi, great job. I also prepare electronics for already printed parts. It's not that easy to make it interactive. Your M41A works perfectly, good job ;)

I will place the electronics and battery instead of the magazine. image

PeteODDShop commented 5 months ago

Looking good! Love the modification to the magazine cap.

ByPS128 commented 4 months ago

Looking good! Love the modification to the magazine cap.

Hi, I released video with all functions in current configuration. HOpe you will watch ;) How it is going with yours build?

https://www.youtube.com/watch?v=IwG0UBBIASA

PeteODDShop commented 4 months ago

Great job on the new vid! 20240711_214806

Few more bits to do on mine. Ammo counter cover, weathering, mag release but almost there :D