Monday, October 16, 2017

Paradise ponders: C programming and compressed air edition...

Paradise ponders: C programming and compressed air edition...  Debbie and I took a beautiful drive yesterday morning up Blacksmith Fork Canyon.  We saw a dozen or so deer – all fat and healthy looking, ready for the privations of winter – and the tail end of the fall color.  It's elk season, and there were hunters all over the place.  Some of them (a minority, thankfully) park along the side of the road and set up what is basically an ambush at the side of a field where an elk might come to forage.  On one stretch of such an ambush, about 50' wide, I counted eleven hunters.  Each had their binoculars up, searching for some elk to poke its head out.  There were four other such ambushes along the edges of the same field, though the others weren't quite so large.  Still, if an elk was dumb enough to stride out onto that field, probably over a dozen rifles would be shooting at it.  I wonder how they decide whose “kill” it is in a situation like that?  We also saw some beautiful effects of the cold weather (it was 15°F where the photos below were taken), around waterfalls and rapids.  The combination of low temperatures and high humidity meant that the fine spray thrown up by the tumbling water stayed in the air as a liquid (or ice crystal) for much longer than usual.  This produced wonderful “steam” effects, and also ice-coated twigs and grasses.  A few photos of some of the better ones:


We also ran a few chores, but for much of the remaining day, and also today, I've been programming in C again.  I greatly expanded the simple little program I wrote about in my previous post, to give me all the functions I could imagine needing for my NTP server.  I've also modularized it in a way that will make it relatively easy to add new features, should I need to.  I'm finding that I quite enjoy the process of programming in C.  It's a far simpler, smaller language that the Java and JavaScript world I've spent the last twenty years in; in that sense it's easier and cleaner.  On the other hand, some things that are easy to do in Java/JavaScript (mainly because of the ubiquitous high quality, well documented libraries) are much harder to do in C.  Then there's the fact that C is fairly close to the hardware and the operating system – not quite as close as assembly, but not too darned far from it.  I like that; it plays to my hardware background and my desire to tinker with little embedded systems (like the NTP server and my irrigation supervisor).  One thing I've come to realize: it's pretty easy to meld the two languages for everything (or nearly so) that I might want to do: I can handle the low-level, close-to-the-hardware stuff in C (where Java either couldn't do it, or would have trouble doing so), and I can run those C “helpers” as a child process under Java.  That's both easy and clean.  I'm doing a test project of that general architecture right now: to let a Java program interpret the NMEA protocol output of the GPS on my NTP server.  A little C program will echo that NMEA data to stdout, and my Java program will run that as a child process and consume its output.  Simple!  But Java couldn't do it on its own...

Our sprinkler contractor showed up this morning, towing a huge air compressor behind his pickup.  He used this compressor to blow all the water out of our underground sprinkler lines, so that when they freeze this winter (as they surely shall), it won't damage any of the system.  The photo at right shows what it looked like as he blew out one zone in our back yard.  The noise as he did this was quite impressive, and full of bass notes that I wouldn't have expected from rapidly moving air...

Saturday, October 14, 2017

Paradise ponders: NTP adventures and old friends edition...

Paradise ponders: NTP adventures and old friends edition...  Debbie and I are both feeling a bit better today, but wimpy as heck.  Debbie's fever seems to have broken last night, and her voice is back.  I can tell she's feeling much better because she did the cat chores today, much to the delight of our feline contingent!

Last night our forecast called for snow, but we didn't get any.  We did get just a bit of a kind of fine-grained hail (photo at right), along with (I'm guessing) about a tenth inch of rain before the temperature dipped below freezing.

I got a real surprise yesterday: a colleague and friend, Ron N., from over ten years ago contacted me out of the blue.  I'm not quite sure how he located me, but he left a comment on my blog and then the two of us got together on email.  It's been interesting to catch up with him, though obviously we've got a lot more to do of that!  He tells me he'd like to come up here to visit sometime next year, which would be really fun...

Most of yesterday and this morning I've been consumed with trying to fix a problem with my NTP project: configuring the GPS to be in stationary mode, wherein it assumes the antenna is not moving.  This translates into more accurate time measurement (more on that below).  The problem I started out with was that the directions I was following for setting up my NTP server included a link to a program that just plain didn't work.  The specific problem was that the program hung when it tried to open the serial port for reading and writing.  I troubleshot it for several hours, but finally gave up because I didn't understand how it could ever work in the first place.

So I decided to write my own program instead.  That meant that I had to understand the rather complex communications protocol that the GPS chip manufacturer uses for the functions I needed, as they're implemented in a proprietary “UBX” protocol.  Then I had to dust off my (extremely) rusty C programming skills – the last time I wrote a complete C program was around 1983 (seriously!).  I've done lots of work since then in C++ and Java, but not in C – and if you're a C programmer, you know it's changed a lot since the '80s!  Finally, I had to learn something completely new to me: serial port programming on Linux. I did the development work on a Raspberry Pi, where the only development tools I had was gcc (the Gnu compiler) and nano (a text editor).  Somehow I managed to get my little program working, which, I have to tell you, was a very satisfying thing indeed – validation, of a sort, that I might have more than two or three little grey cells still working.  If you're geekly enough to be interested, here's my satisfying little program.

