Translate

Sunday 8 November 2020

An experimental Arduino VU meter (and why it's no good)

 In an upcoming project (that is, as usual, taking far too long) requires some indication of audio input level.

So the plan is to have a meter, only this time drive it using an arduino PWM output. Seems like a good plan, as I already use said Arduino to perform one task on start-up, and it's sat there doing nothing most of the time.


So here's the simple input stage. It's job is to take our audio, and amplifying it, so it swings the whole range of our 5V rail, using a rail-to-rail opamp, and centering it on 2.5V, so it doesn't go negative. This is then fed into A0 of our arduino.



Now I need a peak value of our audio, so the usual trick is to rectify it. Rather than implementing this as , say a precision full wave rectifier, I thought I'd have a go in software.

Now the software reads the ADC, and if the result is greater than 512, the result stands and has 512 subrtracted from it. If the result is 511 or less, it's inverted and the result stands, IE is the ADC returns 0, it's inverted to 511, if it's 511, it's inverted to 0. That way, if our peaks are positive or negative, we're measuring a peak. It's a software rectifier.

And that's about all we care about. the output is divided by two and sent as a PWM to the meter. There's a bit in the software to decay the pointer.

At first glance, it appears to work well, given the limitations of the ATMEGA328's A/D ... but it's frequency response is awful...

The problem is with aliasing. Mr Nyquist tells us that we need to sample at least twice as fast as our highest frequency. The software may be going as fast as it can (albeit I haven't employed any techniques to optimise it) , but it's frequency response is poor, and unpredictable (or is it?)

Here's a quick video to show the issue... 

So it is predictable, and poor. Because we are sampling at a constant rate, at anything but that frequency, we will not be sampling the same point of our sinewave, let alone the peak, we could be sampling on the slope, or even at the central crossing point, and giving false readings. We can also see the frequency response improving at the higher frequencies. This is called "spectral folding" , and you can learn more about it here.

So there it is ... it might be OK to give a sort of visual response to some music, but it's woefully inadequate for my purposes. I could use a faster micro (and a better A/D), but that's overkill for this project. I've going back to doing this in good old fashioned analogue!

Here's the code if you fancy playing with it...

int LPeak;
int LoopCounter;

void setup()
{
  pinMode (5, OUTPUT);
  pinMode (3, OUTPUT);
  analogWrite(3, 255);
  delay (1000);
  analogWrite(3, 0);
}

void loop() {
  unsigned int Raw = 0;
  for (int i = 1; i <= 5; i++) {

    Raw += analogRead(A0);

  }
  Raw = Raw / 5;

  int LVal = Raw;

  if (LVal >= 513) {
    LVal = LVal - 512;
  }
  else {
    LVal = map(LVal, 0, 512, 512, 0);
  }
  LVal = (LVal / 2) - 1;

 if (LVal <= 35) {
    LVal =0;
  }
    //LVal =  (106* log10 (abs(LVal)));
  //Serial.println (LVal);
  if (LVal > LPeak) {
    LPeak = LVal;

  }
  if (LPeak >= 210) {
    digitalWrite(LED_BUILTIN, HIGH);
  }
  else {
    digitalWrite(LED_BUILTIN, LOW);
  }
  if (LPeak >= 229) {
    digitalWrite(12, HIGH);
  }
  else {
    digitalWrite(12, LOW);
  }
  if (LPeak <= 32) {
    LPeak =0;
  }
  analogWrite (3, LPeak);
  if (LoopCounter >= 1) {
    LPeak -= 1;
    LoopCounter = 0;
  }

  if (LPeak < 0) {
    LPeak = 0;
  }
  LoopCounter ++;

}

Friday 6 November 2020

Rockit 6 RPG2 repair

Mike brought me a speaker in.... 

"This belongs to my mate, he says it's crackling, can you have a look?"

Yeah ... why not?


It's a Rockit monitor. 

Sure enough it's popping and crackling ... off with those 8 screws on the edge of the back panel, and carefully remove...















Usual idea, amplifiers (in this case two, one for the tweeter, one for the sub) and transformer/ active cross over all built onto the back panel...






The fault is immediately obvious... the dreaded black goo ... This is some sort of adhesive applied liberally to the pcb to stop the capacitors and other large components "falling out" because they don't trust their soldering (this is a somewhat sarcastic guess, but I fail to see any real reason for it!)  It has an issue. After a time, if it's got hot, it can start to conduct, causing undesired operation of the device. I see it quite often.. for example here.


I can see it's got very dry and crusty (and most likely conductive) in a couple of places. Most noticably here ... we'll have to clean it all off to make a reliable repair. The dry stuff mostly chips off.... 




The rest needs a soak in a bit of acetone (or nail varnish remover), I add a bit to bits of kitchen roll, and allow it to soak in for 30 mins, and the goo just wipes off... 





Get as much off as possible. 








... and reassemble. Simple fix. 

I warned Mike the other one would need doing as well, and cleaned that one up too...

Tuesday 3 November 2020

Raspberry Pi400

Well, the latest in the line of Raspberry Pi's is here, the Pi 400 ...
Lord knows why people seem to like unboxing videos ... is it a kind of bragging?

No idea. The kids seem to like it , so here's some pictures...

Oh look a box from Farnell...











It's got some packing in it ... the excitement... 









... the product box...










... behold the Pi400...










... the official power supply, and official mouse ... I can hardly contain myself (if you have detected a shade of sarcasm, you're correct)








Our lovely marketing lady, Jilly.. "Where's the rest of it?"

And LP showing the rear panel. 










Plugged in and booted..










Official mouse ...










.. set up and updated...









So that's the silly unboxing rubbish dealt with. I would have made a video, except I couldn't be bothered, just close your eyes and picture it, with some ghastly music playing over the top. 

Now to the real stuff...

What do you really get for your £90? 

It's a Pi4 with 4GB of ram, only rather than running at 1.5GHz, the same ARM v8 Cortex-A72 is running a bit faster at 1.8GHz, all packaged inside a chiclet keyboard, a 16GB memory card, loaded with the Raspberry OS, a 3A power supply and the offcial mouse.

A review... It performs just like a Pi4, so really that's just fine. The chiclet keyboard works nicely. The offical mouse is ,well, barely adequate, it works, but ergonomics had passed this one by. 
You get one less USB than on a Pi4, and the GPIO port is available on the rear. 

Why would you want one?

I actually bought this for two reasons. One is it's easier to set up projects (destined for a Pi4) on this, as it's compact, and avoids having (yet) even more wires and keyboards hanging about in the workshop.. similar reasons I have an arduino uno board for developing projects that will eventually exist on a stand alone ATMEGA328.

The second is to run the excellent HAMPI radio ham image by Dave Slotter W3DJS. This should give me a flexible, small, quiet, low power platform to run some ham radio experiments on. 








Oh, and yes, there's a third reason. It reminds me of the computers I had in the 80's .. the Oric-1 , C64 and Spectrum. It gives me a nice warm feeling.

Thursday 22 October 2020

BMW Diversity antenna amplifier.

On old school pal, a once estate agent and daytime telly presenter, now a famous comedian (so we'll let him off for the first couple of misdemeanors) dropped me a message on Facebook....

"I've followed some of your repairs with astonishment and very little understanding.

Do you think you could look at something for me?"

Yeah .. why not ..

It's a diversity amplifier from a BMW E61 Tourer. 


They're apparently a really common fault on the E61 tourer, as they're situated in the tailgate, and suffer with water ingress, and Nick confirms this one was full of water when removed, and he'd left it to dry out on a radiator for a few days...

I expect it to be full of corrosion ... 

The plastic case just unclips, and reveals the PCB. 

Which is surprisingly clean and lacking in corrosion... 









So. The plan is to first work out what on earth this thing is supposed to be doing. The faults are the remote locking wasn't working, and the radio would reset to Radio 2 with the bass and treble set to maximum whenever the ignition key was removed... hmmm.

So, a spot of reverse engineering is required. 


The antennas (there are two) seem to feed into the red and black sockets on the top edge of the PCB. I suspect these may well be "hidden" antennas in the glass... The signal is filtered and is sent to a TEA6101 diversity switch. This analyses the signal from each antenna, and sends the strongest one on to the receivers. One signal is sent to a conventional TDA1576 FM demodulator, and on out to an amplifier and off-board via the molded socket. 


The second half goes to a TDA5210 UHF receiver/decoder.. what's the betting that's our remote lock/unlock ? Output from that feeds the IC under the heatsink clamp... 






There's also a small switching supply for +5V, and some amplification and filtering of RF along the way. 

Working out where the +12V power goes to the board, brings up the +5V supply... good. Poking round the data lines with an oscilloscope shows no activity ... but is it expecting data from the car? 

A careful visual inspection of the board under the microscope shows no corrosion. Time to remove the heatsink clamp...

I thought this may be hiding some sort of power amplifier, but no, it's a microcontroller. There's also some corrosion around it's 6MHz ceramic oscillator.... Scoping up around the microcontroller shows no activity ... 




Removing the oscillator shows up the corrosion.. See that black line between the two of those long pads? 











It's duly cleaned up ... 










The oscillator put back into place after checking the bottom of it is clean.... It's soldered back in with the hot air tool.







When I removed the oscillator, I also removed a small decoupling capacitor by accident (there can be some collateral damage with a hot air tool!) ... thankfully I didn't lose it, and this is hand soldered back in place.





I don't think the heatsink clamp is actually anything of the sort. I think it's an RF shield. Anyway it's replaced. Powering up now shows some activity on several of the microcontroller's pins..

 So, it's time to reassemble it, and send it back to Nick to see if it works or not ... fingers crossed.

**** UPDATE **** 
 It worked :)

Saturday 5 September 2020

Glasses manufacturers - a moan.

<MOAN>

I have a moan...

I've been a spectacle wearer for 35 years, and almost every pair I've ever owned has had the same issue... an issue I'm sure many of you can relate to.

There you are, going about your business, then, with no warning ... *thunk*

One of your lenses falls out ...

You pick the lens up, only to find the microscopic screw that held it in has, of course, vanished (or at least, due to your now compromised vision, you can't find it)

Now, I appreciate the need for a fixing to hold the things together. I also appreciate said screw is under a lot of stress, the glasses twisting as you take them on and off, the heating and cooling that goes on etc, so that poor little screw works loose. I get that...





So why in god's name put the screw in from the bottom? Just WHY?

It comes loose, falls out, followed a few seconds later by the lens... 

Why not put it in from the top? It may work loose, but at least it's got less chance of falling out?



Also, have you people never heard of locktight? Boeing have been gluing aeroplane wings on for years... can you not find a suitable adhesive?

It's not like these things are cheap to buy (aeroplanes or glasses)....

So, if you're a glasses wearer, or you partner is, take a moment today to check your screws. Stick a bit of nail varnish on the threads. You're welcome...

</MOAN>

Bush NE-2105 DAB Clock Radio repair.

 Mrs Doz stuck her head round the workshop door...

"The kitchen radio's stopped working. It's just making rude noises."

I went to inspect it ...

Sure enough it's just sat there, with it's LCD display flickering and making raspberry noises..
It's a Bush NE-2015 DAB radio with FM and a now long-obsolete iPod dock. It's put in Sterling service for 9 years...


Anyway... let's get it apart. Bush (or whoever makes their stuff these days) have carefully marked the fixings I need to remove with an arrow ... it's almost like they want someone to repair it...


Four screws on the bottom along the front....













... and two on the back, hidden under a plastic cap which just pops out...

There's a knot in the aerial wire, undo it...










Slide the back off, and undo the mains, auxiliary input connectors, and put the back to one side...











 It all looks rather nicely made. I'm pleasantly surprised.












Even if they didn't *quite* manage to get the switched mode supply IC in straight!

There's no sign of capacitors having blown their tops, no leakage...








5 Screws sees the main PCB lifted so I can gain a bit of access..










There's some signs of that nasty glue, that turns brown and goes conductive... it's scraped off before it gets worse.



Now a hunch tells me the power supply isn't starting up. The supply is started up in the usual manner, by a voltage fed from the mains rectified voltage, via a resistor chain, and a small capacitor. I check the (two) mains reservoir capacitors are dischanged with a 10K resistor (and they were holding a charge, enough to give the unwary engineer an unpleasant zap!) . The small start-up supply capacitor is removed. It's 47uF at 25V... 

 The ever-reliable Jingyan MESR-100 ESR meter shows an ESR of 6.67 ohms... 











A new one measures 0.34 Ohms, much better..












I also check the two main reservoir capacitors... They're 10uF at 400V each...

ESR is acceptable.









As is the measured capacitance. I'll pronounce those fit, and re-fit them, along with the new start-up capacitor...










A quick re-assemble, and, ace ... it all works!


Another saved from land-fill. I'm always surprised by the audio quality from this little radio, and now I'm impressed by it's build-quality too... a rare thing in this day and age. Well done Bush!

Friday 4 September 2020

Garrard Zero 100 Plinth cosmetics.

After the Zero 100 was repaired (here and here) I was left with a very tatty homemade plinth.



The plan is to tart it up and make it something that Mrs Doz will tolerate...

Let's remove the old existing veneer.

First up is to steam the veneer with a clothes iron, and a damp cloth. This should soften the glue. You can then start to work a knife blade under the veneer and slowly remove it. Try to work along the veneer, not splitting it, warming and working your way along as you go.

This veneer is obviously held on with some synthetic (rather than animal) glue, as it was quite tough. Nice thick veneer too... pity it was poorly done. This didn't aid removal!



So after a couple of hours work, we've not got a tatty plywood box. At least it's square...











Now I did consider some black and white plastic laminate, but initial experiments weren't very successful.. wood it is ... but I still want something "different" for a very different turntable...

I experiment with a strip of the available veneer, and some water based stains. I like the ebony, but a straw poll of Mrs Doz, and my neighbours, Suzie and Steve, and anthracite comes out top...

The stain comes from eBay seller letspack_uk , and comes as a small sachet you mix up with hot water, and allow it to cool before applying.





The plinth is veneered, and stained in 4 coats of the anthracite.











This is after 4 coats of stain, and 2 coats of finishing oil with many more to come! After each coat, the finish is flatted back with some fine wire wool.









About 20 coats of finish are applied, carefully flatting back after each one. The result is a lustrous finish. 

The Turntable is mounted solid, as the suspension is missing it's foam dampers (probably long since rotted away), and unlikely to help. 



Rather pleased with the end product :)