Translate

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... 



Saturday 9 August 2014

GEC 2028

Been after one of these old girls for a while now. Picture the scene. It's 1967. Colour TV has just started in the UK. Sets are an arm and a leg. This was the cheapest colour TV available at he launch of the Colour TV service (BBC 2 only at the time) as it used a Mullard 19" tube (A49-11X) , whereas the competition all used the bigger 25" A63-11X.

It's a dual standard 405 line/ 625 line set, and much in keeping with bodges done once everything was in colour this one has had it's system switch permanently set to 625 lines. This I had to reverse to restore the set to full operation.


The set arrives....








Off with the back... system switch lever missing...








One of the RGB output valves is down to air (the getter has turned white). It's a PCL 84, but no worry, I have a NOS "Pinnacle" branded one to fit.







Then, my heart sinks.... I'm just about to check the condition of the CRT, when I spot a crack all the way round the CRT neck....





The CRT is made from purest unobtainium. I'm gutted, but hook up the B&K CRT analyser to check it , but I don't hold out any hope....






As usual with a CRT that's been standing for years, there's almost no emission, but the CRT heaters glow about the right colour when connected to the tester, which is good, as if the tube was down to air, they would burn bright. Slowly, oh so very slowly, emission starts to occur, and after a few hours, the CRT tester shows we have a very good tube. I disconnect the main reservoir capacitors and leave them to reform on the "MK87B Dreadnaught Capacitor reformer"

I'm still very nervous of that crack in the CRT, but gently apply some mains to the set (after replacing the reformed electrolytics). There's a smell of warm dust from the dropper resistor as it wakes from it's slumber... The valve heaters light .... There's a hiss from the speaker ... but no life from the line output stage. Easy fix, the anode wire has broken off the top cap of the PL509 line output valve. A quick dab with a hot iron, and I start the procedure again...

This time, there's some life from the line output stage, followed by some fizzing, popping and crackling from the line output "cage". Not Good. Mains quickly removed. The line output cage houses the line output transformer and a semi-conductor EHT "Tripler" or multiplier. The EHT tripler creates the 25KV used to drive the final anode of the tube, and in this set it also feeds a VDR dividing network to derive the 7KV focus voltage.

I ran the set again in the dark, with the top off the cage, and it was obvious the tripler was arcing to earth where the EHT lead exited the case, so I removed the tripler and the focus VDR.






I removed the damaged insulation, and soldered a new piece of EHT lead to the tripler. I then filled the join with epoxy resin to insulate it. 25KV is difficult to keep insulated, so I also expoxy bonded two pieces of perspex to the tripler case to prevent any corona or arcing.




Once the tripler was installed again, it was time to apply mains again....







.... and after a few minutes, a bit of fiddling, a test card was displayed, low in height and no frame lock at all! Checking around the frame stage revealed 7 resistors well out of spec, and two suspect electrolytic capacitors. Once these were changed....





... the set resolved a very reasonable picture.









Manually operating the standards switch and feeding in a VHF 405 line signal in, the set displayed nothing but interference. No amount of trying could get the tuner to move. It was seized solid. Removal is not an easy task, and I was still wary of that crack in the CRT neck...




The screw threads which move the slugs in and out of the tuning inductors were seized solid. Some cleaning with IPA to remove the hardened grease, and application of petroleum jelly soon freed everything up and restored the operation of the VHF tuner.

Once the tuner was refitted, I could tune in the output from my 405 line test card generator, but line lock was difficult, and getting a lock on 405, threw out the line lock on 625.

After much head scratching , and checking of quite a few components in the 405 section of the line stage, I find the fault .... in the 625 section! It's obvious that the set developed a line sync fault, and was fudged to work on 625 only (what's the betting that's when the standards switch lever was removed). The 625 section of the line oscillator was loading down the 405 section. It was a faulty polyester film capacitor, very much outside of tolerance.

EHT was adjusted to 25KV on both standards, and I set about setting up the convergence...







 ... and snapped the blue lateral magnet in the process ...








.... which was duly repaired with some very nice orange heatshrink sleeving....








... and allowing a very nicely converged colour picture.








