Translate

Saturday, 14 February 2015

Fast Arduino GPS Datalogger.


STOP PRESS! This project is now revised and updated here, and will now create KML files, to open directly in google earth!

Now, my friend Julian and I have, for the past three years, been building a racing car. I've been lending a hand with the electrics and certain mechanical bits.

It's based on a 1971 Mini Clubman (by the name of Florence)

Here's Julian, fitting the door mirror.








After it's first season competing (with Julian at the wheel) , it's not disgraced itself at a few hillclimbs...








This video isn't mine, but this is Julian at the National Championship at Wiscombe Park late last year.

Anyway. Julian wants a bit more power, this has necessitated a new and bigger engine, and a new and bigger carburetor. In turn, the baulkhead had to be modified to accommodate the changes. Now the lovely dashboard we had created to house the instruments had to face some changes, and the large mechanical speedo had to go (when you're racing, you're not looking at how fast you're going!)

We looked for a small speedo that would suit our requirements, but I mooted the idea of a digital speedo, collecting it's data from a GPS receiver... I have previously used U-blox receivers and chipsets commercially, so I ordered one from the lovely people at Hobby Components here.




Excellent. Provides updates at up to 5 times per second.

Now, this coupled to an Arduino pro-mini, and a nice OLED display would provide a nice speedo...

The display is a 128x64 SDD1306 OLED display, and was purchased from eBay.







Then I got to thinking ... what if I could log some data to an SD card as well... might provide some interesting data for when the car is racing. So I ordered an SD card reader at the same time ...


eBay is once again our friend!









Now first things first, we need to configure our GPS receiver. This is done by hooking up the receiver board to our PC (I used the same FTDI converter I use to program the Pro-mini boards).

Go and get yourself a copy of uCenter from the U Blox website here.

Now when the software opens, you will need to tell it which com port and baud rate the receiver is on. Click on the receiver tab, and select the com port. Try 9600 for the baud rate, if you see no data, try another speed. Soon enough you should see some data from the receiver.



Amazing, isn't it!

Now click View and Messages View. Maximise the messages window.

Now scroll down to UBX and click it to expand the tree. Click on CFG . Now click on RATES and change the Measurement Period to 200mS.

Now expand the PORTS section, and change the baudrate to 57600. Once you do this, uCenter will lose communications with the receiver module. Go to Receiver, and re-set the baudrate to 57600.


Now click on Receiver again, selection Action and click Save Config.


You can now disconnect the receiver from the PC.

Now, a word about power. The uBlox receiver is happy at 3.3 or 5v, The Pro-mini I've got is good at 3.3v or 5v, the display works great on 3.3v or 5v... the SD Card reader, whilst it has a pin marked 5v, is only happy with 3.3v on it's data and clock pins. The 5v is purely to power the on-board 3.3v regulator. Now, we can either run everything from 5v and use a level converter between the arduino and the SD card reader (stupid) , or we can use the 3.3v from the card reader's on board reg to drive everything else (a really good idea!)

So, from the car our 12v is dropped to 5v using an ordinary 7805 voltage regulator, this is then supplied to the SD Card reader. The 3.3V pin on the card reader then supplies power to the arduino, the GPS receiver and the display.

SDA on the display is connected to A4, SDC to A5. The SD card interface is connected to pins 4 (CS), 11 (MOSI), 12 (MISO) & 13 (SCK).

A toggle switch is connected between pin 9 and ground. The toggle switch is used to switch on and off the logging feature.

The GPS receiver's TX pin is simply coupled to the hardware RX pin on the arduino, but not until we've uploaded the software!

Now there is an excellent library to control the display from Adafruit, but it is very memory intensive, and somewhat slow. This caused difficulty in writing to the SD card in time.

After spending a while surfing, I happened upon a lightweight library at http://blog.oscarliang.net/arduino-oled-display-library/ which is perfect, although it's not designed for this display. There's a requirement to enable the on-board inverter in our sketch.

We'll also need the most excellent TinyGPSPlus library from https://github.com/mikalhart/TinyGPSPlus

The SD card will need to be formatted on your Windows PC as FAT32. Open notepad and save a blank file as gps.txt to the card.

Here's the schematic:-

You will notice there's a zener diode before the 7805, this to clamp any nasties that might be present on our 12V supply from the vehicle (usually on cranking). Any value between 18 and 32 volts will do. 

 Lashed up for testing...


 7805 power supply.

Will it all fit in the box?


Of course ;)



