Tuesday, February 23, 2021

the interconnections

This is all part of a long, slow realisation. A slow (slower) rewiring of my brain. But what I accomplished tonight is mind-blowing, brain-expanding—to me. I just simply hadn't really thought of it much, thought of it in detail, but the interconnection of computer and mount (and arguably any piece of astronomy equipment) and the ensuing communications between software and mount firmware and hardware is... well... not rocket science. The feeling is that of an epiphany even though it is not a grand thing, a fantastic discovery of something no one knew. But the feeling is the same, me reaching this point of understanding that the communications between my laptop (John Gomez) and my mount (Vixen Super Polaris hacked with the IDEA GoToStar motor system and hand box) is just simple codes, short little codes, along a serial communication channel.


If you'll indulge me, it has this profound sensation all around it and I think it partly because of interconnectedness!? My first forays in the Information Technology industry, going way back, early 80s, on my first work term job, under the remarkable tutelage of the late John Bramwell, was learning about computer communication. One day, John said, "We need a modem to connect our PDP terminal to the remote mainframe computer. Buy a modem for us." And I said, "What's a moe-dum?" He smiled.

Later I procured a 300-1200 baud Gandalf modem.

Some 15 years before I'd start seriously using internet services.

Such a smart man.

How times have changed. How much knowledge have I accumulated. All the experiences I've had. Some of which are getting dusty and musty and tattered. I have not used a serial communications modem since... I can't remember when! I guess essentially I stopped when I started using "high speed" internet service at home. Yes, for a while, I continued carrying around on personal and business trips a portable modem, about the size of a deck of cards, and checked for CompuServe dial-up numbers for my destination. Remember that?! Used my Psion computer for decades with serial communication. But it's been a long time. A long time since I worried about baud rate, stop bits, parity, handshaking protocol, terminal type, serial cables, pin diagrams, gender-benders, 9-pin to 25-pin adapters, null modems, DTE and DCE... But it's all in there, buried in my brain, sitting on engrams. I heard echoes today.

So it's been bubbling away for a couple of months.

And it's all tied to, or reignited with, the Stellarium work, curiously. I wanted/needed to connect a computer to Stellarium so to demonstrate and teach students how to connect the software to a mount and to drive the mount, slew to a target. I had added that frequently-requested topic to the level 2 course outline, I had promised it years ago, and thus I was obligated to talk about it.

I was relieved to get Stellarium and the mount working on 7 Jan 2021, after a scary moment.

That first intermediate level 2 course happened on 25 Jan 2021. It was well-received. Not all the students intend to do the hookup I think but it was helpful and illuminating to some. If nothing else, I was able to show what is possible. An advertised feature of Stellarium is driving a mount and I proved it worked. And, again, as I've said elsewhere, I was certain it would work even though I had never done it before with Stellarium. So that had enormous satisfaction linked to it, to see it functioning.

Now like a good educator or instructor or tour guide, I wanted to be well-versed on the matter. So I started collecting data, reading web sites, watching YouTube videos, reading the 350+ page Stellarium user manual, reaching out to other users, taking screen snaps, requesting screen snaps, making notes. I wanted to see and verify the Stellarium mount control for different mounts, different hardware, different computers and operating systems. And I hate to say this but almost every resource I found on the internet was... (I need to be diplomatic here)... every video and web page was... um, poor. 

Missing information, incompletely information, outdated, lack of understanding of features, lots of luck, incorrect assumptions, convoluted information, ambiguity, shakey cams, unintelligible audio, you name it. Some people had really no idea what they were talking about. It was extraordinarily frustrating and disheartening and... inspiring!

I thought, "Well, there are no good videos out there, so I better make my own." I felt I had a lot of expertise I could bring to the table, experience, background knowledge. I know how to teach, I know how to relay challenging technical concepts with hardware and software. I thought, I can make a video to knock it out of the park. 

My first effort, my first slide deck, my first rehearsal yielded a messy, clunky, two hour video. With a sense of urgency, I redid everything and now have my thorough, deep, expansive series of YouTube videos on interconnecting Stellarium with a mount. That was really satisfying. And again, I learned a lot.

Along the way, I had a chance to get dialled into, dialled back into, working with the ASCOM environment. Years ago I have found a working mount driver solution and it proved its value again for the Stellarium situation. The Vixen SkySensor 2000 PC driver offers a working solution (not perfect) for driving my IDEA GoToStar. And now I've seen it in action with two completely different astronomy applications, SkyTools and Stellarium. By itself a great example of the independence model offered by the ASCOM platform.

I first got the Vixen SS2K driver operating in 11 March 2013.

Some 7½ years later I used it again.

And seeing the SS2K driver working well for the peculiar mount but with a modern planetarium nudged me to update the ASCOM team. It was awesome when they embraced my suggestion.

I learned all the different ways of slewing in Stellarium.

I discovered a bug when slewing by RA and Dec.

I learned that some NexStar and some iOptron hand controllers have built-in USB serial adapters. A good and a bad thing.

