Tag Archives: soldering

Preparing a Raspberry Pi for I2S audio

Our HiFiBerry Mini, HiFiBerry Digi or HiFiBerry DSP boards use a I2S connection to the Raspberry Pi. The Raspberry Pi Release 2 is already prepared for this connection. However you have to solder the necessary pin header by yourself.

Identify the P5 header

If you look on the underside of the Raspberry Pi, you will find 8 pads between the large extension header (2×13 pins) and the SD card connector. This is the connector you have to solder.

If this connector is missing, you have an old Version 1 Raspberry Pi board. Unfortunately there is no header prepared on this board. In this case, we recommend to buy a new Raspberry Pi. All Raspberries bought since autumn 2012 should have the connector.

Solder the P5 header

Now insert an 8-pin header from the top and solder it on the bottom. The result should look like this:

raspberry-pi-p5

That’s it. You can now plug an I2S board (e.g.  HiFiBerry Mini) to the Raspberry Pi.

HiFiBerry DSP Light: Prototyping started

hifiberry-dsp-debuggingOur DSP project for the Raspberry Pi has reached the next milestone: hardware prototyping. The digital part of the circuits is working. There was still a minor bug (wrong pinout of a transistor) that was easy to correct by soldering the transistor on its back. The rest of the circuit worked well. As you can see on the picture, the analog part is not assembled yet. First I want to be able to upload the software to the chip.

Unfortunately, the simple approach to upload the program did not work. The chip simply did not acknowledge any I2S requests. Soldering some cables and connecting the I2S bus to the logic analyzer showed some unexpected behavior. While I2C read requests did not work, there was no problem with write requests. What happened? I had a look at the datasheet again and I think, I found the problem. Before every read request, the chip expects a write request with the address to read. However, both requests have to be in the same I2C transaction. The chip expects multiple start bits. Unfortunately, the Python I2C library that I wanted to use does not support multiple starts. It seems that I have to use the lower-level device driver of the operating system to upload the software to the chip.

Raspberry Pi I2C experiments

eeprom-bugAfter soldering so many 0602 packages and 0.65mm pitch circuits, it is really nice to do some soldering on 1.25mm pitch ICs. You can even solder cables to these ICs. Why should one do this? I have to do some tests with I2C communication on the Raspberry Pi. The Raspberry should program an I2C EEPROM.

That does not look like an audio project, but it is. This is the first step for our DSP project (the DSP will run standalone and has an integrated EEPROM for its program).

The default Raspian distribution does not come with the necessary tools installed. Therefore we first had to install them:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

Then, the I2C modules have to be added to /etc/modules:

i2c-bcm2708
i2c-dev

An they also have to be removed from the /etc/modprobe.d/raspi-blacklist.conf file (just comment them out).

After a reboot I2C communication should work:

[email protected] ~ $ sudo i2cdetect -y 1
...
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
...

The EEPROM has the I2C address 0x50 – correct.

Now we have to write data to it and read it. There is a Python library SMBus, that has a very simple API. Unfortunately there are two issues:

  • there is almost no documentation
  • it is optimized for command-based I2C devices, where all command are single-byte command

With the 16kB EEPROM used here, this does not work very well, because addresses use 2 bytes. Therefore we need an additional abstraction layer to read and write data. Note, that the following program code is not final and only shown as an example.

# Simple I2C EEPROM routines
# works with 16-bit addressable EEPROMs (up to 64kB)

from smbus import SMBus

smb=SMBus(1);
slaveaddr=0x50;

def eeprom_set_current_address(addr):
  a1=addr/256;
  a0=addr%256;
  smb.write_i2c_block_data(slaveaddr,a1,[a0]);

def eeprom_write_block(addr,data):
  a1=addr/256;
  a0=addr%256;
  data.insert(0,a0);
  smb.write_i2c_block_data(slaveaddr,a1,data);

def eeprom_read_byte(addr):
  eeprom_set_current_address(addr);
  return smb.read_byte(slaveaddr);

eeprom_set_current_address(0);
#eeprom_write_block(1024,[3,1,4,1,5])

for x in range(0,10):
  print eeprom_read_byte(x);

for x in range(1024,1030):
  print eeprom_read_byte(x);

HifiBerry Mini Prototyping starts

hifiberry-mini-proto1And there is the next Raspberry sound project – the HifiBerry Mini. This is a DAC for the Raspberry Pi, that is based on a PCM5102 from Texas Instruments. It has a The chip runs at 3.3V and used the 3.3V provided by the Raspberry Pi. Because this supply is quite noisy, it will be used only for the digital part of the chip. The analog output will be sourced by the TPS7A4901 – also from Texas Instruments. This is a high-end voltage regulator specifically designed for ultra-low-noise analog circuits.

This PCB is also a good device to practice SMD soldering. Both ICs comes in 0.65mm pin pitch. Almost all passive components are 0603 packages. But don’t be scared! You only need some magnifying glasses (I use 2.5x magnification), a good soldering iron and good solder paste (this is really important!). If you don’t believe me, check out the soldering tutorials that I linked here. There is no need for a reflow oven for this circuit.

Unfortunately all passive components are missing at the moment. They should arrive in the next days. Then I will be able to test the device. Stay tuned!

Soldering tutorials

Photo courtesy by SparcFunElectronicsWhen it comes to DIY electronics, one of the tasks that many people fear is soldering. Compared to circuits 20 years ago, soldering today seems more complicated. Packages are getting smaller and through-hole components are replaced by SMD components. Professional electronics producers use special reflow ovens to solder all components simultaneously. There are some projects to build reflow ovens for DIY use, but most people still use soldering irons. Can you solder SMD components with a normal soldering station? Yes, you can!

Dave from the EEVBlog has some nice tutorials on soldering. Check out his videos:

Raspberry Pi ready for HiFiBerry development

_MG_6809

The HiFiBerry will be an add-on sound card for the Raspberry Pi. While you can connect it by an external USB connection, it will also be possible to mount it directly on the Raspberry Pi board. To do this, you have to remove the USB port and the audio and the video output. With a desoldering station this is relatively easy to do. Of course, the Raspberry is working without these connectors.

Pinout of the USB header

rpi-usbheader2Ethernet connector is on the top right of the board. Now looking the USB pins are used as follows:

1: GND 3: DATA1 + 5: DATA1 – 7: +5V
2: GND 4: DATA2 + 6: DATA2 – 8: +5V