I fabricated a standard switch lever (which is operated by a cam on the VHF tuner. It operates the lever when switched to the VHF position). A tag soldered on to a piece of wire coathanger at the top....





 ... and a catch at the bottom to hold it in place.









 ... allowing us to switch between 405 lines monochrome...
... and glorious colour 625 lines at the turn of a knob!

Flicker here is caused by the difference in frame rate of the camera and the TV screen. It's not evident in real life!

Post-scipt....

THE CRACK!
After some research (mostly on http://www.forum.radios-tv.co.uk ) , and a chat with Peter from http://www.notobsolete.co.uk , it turns out that the crack is just a weld in the neck of the CRT. This was done by the original manufacturers of the tube (Mullard) when producing a factory re-gunned tube. Now I can relax!

Sunday 15 June 2014

Meanwhile....

Cooking up a few things for you lovely people....

.... but while you're waiting , why not head along to my YouTube channel for some bits & bobs....

https://www.youtube.com/user/MrAndydoz/videos?view=0&flow=list&sort=dd

Sunday 1 June 2014

Vox AC30 repairs

This delightful amp wandered in.

Apparently saved (some while ago) from landfill. The current owner had got it going, but after a fairly short time developed some faults and was put to one side.


 Good fairly unmolested condition.
De Banks EL84s. Never heard of them! Probably Chec or Russian. Logo looks a bit "Edicron" to me.

The driver's an Edicron ECC83. The rectifier a Pinnacle. The phase splitter is Mullard. Everything else is Brimar.
 NOT Celestion Blacks. Original through, and in great condition.
Under chassis of the output stage. Every single resistor in the cathode and screen is out of tolerance.
Electrolytic caps in the power supply and output stage reform 100%. Not so for the cathode by-pass caps in the pre-amp and tremolo circuit. New fitted. There's also a nasty Hunts 0.002 to go in the "Normal" channel.

Tremolo/Vibrato was not working. The oscillator was doing nothing, and the modulator was low in gain. The oscillator had an open circuit anode feed resistor. The modulator had a couple of resistors well out of tolerance.

First check in the output stage aren't too good. The phase splitter is way out of balance, the output is distorted and low and the anodes are starting to cherry-up.

3 out of the 4 resistors in the phase splitter were out of spec. All 4 changed. Bias checked and now at 46mA per tube, which is near enough. One side of the push pull section had obviously had a harder life then the other, with the phase splitter being so out of balance. This would explain the variances in the values of the cathode resistors in the output stage.

Sound is now bright, distortion is gone, and the power is there ... who needs 100s of watts?



Lovely. Now to be re-united with it's owner.



Friday 30 May 2014

Wireless Dehumidifier Controller Completion.

The new transmitter and receiver pair duly arrived, fitted and tested. Great range now. I haven't fully tested it's range, but it works beautifully from my attic to my workshop on the ground floor. During testing I became aware of other transmitters sending data on the same channel every now and again (remember my doorbell and weather station?) Perhaps sending data at such a slow datarate every 2 seconds is a bit anti-social, likely to clutter up the band a bit, and is unnecessary, so I've altered the sketch to send the data every 18 seconds.


Finished receiver in a Hammond clear blue case. Posh eh?

Powered from a redundant mobile phone charger (see note below).








Display on the receiver.











A note on aerials. The aerial (or antenna if you must) is simply 173mm of copper wire. Keep it as straight as possible and vertical. 

For the revised transmission rate, only the transmitter sketch changes. The receiver remains the same.

// 
// FILE:  wireless_dehumid.pde
// Written by Andy Doswell 24th May 2014
// PURPOSE: DHT11 sensor with LCD Display and output for controlling dehumidifier.
// Data send via virtualwire and 433MHZ link to remote display
// Dehumidifier is controlled by a relay attached to pin 7, defined in rlyPin.
// DHT11 sensor is connected to 8, as defined in #define
// LCD is a Hitachi HD44780 or compatible, attached thus:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// RW to GND
// V0 Held high (this may or may not work with your LCD, usual practice is to connect this to a 10K pot between +5 and GND)
// TX connected to pin 10
// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
 double a = 17.271;
 double b = 237.7;
 double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
 double Td = (b * temp) / (a - temp);
 return Td;
}

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