Painted black to match the dash.

Not many satellites being received on the bench!

But a few in the window!

The receiver is actually very sensitive, although initial lock may take a few minutes, once recent data is stored in the receiver's non-volatile memory, warm starts are very quick indeed.





Out for a quick test run, and logged some data....

 It's pretty easy to import the txt file into google maps, and get some useful data...


Here, individual data points are shown, each showing the speed at that point.






Anyway, here's the sketch....


/*
Fast GPS data logger.
(c) 14th February 2015 A.G.Doswell

Released to all and sundry under GNU License.

The sketch uses a U-Blox 6M GPS satellite module connected to the hardware serial interface, 
a 128x64 SDD1306 OLED display module connected as an I2C device to pins A4 (SDA)& A5 (SCL) and an SD card interface 
connected to pins 4 (CS), 11 (MOSI), 12 (MISO) & 13 (SCK) The arduino used is a Nano with 3.3v ATMEGA328P.
Warning - Many SD card interfaces are not 5V. 
There's a toggle switch which connects pin 9 to GND for Record.
Data is written to the card an impressive 4 times per second, in real-time. 

The OzOled library is not quite "right" for this application, but works, and is lightweight and fast enough. Thanks Oscar!
It is available here : http://blog.oscarliang.net/arduino-oled-display-library/
TinyGPSPlus is available here :https://github.com/mikalhart/TinyGPSPlus

*/

#include <SPI.h>
#include <Wire.h>
#include <OzOLED.h>
#include <TinyGPS++.h>
#include <SD.h>

static const uint32_t GPSBaud = 57600;
int SatVal;                        // Number of satellites locked
int Speed;                         // Speed in MPH
char SpeedA [4];                   // Speed as char
TinyGPSPlus gps;                   // Feed gps data to TinySGPSPlus
File myFile;                       // Start SD
int speedDigit;                    // Number of digits in Speedo display 
boolean card;                      // Is there a card present?
boolean rec = false;               // Is the record switch low? (false = high)
int recPin = 9;                    // Record pin (Pull low to record data) 

void setup()   {                

  Serial.begin(GPSBaud);           // Start GPS serial comms
  pinMode (recPin, INPUT_PULLUP);  // recPin as input and pulled high
  OzOled.init();                   // initialze SDD1306 OLED display
  OzOled.sendCommand(0x8d);        // Set displays inbuilt inverter on
  OzOled.sendCommand(0x14);          
  OzOled.setBrightness(0xFF);      // ... and brightness to max
  OzOled.clearDisplay();           // Clear the screen
  OzOled.setNormalDisplay();       // Set display to Normal mode
  pinMode(10, OUTPUT);             // CS for SD card, wether it likes it, or not.
  OzOled.clearDisplay();
  
  
  if (!SD.begin(4)) {              //Check SD card is present
      OzOled.printString("SD card fail    ",0,7);
      card = false;  
      }
      else {
      OzOled.printString("SD card OK      ",0,7);
      card = true;
      }
  
  OzOled.printString("Sats:",0,0);  // Set up display
  OzOled.printString("Speed:",0,1);
  OzOled.printString("MPH",7,6);
}

void loop() {
    while (Serial.available() > 0) //While GPS message received
    if (gps.encode(Serial.read()))
      displayInfo();
}

void displayInfo() {               // Display the data
  SatVal = int(gps.satellites.value());
  Speed = int(gps.speed.mph());
  itoa (Speed,SpeedA,10);
  OzOled.printNumber ((long)SatVal,6,0);
  OzOled.printBigNumber (SpeedA, 7,1);
  speedDigit = strlen(SpeedA);    // get length of Speed , and delete left behind zero if req'd
  if (speedDigit == 1) OzOled.printBigNumber(" ",10,1);
  if (digitalRead(recPin) == HIGH && card == true) { //If the record switch is high and the card is OK, write card data
    rec = true;
    OzOled.printString("SD card OK REC",0,7);
  }
  if (digitalRead(recPin) == LOW && card == true) {
    rec = false;
    OzOled.printString("SD card OK    ",0,7);
  }
  
  if (card==true && rec==true) {
    writeInfo(); //write the data to the SD card
  }
  smartDelay(200);

}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (Serial.available())
      gps.encode(Serial.read());
  } while (millis() - start < ms);
}

