Sunday 25 August 2019

The return of Arch Enemy no. 38

DOCUMENTATION.

Like this but PDF.


If ODOTS is to be successful it is a fact of the universe that 'self documenting code' and 'straightforward hardware' are not going to cut it. Not only is explicit recording of all code and components required but an explanation of the various interfaces in the project is also going to be needed to make sure the ODOTS makes sense to a prospective user/builder.

What am I looking for in the Documentation of the ODOTS?

  1. Enough information for someone to build and use it from scratch.
  2. Enough information for someone to poke around with the design.
  3. Enough information for me to return to the design and still know what is going on.
If the ODOTS is to become community developed a solid baseline design is essential. Building extras is easier when the foundation is not made of sludge!

So you may notice that the ODOTS is not actually finished yet, so any documentation written cannot possibly be correct. This is true, there is currently a lull in the design work: I have finished the firmware and now need to move onto a basic making a basic PC based interface and putting together the final proof of concept hardware design. The interface will manage ODOTS checkpoint unit configuration and handle competitor information sorting and retrieving from cards. (I really don't intend to put much more than bare bones functionality into it.) Back to the original point, this lull provides the perfect opportunity to record work so far and tighten up some functionality definitions from random scribblings on my desk.

I have suffered defeat at the hands of Arch Enemy no. 38 before, each time the horror of having to look at your own work and find it indecipherable is enough to make you say 'next time, next time'. Incidentally the Enemy can strike within a single project, recently the Engineers Flat effort to make a custom Robot Wars Control PCB was derailed when we forgot to write down the sequence of resets required to successfully flash the micro controller we were using.

The good news is that there is nothing truly complicated (after development) about the ODOTS so the documentation has so far gone without a problem!

Monday 19 August 2019

The ODOTS test bed - an example of approximate perfection

HAHA - something that works! (maybe)

So - an exciting day, all individual components have been tested individually. The RFID unit has successfully read and written from both MIFARE 1k and 4k cards, the clock has kept time and had its time set, the buzzer has buzzed and the Microcontroller has sat though it all tolerating my antics. Special mention to the 200mm Telescope which donated one of its off-cuts to the testbed as a back board.

The test bed is really about getting everything together in one place so that it can be worked on as a piece. As mentioned earlier all individual components have been tested to the project from here on out is really about putting it all together, using the clock to generate data to be stored on the card, using the buzzer (and soon to come LED) to indicate to the user operational behaviour and finally building in the magic serial to computer interface that will allow each ODOTS checkpoint device to have its time re-calibrated, its function defined and its ID set.

At this point in the project I have a month and a half (if you squint) before my self imposed deadline which is good as if I can get major functionality done this week I will have a month of poking around, testing (and breaking) before a test-with-public at the end of September and a write up with tutorials by the end of the year. This probably means that it is a good time to look at how the project is tracking against its original objectives. For reference the requirements stated were:

  1. Have 100 competitors on a 20 checkpoint course for under £500.
  2. Ensure top level designs and software are straightforward and accessible.
  3. From a performance standpoint checkpoint registrations should ideally take <20ms at a range of under 0.5m, while competitors should have the ability to record as many checkpoints as possible. Orienteers, being used to current timing systems, will also require the checkpoint registration times to also be recorded to around centi-second accuracy over a course that could take 24 hours!
  4. From a safety standpoint it would also be helpful if checkpoints remember who has visited them as this can help with search and rescue (if needed).
  5. From an operational standpoint the entire system should still work if it has been submerged for a while in a nice wet bog.
The engineer requires that I address these in the simplest way possible, point by point ("Yes" may be a bit too brief).
  1. Cost analysis (a very exciting spread sheet) currently predicts ~£18 per Checkpoint unit (for the proof of concept) and <£1 per competitor recording card. 20x£18 + 100x£1  £500, so this is probably an achievable goal so far.
  2. Arduino libraries are brilliant at keeping you from getting too bogged down in detail, which is generally when the unreadable spaghetti appears. So far the code has been written with the utmost effort to keep relevant variables and constants centralised and accessible. The top level Arduino sketch is currently looking like psuedo-code (because it almost is) but there should be no reason for this to break down. Source code has been split down into device specific headers, or general ODOTS functionality. The proof of concept will be built with through-hole, and widely available, components making it easily replicatable by someone with little specialised tooling or expertise.
  3. Very straightforward functional requirements, these will all be met. Choosing the MIFARE standard gives access to 1-4kbytes of storage (100s of controls) with an RF interface that can generally conclude an exchange within 10-20ms at close range. Engimancy with the clock will allow millisecond precision of timing for the same unit and close to that between units, laziness more than anything else limits the available time frame, the clock has records of the current century if needed!
  4. This is the only objective that may be bent, memory is at a premium in the AtMega chips, unfortunately this feature may have to wait until the system is made slightly more professional.
  5. Lunchboxes and a contactless interface are acting fairly well to keep the entire design pretty easy to keep waterproof. 
Other than final integration big tasks looming on the horizon are dealing with the power situation (especially for the RTC, I am thinking a coin cell hiding behind a diode...) and actually developing my ideas about the enclosure. Also trying to make sure that any user is able to handle the built product intuitively will be good to do. Making an interface for setting Card and Checkpoint IDs as well as changing Checkpoint unit function which is simple as possible with an eye for starting to get it to run on minimalist extra hardware will be a must at some point.

An updated logo, I realised that the antenna is too good
a shape to not include!




Thursday 15 August 2019

Time to think about time....

With the RFID system on a postal adventure for the next few days I decided to give some thought to the T of ODOTS. (It is indeed, T time...)


As a timing system the ODOTS will need to be able to accurately (and to an extent, precisely) track the time at each of the recording stations. The microcontroller unit has the ability to track time to an extent by looking at its own clock (digital signal clock, a simple oscillator) but these tend to be rather inaccurate (because they don't need to be) and also loose track of time when you pull the plug. 

This is where an external clock chip comes in handy both having dedicated hardware ensuring that it is keeping time well, and the ability to run on a very small power supply, allowing it to be powered with a small coin cell while the rest of the system is having a plug-pull induced nap. As mentioned in the last post the proof of concept system is staying in DIP land to reduce required soldering complexity/need for PCBs, on top of this requirement I also wanted the chip to require a minimum of external components. Luckily the handiest chip to use is Maxim's DS1337(+) a brilliant little chip that not only satisfies my generational requirement to meme, but also already has drivers written for it (though I only learned this after getting halfway through writing my own).

Choosing the RTC with the power of 1337.
RTC (Real Time Clock) time will be synchronised with a computer, probably during initial setup and then periodically by some sort of Tech Wiz (capitals necessary), while the microcontroller will periodically re-align its own time estimate with the RTC's during operation. Ideally the update timing slack will be less than 10ms (about the maximum precision I could really expect from the RFID system). The RTC can generate interrupts on second boundaries (effectively showing the 0ms point for that second) which I will be exploiting to allow the Microcontroller to gain some sort of sub-second accuracy. 

The frequency of RTC referrals is interesting, ideally I want to keep the interval small (to prevent inaccuracy buildup), but not so small that referring to the RTC is the only thing the MCU has any time time to do. Initially I had thought 10 minutes would be good, but this would require the Microcontroller to set the next interrupt time after each referral, increasing the time each refferal takes. However, the RTC has inbuilt repeating alarm abilities, once every unit of time (once a second, once a minute e.c.t.) for the time being I will attempt to use the once a minute interrupt to see if this noticeably impacts performance for users. That throws as many 'this is going to cause more work in the future' flags as I have seen but oh well....

Wednesday 14 August 2019

Standard Struggle (or how I learned to stop worrying and love NXP)

Part of the ODOTS project is about tackling the problems that other people wont want to, and I think that I have taken a month to do just that. Today I finally admitted defeat to NXP - if I want the ODOTS competitor timing cad to be a MIFARE device (which I do, they are ubiquitous, diverse and likely to be around for a while) I am going to need to use their Reader/Writer ICs. The bit that finally pushed me over the edge was the realisation that not using an NXP chip was going to doom me to having to run the authentication and encryption on the Micro-controller. A day of searching for a friendly application note/datasheet/tutorial showed up nothing.

Up to this point I had mostly worked out the firmware for the CR95HF (from ST Micro) up to the ISO14443a layer and was feeling like I was understanding how it all hung together (a good indication that you are about 10% of the way there). Unfortunately while the CR95HF is MIFARE Classic compliant it requires encryption and authentication to be handled by the host (the micro-controller), while NXP chips will take the bulk of the work off you conveniently meaning the task of encryption and authentication are not often tackled by the sorts of people that will leave behind handy code libraries and examples. Thus I could continue to try and write code to run MIFARE tags through the CR95HF, but it would be a significant piece of work with little benefit (in the short term) over just using an NXP device.

The beaten track beckons, so I am flipping into complete Arduino-friendly mode and using the MRFC522 chip that has a development board that has been mass produced to the point that you can pick them up for £5 from mystery-meat ebay and amazon sellers. My development article is coming from a more reputable source in the hope that it allows me to avoid the classic block-of-resin-with-solder-pads knockoff syndrome! With all RF and surface mount components handled by the wonder board most other components are going to be possible to do with through hole components (or DIP) - for that sweet sweet 90s look. this will also make it more straightforward to prototype and 'mass' produce proof of concept timing units for demonstrations. Naturally as the likelihood of the ODOTS actually being used goes up the more and more it will approach a single PCB, all surface mount, state. Additionally using a shady source RF board may make it tricky to prove that the device is not producing large amounts of EMI - so it will need to be replaced at some point.

Astro Meandering

It has been a while since my last astronomy post, having to spend all night studying tends to reduce sky watching activities. There have been several developments however.

The 200mm telescope has proved itself as a semi portable device, it was successfully dismantled and transported to Scotland by car where it was reconstructed with no ill effects. The de/construction process takes about 15 minutes and appears with not really change the required mirror tilts for columnation. The telescope was not actually used up there ( :( ) as Scotland in summer only really gets dark in the morning and the trip to Scotland was actually for an Orienteering carnival - something that generally requires the maximum amount of sleep possible!

One deconstruction/construction cycle later and the scope is now working back down south. I took it out for a quick test last night, the forecast promising clear sky and the moon offering a good target for finder alignment and focus testing. Of course the forecast did not include the predictable appearance of thin high altitude clouds after such a warm day so I only got to looking at the moon and a brief look at Andromeda before everything became obscured.

With a nice full(ish) moon I also had the opportunity to  test out my new phone's camera and the darkening filter I have had in my eyepiece box forever. I have put the nicest photos below, but be warned my skills are still low, I have yet to get the exposure settings right, and I really need to come up with a way of holding the phone that is not my hands so that I can fix the positioning of the camera aperture. There is however a marked improvement over using my old phone (not surprising) or the mighty 76 millimeters of the Drinking Straw, though I think the latter is more to do with mow much more stable the 200mm's mount is!
A full moon in a single image, showing some nice detail on the terminator (to the left).

No Moon-photograph session is complete without a photo of Tycho Crater.

Monday 5 August 2019

ODOTS, the nitty gritty

Yesterday I posted about the next project lined up, the Open Design Orienteering Timing System - today I will attempt to go into a bit more depth about what I have done so far, including design choices.
The orange and white checkpoint flag hides, trying to ignore the now well trodden path that leads directly towards it...

To start off the entire system will just be a big RFID network, Orienteers will travel between RFID read/Writers collecting their ID's and timestamps which can then be used to determine who completed the course the fastest. Therefore the RFID stations need to be able to both read cards (to detect them) and then write to them, ideally in a short enough time span that the user does not notice. The first step in this project was to decide on a broad RFID standard that will provide this capability and have widely available components (and compatible tags).

RFID has a wide variety of implementations and the first discriminator is operating frequency. Lower frequencies (such as 125kHz) do not provide sufficient read/write capability (or memory) and are also on the verge of becoming antiquated (HITAG, NXP's standard for this frequency had its last update in 2007). Age could be seen as a boon, the technology is proven, however there is a risk that the ICs will stop being manufactured (not brilliant for availability) and there have been dramatic improvements in communication protocols in the recent past that newer technology will have been able to leverage.

Higher frequencies come with their own problems. RF design becomes harder, which would be an issue if I was to try and start designing my own PCB's. Another issue is that higher frequency spectrum becomes useful for other things too, there are increasing numbers of users all competing for spectrum access, interfering with each other or operating in protected bandwidth.

Therefore 13MHz RFID is a good compromise. The 13MHz standards are currently receiving a lot of love (NFC, contactless payments) and will therefore probably have supporting ICs around for the foreseeable future. 13MHz RF design is hard but not impossible/evil. 13MHz also means that we will have to try hard to become spectrally abusive, power output will be limited by the fact that any antenna we make cannot be well matched to a signal that has a wavelength of 10m. A quick look at the OFCOM band map shows that there are users of this spectrum, however there is specific spectrum usage set aside for Inductive Applications (aka Near Field Communications) and the other users are tolerant enough/wideband enough that the restrictions are not too bad - official testing may be required if the ODOTS were ever to go into widespread usage.

Again NXP loom large in the 13MHz protocol lists their NTAG and MIFARE standards form a large portion of the compliance advertisements for cards and transceivers. To be a rebellious engineer I immediately looked beyond NXP for my RFID chip, in the hope that a separate manufacturer would also be able to cater for non NXP communications if needed. In walks ST Microelectonics with their development boarded CR95HF. This strays off the beaten arduino-compatible path (which about sums up most of my software work so far), but has good higher level drivers - when I can get the basics working. ST Micro are also releasing some very tasty IC designs with capacitive (passive) tag detection. These will be a prime target for upgrading to in a couple of years time if the ODOTS works!
Don't worry LM741 - the fancy RF/digital chips will never have your charm.
I have just mentioned Arduino, so that probably gives my Microcontroller game away. I have opted for an ATMEGA to allow me to sneakily use the Arduino bootloader and maintain compatibility with the beginner friendly Arduino IDE. For all the embedded engineers currently crying about the injustice of it all the 'under the hood' code is written far more practically to ensure that is can fit in the ATMEGAs resources. Using the nice friendly IDE for the top level embedded software will hopefully mean that it remains accessible to anyone who wants to have a poke around. Additionally it will allow me to rely on the many tutorials on how to burn in the bootloader/program for when other people try to use my designs.
The legendary MSP430 got a brief consideration (Energia is nice), but unfortunately it just does not have quite enough memory.
Finally I have given some though to other parts of the design, using the ATMEGA is likely going to mean my Vpp will be 5V - pushing Lithium Ion batteries out of the window, luckily 9V batteries are a thing and if I can come up with a nice openable/resealable enclosure replacing them should not be too difficult. Real time clock options have been glanced at briefly, it looks like I may have to put multiple devices on the same SPI bus which would be really cool to do! The actual user interface is something that also needs to be thought about at this point too - the checkpoint interface is pretty simple but the data needs to be read off the card somehow. Luckily if I am using the ATMEGA chips I can 'just add USB ports' and have a RFID tag's contents read and spat off into a computer for displaying/recording.

Sunday 4 August 2019

The Open Design Orienteering Timing System

Uni finished, the next step not yet begun - obviously time for a large project. I have been kicking around the idea of building a custom timing system for orienteering for a number of years, but I finally got around to setting aside some time and (possibly just as importantly) asking the Orienteering Foundation for funds to go off and buy development and evaluation hardware.

What is the aim of this project? To build a proof of concept low cost open design electronic timing system for  use in orienteering training and small events. For those unfamiliar with the sport an Orienteering race is effectively a cross country race with no streamers showing you where to go - so you have to use a map instead. Thus it becomes a challenge of navigating between checkpoints as fast a possible. 

An example course and map, around the southern side of the University of Bristol campus

Validation systems to ensure competitors actually visit all checkpoints or controls are essential in any races with any sort of stakes. While this used to be achieved with pin punches and bits of card, modern orienteering will use high performance electronic timing systems wherever possible. To newcomers this can often be a very good advertisement of our capabilities ad worthiness as a sport. Unfortunately the current solutions for electronic timing are incredibly expensive which poses issues for clubs starting up or clubs looking to deploy their timing systems in areas prone to theft. Therefore I have the grand plan of building the design (and software) for a low cost electronic timing system. The low cost will reduce the barriers that new clubs can face, while keeping the design open and accessible will allow contributions from other members of the orienteering community to change the capabilities of the system to their requirements.

The final goals are:
  • Have 100 competitors on a 20 checkpoint course for under £500.
  • Ensure top level designs and software are straightforward and accessible.
  • From a performance standpoint checkpoint registrations should ideally take <20ms at a range of under 0.5m, while competitors should have the ability to record as many checkpoints as possible. Orienteers, being used to current timing systems, will also require the checkpoint registration times to also be recorded to around centi-second accuracy over a course that could take 24 hours!
  • From a safety standpoint it would also be helpful if checkpoints remember who has visited them as this can help with search and rescue (if needed).
  • From an operational standpoint the entire system should still work if it has been submerged for a while in a nice wet bog.

To hit these goals 13MHz RFID communications work quite well, allowing competitors to carry around a couple of kilobytes of read/write memory in fairly weather proof packages while also allowing fast communication times on protocols that are likely to last for another decade or so (at least). So far I have been working with the CR95HF chip from ST Micro, which is multi-protocol and also has some ST written drivers for using it to talk to NFC cards which is pretty useful. I expect that eventually I will have to specify more stringent RFID tag requirements for compatibility (as in possibly a specific set of MIFARE standards) as supporting a wide range of tags looks to be beyond the abilities of the micro-controller being used. It also requires minimal external components for RF drivers which will be useful when I finally start thinking about PCBs.

Using an Arduino compatible chip is also good, as writing the top level code in the Arduino style will allow it to be read by beginners. Work over the past month trying to get the RFID drivers to compile onto the AtMega328 have shown me that the lower level 'under the hood' programming will be less friendly (just so that it can fit).

At some point I will also have to start thinking about timing tolerances and potentially Real Time Clocks, but for the moment all effort is being put towards getting the RFID systems to talk!

The most important part, a logo/icon for the ODOTS

An alternative name - and logo, I think I must have had the render settings set much lower for this one!
It is important to note that I enjoy using the current timing solutions a lot, which have been honed over a number of decades to provide reliable, painless timing with brilliant precision. Recent moves to contactless registrations have made passing through checkpoints very fluid and don't require any slowing down at all (brilliant if you are trying to live up to your internal image of running along like the the three hunters).