Everyone plays guitar (Part 2)

It has been over a year, and what a year it has been. Fortunately I don’t have to go into any of that here.

The TV project has all but died. I still have the spare PCB kicking about, but I’ve not got the motivation to fix my BusPirate probes and try to add USB to my TV. The Rasperry Pi2 is out now, and I don’t think my TV could supply enough current regardless. So one rainy day I might look into this again, but for now – everyone plays guitar, right?

As this post is going to deal with the guitar pedal project I think we should go over some history.

The MP-01 design was released 6th July 2013 (wow, that was a long time ago). It used a single PIC32 with external SPI DAC and ADC. Due to quite a lack of foresight, the rotary encoders were not on change notification pins, and any rail noise was put straight onto the guitar signal. That was a major issue that resigned this version to the junk pile, and the less said about this the better.

MP-02 was to be the savour. The design for that was released almost 1 year ago to the day (tomorrow in fact). I learnt my lessons from the first design. The op-amp stage was re-architected to utilise the op-amps supply noise rejection capabilities. I’d been hit by scope creep quite severely by now. I had moved to a 2-PIC solution; a PIC24 to handle the non audio functionality (which went from just LEDs to include an external port for an expression pedal and USB to allow direct loading of patches from a PC), and a dsPIC33 to handle the real-time audio activities (using it’s in-built ADC and DAC along with the rotary encoders, footpedal switch and EEPROM). After building the pedal I had real difficulties getting the thing to work as I expected it to. For some reason I just couldn’t sample quickly enough and there was still far too much noise. I finally fixed the sampling issue by changing how I was clocking everything, and I was having a pedal that was actually passing the guitar signal through, albeit with a lot of white noise on top. This noise was causing me some heartache as I just couldn’t pin down what was causing it; poor layout, inherent ADC and DAC noise issues, op-amp selection, dodgy power supply. I was fighting against so much that I decided that enough was enough. Plus I blew up the dsPIC twice as apparently the metal enclosure is made of metal.

MP-02 v1.1 was to be the savour! I refused to play any more games. The dsPIC range do have inbuilt ADCs and DACs but they just can’t compete against a proper chip. So I enlisted the help of something made for audio; the Wolfson WM8731. This blows the 10 and 12 bit capabilities of the dsPIC out of the water with a whopping 24bits at 192kHz. It supports pass through of the audio without requiring it to even enter the dsPIC. We have volume control, anti-thump mute, and filters coming out of our ears. This is definitely going to go some way to helping the sound. The LMV321 op-amps are out. I looked over the specs and the limited slew rate is fighting against us. I am looking at a couple of different op-amps to use instead, and I am favouring the LMV793. A slew rate of 24V/us (instead of 1V/us), and a noise density of 6.2nV/rt(Hz) (instead of 46 nV/rt(Hz)) means that this pedal will be singing. I’ve added some external SPI SRAM into the mix too. At 512Kb we have enough storage for over 5 seconds of audio (16bit mono 48kHz). This doesn’t sound a lot but it is more than enough for a decent echo. Plus unlike EEPROM, SRAM can be written to again and again and again… I’ve still got the EEPROM though, boosted to 512Kb too. This allows me to bootload both the PIC24 and dsPI33 from SPI or UART without having to support the entire USB stack in the bootloader. Scope creep got me again, and now we support USB OTG. This means that whilst you can plug the pedal into a PC to download new patches, you can download from your phone instead or use that as an expression pedal, or simply plug in a USB memory stick to load patches directly. This just opens up the possibilities. Finally I’ve added filtering and protection. I probably could’ve added extra but it will hopefully that will be enough.

These changes complicated the design no end, but I still managed to get everything on two layers (this may be the problem, we shall have to see), within my 50x100mm outline, and mostly single sided population. I want this pedal to be silent, as well as whisper, sing, and scream. I’ve done all I can to help with this task from additional components to filter the noise to segregation to help keep any noise where it can do no harm. I’ve even gone to a dedicated audio chip. This marks the beginning of the end of my attempt to design a guitar pedal. All will be revealed in a week or two when the new design gets posted through the door.