void writeInfo() { //Write the data to the SD card Date,Time,Lat,Long,Spped (MPH) and number of satellites locked
  
  myFile = SD.open("gps.txt", FILE_WRITE);
  if (myFile) {
    myFile.print(gps.date.month());
    myFile.print(F("/"));
    myFile.print(gps.date.day());
    myFile.print(F("/"));
    myFile.print(gps.date.year());
    myFile.print(F(","));
    if (gps.time.hour() < 10) myFile.print(F("0"));
    myFile.print(gps.time.hour());
    myFile.print(F(":"));
    if (gps.time.minute() < 10) myFile.print(F("0"));
    myFile.print(gps.time.minute());
    myFile.print(F(":"));
    if (gps.time.second() < 10) myFile.print(F("0"));
    myFile.print(gps.time.second());
    myFile.print(F(","));
    myFile.print(gps.location.lat(), 6);
    myFile.print(F(","));
    myFile.print(gps.location.lng(), 6);
    myFile.print(F(","));
    myFile.print(gps.speed.mph(),1);
    myFile.print(F(","));
    myFile.println(gps.satellites.value());
 // close the file:
    myFile.close();
  }
}

Saturday, 24 January 2015

Ekco U353 Basket Case repaired!

There's a lovely chap at work called Terry, who likes to restore old radios and record players. He arrived with this old Ecko U353 in bits in a box. "It's got cut wires and labels and has been got at. Would you like it?" Why not ...


 Wires cut. Looks like someone was going to change the mains smoothing capacitor.
 UL84 getter looks bad.
Most of the white lettering from the scale has gone...
... but on the whole the chassis looks reasonable.










The mains smoothing cap is not original, has been disconnected and is dated Feb '65. It has poor ESR....











.. so each of it's 3 sections is given a few hours on the ole' MK87 Dreadnaught capacitor reformer.....









 .... meanwhile the sad looking UL84 is tested on the AVO two-panel valve tester...

A sad 1.5 mA per Volt. Minimum for a new valve is 9 mA per Volt. No good at all....