#include <dht.h>

dht DHT;

#define DHT11_PIN 8

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// define constants & global variables
const int rlyPin = 7; //defines pin the relay is connected to. relay is active low
const int TimerLength = 1800;// number of seconds in an hour / 2 - this sets the minimum time the dehumidifier will remain on for.
int Timer = 0; //timer is off to start
boolean DewFlag = false; // This is the dew flag. Off as default.
boolean OutputStatus = false; //Output status is off as default
int chk;
int Temp;
int Dew;
int Humidity;
int DewTrip;


// Data structure set up for Transmission

struct TXData
{
  int TX_ID;
  int Temp;
  int Humidity;
  int Dew;
  boolean Output;
};
  

void setup()
{
  lcd.begin(16, 2); // defines the LCD as a 16 x 2
  pinMode (rlyPin, OUTPUT); // sets our relay pin
  digitalWrite (rlyPin, HIGH); // sets the relay off for default condition.
  
  // Virtualwire setup
  vw_set_tx_pin(10); // TX pin set to 10
  vw_set_rx_pin(9); // RX pin set to a spare pin, even though we don't use it. If left as default it interferes with LCD operation.
  vw_setup(300); //sets virtualwire for a tx rate of 300 bits per second
  

}

void loop()
{
  for(int i = 0; i < 10 ; i++) { //transmit only every 9 loops (18 seconds)
    chk = DHT.read11(DHT11_PIN); // these 4 lines get data from the sensor
    Dew = dewPointFast(DHT.temperature, DHT.humidity);
    Temp = (DHT.temperature);
    Humidity = (DHT.humidity);
    DewTrip= Dew + 5; // Brings the dehumidifier on 5 deg C before the dew point. 
  
    // writes information about the system to the LCD
    lcd.clear ();
    lcd.print("Humidity:");
    lcd.print(Humidity);
    lcd.print("%");
    lcd.setCursor(0, 1);
    lcd.print(Temp);
    lcd.print((char)0xDF);
    lcd.print("C");
    lcd.setCursor(6, 1);
    lcd.print("Dew:");
    lcd.print(Dew);
    lcd.print((char)0xDF);
    lcd.print("C");
   
  // Dew detect loop. If the dewTrip point is reached, start the timer running and set the Dew flag
    if ( Temp <= DewTrip ) {
      DewFlag = true;
      Timer = 1;       
    } 
    else {
      DewFlag = false;
    }

  
    if (Timer >= TimerLength and DewFlag == false) { // If the timer has expired and there's no dew, switch the dehumidifier off.
      Timer = 0;
      digitalWrite (rlyPin, HIGH);
   
    }

    if (Timer !=0) {                // If the timer is running, switch the dehumidifier on , and write On to the lcd.
      digitalWrite (rlyPin, LOW);
      lcd.setCursor (13,0);
      lcd.print (" On");
      OutputStatus = true;
      Timer++;
    }
  
    else {
      lcd.setCursor (13,0);
      lcd.print ("off");
      OutputStatus = false;
    }
  
 delay (2000);
  }
  
struct TXData payload; //Loads the Data struct with the payload data
  
payload.TX_ID=10;
payload.Temp = Temp;
payload.Humidity = Humidity;
payload.Dew = Dew;
payload.Output = OutputStatus;
vw_send((uint8_t *)&payload, sizeof(payload)); //Transmits the struct
vw_wait_tx(); //waits for the TX to complete

}  
  
//
// END OF FILE
//


The receiver is powered from a redundant mobile phone charger, rated at 5V at 800mA. I was quite surprised to find it's off load voltage to be just under 7 volts. I expected it to be regulated. I fitted a 7805 voltage regulator inside the case. I was worried if the 7805 had enough headroom, but it seems to function well enough.

Saturday 24 May 2014

Arduino dehumidifier controller project - Wireless update!

Some spare time over the weekend means I can finally crack on with this!