I have been fairly lax in updating this website, but hopefully the next post will bring good news.

More people watch TV (Part 3)

This post I am going to be demonstrating how to read an I2C device using a BusPirate. The BusPirate is a brilliant little tool that provides a command line interface to various communication buses. I am using the BusPirate V4, but the theory will be the same for the V3 and V3.5. The first device I am going to try and read is the ST24LC21. This ST part is a 1Kbit EEPROM that stored the TV’s VGA information that allows a PC to detect the capabilities of the display.

Attach your probes as follows: Vcc -> +5, GND -> GND, SCL -> CLK, SDA -> MOSI, WP -> AUX. Connect to the BusPirate using your favourite terminal program, and type the following “m 4 1 3″ to enter I2C mode. Next enable the power “P”, connect the pull-ups “e”, and enable the pull-ups “W”. Next you can search for any devices on the bus “(1)”. This should show a device on 0xA0 and 0xA1. This is the same device, but the write and read address. To read the data from the chip we set up the address “[0xA0 0]”, and send 128 read commands “[0xA1 r:1EDID28]”. Actually deciphering the numbers means delving into the EDID specification (or at least the Wikipedia article), but with that it is possible to determine manufacturing details of the TV, and its capabilities.
For example, byte7-8 (counting on from byte0) contain a compressed ASCII string. 0x58B3 is 0b0101100010110011, which in this scheme turns into 0bx 10110 00101 10011, or 22 5 19, or VES. Microsoft are responsible for allocating these values, and checking here reveals that the owner of VES is indeed Vestel Elektronik Sanayi ve Ticaret, the manufacturers of the control panel. Looking further on, byte17 (counting from byte0) is the year of manufacture minus 1990. In this instance the value is 0x0A, or 10 in decimal. This puts the manufacture year at 2000. I was expecting a much later year, but maybe the EEPROM image hasn’t been updated over all these years.

That’s enough for today, especially as I managed to break one of my BusPirate probe leads. Next time I will be looking through the main NVM chip to see if there is anything recognisable that I can modify. Wish me luck.

More people watch TV (Part 2)

I have three problems that I need to tackle; USB, 3x HDMI ports, HDMI-CEC. So again, lets head to the service manual to avoid embarrassment.

 

Connectors

There are footprints for 2 USB connectors. Even though I don’t want to plug a memory stick in, it did pique my interest as to the differences. The top-most connector (CN125) is labelled DIGITAL_USB, as opposed to the plain USB of the bottom connector (CN112). Neither of the connectors have a direct connection to the 5V_VCC rail, but instead go through an IC labelled STMP2161. On my spare PCB this part is missing (as I expected), and I couldn’t find a datasheet or anywhere to get one from. Thankfully, the part has both pins and nets labelled, so it isn’t too difficult to at least identify the function of the part, allowing a suitable replacement to be found. The device features ENABLE and FAULT pins, of which the FAULT pin is connected to a net labelled USB_OCD. This device is probably a current limited load switch (OCD being short for Over Current Detected).

 

USB SchematicTests have shown the Raspberry Pi has a maximum current consumption of between 500-600mA. This is just a guess, but I doubt that the STMP2161could handle 600mA, so if anything I am lucky that I have to source my own current limited load switch. Failing that I could bypass the switch circuitry and use a resettable fuse instead.

Back to the differences between the two connectors. the DIGITAL_USB goes to a CT216T-R – the Cheertek Integrated DVB-T Receiver. Given this device has digital video and audio decoding capabilities, it is likely that the DIGITAL_USB connection would be used for playing video from a memory stick.

The plain USB connector goes to the MST6WB7GQ-3 – the main MSTAR microcontroller. This is the brains that bring everything together. I couldn’t find any other information about the MSTAR processor, or its USB capabilities. The service manual makes reference to an “Analog USB” port which I didn’t even think was possible.

