No Sound :-(

Pokitto use I2C to control volume with a the digital potentiometer, but it’s connected in reverse.

Are you sure the plug is going all the way into the headphone jack? The switch is activated by the tip of the plug, so if it doesn’t go all the way in, the switch won’t open and the PEX pin will still (somewhat dangerously) feed the headphones.

I tried using the shaft of a “Q-tip” cotton swab to activate the switch. It’s only 2.5mm in diameter, which is too narrow to open the switch. However, even if the switch doesn’t open, you should still get sound through the speaker. I suspect either the amplifier hasn’t been enabled, as @bl_ackrain pointed out, or the amplifier circuit is damaged. If the speaker still works with a game that generates sound, then you can rule out damage.

The potentiometer’s position in the signal path is before the PEX pin, so it won’t affect any signal injected into the pin.

If you open the Pokitto to view the top of the circuit board, you can see if switch in the headphone jack is opening when something is plugged into it.



I know i did mention that because he lost the communication with the I2C FM chip.

1 Like
  • Observations -
    Playing sound internally FROM Pokitto
    Sound comes from both internal speaker AND is output through speaker pin. Headphones cut both off.

Playing sound INTO the audio pex pin
Sound comes from internal speaker.
When headphones are plugged in, then sound comes from the headphones only and NOT the internal speaker.
When dummy plug (q-tip with tape around to match the size) is plugged in, again no sound at all from internal speaker.

What that says about the internal wiring I don’t know :stuck_out_tongue:

On a related note, anyone want to design a small PCB for this?

[Edit] had this on all morning, no adverse effects on the pokitto yet.


This still doesn’t make sense, if the schematic that @jonne posted is correct and complete.

Plugging something into the headphone jack to open the switch shouldn’t be able to interrupt sounds to the speaker, that are fed into the PEX pin, since the pin is directly connected to the speaker amp input. The only way to disable the speaker in this case would be by setting the OFFn control pin low through software.

Also, if plugging in headphones properly opens the jack switch, then audio fed into the PEX pin shouldn’t be able to get to the headphones. The open switch would break any connections between the PEX pin and all other headphone contacts.

Since plugging in headphones cuts off sound to the speaker that is generated internally by the Pokitto, this implies that the jack switch is opening properly.

This is all very confusing! :thinking: :confused:


Something you may wish to consider as a different way of playing the radio audio via the Pokitto:

Feed the radio’s audio output to an “analog in” capable pin on the PEX, instead of using the AUDIO OUT pin. (You may have to add a bit of circuitry to condition the radio output to something better suited to the analog input.) You would then have software read the input using the ADC and “echo” it to the DAC0 input of the Pokitto’s audio circuit.

This way, the radio’s audio could be treated the same way as sound generated by the Pokitto itself. You would have the same volume and mute control, and automatic switching between the speaker and headphones. Depending on processor power, you may even be able to do some Digital Signal Processing (DSP) on the signal before feeding it to the DAC. Likewise, you could mix the radio audio with sound generated internally. (Like play a game with sounds while the radio plays in the background.)

Plus, you wouldn’t have to worry about damaging the Pokitto by feeding a signal into the PEX AUDIO OUT pin, which isn’t intended to be an input. You would even be able use the AUDIO OUT pin to feed an external amplifier, while using the Pokitto to control the radio tuner.

Funny you should suggest that, I tried all day yesterday to get that to work. Results ranged from the radio simply not working, to the pokitto white screening.
I believe it has something to do with the amp being controlled by i2c and apparently wired back to front.
What I was hoping to be able to do, is record to SD card. That would be nice.

1 Like

I2C can be done, its a bit similar to the eeprom issue. You need to initialize in the right order

I’ve done it, I need to dig up an example

1 Like

I would do it in steps:

  • Feed a manually variable DC voltage into the desired analog input pin on the PEX. You should vary the voltage between the voltages on the microcontroller’s VREFP and VREFN pins. (I don’t know what VREFP and VREFN are set at. @jonne will have to tell us, if it hasn’t already been published. I’d guess it’s likely VREFP = 3.3V and VREFN = 0V.) Set up the ADC to read from the PEX pin and make sure the readings match what’s expected based on the input voltage.

  • Write a program that uses the ADC to continually read from the input pin and write an equivalent value to the DAC0 output for the audio section. (Again, I don’t know exactly what the DAC0 signal is, where it comes from or how to use it.) Use a multimeter to verify that the DAC0 voltage is properly proportional to the voltage currently on the input pin.

  • Using the same setup as the previous step, feed an audio signal into the PEX input and make sure you can hear that audio from the speaker or headphones.

  • Get the radio working along with the above set up. Don’t connect the radio output to the PEX input yet.

  • Verify that you are getting audio out from the radio. Make sure you’re getting an output with a voltage swing suitable for the ADC input, using an oscilloscope if you have one. If the output voltage swing isn’t sufficient (Ideally you want it to swing between VREFP and VREFN with the radio set for maximum volume), you may need to add an op amp to boost the voltage. (I’m guessing your radio uses the RDA5807M FM tuner IC, which, according to the datasheet only outputs 0.36V, which is about 1/10 of the ADC full scale if VREFP - VREFN = 3.3V)

  • Connect the radio output to the PEX pin. If all the above steps are successful your radio should be playing though the speaker or headphones.

If this setup is successful, I’d consider having the ADC readings triggered automatically by a timer at maybe about 50kHz. The ADC would be set to generate an interrupt when it completes a conversion. In the interrupt service routine you would retrieve the value from the ADC and write it (with scaling if necessary) to the DAC0 output. This way audio from the radio would be handled in the background without needing continuous attention from the software running in the foreground.

Will I need to mess about with pokitto lib, or just juggle how my own project does things?

Basically you need to make your I2C object local inside the function where you need it. In that way it is created.after the softI2C is done with the amp

1 Like

Found a soft i2c library, seems to do the trick :slightly_smiling_face:. Perhaps an article would be longer than two sentences after all.

…hmmm… is it possible to read an analog pin as fast as the audio interrupt?

[edit] Wow, yes. If the sample rate is lower. Current test is inputting audio on EXT3 and outputting it directly at 22050 and it sounds… well, it sounds at least. I’m not sure if the quality issues are because of the radio or just the sample rate…

AnalogIn testPin = AnalogIn(P0_13);
inline void pokSoundBufferedIRQ() {

           uint32_t output = mixSound();
           uint32_t output =*512;
//           uint32_t output = soundbuf[soundbufindex+=Pokitto::streamon];
           if (soundbufindex==SBUFSIZE) soundbufindex=0;
           //if (p==sizeof(beat_11025_raw)) p=0;
           //soundbuf[soundbufindex++] = output;
           //uint32_t t_on = (uint32_t)(((obj->pwm->MATCHREL0)*output)>>8); //cut out float
           //obj->pwm->MATCHREL1 = t_on;
           output *= discrete_vol_multipliers[discrete_vol];
           output >>= 8;

           //setDRAMpoint(pixx, pixy);

The datasheet states that the ADC can acquire 12 bit samples at a rate of up to 2 Mega-samples per second.

FM radio has an upper audio frequency limit of 15kHz. You need to sample and output at, at least, two times the maximum frequency that you want to reproduce (the Nyquist rate). For a maximum 15kHz signal, this would be 30kHz but you would need perfect low pass input and output filters at this rate. That’s why I suggested 50kHz (which is still relatively slow with regard to the ADC’s capabilities.)

1 Like

I don’t think 50khz will work on Pokitto. I get black screen when setting above 30.
Are we sure that playing into the speaker pin is unsafe? it does give much better results.

It should. The black screen may be a flaw or limitation of whatever functions you’re using. Like I said previously, I’d try to do the whole thing under interrupts.

  • Set a timer to trigger the ADC to acquire a reading every 20µs (50kHz).
  • Set the ADC to generate an interrupt whenever an acquisition is complete.
  • In the ADC interrupt service routine, read the ADC value, scale the reading (if necessary) and write it to the DAC0 output. The interrupt routine may also have to re-arm the ADC and/or do whatever else is required to prepare for the next acquisition.

I still don’t know exactly what the DAC0 output is. If it’s generated by PWM, you may have to properly configure a timer to generate a suitable PWM signal for this situation.

I can’t say for certain. Without anything plugged into the headphone jack, you’ll be feeding a signal (through capacitors C22 and C23) into the output of op amp U4. You would have to analyse whether this is safe or not.

Besides, you said you were hoping to also be able to save the radio output to the Pokitto’s SD card. You can’t do that using the PEX AUDIO OUT pin.

I can think of two possible reasons for the poor quality of audio echoed from the ADC to the DAC0 output.

  1. You’re sampling at below the Nyquist rate, causing aliasing. (You don’t need a low pass filter on the input to the ADC. The radio output will be naturally limited to under 15kHz because of the audio bandwidth limit of FM radio. And, for the DAC0 output, U2 is the low pass filter, with a cutoff of 23.4kHz.)

  2. You’re not taking advantage of the full reading range of the ADC. As I said previously, the radio only outputs a maximum swing of 0.36V. A full scale input for the ADC is probably 3.3V. Therefore, you’ll be getting a resolution of less than 9 bits with the 12 bit ADC. You likely need to add an op amp on the output of the radio to boost the signal to something close to the ADC’s full scale voltage.

Pokitto have 2 audio outputs (DAC0, AudioOutput) one of them is PWM and the other is 8 bit resistor ladder.


With my settings.h only having screen mode 15 setup, and setting a timer in my own code to read the analog pin and do a tiny bit of float calculations, sending the result to dac, I can set the timer much above 11025 without black screening.
Any I ideas for better speed?

? Does not compute.