Thankfully, we have a NOS replacement. Just look at the difference in the gettering (that's the shiny bit at the top). The new valve is on the left. The gettering is bright and has a nice sharp edge. The blacker the gettering is, the better. This new valve reads 15mA per Volt on the AVO!





Stamped on the chassis is a date ... 1st Sept ...19 ?? 1957 perhaps? Seems a bit early for this receiver...








There were many leaking and cracked Hunts capacitors to be changed, along with some suspect TCC electrolytics. The cathode bypass capacitor for the UL84 was short-circuit. That's probably why the valve was worn out.






 Remembering how there was a small decoupling capacitor in the U319 VHF tuner, which caused issues, I removed the cover to this unit (a much easier job that the U319!!!)
But the decoupling caps are Eire types, and all read in very good condition...


So, after leaving the mains smoother on the reformer with all 3 sections in parallel, the leakage had dropped to a very low 50uA!  ESR was good too, so it was re-installed and connected up. So all in all, 1 valve and 9 capacitors, and we're ready to go! Connect to the safety mains isolation transformer, switch on ....






... and after a few minutes warm up time, the DM70 indicator tube lights, and the set performs well...








In common with most mains sets of the period, the metal chassis is connected straight to one side of our AC line (in normal practice, the neutral)... this is referred to as a "live chassis" (even if it is neutral) , which mean the shafts for the controls are also "live". Now, until a set of insulating knobs can be found, this set can only be safely operated though an isolation transformer.


I did locate a nice shiny set of plastic knobs at a dealer locally. Whilst the knobs are plastic, the shiny coating must be metallic, as they conduct very well! These will NOT be safe!







Anyways, here's some good-looking chap to explain the set to you!

Wednesday, 14 January 2015

Hello!

I'd like to say a big "Hello" to Nicu from Romania, who's taken the pond pump controller and added a DHT11 to it to make a weather station.

You can read more here:

http://nicuflorica.blogspot.ro/2015/01/ceas-rtc-cu-ds1307-si-date-mediu-cu.html

Sunday, 11 January 2015

Sony KV1320 UB MKI restoration.

This has to be the shortest restoration ever. I normally like a bit of a fight from my restorations! A few juicy faults, but not this one! Testament to the quality of late 60's Japanese Engineering.

Now back in the day, set manufacturers had to pay a license fee to Telefunken to use the PAL system, rumoured to be about £30 a set. Sony got around this by decoding the colour signal in a manner which didn't infringe Telefunken's patents. Sony used a modified NTSC decoder, which had an additional delay line, and the colour was repeated from the previously decoded line, reducing the colour resolution, but on such a small screen this isn't noticeable. Any problems with phase could be corrected with the provided hue control, which PAL receivers didn't have, nor need.

Most of these sets died due to being worn out. It is very rare to find one with a decent CRT in, so I wasn't hoping for much, and anyways I paid little money for it, and it's a KV-1320 MKI, a very early one, as several revisions were made.

Being an early model, it has a 3AT2 EHT rectifier valve, and has the CRT heaters permanently connected and warm (not good for CRT longevity!) , regardless of the mains switch position.

This one arrived dead. No tube heaters, nothing.





Opening the mains plug... and the fuse is open circuit!







Replacing that and great pictures!!



 A quick tweak to the frame height and centering


Sit down, and watch telly! A sticker on the chassis show the manufacturing date as June 1969! Fantastic tube which these pictures really don't do justice to.








This sticker is intriguing. Most sets in the UK of this vintage had "live" chassis working, that is one side of the chassis tied to the neutral of the supply, and this has a warning sticker to that effect, but the set doesn't have this! It's a fully isolated design!

Friday, 9 January 2015

Workshop video rack.

Whilst I don't get as much time as I'd like to "play tellys", the state of the workshop video sources has been plaguing me recently.

For those outside the UK, I'll explain a little. All TV transmissions in the UK are now digital. They're delivered in Band IV UHF.

In times gone by, there used to be a 405 line black and white only service (System A). This existed  from 1936 until 1984 and started out in Band I VHF, and then expanded into Band III when ITV started in 1955. 625 lines (System I) was introduced for the start of the BBC2 service in 1964, in UHF only (it went colour (PAL) in 1967, and all services moved to UHF 625, both in bands IV and V (Band V has now been flogged off to the mobile phone operators for 4G etc.) )

Now, to run my old tellys we need to generate at least some of these signals. The UHF 625 line colour stuff is easy, just get a DVB receiver (Freeview) with a modulator built in. 405 lines is a little more tricky, but thankfully there exists a small box called an Aurora, which is a 625 line to 405 converter (there are other types available too, to convert between almost anything!)  with a built in VHF modulator. It's superb. Auroras (Auroae?) can be found here. If you are inside the EU, you can order them from Crowthorne tubes here.

The big problem is this motly collection  of boxes and power  supplies, the odd DVD player etc, has just been jury rigged as required. Not a satisfactory situation.

So, I designed myself a little rack to house it all.





 All connections are made on the front panel. This is a workshop piece of equipment, and you don't want to go fiddling around the back. The signal from our aerial (with our digital TV signal on) feeds the top Belling Lee socket, this is passed to a "4G" filter to remove any signals from band V. The RF then feeds the two freeview boxes and the outputs from these (in Band V) are mixed and sent to the mixer in a UHF modulator. The band I output from the Aurora standards converter feeds an attenuator (it's output is hot!) and a low pass filter, this is then combined with the UHF RF and passed (finally!) to the lower Belling Lee locket for connection to the set or sets.





Video to the standards converter is switchable from nothing (which causes the Aurora to output test card C), the Aux input sockets on the front, the DVD or either freeview receivers. Video to the UHF modulator can be switched from the Aux sockets or the DVD player (The freeview is already modulated)





 Much neater and I'm rather pleased with how it's all come out.











I've subsequently added a small Sumvision Cyclone media player to the set up, which is great for playing video files and test cards from a USB memory stick.