0

I was working on this project : http://elm-chan.org/works/sd8p/report.html and I failed in every possible way from the start. Now that the .Hex files have been uploaded, and the fuses written, when I plugged the SD card in, nothing happened. Nothing at all. Directly asking for a solution might be impossible here as I have no idea what went wrong. So instead I tested the speaker's positive connection with the arduino serial plotter, and I found some interesting results. The output gave some cool irregular pattern of waves,similar to what I would expect from a sound output. But there was no sound, and I suspect that it was because of the output size being too small.(60/1023 is around 0.06 volts, 200/1023 is around 0.2 volts and the bigger output at 500++ levels out, so it shouldn't produce a sound.)

So now I would like to ask whether I can change the fuses of the .hex file(or the hex file itself, but its big.) to produce a larger output. I have not much understanding in hex files or even AVR devices, so any hep at all would be useful.

Thanks in advance.

the graphs

Please let me know if any other information is needed.

ɢʀᴜɴᴛ
  • 32,025
  • 15
  • 116
  • 110

1 Answers1

0

Your voltage output on a GPIO pin is limited to your supply voltage, so no you probably can't fix your problem by changing the software or the fuse bits. Depending on your current supply voltage, you might be able to crank that higher, which would increase your voltage output of the PWM, but the supply voltage can only go so high without damaging the chip.

That being said, you need to disconnect the amp and speaker from the AVR and probe the output pin of the PWM and make sure that it is actually producing a signal on that pin. The plots that you posted with that amplitude look like they are nothing but random electrical noise to me.

  • I'll try that in a bit. When I connect 5V to the system, my arduino shorts and shut down (I'm using arduino as power supply), and I think it is a bad thing. These plots were done with the speaker disconnected, and they go away when I unplug the SD card. With that said, I'll try probing it with a blank SD card. 2 4ohm, each 2W speakers works in place for the 8~16ohm speaker .....Right ? – See Jian Shin May 30 '17 at 07:22
  • We are getting a little off topic here, but whether or not those speakers will work depends on the circuit that is in front of it. It's possible that you could burn out your amp and/or your speakers. What arduino are you using? What compiler flags did you have set when you compiled the code? And which of the 4 hardware configurations did you pick? – rlphillipsiii May 30 '17 at 15:32
  • the speakers are working fine, I test them regularly by playing some Mario tune with my arduino. I'm using an arduino uno. Compiler flags was avrdude -c avrisp -p t85 -b 19200 -Uflash:w:(hexfile):i (these are flags right). I also wrote the three fuses later. Hardware configuration is mono. – See Jian Shin May 30 '17 at 15:42
  • That's the command you are using to program the MCU, but that looks suspicious. What Atmel chip are you using? Unless I'm mistaken, the uno is based on the ATmega328p. Did you connect an ATtiny to your uno or something? – rlphillipsiii May 30 '17 at 17:08
  • Yes I did. I don't have an interface device so I used arduino as my programmer. – See Jian Shin May 31 '17 at 05:56
  • Ah I see. I took a look at the code and conceptually it's not difficult to understand. It's reading bytes from the SD card and using a PWM to reconstruct a sine wave. OCR1B is the the PWM that's being used, so probe pin 3 on the ATtiny, and you should see a square wave that's 5V pk to pk assuming VCC is 5V (that's the UNO's operating voltage). That being said 5V is outside of the operating range of a micro SD card, so you may have damaged your SD card and that's why you don't hear any sound. – rlphillipsiii May 31 '17 at 07:35
  • when I run the attiny system I use 3.3 volts from the arduino. (When I probed it I got around 2.8 volts). The sd card is working too(I guess), as when I plug it into my laptop I can play songs from it and download songs into it. – See Jian Shin May 31 '17 at 17:10
  • 2.8 volts should be within the operating range of the tiny and the sd card, so you should be fine. Another thing to check is the file format of the audio files. Make sure that the audio files you are using are one of the formats that the AVR supports. – rlphillipsiii May 31 '17 at 20:20
  • they are on the common .wav file which was mentioned in the original post. WAV in lpcm is just .Wav, right. And also I changed the file to 8 bit with audacity export, not sure if it worked or not. – See Jian Shin Jun 04 '17 at 14:38
  • Yes a wav file that uses 8 bit LPCM encoding seems to be supported. One thing that I'm seeing in the code that is not mentioned in the documentation is that the software attempts to filter out files that are not wav format by checking the file extension. The check is case sensitive, so your files will be ignored unless they have ".WAV" somewhere in the name. Notice the all caps. My version of audacity uses lowercase letters for the extension, so might be worth checking that as well. – rlphillipsiii Jun 06 '17 at 19:05