Enabling the power for the DIGITAL_USB connector is easy, but I wonder how much work would be involved in getting the actual USB data side to work. I am going on the presumption that all MSTAR microprocessors go out the same, and it is just a configuration page in external EEPROM that enables the features. This idea explains a number of things found in the Service Menu (found by pressing 4725 whilst in the TV’s menu). Firstly, there are options for “Digital USB Hotplug”, “CEC Enable”, HDMI3, HDMI4 but they are all greyed out. Secondly, there is the ability to modify NVM (non-volatile memory) data. I think that modifying the correct byte in NVM will enable the greyed out features.

Before I modify the NVM, it makes sense to make a backup. But first I need to find the NVM. Hunting for NVM on the schematic leads to a net labelled SCL_NVM. This is an I2C clock line for the NVM device, in this case a Microchip’s 24C32. Admittedly, I’m getting a bit ahead of ourselves, but it is obvious how the building blocks all come together and what started as a horrifically complicated design is getting simpler.

Back to the USB, and there is another unidentified device – a AZ099-04S. I am guessing this is probably something to help with ESD – maybe an array of bi-directional transient voltage suppressor (TVS) diode clamps. The last interesting part of the schematic is “Impedance 90R olacak”. USB is a differentially driven bus with a characteristic impedance of 90 ohms, and olacak is Turkish for “it will happen”. As to why there are Turkish instructions of the schematic, Vestel is a Turkish firm.

Jobs before the next post are dump the contents of any EEPROM on the board. This includes the main NVM EEPROM (U103) that hopefully enables features, and the VGA EEPROM (U112) responsible for identifying the TV as a PC monitor and presumably including EDID (Extended Display Indification Data). Additionally, the HDMI switch contains an EDID table that should be visible over I2C. There are two I2C flash chips; one on the MPEG decoder (U114), and one on the main microcontroller (U132), that can also be read.

Everyone plays guitar, but more people watch TV

Guitar pedals are harder than they look – at least this one has been. I’ve learnt some valuable lessons that I’ve never had to worry too much about before. The most valuable lesson is that noise is not fun. Living in the digital domain is brilliant because is it far less affected by noise. Analogue is the complete opposite.

If you remember from last time, I had to bias my guitar input at Vcc/2, so that I could feed it into my first op-amp. This meant that any noise present on the voltage rail was put straight on my input, and amplified – not a good start. Thankfully, all is not lost as I just need to convert the input stage to an inverting op-amp with the reference set on the non-inverting input. It should just be a case of moving a few components around as I has enough forsite to scatter passives around the op-amp.

In the meantime I want to talk about my TV. It is a low-end 32inch LCD Hitachi with IO that fits the price tag – no USB, only 2 HDMI, Component, Composite, and VGA. It’s pretty basic, but it fulfils MOST requirements of it, and was a bargain when we bought it. However, over the last two years my needs have changed, but I cant justify buying a new TV. I’m sure modern TV’s are extremely complicated, but like all good hackers/engineers, I needed to know just how complicated. More than a few years ago I would have just taken the back off and gone oscilloscope crazy, but I’ve learnt my lesson by poking around inside said oscilloscope so instead started with the service manual.

In fact I started by searching for spares for my TV (Hitachi 32LD30UA). That gave me a part number of my main control board – the Vestel 17MB35. I can only assume it is a popular control board, purely based on the amount of information I can find about it. Amazingly I found a service manual on the ArgosSpares website. I don’t know why I say that’s amazing, as Argos is where I bought the TV, but I didn’t expect to find a service manual there. Anyway, hunting through the manual I found out that my control board should have footprints for 4 (not just 2) HDMI connectors, 2 USB connectors, and even a “Ye Olde” DSub9 connector. Thinks were looking up, as I needed a USB port just to power my Raspberry Pi. I have been tempted to open the back of the TV and piggy-back off of a voltage regular, but not all I need to do it fit a USB socket instead – a nice and clean modification.

