Translate

Saturday 25 February 2017

Arduino "analog" (analogue!!) clock.

I conceived this daft project a while back, after being given a box of surplus moving coil meters...

An Arduino driving three analogue meter movements to show hours, minutes and seconds.

There are lots of designs on the net, so here's another.

Now, I'd seen several clock designs on the net, whereby the Arduino's PWM signal is used to keep accurate time. I must say, whilst the idea is sound, most of the stuff I got hold of and downloaded didn't work for one reason or another.

The idea goes like this...

We couple the PWM output of a pin to an interrupt. We set the PWM output going with a mark to space ratio of 50%. The PWM frequency is governed by the internal architecture of the ATMEGA328, and is derived by some programmable timers, which divide down the clock frequency of the micro. The clock frequency on "posh" arduino boards is generated by a nice crystal (on not-so-posh boards, it may be a ceramic resonator, not so accurate). 16MHz. So dividing down this 16MHz should give quite a low error. Good news. So all we need to do is set up an interrupt, so that every time it sees a rising edge of our PWM signal, it increments a counter.

I measured the frequency of the PWM signal, and on a crystal clocked board, with a ATMEGA328P at 16MHz, it's 490.36Hz. (Due's/ Mega's etc will vary as the micro/clock frequency is different).


Excellent, so all we need to do is add a second on every time our counter hits 490 (Let's forget about the 0.36, shall we?). It should keep reasonable time.


After running for a day or so, the drift (caused by the 0.36 Hz left over) does become noticeable, but I recon it's no worse than a DS1307 RTC. So, to correct for this drift, I'll add in a 433MHz radio receiver module, and make it updatable from the GPS Master Clock project. Excellent.

So after a bit of tinkering this was born...


I've added three momentary push buttons, which allows the time to be set manually, and a "Cal" button. Once cal is pressed, the PWM output is switched off for 10 seconds, and then set to 100% for 10 seconds. This allows the user to set the zero mechanically on the meters, and the FSD (Full scale deflection) on the meter using the three pots, R7,R9 and R11. All three of my meters require 1mA for FSD, yours may vary, and you can alter the value of R7, R9 and R11 to suit your meters.

Each meter is driven by a small transistor. With my meters needing just 1mA, there's absolutely no reason why I couldn't just eliminate the transistor and drive the meters directly from the output of the micro to ground. I've added them in, just in case I need some more current, or decide to drive them from a higher voltage source than 5V. 

There's two toggle switches too... 

The 24 hour select switch changes the hour display from 0-24 hours to 0-12 (actually 12:00 or 0:00 is 0 on the meter, but it'll make sense in a minute)

The smooth select switch I'm rather pleased with. I started out wanting the seconds meter to move smoothly, rather that "tick" once a second. I coded this, and then thought I'd apply the same to the hours and minutes. This has one very pleasing effect. All the meters are moving smoothly. so the hour meter will read halfway between 1 and 2 when it's 1:30 ... same with the minutes. It also means that FSD on the hours meter occurs at 23:59 (in 24h mode or 11:59 in 12h mode), rather than going straight from 23 to 0 ..... 

Now, one big issue is daylight saving time. My master clock transmits GMT. I've added a routine that detects BST (British Summer Time) and adds an hour on if required. I've blatantly stolen this routine from here, , and modified it because I'm avoiding the time.h library (although I've no reason too!).

So a prototype is created....

Some meters selected, and calibrated ...












... and a clock created!...



Here's the code ...

Tuesday 21 February 2017

Problems with KDEnlive video editor.

Since (more or less) abandoning Windows in favour of Ubuntu, I've been using KDElive video editor. For the most part it's been a great thing, but just before Christmas I got a new (albeit secondhand PC). After installing Ubuntu on it, I didn't have much use for video editing until the recent spate of projects...

So I went to the Ubuntu Software thing and got myself a fresh install.

Now, sometimes the "old" PC would get a bit crashy when editing video, but the new install was horrific. Utterly useless...

I search around for a few days, tried a couple of other video editors, which, whilst stable, didn't offer the great functionality of KDEnlive... I decided to persevere.

Well, it turns out the Ubuntu Software centre thing has a *very* outdated and buggy version.

So, the fix is to give Ubuntu the correct and current repository to get the software from....

Here's how..

Open a terminal (CTRL-ALT-T)

and type the following....

sudo add-apt-repository ppa:kdenlive/kdenlive-stable
sudo apt-get update
sudo apt-get install kdenlive

Bingo. I don't think it's crashed once!



I hope this saves someone some time.


Saturday 18 February 2017

The Sainsbury's supermarket Microwave Oven....

The wife called me at work...

"Mum's microwave has died, can you have a look?"

Yeah .... why not ...

It's a cheap and cheerful microwave oven from Sainsbury's....

... everything works, except it doesn't get hot.

First things first ... look at the warning in the top right hand corner of my website, the bit in red.

Every microwave ever made, carries this warning... I must insist you follow it's warning.. leave it to the professionals... m'kay?











Right, being the professional, I unscrew the cover to reveal the inner workings of the oven...











Here's an annotated picture...












First thing to check is for safety. The high voltage capacitor can store ~2,500 volts , let's make sure it's safe before going anywhere near it. There's enough charge in there to floor you, or kill you. I check it's dead with a high voltage probe.... It's not charged up ... good.

It's then time to check the high voltage fuse, which turns out to be open circuit :)

Now it's not an ordinary 1.25" fuse. It's a special high voltage fuse. A like-for-like replacement is ordered and fitted.

This poor fuse suffers a lot of stress in it's life, and most seem to fail through old age, rather than protecting a failed circuit.




Here's a diagram of the all important high voltage section I've pinched from a Daewoo manual. It neatly shows the simplicity of the circuit.
















... and here's the obligatory video....

Monday 13 February 2017

Sam's Bush VHF90

Sam popped by with her much beloved, but sadly non-working Bush VHF90 radio...

"It sometimes picks up Radio 2, but nothing else.. Can you take a look?"

Yeah , why not?


It's a dual-band MW and VHF (FM) set, dating from 1956. Now, back then, VHF was in it's infancy. There wasn't any commercial radio in the UK until the 70's, so it was all BBC only. The band extended from 88 - 100 MHz only, not up to the current band edge at 108 MHz.


Removal of the back, and the first thing I notice...













...the mains tap is set to 200-210 Volts .... aghh ! This is never a good sign. The mains voltage in the UK is 240V (listed as 230V since European "harmonisation", but nothing actually changed). As a set's valves aged, unscrupulous repairers (bodgers) would lower the tap setting, giving the warn out valves a bit more voltage in an attempt to eek a little more life out of them, but putting the rest of the set under undue stresses and strains..... It's a practice known as "tapping up the set". Bad news...



Putting the UL84 output valve on test shows the sorry state of things...

Every valve in the set tests bad, and will require replacement.

Thankfully, they're all U pre-fix (designed for 100mA series heaters) valves, and are reasonably inexpensive.




So, I've got a couple of valves in stock, and a couple sourced locally... I can get on with the rest of the chassis whilst the others turn up from the internet.

First off, let's check out the dropper resistor, as it's going to have a hard life, having had the wrong tap selected....

.... hang on a minute... the bodger's been here again! There's a section physically missing! It's the 240-250V section. The 220-230V section is also open circuit... both are replaced.










Whilst most of the wiring is PVC, there's some rubber insulated wire which has perished. It's replaced with PVC....








In a break with usual tradition, the whole chassis recapped wholesale...












After a couple of days, the new valves turned up, and the set was powered up... sure enough BBC Radio Two on 88.6 MHz is all that can be received... and with the tuning dial set to 100 MHz! There's absolutely nothing on Medium wave at all .... not even a crackle...

I start with the lack of medium wave. Much head-scratching, staring at the circuit diagram, drinking of tea, and measuring of components followed.... There's a positive voltage on the grid of the UCH81 mixer-oscillator which shouldn't be there. Tests proved the new valve wasn't the fault, so where was this voltage coming from? I disconnected the wire to the valve pin, and the voltage is on the wire... medium wave starts working (ish) but the voltage should be disconnected by the switch...

Then I found this ... http://www.vintage-radio.com/recent-repairs/bush-vhf90-1.html

The switch has become conductive and is leaking! I cleaned it up.. it didn't help. Thankfully the webpage describes a work-around...










... which is duly implemented, and works well...

Medium wave is restored, but it's really weak.

Re-aligning the set provides great improvements, the second IF amp being way off the mark, as was the front end... Mr Bodger again?

The cathode resistor to the UL84 output pentode was also found to be low in value!


Next to sort out the VHF....

The tuning drive cord had been replaced (bodged) with string at some stage in it's life, it was slipping badly... The pointer had been replaced with a bit of copper wire, something I've done in the past when the original is missing and unobtainable..

The whole drive was slipping badly. There should be a spring in there somewhere, to tension the cord around the drum and pulleys too. The drum is directly connected to the AM tuning capacitor. VHF tuning, is that piece of cord you can see disappearing into the grey VHF front end to the left. It pulls a spring-loaded ferrite core out of an inductor inside the can, thus changing the frequency. It looks like the whole lot had been assembled wrongly.

After more tea, a new drive cord, some more tea, and some considerable head scratching, it all works as it should.

After a quick re-alignment of the VHF stages, it happily tunes from 87.5 -102.5 MHz.


Now Sam was keen to do the cabinet herself... but we had a problem...

I won't let it leave my workshop with a gaping hole in the bottom, as the chassis is connected to the neutral, and there's all sorts of live bits accessible through that hole... Electric shock is not an option.






A small piece of glass-fibre matt is cut...













... and hardened with resin to make it safe.

Sam seems to think she knows where the bit that fell out is, so she can cut this out at a later date and refit.








The guilty parties ...












Here's a quick video description and the thing finally working on AM....

Sunday 5 February 2017

Arduino PPM monitoring and switching.

I got involved with the local hospital radio station back in 2000, as station engineer. Been there ever since.

Now the station's studio used to be in a rather damp basement of a building built in about 1860. The hospital have decided to sell the building, so the station was evicted. They found us some nice new accommodation in a nice new building, and built us a super studio. All we had to do was move the kit and get it back on the air.


 The old studio used an undocumented "TX bay" rack to route the signals from 2 separate control studios and one presenter booth to the broadcast output. One studio would be live, and one for rehearsal/production.

Now we had one studio, so a lot of the switching could be eliminated. We would still need a rehearsal solution though.

This is the old TX bay, now minus it's switching and compressors etc... It was designed and built in the early 80's by person or persons unknown. It had a propensity to blow logic and transistor arrays up with the slightest hint of a rumble of thunder within a 100 mile radius! I shan't really miss it!



So, the desk was moved, and a nice new rack donated to house all the broadcast gear!

After a long day, the thing is back on the air!
















I built up a new headphone distribution amplifier, using 5 Class-D PM8403 amplifiers, wired for mono. A note here, the PAM8403 does not allow you to tie the -ve speaker outputs together for stereo headphone operation! The station is mono anyway, so it doesn't matter!










Completed headphone distribution amplifier.









Looking all quite nice and professional...


 


... but there's no method of switching the studio into rehearsal mode, and the PPM monitoring (allowing the operator to set her or his levels before going live) was lashed up using an old box donated by my good friend Piers at Raycom.

So... we need a small box, that will allow the following...

PPM level display from the monitor output from the mixing desk.
Switching to allow the desk output to be disconnected from the transmitter feed, and switch in the output from the 24 hour play out computer, to allow rehearsal mode.
Drive the "MIC LIVE" red lights.

So... after a bit of head scratching ....



Now the studio uses professional level, balanced audio (mostly). The output from the 24 hour playout system isn't. This is fed into the box, and it's turned into a balanced signal by IC5, and IC6A. There's a bit of amplification there too, to take the level up match the rest of the studio. This signal is fed back out to it's own fader on the desk, to allow for a seamless transition between live and rehearse.
In rehearsal mode, this signal is also fed straight out to the transmitter feed.
The live/ rehearsal switching is carried out by the microcontroller, controlling relay K1
In "live" mode, the signal from the desk is routed straight from the desk to the transmitter feed.

The monitor signal is also sent to the box, and is unbalanced by IC6B, and fed to the analogue input of our microcontroller. R29 and R31 are used to give the signal a 2.5V off-set.

The "mic live" signal (18V active low) is connected from the desk, via an opto-coupler, to the micro, where it's inverted in the code, and used to control the Mic live output FET Q2.

You will notice there are two, quite separate power supplies. One supplies +/-15V for the audio stuff, and the other an unregulated +15V and a regulated 5V for the micro and switching duties. The grounds are only commoned at one location.

There's a couple of LEDs to indicate the rehearsal status, and for peak (overload) warning. A 20x4 LCD provides the same information, as well as Mic live status and the level monitoring...

Now the level display. I wanted something smooth, not just using whole character blocks...
So I've defined a bunch of single pixel wide special characters, which are written to the display on the fly.

I also wanted a slower responding "peak" display. This is implemented in a similar manner.

(When I refer to the Pin's here, it's the physical pin on the ATMEGA328 IC itself, NOT arduino pin numbers.)

The audio is sampled (in the void getSample) from the ADC 0 pin, 48 times. This provides the required 5mS delay to stop the meter flickering around wildly. The maximum value is taken, and centered around 512 (our 2.5V offset) and then converted into a log scale.
The bar graph level is then plotted.

If the peak level is exceeded, it's updated and plotted too. It decays 0.1dB every loop cycle. It's limited to -54.19 dB to prevent a divide by zero error!

The mic live signal is read in via pin 14 and inverted, and then output on pin 12, which causes the output FET Q2 to switch the LED lamps on.

The Live/Rehearsal switch is read, and used to start a timer, which provides debounce, and plots a bar graph to give the user some feedback that switching is about to occur. The switching is carried out at pin 16, which switches T1, and the relay.

The Mic live lamps themselves, are a 3W LED, and a simple LM317T constant current source set to about 500mA.

 Construction was on three boards, the display has the digital and switching board "piggybacked", the analogue stuff is kept separate, and the two power supplies are on the third board.

All the interconnecting signal and power supply connections are twisted where possible.














Mic-live lamps are simple....












... but effective, and much more energy efficient than the old 60 watt incandescent lamps!











I'm rather pleased with the look of the thing.

It was built up into a second hand case, which I put in the dishwasher and re-painted :)