A couple of my readers wanted to know what the heck a GPS receiver has to do with keeping good time on my network.  If you don't know anything about how GPS actually works, I can imagine this is really quite puzzling!  The first thing you need to know is that each GPS satellite has an incredibly accurate atomic clock in it.  There are over 50 of these satellites in four separate systems (the US, Russia, China, and Europe each have their own independent system), so there are a lot of these awesomely precise clocks flying around.  The GPS receiver I'm using can listen to all four systems, and at any given moment it likely has 10 or 12 satellites “in view” (meaning that it can hear their signals). Once my receiver can “hear” at least four satellites, it can tell the time very precisely indeed.  In fact, its accuracy is very nearly that of an atomic clock, as if I owned one of these (very expensive!) things.  All that with a $39 GPS receiver and a $29 antenna!

With the success of my little program, I've now got my stratum 1 NTP server up and running.  It's working great, passing all the tests I can throw at it.  Now the only things left to do are to mount the antenna on my barn's roof (that might be a challenge!) and to make a case for the Raspberry Pi.  I've already got it in use on my network, though – even with the antenna just pointed out of a window in my office, it's much more accurate than any NTP server I can access over the Internet...

Thursday, October 12, 2017

Paradise ponders: finishing touches and beginnings...

Paradise ponders: finishing touches and beginnings...  I woke up this morning feeling pretty lousy – mainly because I was running a fever – but by the end of the day my temperature was nearly normal, and I was feeling ok.  Debbie is continuing to get better as well.

Today the special battery arrived for the alarm panel (part of the much-bigger-than-expected gate sensor project).  This was the last piece I needed to complete the whole project.  I installed it, expecting instant gratification, but I still was getting a low battery alarm.  Dang!  On the off chance that the battery wasn't shipped fully charged, I decided to wait a few hours before troubleshooting.  Glad I did!  About two hours after I installed the battery, my low battery alarm went away.  Yay!  Everything is now working properly – quite a relief after all the trials and tribulations it took to get the right parts.  Now I have a new skill: programming Ademco/Honeywell alarm panels.  For a geek, that's roughly the equivalent of an auto mechanic understanding how to rebuild a 1927 Ford's engine – interesting, possibly even cool, but pretty much worthless in the real world.

I also got started on my stratum 1 NTP server project, mentioned in an earlier post.  I configured a new Raspberry Pi 3b to run as a standalone server, then followed these directions to get a GPS receiver working and configured as an NTP server referencing the PPS signal put out by the GPS board.  That's all working, more or less on the first try, much to my amazement.  I'm having some trouble at the moment with a little detail: configuring the GPS board as a stationary GPS device, rather than a portable one.  In the stationary mode, the timing output is even more accurate, and it will collect a long-term average of its position that's more accurate than the usual GPS mode.  That little detail, plus mounting the antenna on the roof, is all I have left to get my stratum 1 NTP server into a usable state.  I'm going to make a wooden case for it as well, but obviously that doesn't affect its function...

Wednesday, October 11, 2017

Paradise ponders: urgent care edition...

Paradise ponders: urgent care edition...  Well, this morning it was back to the urgent care again.  Debbie's existing symptoms got even worse – especially her coughing and sore throat.  On top of that, she's developed an eye infection, and when she woke up this morning she could hardly open her eyes for all the gunk that had showed up.  We saw a different doctor this time, just as competent and nice as the last one.  This time, though, the treatment was more aggressive, mainly because the symptoms had worsened.  She got a chest X-ray (that ruled out pneumonia), a treatment on the nebulizer machine (to clear up her lungs), a steroid injection (to quickly clear up her lungs), and a whole shopping bag full of meds to attack the eye infection, the cough, and the clogged up lungs.  I'm writing this a few hours after we got home, and she's already feeling better.  Let's hope this trajectory continues!

Yesterday I installed the last major bit of my wireless gate sensor project: an RF repeater to extend the range enough to allow the furthest gate from the house to work.  I put it in my cedar shed pump house, and it all worked right away.  Imagine that!  Now all that's left is to mount the two gate sensors onto the gates that have yet to be repaired, and then that project is completely finished.

A few minutes ago, one of our neighbors brought over a big container of homemade chicken soup, a repeat from a couple days ago.  This stuff tastes really good to Debbie, and it's one of the few things she can reliably hold down, so this gesture is much appreciated.  What a great community to live in!

Monday, October 9, 2017

Paradise ponders: creeping crud and remote gate sensing edition...

Paradise ponders: creeping crud and remote gate sensing edition...  Poor Debbie is laid pretty low with some virus she most likely caught on her travels.   I took her to our local Urgent Care facility yesterday just to make sure it wasn't something truly awful.  The doc said it's just your usual virus, gave her a prescription for some codeine-based cough suppressant (seems to be working ok), and a backup prescription for antibiotics in case it was something more than a virus.  The doc practically begged us not to use the antibiotics, but to save us a possible second trip he gave us the prescription anyway, once he was sure that we understood his pleas.  From the manner of his delivery, I'm guessing that many people don't realize that (a) antibiotics are completely ineffective against viruses, and (b) that taking antibiotics when they're not needed has some undesirable effects.  You'd think by now, almost 100 years into a good understanding of viruses versus bacteria, that these things would be more generally known.  Apparently not...

