Category Archives: Project diary

A chronological blog about all sorts of projects that I am undertaking

The Hands

Surely the hands must be easy to sort out?

Unfortunately not!  Quite a few people have used these stepper motors, but I haven’t seen any that have beautiful hands (I’m talking about the pointers on clock dials).  Many old gauges did have beautiful hands – delicately-shaped blued steel needles with an elegant point and attractive flight.  I searched high and low for clock hands but couldn’t find anything I liked.

The steppers have a 1 mm shaft but standard clock hands are designed to fit standard quartz drives. There are several different standards: one of these has a ‘collet’ for the seconds hand that will push onto a shaft.  A seconds hand was the most promising because they are available in simple and delicate designs. Eventually I found a supplier that offered them in a range of lengths and could provide these separately from the other hands.

Of course, they don’t tell you the exact size of the shaft that the collet will fit,  and I found that this was slightly less than the 1 mm of my steppers. What to do?

I found that I couldn’t widen the collet with a point – there was a real risk of splitting it or breaking it away from the hand. On one of my many trips to Maplin, I found a pin vice (a sort of pen with a small drill chuck at the end) with a set of fine drills. Perfect! I could open out the collet just the right amount.

Next instalment – the Bezel

The Dials

The first thing that people see will be the dials.

They need to be beautiful. But also legible.  The problem with my brass plate is that the patterning, though beautiful, will tend to make both the gradations and the hands harder to see. I want to keep as much of the patterning as visible as possible whilst maintaining clarity.

You can buy brass or brass effect chapter rings from clock maker’s suppliers. These let you see the background of the dial except for the ring that carries the gradations. The ones available off the shelf are in a limited range of sizes and are numbered like a clock. If I could buy blank chapter rings, perhaps I could have them engraved?  Or I could make acetate prints of the scales and stick them onto the blank?

But I still need to be able to create the scale before I can print or engrave it.

I researched software to create dials (the correct name for a clock face) and found alternative names like gauge and scale, and that people had been very creative in using drawing packages for making beautiful dials. I even discovered a hobbyist interest in re-creating vintage aircraft and steam-engine gauges.

But although I was happy to spend a lot of time on making the dials, I didn’t want to spend time learning a professional-type drawing package. There is a lot of work in calculating the angular spacing and positioning of the tick-marks and lettering, and I would have to spend a lot more time finding a pleasing layout.

I found a clever product called “Gauge Face” that was free and which could create the circular dials that I wanted- including ones with zero at the top. But sadly the output was only at screen resolution and was hopelessly grainy for my dials. I wasn’t able to contact the developer to see if he had a high-res version.

So I trawled the Net again and found a product called Meter by Jim Tonne, of Tonne Software. This is a clever and adaptable product that uses vector drawing for the scales, thus avoiding the aliasing and scaling problems of raster drawing.  It does have one slight issue that is a problem for clock dials – the scale always starts at the bottom and increases clockwise (as far as I can see).

Neverthless it is by far the best that I have been able to find. I paid Jim the modest fee for the ‘professional’ version and l’m just learning what I can do with it.

How am I going to make the chapter rings?

I can’t allow the project to expand for ever, so rather than learn about engraving on brass, I’ve decided I will print them on glossy white card. Many (most?) classic clocks have white dials for a reason!

I’ve bought a device for cutting circles out of card – I think that perfectly circular dials are one of the essentials.

Next, I need to sort out the hands.

Thinking about the display

Now I knew that I could read the RSS feed, and what information it contained, I could start thinking about what to display, and how to do it.

The feed contains a great deal of information which can be summarised as: Weather type,  Maximum and Minimum Temperature, Sunrise, Sunset times, Wind Direction and Speed, Pressure, Humidity, UV risk, Pollution level, day of week and time of forecast.  Thirteen basic items of information.

I’d bought 6 stepper motors, and I’ve already mentioned that I’d bought a brass tray about 350 mm in diameter (13 3/4 inches).  However, it has a bevelled lip, so the flat, usable central part is only 280 mm (11 inches) in diameter.   With six dials and using each one for an ‘Upper’ and ‘Lower’ function I could display 12 of the 13 items in the forecast. I’m sure that I can drop a couple of these without much loss.

But how to arrange the six dials onto a circular plate?  I decided that the main dial would be the weather type (Sunny, Rainy, Cloudy, Snowy, etc) and that this should be half the diameter of the plate, so 140 mm (5 1/2 inches).  I decided that this should be at the top of the plate and the other five dials arranged around the bottom part of the plate.

