Showing posts with label rts2. Show all posts
Showing posts with label rts2. Show all posts

Friday, June 1, 2012

Controling Devices With JSON

RTS2 has an XMLRPC which also supports JSON. This make it very easy to poll and control devices external of the driver. Here is a simple example of controlling the Tban fan controller based on temperature difference between inside the dome and the outside ambient temperature.




from rts2json import jsonProxy, createJsonServer 
import socket
import xmlrpclib
import json
import httplib

#connect to server
createJsonServer('localhost:8889','','')

#get temps from devices
externalTemp = jsonProxy().getValue('S0','TEMP_AMB')
internalTemp = jsonProxy().getValue('S2','DS1')

#calc the difference
diffTemp = internalTemp - externalTemp

#set the fan speed based on rules
if diffTemp < 0:
    jsonProxy().setValue('S2','MFanCon',0)

elif diffTemp > 7:
    jsonProxy().setValue('S2','MFanCon',3)

elif diffTemp > 4:
    jsonProxy().setValue('S2','MFanCon',2)

elif diffTemp > 0:
    jsonProxy().setValue('S2','MFanCon',1)

The rts2json is in the RTS2 repo. Simply connect via a JSON proxy and get and set values of devices. The script is set to a 15 minute cron and adjust fans speeds accordingly.

Wednesday, February 8, 2012

First light....

Last Monday we finally got first images running through RTS2. The only missing part of the image acquisition is automatic focusing. Focuser still needs testing which we will probably get to end of this week.

Our Proof

Though this is quite a milestone there is still loads of work left to do. There are several software pieces that need work before BORAT can really achieve a primitive autonomous state.

Monday, September 26, 2011

Problems of 9/25/2011

Got a lot accomplished since last list but as usual more problems creep up over time.

Software
  • Focus driver - implementing in RTS2 - DONE
  • AstroHaven dome driver needs update to stop spamming error messages and to add feedback from new dome control hardware
  • TBan driver needs code to handle when device is not there rather than spam messages - DONE
  • Add user friendly GUI to control primitive features of the system
  • Possibly add Android app interface/add
Hardware
  • Ordered another Webswitch, they are so cool - DONE
  • Mount Telescope and pier - DONE
  • Buy cabling management for inside of dome
  • Repair crack in AstroHaven Dome
  • Still need to spec out computer capable of extreme temperatures. Computer still needs to have PCI slots and serial ports. Don't want to use USB<->Serial
  • Draw a plan for UPS during extreme temps - put off
  • Add lens heater on LX200GPS to reduce night dew.
  • Corrosion on BigNG board - ordered new one - DONE

Wednesday, August 17, 2011

The Instrument

Our system will be using an instrument composed of a custom focuser, filterwheel, and CCD. These pieces must be assembled each time we attach it to the telescope. When the security system matures and we have the fence installed we will be able to leave it at the site in one piece.

The focusing device is essentially two motors on a specially constructed piece of metal to operate the telescope's focus knobs. It's in the upper right of the photo.

The filterwheel is a USB Apogee AFW50-9R. It takes 50mm round filters (we have U, V, B, R, and I). The driver had to be tweaked a bit but now it works well in RTS2.

Our CCD is an Apogee Alta U47. For all the details you can see their official specs here. We have three of these devices at our observatory and use them in several projects. We're currently having some issues with the RTS2 integration (some binning issues) but expect to have it sorted out soon. 

The actual assembly of this instrument takes about 15 minutes to an hour, depending the experience of the person doing the assembly. It takes a total of 5 different hex wrenches to complete! The CCD connects to a mounting plate and then to the filterwheel. The filterwheel is screwed into an adaptor plate and this is bolted to the focus ring. After this, all you have to do is carefully screw it onto the back of the telescope and attach the cables and belts. I personally can't wait until we can put everything together and leave it at the observatory.

The completed instrument with all the rings and equipment connected weighs about 10 pounds. Our counter weight system only went to 6 pounds and this proved to be a problem when it comes to tracking on the Meade forkmount. That is a problem for another post, though!

Monday, July 18, 2011

Fixing AstroHaven Enterprises dome driver

Timing is everything and especially so when it comes to computers.

When issuing a command the dome controller will run the command exactly for one second. So when writing the driver the code to open and close the leafs were dead simple. Or so I thought so......


cmdSent=0;
response = '\x00';

while(response != POLL_B_OPENED && cmdSent < MAX_COMMANDS)
{
sconn->writePort(CMD_B_OPEN);
sconn->readPort(response);
cmdSent++;
}

if(cmdSent < MAX_COMMANDS)
{
return 1;
}
else
{
return -1;
}


This code simply sends the command and keeps sending till it gets the wanted response. There is a upper limit set in the header file. The variable cmdSent is incrementing to the limit. The limit is just in case something might happen we can report a fail to open or close. A question might come up why we can't simply hard code a number?

Two reason, first is the controller and motors isn't exact. I can't say opening the dome will take X amount of seconds because with age the time to open and close will change. Second this driver will work for all three sizes of AHE domes with same controller. (Heard AHE now ships with different controller) Make it versatile as much as possible.

The problem started when converting the AHE driver from a custom serial driver to the standard RTS2 ConnSerial driver. So simply replaced write and read with the functions of the ConnSerial and tested. Everything worked except the opening and closing.

I worked on this problem for several hours. Mainly it took so long because it was super late and debugging abilities lessen with lack of sleep. :) Can you spot the problem? Hint: readPort() is non blocking......

Originally the serial read function of the custom serial was blocking. So when I replaced with the new code forgot it was non blocking. When this code runs it will reach the upper limit before the leaf started to close or open thus throwing an error and quitting. Quick fix is to sleep giving time for dome controller to move.


while(response != POLL_B_OPENED && cmdSent < MAX_COMMANDS)
{
sconn->writePort(CMD_B_OPEN);
sleep(1); //simple fix here
sconn->readPort(response);
cmdSent++;
}


Lesson learned, never assume anything and RTFM!