Translate

Wednesday 22 October 2014

Ekco U319 Radio Restoration.

I have one of these radios myself, and it sits in my hallway, minding it's own business. It's VHF doesn't work, and the speaker cloth is ghastly. But a friend of mine passed comment on it... "I've got one of those! Can you get it going for me?" Of course I can ....

Arrival. A few issues are immediately obvious. The case is cracked, the dial glass is broken, there's no pointer in the dial...









 Not much we can do about the crack, unless we fill it using car body filler, flat it and paint it up to look like bakelite.









Electronically, things are looking better...








 Chassis is removed and examined.
The on/off volume control is a replacement, but has worked lose, and has wrenched all it's wiring off, and the suppressor cap has long since exploded!.....







... Here's it's other end!










Plenty of horrible hunts. These have little cardboard sleeves, wrapped round little black caps, which interestingly have the value printed directly on the cap's body too!







The more traditional wax cap. They will all have to go!...

... as well as re-stuffing the electrolytic's where possible.


The mains smoother has been replaced in the past, with this expensive component! .... we'll see how it reforms....








... And after a few hours on the "Dreadnaught" capacitor reformer, it passes with flying colours, exhibiting correct capacity and acceptable ESR & leakage.














Case is removed....
 ... and given a bath
Chassis and dial is cleaned. Tuning is re-strung...
 ... and a dial pointer fabricated...
... capacitors changed, and electrically tested, medium wave and long wave working well, but no VHF reception....








VHF tuner is removed (a tedious job)...
 ... and a small decoupling capacitor is found to be electrically leaky (no surprise, it's a Hunts!) ... and VHF operation is restored...
















 This radio also has a "gram" setting. This allowed connection of a record player (gramophone) back in the day. My friend wished to connect it to his iPod. The gram input was originally electrically isolated from the live mains chassis by some (now replaced) capacitors. Now in this day and age, I'm not happy with one side of the chassis being connected to neutral, and using this method to isolate a hand held device.

So I've fitted a small audio isolation transformer, which is eventually fitted to a bracket by the IF transformer. This is checked with a megger tester to confirm isolation from the mains.






Now all that remains is to re-assemble and sit back and listen!


Caroline ... on 319!!!


.... now I really should look at mine ....






Thursday 9 October 2014

Thank You.

Thank to all the visitors to my website. There's been over 800 visits since it started, and I think that's nothing short of miraculous.

It amazes me the diverse countries that have visited. Everywhere from USA, UK, France, Germany, Russia, Argentina, Australia, Iraq, Thailand, Brazil, Canada, Indonesia, Romania. This list is constantly growing. I am humbled!

Coming up in the next few weeks:

1957 Ekco U341 repairs and restoration, and iPod modification.
WEM (Watkins) Copycat repairs and restoration.

I'm also planning on doing a bit about my 1978 Mini 1275GT, since the MOT (annual inspection) failed! Expect lots of pictures of corrosion here!

There's also a plan to add temperature monitoring to the pond pump controller. I'm slightly concerned that the pump may try to run if the water is frozen, and either damage the pump, or attempt to pump water over a frozen waterfall, and empty the pond.

There's a lot to do, and a lot to share, so pop back soon.

840 visits ... who'd have thought it ....







Sunday 7 September 2014

Simple TV using DG7-32 'scope tube

A while I go I set myself a challenge... to design an make a simple TV using only valves. Not a semiconductor in sight.

WARNING. Do NOT try this at home. This project calls for some high HT voltages. The main EHT rail is some 700 VDC. It will floor you or kill you if you come into contact with it. It will not warn you, blow a fuse, nor pull your safety trip. It may not give you a second chance. RESPECT IT'S AUTHORITY

I will not, under any circumstances, accept any liability if you decide to re-create this project for yourself.

I procured an electrostatically deflected DG7-32 oscilloscope tube from the usual sources, a base , a handful of very nice Russian 6N1P valves, a couple of EF91s and a ECL83 for the sound. An EZ81 provides (some) rectification. Enter some transformers from the scrap bin, some tag strips and a couple of scrap aluminium enclosures.

My first design was too complicated, used too many valves, and, most importantly didn't work.

 

You'll notice a few things:

1) The raster is all "in one corner", this is because I didn't employ a differential drive to the X &Y plates.
2) There's precious little video modulation. I gave most of it away to Miller capacitance.

All-in-all, rubbish.

It sat on a shelf for a year, sneering at me.

I took it to pieces, and completely re-vamped it. I'd subsequently robbed the mains transformers for another project, so I ended up with a nice transformer from an old audio amplifier to provide the +300V and 6.3V for the heaters. I also needed to develop the 700 V EHT. In the original design I had a separate transformer, with a nice high voltage winding and an isolated heater winding. No such luck this time. I had a small insolating transformer from an old bathroom shaver point. 240VAC in, 240VAC out. This would have to do.

Let's have a quick look at the schematic:-




Yeah, you're going to want to zoom in on that a bit...


The Power Supply

Mains comes in and is fused by F1. TR2 and TR3 are actually one transformer, with centre-tapped heaters and HT winding. R1 and R2 provide a little peak current limiting to keep our EZ81 rectifier happy. The cathode of the rectifier is connected to our main smoothing capacitor C1. This must be no larger than 50uF, so 22uF is fine here, and we're not pulling much current. R3 and C2 provide additional filtering, and R4 and C3 provide a lower voltage supply for the screens of our video amplifiers. TR1 is the shaver transformer, and provides and quick and dirty 350V supply via D1 and C4. This 350V supply is not referenced to earth, but our 300V HT supply, giving around 650 VDC (More like 700VDC off-load)

I'll repeat my warning at the start of the article at this point. This power supply is more than capable of supplying enough current to kill you. Yes. Really. This means you. Don't do it. 

Whilst I was developing this gadget, I kept a voltmeter permanently attached between GND and 700V. Also, I kept a 10W 10K resistor connected to GND, and to an insulated lead, which was connected to the +700 VDC rail whilst I was working on the circuit. I've also installed 2x220K resistors in series directly across C1, C2 and C4 to bleed away any charge within a few minutes. These resistors aren't shown on the diagram. 

The original version also had separate fuses for each HT supply, and, stupidly, for the EHT supply. I used the ordinary type of 20mm fuse. During development, I inadvertently shorted out the EHT supply. The 20mm fuse blew violently, vapourising the wire against the inside of the glass, which carried on conducting! The resulting burned mess of fuseholder resulted in a lesson learned. Fuses have voltage ratings. 20mm fuses are rated to 250V. 

The Signal Stages.

Video comes in on X1, and is loaded by a 75 ohm resistor. Video is passed via C1 to the grid of our first video amplifier VT2, an EF91 (6AM6) pentode. This is further amplified by VT3 and passed to the first grid of the CRT. 

Video is also taken from VT2 to VT4a, the sync amplifier. Here some of the video information is lost (mainly through miller capacitance), but the line and frame sync pulses are retained. The sync pulses are passed from the anode load to VT4b, the frame sync separator, whereby the higher frequency line sync pulses are filtered out by C13 and R19, and the remaining frame sync pulses are used to sync the fantastron oscilator formed by VT5a & VT5b. This gives us a nice sawtooth waveform, locked to our video frames at 50Hz (in the UK). Although I haven't tried it, I'm sure it will work just fine with NTSC at 60Hz.

The frame sawtooth waveform is then passed to VT9A & VT10B (what happened there? It should read VT9B!)  which forms a differential amplifier and drives the Y-plates of the CRT. The plates are coupled to the anodes of the differential amplifier by 10nF, 1.6KV capacitors, as the deflection plates are referenced to the EHT by R46 and R47.