A bit of work with Pythagoras showed that five dials each 75 mm in diameter (2 15/16 inches) would fit nicely.  There’s even a bit of space in the middle where the pattern on the plate is visible.

The next issue is how to make the dials or gauges. I will have a pointer or hand  that indicates the condition on the dial.  The brass plate, having quite a complex pattern on it, will make the hands hard to see,  but I thought that a ‘Chapter Ring’ would be nice – this is a ring that carries the gradations and legends around its outer edge, with a hole in the middle where the plate can be seen.

You can buy these for clocks, but obviously they are numbered 1 to 12 for the hours. I couldn’t see any blank chapter rings, they weren’t the right size and they were mainly aluminium.  I could use the back, but would still have to mark them in some way.  I saw that I could get some chapter rings etched but I would need to provide the artwork. Looking at a number of old clocks, most of the dials are either silver or white with a black scale.  So I could mark/print a scale on white paper/card: what mattered most was that the scale should look nice, and that means having a really professional way of printing it.

I searched and searched the Web, and have eventually found some software that will produce high-definition scales.  (There is a large hobby market in flight and other simulations but these are almost all on-screen simulators so they don’t need to print high-resolution hard copy gauges.)  I’m hoping to purchase the software soon.

Next installment – the casing

 

Writing the RSS Parser Code

I’d read that Python was easy to use. I don’t know what definition of ‘easy’ these writers are using. Just because they find it easy doesn’t mean that others will.

The problem is that when you start out, you don’t know how much functionality is built into the language. Moreover, each language uses its own terminology, which can make it hard to find the reference that you need.  Tutorials, of necessity, start with the fundamentals, but once you have some experience, you don’t need to be told what a variable is, for example.  Arrays are another matter.  They are extremely useful in many tasks, but they are implemented differently in the various languages that I know, so you have to know what is available and how it is used.

I felt sure that Python would be good at byte/string manipulation, because it is more likely to be used in text analysis than for engineering.

This turned out to be true.   You can have string variables of any length, although there is a complexity that when you read the RSS feed (using the urlopen().read() function) the result is a byte array and you have to convert it to a string using
doc.decode(encoding=’utf-8′)

I suppose this is reasonable when you think about it – Python receives an array of bytes that could mean anything, so you do need to say how to interpret it (although in fact a website feed should always start with a preamble declaring the encoding.)

I downloaded and printed out a few RSS feeds to see how they were structured.  They were all of the same format, although the structured varied slightly and the information differed according to the time of day and actual weather forecast.

I noticed that, being a well-structured feed, the information of interest was always enclosed in tags like <title>, </title>, <item>, </item>, <description>, </description>.

So, once I had got the web feed into an array (which could be rather long) then to parse it, I just had to search for the tags that identified the information I needed.