After experimenting with a number of methods of sending and receiving data, I came across the virtualwire library here: http://www.airspayce.com/mikem/arduino/VirtualWire/

Now, there's a few things to note. Whilst surfing the various boards, there's talk of virtualwire only being able to send characters, which makes sending an integer a bit of a bind. There's people doing itoa's and atoi's back again. What happens if you need to send multiple values like we do? Temperature, humidity etc? We'll have to sync the transmitter and receiver for the first time... then what happens if a packet is dropped? It was all a bit much really, and sending integers as character arrays was all a bit wasteful of bandwidth. 

Now virtualwire is great, it takes care of manchester coding your data, and provides a bit of pre-amble so your simple receiver can sort out it's agc before outputing data. It's data is defined as uint_8 .... hang on ... that's a byte isn't it? So why can't I send an integer? It's just data ... 

So, pencil and pad at the ready, and a bit of a read about struct in by big book of C and we can create a custom message, with a unique identifier (just in case someone rings my wireless doorbell or my wireless weather station happens to transmit at the same time and corrupts our message, or indeed preventing our receiver attempting to decode such a message!)

For testing purposes, the two arduinos (arduini?) were linked by a bit of wire instead of the RF link. (Connect your output pin to the input, and link the grounds.)

Data rate during testing was 2000 bits per second.
Once the RF link was added I reduced this to 300 bits per second to make the link a little more robust.

Even reducing the data rate to 300 bits left me with woeful range, so I investigated. Output from the transmitter seemed good on the spectrum analyser, on frequency and plenty of output. 
Output from the receiver was noisy and it appeared the receiver was particularly "deaf". 
I used a frequency source to sweep the receiver, to see if it was tuned in accurately, my thinking being there's a nice big coil on the top to tweak! Sweeping the tuner found it tuned to 315MHz! Great. A 433 TX and a 315 RX. It was amazing it worked at all on the bench! Thankfully the supplier has agreed to send me out a new set, so hopefully It'll be wireless soon enough! 

Here's the transmitter code:-



// 
// FILE:  wireless_dehumid.pde
// Written by Andy Doswell 24th May 2014
// PURPOSE: DHT11 sensor with LCD Display and output for controlling dehumidifier.
// Data send via virtualwire and 433MHZ link to remote display
// Dehumidifier is controlled by a relay attached to pin 7, defined in rlyPin.
// DHT11 sensor is connected to 8, as defined in #define
// LCD is a Hitachi HD44780 or compatible, attached thus:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// RW to GND
// V0 Held high (this may or may not work with your LCD, usual practice is to connect this to a 10K pot between +5 and GND)
// TX connected to pin 10
// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
 double a = 17.271;
 double b = 237.7;
 double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
 double Td = (b * temp) / (a - temp);
 return Td;
}

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

#include <dht.h>

dht DHT;

#define DHT11_PIN 8

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// define constants & global variables
const int rlyPin = 7; //defines pin the relay is connected to. relay is active low
const int TimerLength = 1800;// number of seconds in an hour / 2 - this sets the minimum time the dehumidifier will remain on for.
int Timer = 0; //timer is off to start
boolean DewFlag = false; // This is the dew flag. Off as default.
boolean OutputStatus = false; //Output status is off as default

// Data structure set up for Transmission

struct TXData
{
  int TX_ID;
  int Temp;
  int Humidity;
  int Dew;
  boolean Output;
};
  

void setup()
{
  lcd.begin(16, 2); // defines the LCD as a 16 x 2
  pinMode (rlyPin, OUTPUT); // sets our relay pin
  digitalWrite (rlyPin, HIGH); // sets the relay off for default condition.
  
  // Virtualwire setup
  vw_set_tx_pin(10); // TX pin set to 10
  vw_set_rx_pin(9); // RX pin set to a spare pin, even though we don't use it. If left as default it interferes with LCD operation.
  vw_setup(300); //sets virtualwire for a tx rate of 300 bits per second
  

}