Recalling that USB is serial communications... you know, Universal Serial Bus.

I learned about the INDI GO initiative.

I learned that StellariumScope is not really needed anymore.

I learned how to use a remote computer for Stellarium control.

It reminded me that I have used ASCOM in many ways. I had forgotten my Gemini 1 Losmandy experience. I had forgotten, in the sands of time, my ASCOM electronic focuser experience. It was good revisiting those memories.

The pedagogical rewards. Wow. To teach all this, to explain all this, I had to do so much research and testing and experimenting and it was all amazing! So amazing. It's been fantastic developing this deep understanding of the tool.

Yet, I was feeling a nagging sensation. Maybe it was highlighted, elevated with Stellarium as it is lacking in some interface controls. I currently caution users that there's no Stop or Abort button in the Slew Telescope To window. I really worry that an excited telescope user is going to crash their telescope into something, or snap a cable, or burn out a motor. One must know and be ready to deploy the keyboard shortcut in Stellarium for halting a slew. That whole thing strikes me as very odd...

It got me thinking, is there a way to have more control? Stellarium is the chart, the map, and can get you to a target. But could another tool offer additional controls of the mount? I remembered, vaguely, the plethora of options made available by EQMOD et al. But I was a little fuzzy on the particulars. It was a year ago (which oddly feels like so much more) that I explored EQMOD, the virtual hand controller, the target list plug-in EQTOUR.

(Re-read information and, dismayed, found that the EQMOD stuff is only for the SynScan world.)

Then I headed down a path of... let's try again. So I revisited many of the options available for iOptron mounts. Didn't meet with much success.

I had a quick look into the INDI environment but nothing grabbed me.

Rattling around in my noggin was the idea of DIY. What if I wrote my own driver? In my ASCOM travels I noted the pages for developers and I read some of the notes and watched a video and saw the caution that a mount driver was the most complex work one might undertake and I spotted the supported languages and frankly perked up a bit when I saw it could be done in VBA! The reference to Python got me thinkin' that I should learn it anyway, given its broad appeal in single board computer projects. But after a bit of reading and testing I wondered just how easy Python would be for me and was it the right way to go if I was trying to build a complex driver... What about VB? I know VBA reasonably well. Maybe doing work in Visual Basic would be easier. Maybe a lot easier. I downloaded the free Visual Studio.

One evening, it struck me that writing a complete full driver, yes, could be very challenging. But what about a not a whole driver. What if I worked on a smaller idea, an adjunct, a sidecar type of idea. What if I made a small virtual hand controller...

I got so excited on that notion that I designed the graphical interface for a virtual hand controller! Display panels to show data from the mount. A very large Emergency Stop button. N-S / Dec buttons; E-W / RA buttons. Slew speed slider. Switch for tracking. And then wish-list things: Connect and Disconnect buttons, a Load Gears button, Spiral Search, Park button, Sync button (which would really work). Heh. Go big or go home, eh?

Those N-S / E-W buttons remind me of the DDO 74! What a treat being able to fly that big 'scope.

Somewhere I wondered about source code and I spotted the source provided with a LXP ASCOM driver. Yes, I know, I saw the warning that one should not use another developer's code... Still, I didn't see that it would hurt if I just had a look. For the broad strokes...

On the evening of 30 January 2021, I wanted to have a go at Sirius and then "get some data" for the OSC Virtual Star Party 'cause I just felt it was going to be cloudy. Star parties in February in Canada? Hrrm. But here was a brief patch of clear skies offered to me so I tried to split Sirius B. Nope. No joy. But then I imaged the sigma Orionis target. And for the first time, I operated the camera inside, using my USB-ethernet extension. That worked great but Holy Universe did that make me appreciate the perks of RASC membership and being in the Toronto Centre and having the keys to the Carr Astronomical Observatory and being a training supervisor so to have access to the Geoff Brown Observatory and being able to use a Paramount, a big 'scope, TheSky, TPoint modelling, and an electronic temperature controller focuser. Spoiled rotten. 

I sure missed the remote mount control on the 30th. So was pleased when I got things working, the next night, along another long data connection. Now I could control a camera and I could drive a mount, both from indoors. 

Focusing? That remains an issue. That triggered another pursuit of building an electronic solution. I started looking at Pulse Width Modulation wiring diagrams, stepper motor tricks, Arduino solutions. But that's a story for another day...

And I think it was around this time that I noted something very interesting. I don't remember exactly where but I believe it was in reference to an iOptron driver and Meade LX200 commands. Which cracked through my brain like a bolt of lightning. What? What?! If iOptron uses the common LX200 language or command set, does the old IDEA GotoStar use LX200? Early 2 February 2021, I was vibrating at the prospect.

With high hopes, I tried a boatload of ASCOM LX200 drivers! Sadly, nothing worked. Or it didn't improve on what I have with the SS2K. I tried ASCOMPad. Didn't work. I was very excited when I found the "Advanced LX200 driver" with little hand controller interface. No fricking documentation, weird results, improper treatment of the side-of-pier information, sporadic results, occasional lock-ups, and frequently changed things on the hand controller for no obvious reason. Damnit!