This turned out to be easy because there is a ‘find’ “method” for text strings. [I won’t go into the technicalities of “methods” here – you can treat them as ‘functions’ (operations you can perform on data).

All you need to do to find the tag ‘<title>’ is to use the find method, giving the starting point to search and it will tell you where this is.  You can then just extract the following information, because you can give the starting and ending position in the original string and assign this sub-string to a new variable.  Extremely powerful.

Following this approach, I got the basic RSS parser working in Python on my PC in about half a day. Then I copied it to the Pi.  Oh tusk! some of the syntax I’d used was for Python 2 and I had to reconfigure it to IDLE3/Python 3.

It works!

Next instalment – thinking about the display. Coming soon.

Getting the Raspberry Pi out of the box

I’ve had a Rasberry Pi model B2 on top of my wardrobe since January 2012, but I hadn’t been able to think of a use for it until now.  In particular, I had been reluctant to learn Python.  Perhaps the name had put me off, the same as I won’t drink beers with strange names such as Bladdablasta, on the basis that if it has to have a strange name to make you notice it, probably it’s not very good.

But first I’d better see if I can get the Pi working. I plugged it all in and it came up straight away.  My Eizo monitor has an HDMI input which I’m not using (I use the DisplayPort input for my PC) and I can just switch between the two computers with the monitor’s front panel button, so I can use the Pi and the PC simultaneously.

The first issue was that Eric (or do I mean IDLE?) was out of date.  You have to update it by copying the new IDLE from the Pi website onto a new SD card (never overwrite you old SD card in case the update goes wrong and you have to revert to the old one). There instructions for copying the new IDLE 3 from the Pi website.  I only had a 32 GB SD card in the drawer so I downloaded onto that using my PC and fast internet connection.  It took hours.  And then the Pi refused to boot from it.

When you go to the Pi website, the first thing they tell you is to reformat the SD card, which I had done, but I’d got some error message so I think the card wasn’t properly formatted, which may explain the really slow download.

So I bought a new 8 GB SD card and this time I didn’t try to format it. I decompressed the NOOBS software from the Pi website and copied it straight to the SD card.

I then put the card into the Pi, turned it on and it booted! After doing something (don’t ask me what) with the SD card, the Pi asked you to load Raspian Jessie.  This is the current version of the operating system. Then it tells you it will extract the OS and load it onto the SD card. This took another 30 minutes. I sat there wondering if it would be worth it.

The next problem is that there are (at least) two versions of Python. I decided that in the interests of future-proofing, I’d used the latest, Python 3. But since much of the sample code is written for Python 2, and it seems there are some comaptibility issues, I anticipate that there will be trouble ahead.

Next Instalment – writing the RSS  Parser Code.

How do you use an Arduino’s Wifi?

It seems that the most common application for Arduino WiFi is as a web-server. The idea is that the Arduino acts as the interface to some measuring device or other thing that you want to control from the internet.

However, it is less clear how to use it as a ‘Client’, where the Arduino downloads information from the internet and then processes it.

The Arduino does not have an Operating System apart from a ‘Bootloader’ which loads programs from an external source, such as a PC, and then runs them. All the hardware must be driven by software/firmware that you upload to the Arduino yourself. Once uploaded, the Arduino runs the software/firmware to perform the functions you have designed.

Few programmers know anything about the ‘low-level’ coding of the actual hardware.  PC programmers expect their computers to have ‘drivers’ that handle the complexities of communicating with the actual hardware.  But the Arduino lacks the memory and processing power needed by this approach.

Fortunately, there are many libraries of free ‘utility’ software for controlling the Arduino’s hardware and for communicating with the Arduino.

Unfortunately, many of these libraries are badly documented so it is unclear which are the most appropriate for a particular application, and particularly how to use them. Even worse, they exist in many different versions according to the exact model of Arduino that you have (and there are very many different models), meaning that often they don’t work and you have no idea why. To make matters worse, the libraries are updated frequently, so examples of how to do things are often out of date. Check the date of any post and be wary of anything that is several years old.

I managed to get the Arduino Uno Wifi to work as a web server and as a web client once I realised that I had to update the IDE from 1.6.5 to 1.7.10.

I could communicate from my PC, but this needed several libraries to be loaded. Also, I loaded the stepper class library to drive the stepper gauge motors that had just arrived.  The steppers worked!

I got rather bothered when I found out that the library for the WiFi drivers was apparently incomplete and also that the WiFi library took up a large part of the available memory, leaving little room for anything else. I was advised on one of the forums that I might need to program the WiFi chip manually.  I can see how this would save space, because I would need quite a lot of memory to parse the RSS feed, but I have done hand-coding of UARTs in the past and having been there and got the T-shirt, I had no desire to return!  I started reading how you could store data in the EEPROM, but this had to a done a byte at a time, so again this looked like a huge learning curve.

Yes, it would be within my capability to do it, but I had no desire to emulate the man who was asked why he was hitting himself on the head with a hammer: he replied that it was so nice when he stopped.

My objective was to make a device, not to develop a skill that I’d never be likely to use again.

Then I realised that I had a Raspberry Pi on top of my wardrobe. I’d bought it on a whim and apart from testing to see if it worked, I’d never used it.

I knew it had a proper Unix/Linux-type operating system called Raspbian – I had some experience with Unix and SunOs from ‘the old days’.  Moreover, it had a reasonable processor, lots of memory (on SD card), properly-implemented WiFi (using a plug-in USB dongle) and a decent array of GPIO pins (though not as good as the Arduino).

There is even an on-board development environment called IDLE One downside is that the main programming is Python, which I don’t have the faintest idea about, other than the allusions to the TV series are intentional!

The makers of the Raspberry Pi are clearly addicted to bad puns.

Next instalment to come – getting the Rasberry Pi out of its box.