void loop()
{
  int chk = DHT.read11(DHT11_PIN); // these 4 lines get data from the sensor
  int Dew = dewPointFast(DHT.temperature, DHT.humidity);
  int Temp = (DHT.temperature);
  int Humidity = (DHT.humidity);
  int DewTrip= Dew + 5; // Brings the dehumidifier on 5 deg C before the dew point. 
  
// writes information about the system to the LCD
  lcd.clear ();
  lcd.print("Humidity:");
  lcd.print(Humidity);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print(Temp);
  lcd.print((char)0xDF);
  lcd.print("C");
  lcd.setCursor(6, 1);
  lcd.print("Dew:");
  lcd.print(Dew);
  lcd.print((char)0xDF);
  lcd.print("C");
  
  struct TXData payload; //Loads the Data struct with the payload data
  
  payload.TX_ID=10;
  payload.Temp = Temp;
  payload.Humidity = Humidity;
  payload.Dew = Dew;
  payload.Output = OutputStatus;
  
  vw_send((uint8_t *)&payload, sizeof(payload)); //Transmits the struct
  vw_wait_tx(); //waits for the TX to complete
  
// Dew detect loop. If the dewTrip point is reached, start the timer running and set the Dew flag
  if ( Temp <= DewTrip ) {
    DewFlag = true;
    Timer = 1;       
  } 
  else {
    DewFlag = false;
}

  
  if (Timer >= TimerLength and DewFlag == false) { // If the timer has expired and there's no dew, switch the dehumidifier off.
    Timer = 0;
    digitalWrite (rlyPin, HIGH);
   
  }

  if (Timer !=0) {                // If the timer is running, switch the dehumidifier on , and write On to the lcd.
    digitalWrite (rlyPin, LOW);
    lcd.setCursor (13,0);
    lcd.print (" On");
    OutputStatus = true;
    Timer++;
  }
  
 else {
   lcd.setCursor (13,0);
    lcd.print ("off");
    OutputStatus = false;
 }
  
 delay (2000);

}
//
// END OF FILE
//





and the receiver code:-




// Receiver Sketch for Dehumidifier controller project
// Written by A.G.Doswell 23 May 2014
// LCD is a Hitachi HD44780 or compatible, attached thus:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// RW to GND
// V0 Held high (this may or may not work with your LCD, usual practice is to connect this to a 10K pot between +5 and GND)
// Receiver connected to pin 9


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

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int TX_ID =10;
int Temp;
int Humidity;
int Dew;
boolean Output;



void setup() {
              lcd.begin (16, 2);
              // 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.
    lcd.setCursor(13,0);
    lcd.print (" Rx");
    delay (100);
    int TX_ID = receivedData.TX_ID;
    int Temp = receivedData.Temp;
    int Humidity = receivedData.Humidity;
    int Dew = receivedData.Dew;
    boolean Output = receivedData.Output;
    
        
      // writes the received data to the LCD
  lcd.clear ();
  lcd.print("Humidity:");
  lcd.print(Humidity);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print(Temp);
  lcd.print((char)0xDF);
  lcd.print("C");
  lcd.setCursor(6, 1);
  lcd.print("Dew:");
  lcd.print(Dew);
  lcd.print((char)0xDF);
  lcd.print("C");
  
  if (Output == true) {
      lcd.setCursor (13,0);
      lcd.print (" On");
    
  }
     else {
       lcd.setCursor (13,0);
       lcd.print ("off");

           }
  
      } 

  }
}

// End of file

Let me know if this has been of any use...  but for now I have a nice dry loft!

Saturday 10 May 2014

His Master's Voice 1373

I was going to push on with the dehumidifier wireless controller this weekend, but I've hit an issue. The LCD display I had in stock turns out to be duff, so I'll wait for the others to arrive from China.

In the meantime, a friend bought this in for repair. It's a 1958 HMV Radio. Long and medium wave only, superhet.

Nice maroon cabinet, would suit a West Ham supporter.










PCB in grubby condition. Some evidence of  a burn up by the thermistor.


Took the mains electrolytic capacitor out, and left it on a high voltage, current limited supply overnight to reform. It came up very well. Both 50uF sections measuring 52uF, and both having an ESR of less than an ohm. Not bad for a 56 year old capacitor!  There's a few "Hunts" capacitors that we'll need to change, and an old Plessey electrolytic decoupling the cathode of the output amplifier, so we'll change that as a matter of course.
PCB removed and cleaned up in the sink....