In between caring for Debbie and the animals I've been working away on the remote gate sensing project.  Today I got the Tuxedo panel, the RF receiver, and the alarm panel all installed and working.  Furthermore, I got three of the five gate sensor installed and also working.  Woo hoo!  The remaining two gate sensors have to wait until my contractor has fixed the two gates they're going onto.  The only thing I have left to do is some caulking and painting of the cables running along the outside wall, which, weather permitting, I will do tomorrow.

Meanwhile, here's what the visible components of the system look like.  The first photo is the Tuxedo panel, which is installed in our kitchen, right alongside the door we use to let the dogs into the back yard.  It looks a bit like an iPad mounted on the wall.  The screen turns off after a few minutes of disuse, leaving a bland plastic slab visible – not exactly beautiful, but at least not obnoxious.  A touch to the screen lights it up again, at which point that green bar across the top means “All gates are closed!”   If that bar turns orange, one or more gates is open.  In that case, a couple of click on the touch screen will show the open gates, by name.  The second photo is the RF receiver, which I've mounted in the kitchen just above the aforementioned door.  It's particularly unobtrusive – you'd have to have an unusually observant person to even notice it was there.


An inquiring reader wants to know...

An inquiring reader wants to know: what's it like for one who drinks alcohol to live in one of the states most restrictive about selling alcoholic beverages?  For those who don't know: in Utah one can only purchase packaged alcoholic beverages at a State Liquor Store.  There's one twelve miles from our home, in Logan.  An alcoholic beverage is apparently defined as anything containing more than 3.2% alcohol, because “3.2 beer” is sold in every grocery store.  You can also buy alcohol at bars (which we never go to) or in restaurants who have obtained a liquor license and who obey the rather arcane rules surrounding serving food and alcohol together in Utah.  It is illegal to ship alcoholic beverages into Utah, so we can't use online vendors like this.

Between the two of us, Debbie and I drink wine, beer, and scotch, all in small quantities.  We like to get “the good stuff”; it's one of the perks of retiring with enough money to afford it.  So how has living in such a restrictive state affected us?  Bottom line: hardly at all, and certainly not to the degree we expected it to.  Mainly this is because the State Liquor Stores actually carry a rather nice selection of the beverages we enjoy – better, in fact, than most of the retail outlets we knew best in San Diego.  There's one particular location (in Salt Lake City, of course) with an especially good wine selection.  Our local store's wine selection is decent, too.  All the locations seem to carry a broad selection of top-drawer single malt Scotch.  And all the locations also carry a wide variety of the craft beers that Debbie loves – including some from local craft breweries (mainly in Salt Lake City).

About the main effect we've actually been impacted by is being sawed off from the online vendors.  That we really do miss.  There's a fairly easy workaround we haven't yet employed: we could obtain a PO box from a place like Mail Boxes, Etc. in a nearby Idaho town, and have it shipped there.  It would be about an hour's round trip to go retrieve it.  We haven't been so motivated yet, though that's still a distinct possibility...

Paradise ponders: missions to space...

Paradise ponders: missions to space...  I'm sitting here this morning watching the live webcast of the latest SpaceX Falcon 9 launch, on my laptop in my kitchen (screenshot at right).  Watching this got me to remembering the first such launch I followed: the launch of Vanguard 1, on March 17, 1958.  I didn't see this on television; I listened to it on my crystal radio, the one my dad helped me build.  After that, every chance I got I listened to (on radio), watched (on television), and read (in science related magazines) everything I could, up through the Apollo moon missions.  Much of the detailed information about those missions came from books and magazines published long after the actual launch.

Now fast-forward nearly 60 years, and here I am in my kitchen.  I'm watching a high-fidelity, realtime presentation on the SpaceX launch, on my laptop computer.  It's connected by WiFi to the Internet, which is how the video is being sent to me.  It's in hi-fidelity, full-color, with great audio.  There is realtime video from the launch pad, from the first stage, from the second stage, and from the drone ship where the first stage will attempt to land.

It's a few minutes since I wrote the above paragraph, and now the first stage has successfully landed on the drone ship.  The second stage is in parking orbit, preparing to transition to a higher orbit where the Iridium satellites (ten of them) will be deployed. 

SpaceX is really starting to make satellite launching routine, in a way that NASA was never able to do.  So far this year they've launched 15 rockets to orbit, and recovered the first stage successfully on 8 of those flights (something NASA once declared “impossible”).  For me, the excitement I'm feeling today about SpaceX's efforts is that they provide a promise that commercial exploitation of space might just be possible.  Elon Musk has far grander visions than that, but personally I'd be satisfied with nothing more than igniting commercial exploitation – because then I know for sure that mankind's ventures into space will be better-managed, sustained, and successful...