Here's a quick video of the thing in action!


There, the patients at two hospitals can enjoy some relaxing music and requests once more!

Here's the code:

Friday 3 February 2017

Harman Kardon PM660

Hamstall called by. I've got this 'arman Kardon, can you give it the once-over?



Yeah, why not.

It a nice early 80's integrated amplifier. Spec recons on about 80 watts per channel into 8 Ohms. No spec is given for power into 4 ohms. It's a completely discrete design. Not an op-amp in sight.



Nicely laid out...











A good-sized transformer and rectifiers... and plenty of smoothing caps.










10,000 uF , and there's 4 of 'em....













... and that "Sony" on//off switch .... (it all looks a bit Sony to be honest)











Super phono pre-amp, MC and MM....












... fitting with a smattering of ELNA "for audio" capacitors, so you know where your money went....











... and four position, front panel adjustable, capacitance loading for your odd-ball cartridge....


















Underneath reveals, well, not a lot really. 4 pairs of Toshiba 2SB775/2SD845 output transistors. Cleverly mounted through holes in the PCB, straight onto those gargantuan heatsinks....































Speaker wiring takes a bit of a long route home....











... and through some rather flimsy looking speaker select switches. I don't think I'd want to be switching speakers whilst playing....

























Two tape loops, two phono inputs (with short circuit plugs if you're not using one to keep the noise out), an aux and a tuner input....









So ... set the bias up (a blissfully easy procedure, thanks to a great service manual), a clean up of the pots and switches, all the caps look in great condition, and testing the ESR of a good few proves this to be the case.

The tuner indicator lamp is open-circuit...

Diminutive little lamp, so we'll replace it with a warm-white wide-angle LED...










The holder had to be drilled out slightly to enable the slightly fatter legs of the LED to pass through, and a 10K currently limiting resistor is fitted, to run the LED at a low ~1mA.









Not a bad colour match....

It plays effortlessly. I've no idea on it's output power as it easily over-ranges my audio wattmeter at 50 watts, with no sign of distress.

The phono stage is a delight. Nice and quiet.

Tone controls have a lot more range than is probably required...

There... another repair done...