..... Followed by an hour in the oven at 50 deg to dry it out.....
Caps changed, and reassembled.
... and gently on with some power....



The speakers buzzing a little, but we can fix that, and there's a dial lamp out. I've ordered a couple of replacements.




Wednesday 7 May 2014

New 433 MHz Transmitter and receiver pair have arrived courtesy of the lovely people at QQLX.co.uk . Now to revise the hardware & software


Tuesday 6 May 2014

Arduino dehumidifier controller project.

OK, so last year I moved into my lovely new house. Well, it wasn't lovely at the time, pink walls, and green carpets, and no Earth! However it was well insulated. Very well insulated. Cavity wall insulation, many mm of loft insulation. Great. Well that's what I thought. It turns out that the new building regs that require many mm of loft insulation are all very well in new build houses that are designed to take it. They have well ventilated loft spaces or "warm lofts" where the loft is insulated with Kingspan (other insulation manufacturers are available) just below the tiles. This isn't the case with my old house. My house was built when I was born, but the insulation had been "upgraded". Many mm of that hairy glass fibre stuff above the ceiling. This had caused a major issue with condensation in the loft. Insulation was so good, the loft space would stay considerably cooler in the winter months and condensation would literally rain down from the membrane under the tiles. This "rain" then soaked into the hairy glass fibre stuff, holding the water and waiting for the next bit of heat to evaporate it and start the cycle again. Not good. Not good at all. To temporarily fix the issue, I nipped down to our local Argos, and purchased the cheapest dehumidifier I could find. Change out of £100. Problem solved... but what about my energy bill running the damn thing? I would probably have been better to remove the excess loft insulation! Now, I've done a fair amount of research into this whole condensation thing. The answer might be ventilation. Chop some holes in the (probably asbestos) soffit, pull back the excess insulation form the edges to expose said holes, and it might solve the problems. My roofing bloke Gary said it might. I might also drop dead of some asbestos related cancer in 30 years time. Nah... this calls for an engineering solution....

... enter the world of climate control!

So, the thought process goes a little like this. I need to bring the dehumidifier on when it gets sweaty up there.... OK. I think back to my days of video recorder repair. They had a little ceramic dew sensor on the video head drum, that would shut the machine down if there was condensation on the head drum, thus preserving your beloved pirate copy of ET from getting minced....

So, I search out such a sensor...



How does it do? Well, it needs AC to operate for a start, about 1KHz, and the RMS voltage quite tightly regulated, and it's impedance measured to give you a "sweaty" or "not sweaty" reading.
After a few evenings mucking about with op-amps, it works. Not very well. At all. No. Whilst it may be fine for preventing the tape from getting wrapped up in your aging VCR, it's no good for switching on my dehumidifier.
Right, enter the DHT 11....
A super little chap, which can be had on eBay for peanuts. Fewer peanuts than his analogue colleague above, which surprises me, as he's got one of those inside him.

So, we give him a nice 5 volts, a ground and he dutifully outputs temperature and humidity on a single wire serial interface. Superb.
And someone's written an Arduino library for the little chap too. Super.
So, armed with an Arduino Uno, an uninterrupted Sunday morning... the super dehumidifier conrtoller is born.

So, you'll need an Arduino of some description. I developed it on an Uno, them built it up on a Pro Nano copy (£1.75 from China... £1.75!!!!) as I like the size. Field in a nice Hitachi HD44780 display clone with a nice blue backlight, and you have it.

You'll need the DHT11 library from here.

and cut and paste this delightful code into the Arduino thingy:



// 
// FILE:  dehumid.pde
// Written by Andy Doswell 4th May 2014
// PURPOSE: DHT11 sensor with LCD Display and output for controlling dehumidifier.
// Dehumidifier is controlled by a relay attached to pin 7, defined in rlyPin.
// DHT11 sensor is connected to 8, as defined in #define
// LCD is a Hitachi HD44780 or compatible, attached thus:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// RW to GND
// V0 Held high (this may or may not work with your LCD, usual practice is to connect this to a 10K pot between +5 and GND)
// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
 double a = 17.271;
 double b = 237.7;
 double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
 double Td = (b * temp) / (a - temp);
 return Td;
}