At this point, I still haven’t actually opened up the TV, but I have ordered and received a spare control board. I figured when I eventually open the TV I can copy the contents of my TV’s EEPROM into this board, and see what happens when I switch them over.

My aim is to have the Raspberry Pi powered from a USB port on my TV, have a third HDMI channel, and enable HDMI-CEC. I am pretty confident in the USB power, but who knows about the rest – wish me luck.

Everyone plays guitar…

It has dawned on me that whilst I don’t pay a lot a month for hosting, I do actually pay something and so not keeping this blog up-to-date could be construed as a waste of money.

With that in mind I have an update – hooray.

I built my first guitar more than 10 years ago, whilst still at secondary school. I had only been playing for a few years, and I wanted something that would stand out both visually and aurally.

I started with a strat body, and a random neck I bought off eBay. I cut the scratch plate out of some clear acrylic, and mounted combination of a P-90, humbucker and single coil pickups. These were all wired together through a vast array of switches to enable me to switch any combination of pickups in both parallel or series, and either in or out of phase. Looking back it was a hideous rats nest of wiring, but that was nothing compared to the paint job.

I sat in the garage with my sister, who was 5 at the time, and we painted it with all the paints I could find. It was gloss, matte, and metallic, with a crackled finish in areas.

Since then I’ve bought 2 more guitars, and modified the wiring each time, but now I am more selective over the components. I try to select parts that match the current hardware, or add functionality without adding to the part count. All of this is leading to the real point of this post. I am designing a guitar pedal.

I have been meaning to design a pedal for a number of years, and I had no real reason to not do it. Every time I would sit down and work out what it needed, but I would always be put off by one aspect or another. There are hundreds of questions that stop me from progressing. What do I want the pedal to do? How do I control the modification to the sound? Is a 12bit ADC and DAC going to be enough? Do I have an analogue front end to mix the effect in, or deal with it in digital? Do I want a “true bypass” pedal, or is all the signal going into the processor at all times? Do I stick with what I know and use Microchip’s PIC32, go for a multi-core Parallax Propeller, or try my hand at one of Freescale’s DSP chips? Instead of letting the questions buzz around, I took the plunge and started the design of my pedal.

The signal is first passed through a capacitor, effectively removing the DC component. The signal is the biased at Vcc/2, and pass through an op-amp – TI’s LMV321. This will apply some gain to the signal, before feeding into the ADC – Microchip’s MCP3202; a 12bit ADC. It’s not the best ADC on the market, but it’s pretty cheap and will do the job for now. The digital data is then read in by Microchip’s PIC32MX764F128H. With a core frequency of 80MHz, this should be more than enough to perform some basic effects. Following manipulation, the data is then sent to the DAC – Microchip’s MCP4822; a 12bit DAC. Again, it’s not the best DAC around, but I am not aiming for that yet. Finally, I used a unity gain buffer to match any impedances, remove any DC component, and allow the next device in the chain to handle the signal. The parts selected were spares left over from previous projects. The only new purchases were the 6.35mm jacks and metal 1590A enclosure. It should be obvious that this is not going to be the best pedal in the world. I’m sure that any analogue aficionado will berate me for my choice of op-amp, and any audiophile will say that the minimum number of bits to consider would be 24. But they would be missing the point.

This pedal is my start line. It will allow me to see the weak points in the design. I should have mapped the control rotary encoders to an “Interrupt-On-Change” pin as the are a bit slow to respond, or sometimes appear to run in reverse. I should have use a codec IC with build-in 24bit ADC/DAC. I should have used analogue switches to bypass the circuit when disabled. By this time next week, I will have some answers.

After antagonising over this pedal for years, I have finally started. I spent around 2 days drawing a schematic and laying out a PCB. There’s some code still to be done, but a lot of it was written in the 2 weeks waiting for PCB’s to arrive. I’ve got PCBs from iTeadStudio for $27.59 (under £20), and all my components for around £25. For under £50, I have designed a programmable multi-fx guitar pedal. And I have no doubt that I’ll be doing the same next week.