The sync pluses are also fed from VT4a via a high pass filter formed by C16-19 and R23-26, to pass the line sync pulses, to another fantastron amplifier, this time synced to the line pulses at 15.625 KHZ (again, I've not tried it, but it should be OK with NTSC too).  Once again this syncs another fantastron oscillator, and provides us with our sawtooth waveform to drive the X-plates via differential amplifier VT7a and VT8b (Again? This should read VT7B!)

The CRT is provided with a focus voltage via R50, and the cathode is supplied by R51 to slightly elevate it above 0V, to allow our negative going video to modulate the grid. 

Audio is provided by a very simple ECL83 amplifier. It's not going to win any awards for design or performance, but it functions. The output transformer is simply a 9V mains transformer. I know all about the fact that the transformer is totally unsuitable due to DC on the windings etc etc, but I had it to hand, and it works! 

Construction is fugly to say the least. 











I intended it to be a sort of homage to the home constructor of the 1940's / 1950's. 










There it is... exposed HT wiring an' all...














Performace isn't fantastic. The circuit is simple, the tube was never designed to show a raster scanned image... but it's definitely Dr. Sheldon Cooper!







Some retrace (flyback) lines are visible, as there's no supression. 








Feeling cheated? Yes, me too. I promised a design with no semiconductors, and yet the EHT rectifier is clearly a grain of sand. As I said originally, the EHT was originally supplied by a separate transformer, and this allowed me to use a valve rectifier (I actually used an EZ80), and I elevated it's heater winding to 350VDC, so as not to compromise the heater/cathode insulation. I did try putting the EZ80 into this circuit (if you look carefully you can still see it's Noval base below the speaker magnet) but the heater cathode insulation was just not good enough to hold off the ~700 volts and flashed over :(

Saturday 30 August 2014

Arduino Astronomical Clock (or Arduino Pond Pump Controller!)

****** A lot of people land on this page. Welcome. There are a few updates on this project (the last being here.) so it's worth checking through the blog for updates. Thanks ******




It's been a great summer here in the UK. I built myself something I'd always wanted. A bit of a water feature in my garden. The sound of trickling water whilst relaxing in the garden ... ahhhh !

Well, I didn't like the thought of the pump running all night, wasting all that precious energy, so a solution was required....

The usual thoughts of a photodiode (even an led works as a photodiode, try it!) or LDR and comparator were soon dispelled, as I'd done such things as a kid, and it's a horrible thing to set up. Clouds causing shadows, neighbours outside lights switching it on etc etc ... no , we need something a little more sophisticated.

Now, a guy called Paul had done the same thing, but backwards (switching something on at dusk, and off at dawn), and his website here shows a rather nice unit built using recycled bits and pieces. "Just the job".. except I need more coding experience, so I blatantly copy some of Paul's thoughts and the use of the Timelord library.

Although I love the idea of recycling the display, I just don't have anything to recycle at present, other than the usual 2 x 16 LCD I've removed from a DAB radio, and a nice rotary encoder, so we'll go with those.

Now, keeping time....

This is a DS1307 module, purchased at very little expense (but a bit of a wait) on eBay. It's a fully fledged real-time clock, which sends it's data via an I2C interface. Just the job. On the rear of this fella is a button cell holder. Just beware. Order yours with the battery. You can get a version which takes an ordinary 2023 Lithium coin cell, or an LIR2023 Lithium-ion coin cell, which charges off the supplied 3.3 or 5 volts. Don't try and charge an ordinary 2023 cell. It won't be pretty.


OK, so that's our time keeping sorted.

So, time to conjure up some hardware....




My 5v supply is a little buck converter, which is driven from the 24VAC from the pond transformer. The Arduino (Nano in this example) is mounted on a bit of perf board, along with a relay module and the DS1307 RTC board.
















Now copy the code into your IDE, and alter the LATITUDE and LONGITUDE constants to your position on the planet. Google maps comes in handy here, or just pop outside with a GPS.
Upload the code (below) and your display should show something like this. American users may wish to note the date is in the UK standard (DD/MM/YYYY), you can, of course, alter the code to suit your own preferred format.

Now, if that's not UTC (and unless you're in the UK in winter, or your PC is set to UTC, it won't be) press and hold the button for 5 seconds. When you release the button the display will show "Set Year". You can alter this using the rotary encoder. If the encoder works back to front, reverse the wires to pins D2 & D3 on the Arduino board. Pressing the button moves the menu on to set Month. Pressing again, set the day, then hour and then minute. Once the minute is set the RTC is set, and the clock display will revert after 1 second. Excellent. The clock is now set and running.

Pressing and releasing the button once will display the current calculated sun rise and sunset time.

If you wait the display will revert back to the clock after a few seconds.

Pressing again whilst the sunrise and sunset times are display will allow you to alter the mode of the clock. Auto switches the output on when the sun rises, and off when it sets.
On switches the output on permanently. Finally off leaves the output off.


Finally, mount the whole shooting match on the wall, make it neat and go for a pint or two to celebrate!















Here's the code:

// Dawn & Dusk controller.
// 16th August 2014.
// (C) A.G.Doswell 2014
//
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
//
// Designed to control a relay connected to pin A3. Pin goes low during daylight hours and high during night. Relay uses active low, so is
// "On" during the day. This is connected to the fountain pump in my garden.
//
// Time is set using a rotary encoder with integral push button. The Encoder is connected to interrupt pins D2 & D3 (and GND), 
// and the push button to pin analogue 0 (and GND)
// The RTC is connections are: Analogue pin 4 to SDA. Connect analogue pin 5 to SCL.
// A 2 x 16 LCD display is connected as follows (NOTE. This is NOT conventional, as interrupt pins are required for the encoder)
//  Arduino LCD  
//  D4      DB7
//  D5      DB6
//  D6      DB5
//  D7      DB4
//  D12     RS
//  D13     E
//
// Use: Pressing and holding the button will enter the clock set mode (on release of the button). Clock is set using the rotary encoder. 
// The clock must be set to UTC.
// Pressing and releasing the button quickly will display the current sun rise and sun set times. Pressing the button again will enter the mode select menu. 
// Modes are AUTO: On when the sun rises, off when it sets.
//           ON: Permanently ON
//           OFF: Permanently OFF (Who'd have guessed it?)
//
// Change the LATTITUDE and LONGITUDE constant to your location.

#include <Wire.h>
#include "RTClib.h" // from https://github.com/adafruit/RTClib
#include <LiquidCrystal.h>
#include <Encoder.h> // from http://www.pjrc.com/teensy/td_libs_Encoder.html
#include <TimeLord.h> // from http://swfltek.com/arduino/timelord.html. When adding it to your IDE, rename the file, removing the "-depreciated" 

RTC_DS1307 RTC; // Tells the RTC library that we're using a DS1307 RTC
Encoder knob(2, 3); //encoder connected to pins 2 and 3 (and ground)
LiquidCrystal lcd(12, 13, 7, 6, 5, 4); // I used an odd pin combination because I need pin 2 and 3 for the interrupts.
//the variables provide the holding values for the set clock routine
int setyeartemp; 
int setmonthtemp;
int setdaytemp;
int sethourstemp;
int setminstemp;
int setsecs = 0;
int maxday; // maximum number of days in the given month
int TimeMins; // number of seconds since midnight
int TimerMode = 2; //mode 0=Off 1=On 2=Auto
int TimeOut = 10;
int TimeOutCounter;

// These variables are for the push button routine
int buttonstate = 0; //flag to see if the button has been pressed, used internal on the subroutine only
int pushlengthset = 3000; // value for a long push in mS
int pushlength = pushlengthset; // set default pushlength
int pushstart = 0;// sets default push value for the button going low
int pushstop = 0;// sets the default value for when the button goes back high

int knobval; // value for the rotation of the knob
boolean buttonflag = false; // default value for the button flag


const int TIMEZONE = 0; //UTC
const float LATITUDE = 51.89, LONGITUDE = -2.04; // set YOUR position here 
int Sunrise, Sunset; //sunrise and sunset expressed as minute of day (0-1439)
TimeLord myLord; // TimeLord Object, Global variable
byte sunTime[]  = {0, 0, 0, 1, 1, 13}; // 17 Oct 2013
int SunriseHour, SunriseMin, SunsetHour, SunsetMin; //Variables used to make a decent display of our sunset and sunrise time.

void setup () {
    //Serial.begin(57600); //start debug serial interface
    Wire.begin(); //start I2C interface
    RTC.begin(); //start RTC interface
    lcd.begin(16,2); //Start LCD (defined as 16 x 2 characters)
    lcd.clear(); 
    pinMode(A0,INPUT);//push button on encoder connected to A0 (and GND)
    digitalWrite(A0,HIGH); //Pull A0 high
    pinMode(A3,OUTPUT); //Relay connected to A3
    digitalWrite (A3, HIGH); //sets relay off (default condition)
    
    //Checks to see if the RTC is runnning, and if not, sets the time to the time this sketch was compiled.
    if (! RTC.isrunning()) {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
 
 
    //Timelord initialisation
    myLord.TimeZone(TIMEZONE * 60);
    myLord.Position(LATITUDE, LONGITUDE);
    CalcSun ();
}
           

void loop () {
  
    DateTime now = RTC.now(); //get time from RTC
    //Display current time
    lcd.setCursor (0,0);
    lcd.print(now.day(), DEC);
    lcd.print('/');
    lcd.print(now.month());
    lcd.print('/');
    lcd.print(now.year(), DEC);
    lcd.print("    ");
    lcd.setCursor (0,1);
    lcd.print(now.hour(), DEC);
    lcd.print(':');
    if (now.minute() <10) 
      {
        lcd.print("0");
      }
    lcd.print(now.minute(), DEC);
    lcd.print(':');
    if (now.second() <10) 
      {
        lcd.print("0");
      }
    lcd.print(now.second());
    lcd.print("     ");
    
    //current time in minutes since midnight (used to check against sunrise/sunset easily)
    TimeMins = (now.hour() * 60) + now.minute();
    
    // Calculate sun times once a day at a minute past midnight
    if (TimeMins == 1) {
      CalcSun ();
    }
    if (TimerMode ==2) {
      if (TimeMins >= Sunrise && TimeMins <=Sunset-1) { //If it's after sunrise and before sunset, switch our relay on
          digitalWrite (A3, LOW);
          lcd.setCursor (13,1);
          lcd.print ("On ");
        }
        else {  //otherwise switch it off
          digitalWrite (A3, HIGH);
          lcd.setCursor (13,1);
          lcd.print ("Off");
        }
      }
       if (TimerMode ==0) {
         digitalWrite (A3, HIGH);
         lcd.setCursor (13,1);
         lcd.print ("Off");
       }
     
       if (TimerMode ==1) {
         digitalWrite (A3, LOW);
         lcd.setCursor (13,1);
         lcd.print ("On ");
       }
    
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    delay (10);
    
    if (pushlength <pushlengthset) {
     
      ShortPush ();   
    }
    
       
       //This runs the setclock routine if the knob is pushed for a long time
       if (pushlength >pushlengthset) {
         lcd.clear();
         DateTime now = RTC.now();
         setyeartemp=now.year(),DEC;
         setmonthtemp=now.month(),DEC;
         setdaytemp=now.day(),DEC;
         sethourstemp=now.hour(),DEC;
         setminstemp=now.minute(),DEC;
         setclock();
         pushlength = pushlengthset;
       };
}

//sets the clock
void setclock (){
   setyear ();
   lcd.clear ();
   setmonth ();
   lcd.clear ();
   setday ();
   lcd.clear ();
   sethours ();
   lcd.clear ();
   setmins ();
   lcd.clear();
   
   RTC.adjust(DateTime(setyeartemp,setmonthtemp,setdaytemp,sethourstemp,setminstemp,setsecs));
   CalcSun ();
   delay (1000);
   
}

// subroutine to return the length of the button push.
int getpushlength () {
  buttonstate = digitalRead(A0);  
       if(buttonstate == LOW && buttonflag==false) {     
              pushstart = millis();
              buttonflag = true;
          };
          
       if (buttonstate == HIGH && buttonflag==true) {
         pushstop = millis ();
         pushlength = pushstop - pushstart;
         buttonflag = false;
       };
       return pushlength;
}
// The following subroutines set the individual clock parameters
int setyear () {
   lcd.setCursor (0,0);
    lcd.print ("Set Year");
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    if (pushlength != pushlengthset) {
      return setyeartemp;
    }

    lcd.setCursor (0,1);
    knob.write(0);
    delay (50);
    knobval=knob.read();
    if (knobval < -1) { //bit of software de-bounce
      knobval = -1;
    }
    if (knobval > 1) {
      knobval = 1;
    }
    setyeartemp=setyeartemp + knobval;
    if (setyeartemp < 2014) { //Year can't be older than currently, it's not a time machine.
      setyeartemp = 2014;
    }
    lcd.print (setyeartemp);
    lcd.print("  "); 
    setyear();
}
  
int setmonth () {

   lcd.setCursor (0,0);
    lcd.print ("Set Month");
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    if (pushlength != pushlengthset) {
      return setmonthtemp;
    }

    lcd.setCursor (0,1);
    knob.write(0);
    delay (50);
    knobval=knob.read();
    if (knobval < -1) {
      knobval = -1;
    }
    if (knobval > 1) {
      knobval = 1;
    }
    setmonthtemp=setmonthtemp + knobval;
    if (setmonthtemp < 1) {// month must be between 1 and 12
      setmonthtemp = 1;
    }
    if (setmonthtemp > 12) {
      setmonthtemp=12;
    }
    lcd.print (setmonthtemp);
    lcd.print("  "); 
    setmonth();
}

int setday () {
  if (setmonthtemp == 4 || setmonthtemp == 5 || setmonthtemp == 9 || setmonthtemp == 11) { //30 days hath September, April June and November
    maxday = 30;
  }
  else {
  maxday = 31; //... all the others have 31
  }
  if (setmonthtemp ==2 && setyeartemp % 4 ==0) { //... Except February alone, and that has 28 days clear, and 29 in a leap year.
    maxday = 29;
  }
  if (setmonthtemp ==2 && setyeartemp % 4 !=0) {
    maxday = 28;
  }
  
   lcd.setCursor (0,0);
    lcd.print ("Set Day");
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    if (pushlength != pushlengthset) {
      return setdaytemp;
    }

    lcd.setCursor (0,1);
    knob.write(0);
    delay (50);
    knobval=knob.read();
    if (knobval < -1) {
      knobval = -1;
    }
    if (knobval > 1) {
      knobval = 1;
    }
    setdaytemp=setdaytemp+ knobval;
    if (setdaytemp < 1) {
      setdaytemp = 1;
    }
    if (setdaytemp > maxday) {
      setdaytemp = maxday;
    }
    lcd.print (setdaytemp);
    lcd.print("  "); 
    setday();
}

int sethours () {
    lcd.setCursor (0,0);
    lcd.print ("Set Hours");
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    if (pushlength != pushlengthset) {
      return sethourstemp;
    }

    lcd.setCursor (0,1);
    knob.write(0);
    delay (50);
    knobval=knob.read();
    if (knobval < -1) {
      knobval = -1;
    }
    if (knobval > 1) {
      knobval = 1;
    }
    sethourstemp=sethourstemp + knobval;
    if (sethourstemp < 1) {
      sethourstemp = 1;
    }
    if (sethourstemp > 23) {
      sethourstemp=23;
    }
    lcd.print (sethourstemp);
    lcd.print("  "); 
    sethours();
}

int setmins () {

   lcd.setCursor (0,0);
    lcd.print ("Set Mins");
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    if (pushlength != pushlengthset) {
      return setminstemp;
    }

    lcd.setCursor (0,1);
    knob.write(0);
    delay (50);
    knobval=knob.read();
    if (knobval < -1) {
      knobval = -1;
    }
    if (knobval > 1) {
      knobval = 1;
    }
    setminstemp=setminstemp + knobval;
    if (setminstemp < 0) {
      setminstemp = 0;
    }
    if (setminstemp > 59) {
      setminstemp=59;
    }
    lcd.print (setminstemp);
    lcd.print("  "); 
    setmins();
}

int setmode () { //Sets the mode of the timer. Auto, On or Off

    lcd.setCursor (0,0);
    lcd.print ("Set Mode");
    pushlength = pushlengthset;
    pushlength = getpushlength ();
    if (pushlength != pushlengthset) {
      return TimerMode;
    }

    lcd.setCursor (0,1);
    knob.write(0);
    delay (50);
    knobval=knob.read();
    if (knobval < -1) {
      knobval = -1;
    }
    if (knobval > 1) {
      knobval = 1;
    }
    TimerMode=TimerMode + knobval;
    if (TimerMode < 0) {
      TimerMode = 0;
    }
    if (TimerMode > 2) {
      TimerMode=2;
    }
    if (TimerMode == 0) {
    lcd.print("Off");
    lcd.print("  "); 
    }
    if (TimerMode == 1) {
    lcd.print("On");
    lcd.print("  "); 
    }
    if (TimerMode == 2) {
    lcd.print("Auto");
    lcd.print("  "); 
    }
    setmode ();
}

int CalcSun () { //Calculates the Sunrise and Sunset times
    DateTime now = RTC.now();
    sunTime[3] = now.day(); // Give Timelord the current date
    sunTime[4] = now.month();
    sunTime[5] = now.year();
    myLord.SunRise(sunTime); // Computes Sun Rise.
    Sunrise = sunTime[2] * 60 + sunTime[1]; // Sunrise returned in minutes past midnight
    SunriseHour = sunTime[2];
    SunriseMin = sunTime [1];
    sunTime[3] = now.day(); // Uses the Time library to give Timelord the current date
    sunTime[4] = now.month();
    sunTime[5] = now.year();
    myLord.SunSet(sunTime); // Computes Sun Set.
    Sunset = sunTime[2] * 60 + sunTime[1]; // Sunset returned in minutes past midnight
    SunsetHour = sunTime[2];
    SunsetMin = sunTime [1];
}

void ShortPush () {
  //This displays the calculated sunrise and sunset times when the knob is pushed for a short time.
for (long Counter = 0; Counter < 604 ; Counter ++) { //returns to the main loop if it's been run 604 times 
                                                     //(don't ask me why I've set 604,it seemed like a good number)
  lcd.setCursor (0,0);
  lcd.print ("Sunrise ");
  lcd.print (SunriseHour);
  lcd.print (":");
  if (SunriseMin <10) 
     {
     lcd.print("0");
     }
  lcd.print (SunriseMin);
  lcd.setCursor (0,1);
  lcd.print ("Sunset ");
  lcd.print (SunsetHour);
  lcd.print (":"); 
    if (SunsetMin <10) 
     {
     lcd.print("0");
     }
  lcd.print (SunsetMin);        

    
  //If the knob is pushed again, enter the mode set menu
  pushlength = pushlengthset;
  pushlength = getpushlength ();
  if (pushlength != pushlengthset) {
    lcd.clear ();
    TimerMode = setmode ();

  }
  
}

}
  
 

Thursday 14 August 2014

Remote control solutions.

Been after a reliable replacement computer remote control solution ever since Logmein started charging. I don't use it enough or professionally, so couldn't justify coughing up for it.

A work collegue showed me the offering from TeamViewer. (http://www.teamviewer.com/) and it's just the job. File transfer, Apple, Windows, Linux & Android.

Nice....

Sunday 10 August 2014

Dehumidifer datalogging...

<Deep voice over> Just when you thought it was safe to go into the attic</Deep voice over>

 Just when you thought the project was over (and it is really!) someone comes along and puts an idea in your head... "Hey, Andy, Why don't you log the data, and make some nice graphs" ... and, in reality, why would I want to .... because

a) I'm erring on the side of geeky

and

b) Because I can...

So, what's needed...

A scrappy old Windows box ... yes, this is just the ticket , 500 MB of RAM, 900MHz processor, 100MB HDD ... more than enough for the job.

A copy of Gobetwino, available here http://mikmo.dk/gobetwino.html

Another arduino board, another receiver and some code. (I suppose you could use your exisiting display, and just add the Serial.print bits to that code if you wished. Mine's all nicely boxed up, so it had to be stand alone)

// Receiver Sketch for Dehumidifier controller project
// Written by A.G.Doswell 08 Aug 2014
// Receiver connected to pin 9


#include <VirtualWire.h>
#include <VirtualWire_Config.h>

int TX_ID =10;
int Temp;
int Humidity;
int Dew;
boolean Output;
char buffer[5];
int led = 13;


void setup() {
              pinMode(led, OUTPUT);   
              //Comms set up
              Serial.begin(9600);
              // Virtualwire setup
              vw_set_tx_pin(10); // Even though it's not used, we'll define it so the default doesn't interfere with the LCD library.
              vw_set_rx_pin(9); // RX pin set to pin 9
              vw_setup(300); //sets virtualwire for a tx rate of 300 bits per second, nice and slow! 
              vw_rx_start();     
              }  
void loop()
{
typedef struct rxRemoteData //Defines the received data, this is the same as the TX struct
{
int    TX_ID; 
int    Temp;   
int    Humidity;
int    Dew;
boolean Output;

};

struct rxRemoteData receivedData;
uint8_t rcvdSize = sizeof(receivedData);

if (vw_get_message((uint8_t *)&receivedData, &rcvdSize)) 
{
  if (receivedData.TX_ID == 10)     { //Only if the TX_ID=10 do we process the data.
    int TX_ID = receivedData.TX_ID;
    int Temp = receivedData.Temp;
    int Humidity = receivedData.Humidity;
    int Dew = receivedData.Dew;
    boolean Output = receivedData.Output;
    digitalWrite(led, HIGH);
        
      // writes the received data to the serial interface
      
      Serial.print("#S|DATA|[");
      Serial.print(itoa((Humidity), buffer, 10));
      Serial.print(";");
      Serial.print(itoa((Temp), buffer, 10));
      Serial.print(";");
      Serial.print(itoa((Dew), buffer, 10));
      Serial.println("]#");
      digitalWrite(led, LOW);
 
      } 

  }
}

// End of file


So there it is. Load that into your favorite arduino, and connect a receiver to pin 9.
Now we need to tell Gobetwino what to do when it sees data from the com port. Firstly, quit the Arduino IDE. The two can't be running at the same time, or Gobetwino can't access the serial port the arduino is chatting on.

Firstly click on Commands.


Then click the New Command button. Using the drop down box , select LGFIL (Log data to file). Give it the Command name DATA (must be in capitals to match our Arduino data). Now create a blank data.txt file somewhere, using Windows explorer, just right click on a directory, click new and Text document. Name it data.txt. I chose the root of C: here for ease, but it can be anywhere....



Now back to Gobetwino. Click on the browse button, and point it to our freshly created data.txt file.


Check the Time stamp box. 

Click on save, and click on settings. Now click the serial port tab, and select the serial port our Arduino is communicating on. This is the same port the Arduino IDE was using.

Now every time the Arduino receives data from our transmitter, it will blink it's LED breifly, and send the data to Gobetwino, which will add a time stamp, and save it dutifully to the data.txt file.

You should end up (after a while) with a txt file looking a bit like this....

08/08/2014 16:13:15;28;36;14
08/08/2014 16:13:36;29;38;16
08/08/2014 16:13:58;29;38;16
08/08/2014 16:14:19;28;36;14
08/08/2014 16:14:40;28;36;14
08/08/2014 16:15:01;29;38;16
08/08/2014 16:15:22;28;36;14
08/08/2014 16:15:43;29;38;16
08/08/2014 16:16:04;29;38;16
08/08/2014 16:16:26;29;38;16
08/08/2014 16:16:47;29;38;16
08/08/2014 16:17:08;29;38;16
08/08/2014 16:17:29;29;38;16
08/08/2014 16:17:50;29;38;16
08/08/2014 16:18:11;28;36;14
08/08/2014 16:18:33;29;38;16
08/08/2014 16:18:54;29;38;16
08/08/2014 16:19:15;29;38;16
08/08/2014 16:19:36;29;38;16
08/08/2014 16:19:57;29;38;16
08/08/2014 16:20:18;29;38;16
08/08/2014 16:20:39;29;38;16
08/08/2014 16:21:01;28;36;14
08/08/2014 16:21:22;28;36;14
08/08/2014 16:21:43;28;36;14
08/08/2014 16:22:04;29;37;15


Now if we make a copy of the file, and change the extension to .csv (if windows worries about this making our file unusable, just carry on regardless!) It will then open in the spreadsheet programme of your choice (I choose OpenOffice), and with a little charting, we can create our graph...


Yes well, that's all very nice 'an 'all.... but wouldn't it be nice if the data was sent to me?

I'm not going to go into this in detail... as it took me hours to get it to work, and I'm still not really sure how I got it all to work... but there's a very useful piece of software called Sendemail available here: http://caspian.dotconf.net/menu/Software/SendEmail/ that I configured using the usual Windows task scheduler to copy the file, email me the copy, and then install a new blank in it's place... and it works a treat!

That's it for this project. It REALLY is...