#include <dht.h>

dht DHT;

#define DHT11_PIN 8

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// define constants & global variables
const int rlyPin = 7; //defines pin the relay is connected to. relay is active low
int WatchDog = 0; //watchdog default
const int TimerLength = 1800;// number of seconds in an hour / 2 - this sets the minimum time the dehumidifier will remain on for.
int Timer = 0; //timer is off to start
boolean Dew = false; // This is the dew flag. Off as default.

void setup()
{

  lcd.begin(16, 2); // defines the LCD as a 16 x 2
  pinMode (rlyPin, OUTPUT); // sets our relay pin
  digitalWrite (rlyPin, HIGH); // sets the relay off for default condition.

}

void loop()
{
  int chk = DHT.read11(DHT11_PIN); // these 4 lines get data from the sensor
  int dew = dewPointFast(DHT.temperature, DHT.humidity);
  int temp = (DHT.temperature);
  int humidity = (DHT.humidity);
  
  int dewTrip= dew + 5; // Brings the dehumidifier on 5 deg C before the dew point. 

// writes information about the system to the LCD
  lcd.clear ();
  lcd.print("Humidity:");
  lcd.print(humidity);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print(temp);
  lcd.print((char)0xDF);
  lcd.print("C");
  lcd.setCursor(6, 1);
  lcd.print("Dew:");
  lcd.print(dew);
  lcd.print((char)0xDF);
  lcd.print("C");

// Dew detect loop. If the dewTrip point is reached, start the timer running and set the Dew flag
  if ( temp <= dewTrip ) {
    Dew = true;
    Timer = 1;       
  } 
  else {
    Dew = false;
}

  
  if (Timer >= TimerLength and Dew == false) { // If the timer has expired and there's no dew, switch the dehumidifier off.
    Timer = 0;
    digitalWrite (rlyPin, HIGH);
   
  }

  if (Timer !=0) {                // If the timer is running, switch the dehumidifier on , and write On to the lcd.
    digitalWrite (rlyPin, LOW);
    lcd.setCursor (13,0);
    lcd.print ("On");
    Timer++;
  }
  
 else {
   lcd.setCursor (13,0);
    lcd.print ("off");
 }
  
// Watchdog loop - blinks a curson in the bottom right of the LCD, just to let us know the thing is still running
  if ( WatchDog == 0 ) {
    lcd.setCursor (15, 1);
    lcd.print (" ");
    WatchDog++ ;
  }
  else {
    
    WatchDog-- ;
    lcd.setCursor (15, 1);
    lcd.print ((char)0xFF);
  }
      


  delay(2000); // we can only get data from the sensor once every 2 seconds.
}
//
// END OF FILE
//
So here it is ....

Most of what you see on the perf-board is the power supply. You can see the DHT-11 and the very pretty white on blue LCD with essential information.
The code calculates the dew point, and switches the relay (that's the blue box hiding behind the mains transformer on the perf-board, another Chinese eBay purchase)when the actual temperature gets to within 5 deg C of the dew point. The relay will switch on the mains supply to the dehumidifier, and leave it running for an hour. Smashing. This should prevent condensation, not just clear it up after it forms. Get it boxed up and stashed in the attic.....
... but wait ... that lovely blue and white LCD display... hiding out of sight in the attic... oh what a waste. What's needed here is a wireless external display... just shows how these jobs can snowball....



Monday 5 May 2014

In the beginning...

Right... Here's the plan. I need somewhere to stash bits and pieces of projects, so it may as well be on a blog and available to the world. It's good to share.

I'm open to comments, advice, criticism etc so feel free to join in.

A bit of background. I'm an electronics engineer, currently involved in the calibration of some ancient analogue electronics somewhere in the UK. In my spare time, I little to play with stuff. Old stuff generally. If it's got valves in, more's the better.