Lookin' more and more like I'll have to make my own.

So, tonight, I thought, let's see what I can do. Let's see if the LX200-like commands in the GoToNova documentation will work with the earlier GoToStar. Fired up the mount and accepted Aldebaran as the alignment star. After sorting out things with the Tera Term, port, speed, protocol, restarting, I readied to send some passive codes, codes to read or pull data from the hand box... 

From the "General Telescope Information" section, I tried to get offset from Greenwich Mean Time or UTC. I entered :GG into the terminal app and on pressing the hash or pound (#) (and I remembered some discussion about that in a ASCOM programming video), I immediately saw W 05:00#

Holy Space Balls. It worked! Wow. This changed everything. This meant I could do what I wanted. I could write a program to open the serial port and issue commands and the mount should work. A full driver? I dunno. But a little virtual hand controller to augment stuff in Stellarium or SkyTools. Oh, that would be sweet!

Asked for the current date with :GC#. Worked.

Asked for the current local time with :GL#. Worked.

Requested the current local sidereal time with :GS#. Fine. Compared to MySiderealTime on the Android. Close enough.

Asked for the current latitude with :Gt# and longitude with :Gg#. No problem. Bit of a funny display format, sDD*MM:SS#, until I realised the asterisk looks a bit like the degree symbol.

Retrieved the current Right Ascension with :GR# and Declination with :GD# and double-checked the values against SkyTools. I also pulled the current Altitude with :GA# and Azimuth with :GZ# and verified with ST4VP.

I queried the side of the pier which telescope was positioned on with :pS#. All good! Look at that.

Encouraged, I decided to start pushing data...

I set the GMT offset with :SG sHH#. The response code 1 appeared and the hand controller showed the change.

Just incredible. I was successful sending commands to the mount. This was so exciting.

I set the date with :SC MM/DD/YY# and time with :SL HH:MM:SS#. Worked.

Changed the location using the latitude and longitude for the CAO. Used :St sDD*MM:SS and :Sg sDDD*MM:SS#. So amazing seeing the new information on the hand controller screen.

OK. Time for the big thing! Slewing to an object.

I defined the target Right Ascension with :Sr HH:MM:SS.S#. Accepted. I commanded the target Declination with :Sd sDD*MM:SS#. Accepted. Eeeee. 

Readied for my first Telescope Motion command. I composed a command to slew to most recently defined RA and DEC coordinates. I slowly typed :MS, turned to the mount in case it went hayware, and pressed #. Off it went. Slewing to Alphard. Incredible. 

I gave new coordinates for a star below the horizon. As expected, the mount didn't move, and it returned the string 1Object is below horizon #. Impressive.

I was able to set the slew or moving speed for the N-S-E-W direction keys with :RC0# for 16x, :RC1# for 64x, :RC2# for 256x, and :RC3# for 512x. I found that :RG# set the rate to 1x. I believe that is specifically a guide rate command. I tried a few random things to apply different rates without success. The HC itself offers 9 speeds via the number buttons 1 through 9. Missing was 2x, 8x, 128x, and MAX. Perhaps a limitation of the original LX200 language?

I tried the motion commands, slewing in a particular direction, like holding the relevant button on the control pad. I used :Mn# to head north. Then I issued the stop command with :Qn# and it spun down.

The powerful stop command, killing motion in both axes, worked fine with :Q#. The hand controller switched from Cel. rate to Stop. I've seen that behaviour. Huh.

With some experimenting, I was able get the slewing status with the :SE?# command. Either "slewing" or not.

I was successful getting current tracking rate with :GTR# and changing it with :STR0# for sidereal, :STR1# for solar, and :STR2# for lunar.

I was very happy to see the park command work with :PK# though it didn't seem to close-out like it does from the HC, with the "you can power off now" message.

Tried the current servo controller software RS232 command language version query with :V#. Worked.

Tried the current servo controller software information with :Vs#. Yep.

Tried the current mount type command :GAM#. Worked.

There appear to be commands for syncing, called calibrate mount, :CM# and :CMR#, but I did not try them. I was tired.

There are other intriguing things, like slewing to a location by altitude and azimuth, setting the mount park position.

I had a quick scan of an official Meade LX200 guide and not surprisingly the command set has been extended for modern, more powerful mounts. Still, it looks like the core, basic command set is well-supported by the old, crazy, weird, unique, powerful, impressive IDEA GoToStar.

I'm excited to go to the next stage... I think by idea is quite doable.

A crystalline thought today was: "It's simple." It's not as complex as you think. It's just simple codes on a serial line.

It still all has me reeling. This strange culmination of so many things, serial communications, cable building and pinouts, coding, a curious motor control system that I'm still learning things about, the possibility of having dramatically improved mount control, remotely controlled from my computer.

No comments: