Thursday, June 27, 2013

Start your motors

I finally had some time tonight to get some work done. I was having some trouble getting my motors to work with the EasyDriver when I last worked on the project. Tonight I was able to figure out why. Apparently the EasyDriver defaults to running in 1/8th of a step (or microsteps). Since my motor was already built to go pretty slow, this made it not move at all effectively (or at least it went very very very slow). After actually reading some of the EasyDriver's documentation, I realized this and that this can be changed. It will require me to do some soldering though which unfortunately I don't have time to do tonight. I should be able to hook up the pins that control the microstepping to the CPIO pins on the raspberry pi. I might be able to just connect both EasyDrivers to the same GPIO pin to make it easier, but I haven't researched that at all yet, I'm just hopeful. This is a very big step in the project since now I can control the motors (albeit in a limited fashion) and read in the sensor data (even if the data isn't completely accurate yet) all into the raspberry pi.

Friday, May 17, 2013

RXTX on RPI, mirror scratch, cases, and GUI

Last night I was able to get my code to work on my Raspberry Pi. I had a little trouble at first, but then I figure out what I needed to do. In order to get the RXTX api to work on the pi with the program I had to include the RXTXcomm.jar in the build path of the project. This way when I exported it as a runnable jar it would be included in the jar. I'm not sure if this next step was necessary, but I did it anyway. I installed the RXTX api on the RPI using this command "sudo apt-get install librxtx-java".

I also cleaned the primary mirror on my telescope last night. It was very dusty, but luckily didn't have too much stuff that wouldn't come off with just soap and water. I did make a small scratch on the mirror though (I'm not happy with myself for it). My screwdriver slipped a little when I was taking the mirror off of the telescope and made about  a 1 inch scratch on the edge. From what I've read, it should be fine, but it will reduce the amount of light I can collect by a small amount. I also had to collminate the telescope when I put it back together. I'm not sure how well it was collminate before, but it should be pretty good now. I'm hoping it is clear tonight so I can test out my work. Hopefully it will make things a lot clearer through my telescope. I will post pictures if I get the chance to take them.

I am going to order some project cases today. I am getting one for the ArduIMU and one for the RPI and two EasyDrivers. Once I get the cases I will start verifying that the ArduIMU is actually giving me good data. I'm expect that to be sometime next week. I'll post the cases I actually get in the parts page once I figure out which ones I'm getting.

I am also starting to work design a GUI for all of this. I have only made a simple drawing on some graph paper so far, but I will post a computer sketch of it when I'm further along. I think I'm going to try to use the WindowBuilder tool found here. I have never used it before, but after a quick google search it is the one I found that is recommended.

Wednesday, May 15, 2013

Component Drawing, a few changes

I have created a drawing of the different components of this project. I used a handy tool at https://www.circuitlab.com/. This is only a rough drawing and the placement of the inputs/outputs on the different components is not accurate. It's just to see how everything will connect together.


One key change I've made for now is to use the Raspberry Pi model B instead of the model A. This is to avoid problems of attaching the ArduIMU directly to the GPIO pins. The ArduIMU is runs on 5v and the RPI GPIO pins output 3.3v so I would have to get a logic leveler or something to fix this problem. Since I already have a RPI model B (rev 1 though, so it only has 256mb RAM), I decided to take advantage of its extra USB port and not worry about connecting the ArduIMU to the GPIO pins for now. I am also planning on only mounting the ArduIMU on the tube of the telescope so the long FDTI USB cable should work nicely to connect to the RPI anyway.

Monday, May 13, 2013

Phase I Complete

Success! I am now able to feed live sensor data from my ArduIMU into my java program. Once in the program I can convert the horizontal coordinates given by the Euler angles the ArduIMU calculates into equatorial coordinates that I can use with my telescope. There is only one problem. I have no idea whether or not the readings from my IMU are actually accurate. The only way to test that will be to mount it on my telescope and see if the coordinates match up or not by eyeballing it. To do that I still need to get my program and ArduIMU to work with my Raspberry pi and figure out a way to mount the ArduIMU/Raspberry pi on the telescope so that the ArduIMU is level with the telescope. I have posted all of the code that I have used to calculate the conversion on the code section. If you have any questions let me know.

Conversion 75% complete, PyEphem=out Kstars=in

So after I looked at PyEphem a little harder I realized that it actually doesn't do what I wanted it to do. Because of this I have completely abandon using it. I did find some else that was very useful. Kstars is an open source program (sort of like stellerium) for linux. The reason it caught my attention is because of its astrocalc feature which allows you to convert horizontal coordinates to equatorial coordinates, and this is exactly what I am trying to do. The only thing stopping me from using it's source code directly is that it is written in C++. So I decided to just use it as a guide to write my own java code.

After a nightmare of conversion problems (degrees to radians and radians to degrees or hours) I have finally gotten my program to calculate declination correctly. I am very close to getting the right ascension too. I believe I have fixed all of the conversion issues, but I am getting a null pointer exception when I do local side reel time - local hour angle. Hopefully it is a simple mistake, but I haven't had much time to debug it yet. I should have it fixed by tonight. I will post all of my code under the code tab once I get it working.

Once that is fixed, on to the next step: testing the accuracy of the IMU. At the moment, I have no idea if the IMU is even giving me good horizontal coordinates. I have had to assume they are correct so that I can make sure the math for the conversion is correct. I'll be mounting the ArduIMU to the top of my raspberry pi tin for now. I've tried a temporary electrical tape mount already, but I'll have to figure a better way to do it for testing. Any suggestions on doing this would be very welcome. My ideas right now are hot glue, double sided tape (strongest possible), or maybe even something as simple as a zip tie. I'm hoping to start this testing this weekend, or the next. At some point this week I have to take the primary mirror out of my telescope for cleaning though. It should be fairly easy to do, but if anything goes wrong it could delay this project significantly.

After I confirm that the IMU is actually working correctly, I need to figure out a way to directly connect it to the Raspberry pi using the GPIO. I have to do this for both the ArduIMU because the RPI model A I will be using only has 1 USB port which I plan to use for the keyboard/mouse combo. If power is not as much as concern as I anticipated I might be able to get away with using the RPI model B that I have and just use the FTDI cable I'm currently using, but I would rather use the model A since I kind of bought it specifically for this project. Once I figure out all of that, then the next step will be to start working with the motors. I am thinking I might start by hooking the EasyDrivers up to my Arduino Uno just to figure out how they work a little bit. Then I think I will know what I need to do in order to hook them up to the RPI's GPIO pins. Worst case, I think I can easily figure out how to connect my Arduino Uno to my RPI so I could just use that to control the EasyDrivers, but that would cost a fair amount of power I'm guessing.
 

Friday, May 10, 2013

PyEphem

As I was thinking about the conversion process that will need to be done, I figured out that I was over thinking it. The angles that my ArduIMU puts out should all give me the coordinates in the horizontal (or altitude-azimuth). This means I only have to do one conversion, from horizontal coordinates to equatorial coordinates. Luckily, I have found equations that allow you to do this easy. As I was searching for those equations though I found something even better.

I found a python library called PyEphem (here is their website). This library actually has a conversion function built in. It also has several other useful tools that I was going to have to create from scratch. The only downside is that it is for python. From what I've read so far I can create some kind of jython interface that will allow java to use the python module. Everyone says it is simple and easy to do so I think I'll give it a try.

The PyEphem site also has some nice links to databases of celestial objects. They don't seem to be too large so I should be able to store at least some of them on the RPI's SD card. Here is where those links are located.

I also found some java libraries that are similar, but no where near as functional as PyEphem. I am thinking this one might be the most useful. It would allow me to do some things inside the java code which could save some needed time when the program is running. I'm planning on working on the project as much as possible this weekend, unless it isn't cloudy. Then I'll be testing out my new camera!

If you have any suggestions or questions, please leave me a comment.

Tuesday, May 7, 2013

First attempt at astrophotography, and getting into the project

After getting into this project a little further, I have decided to first get everything to work with manual control. By that I mean I will be able to read the sensor data to see the position of the telescope, and control the motors manually through the raspberry pi. Once this is complete, then I will start automating the motor control and set up procedures.

I have figured out a few things now. It looks like I am going to have to do two conversions for each line read in by my sensors. Conversion one will be to convert the Euler angles to the Alt/Az coordinates which isn't that hard to calculate. The second conversion will be from the Alt/Az coordinates to Equatorial coordinates which is also fairly straightforward. I am hoping the raspberry pi will be able to do this fast enough it can handle doing it each time a line is read from the sensors.

I am now able to read in the sensor data directly into a java program using the RXTX library. This was a little complicated to setup because I am using a 64 bit version of Ubuntu to program in, but I tried using the latest (not the latest stable) build of it and it works fine. I did have to go into the project properties and remove and then re-add the system JRE to the project in order to solve some problems.

On a side note, this past weekend I tested out my new camera adapter for my telescope (here it is on amazon). It allows you to take pictures through your telescope by mounting your point and shoot camera to the adapter, and then mounting the adapter to your eyepiece. The camera looks through an eyepiece, which isn't ideal. You can see the results of my first try in the pictures section or by clicking here. After taking all of these pictures, I kind a little excited and decided to take it a step further. So I ordered a Canon EOS Rebel T3 DSLR with some accessories that will allow me to directly connect the camera to the telescope without using an eyepiece. This is a much better way to take pictures with your telescope. One of the main concerns I had while doing research for what I would need is that there are issues with telescopes like mine (a Newtonian). Basically, where the eyepieces go is the focal point of the telescope. Now if you replace the eyepiece with a DSLR, the focuser will have to be moved in quite a bit more to be in focus. The problem is that most Newtonians have focusers that cannot go far enough in to compensate for this. I was very lucky with mine as it was made with this in mind. On mine, you can actually remove the part of the focuser where the eyepiece goes, and there is a T-adapter build in to it. The part that was removed is big enough that it allows the scope to be focused when a DSLR is used with it. Check back on the pictures section next week. Hopefully I'll be able to take some pictures with my new camera as long as it's not too cloudy (though I will still try even if I can see just a little part of the sky).

Tuesday, April 16, 2013

Conversion Troubles

I have made some progress since last time I posted. I have now create an algorithm that can calculate the local side reel time. This will allow me to figure out where the equatorial coordinate system is currently located, and it will let me track objects with precision. The psudocode for this is made of these three functions:


public float getJulianDate(Date date){
    //calc julain date at 00:00:00 GMT on input date
    month = date.getMonth();
    year = date.getYear();
    day = date.getday();
   
    tempA = int(year/100);
    tempB = 2-tempA+int(tempA/4);
    tempC = int(365.25*year);
    tempE = int(30.6001*(month+1));
   
    return tempB + tempC+ tempE + day + 1720994.5;
}

public float getGST(Date date, Time gtime){
    float jdate = getJuLianDate(date);
    temp = (jdate - 2451545.0)/36525.0;
    temp0 = 6.697374558+ (2400.051336*temp)+(0.000025862*(T^2))+(gtime*1.0027379093);
    while(temp0>24 || temp0<0){
        if(temp0>24)
            temp0 = temp0 - 24;
        else if(temp0<0)
            temp0 = temp0 + 24;
    }
    return temp0;
}

public float getLST(Float longitude, Time ltime, Time utime, Date date){
    float gst = getGST(date, utime);
    Float lst = gst + (longitude/15);
    if(lst<0){
        while(lst<0)
            lst= lst+24;
    }
    else{
        while(lst>24)
            lst = lst-24;
    }
    return lst;
}

Right now, I am trying to figure out the next step. That is reading the Euler angles from my ArduIMU and converting them to a position on the equatorial coordinate system. This is proving to be complicate since the coordinate system literally changes with each passing second. I'm hoping to maybe just calculate this every couple of minutes to check for accuracy and somehow write an algorithm that will follow the movement of the coordinate system between the checks.

I am about half way through figure out the conversion. I believe the yaw is equal to declination and the roll is equal to the right ascension. This make working with declination really simply. I can basically treat it as the radius in a set of polar coordinates. The only problem is instead of starting at 0 it will start at 90 and decrease. Even as it crosses the the celestial equator, I believe this method should work. The right ascension will be a little more tricky since it will be constantly changing. So far this is what I have come up with for it. First I will have to convert hours to degrees (shouldn't be hard, 360/about24=about 15 degrees). At this point, I'm having a little trouble wrapping my head around what I should do next. Obviously local side reel time comes into play since it tells where the coordinate system is at the moment. I think I'm going to have to go and play around with the ArduIMU to better understand what the yaw angle is actually telling me and how it relates to right ascension. If you have any suggestions, feel free to jump in.

Thursday, April 11, 2013

Hello all. This blog will be dedicated to a new project of mine. I am just starting a project to create a tracking system for my Celestron C10-N telescope. I am very interested in astrophotography, but I do not want to pay $750+ for a new computerized telescope mount or a new telescope that includes a computerized mount. I have come up with a plan to create my own tracking system that uses fairly simple parts, and hopefully not too complicated programming.  I plan on using the following parts:
  1. ArduIMU+ V3
  2. 20 Channel EM-406A SiRF III GPS Receiver with Antenna (connects to ArduIMU+ V3)
  3. Two EasyDriver motor drivers from sparkfun.com
  4. One model A Raspberry Pi (I'm using this model to lower my power requirements)
  5. Dual axis motor drive from Celestron #93523 (basic stepper motors to move the telescope)
  6. 4.3" LCD meant for a backup camera system (you can buy them from popular sites, but you can get them for half the price if you search amazon for backup camera lcd and it is the same product)
  7. 2in1 Media keyboard/mouse. (Mine also has a built in laser pointer which will hopefully work well as a star pointer)
  8. Unknown power supplies for all of the above. I'm waiting to build everything so that I can measure how much power I will actually need to have.  
This is how I expect the system to be put together:
  •  The raspberry pi will be the main controller. It will have the 4.3" LCD hooked up to it as well as a 2in1 media keyboard/mouse. This will be where the user interface will be.
  • The ArduIMU will be connected to the RPI through the RPI's GPIO pins. This will be a serial connection.
  • The ArduIMU will provide a few bits of key information from its many sensors:
    • GPS coordinates (longitude and latitude)
    • Heading (or direction I'm pointing, from the GPS unit and the
      magnetometer)
    • Pitch, Roll, and Yaw. These will tell me exactly where the telescope is pointing. I can map these coordinates to match the equatorial coordinate system used for astronomy.
  •  The two EasyDriver motor dirvers will also be connected to the RPI via its GPIO pins. This will allow each motor to be independently controlled enabling them to possibly move at the same time if needed.
  • The motors (there are two of them, hence dual axis above) will be connect to there own EasyDriver.
  • I'm hoping to have one main power source for everything, but I know that the following will need to be connected directly for power: RPI and the EasyDrivers(partially). The Easy drivers will be powered two ways. The actually driver will be powered by the RPI, but the motors they drive will need another power supply that is more powerful. I'm hoping that the RPI will have enough power to power the ArduIMU through the GPIO pins, but I'm not sure if this will work or not.
So far, I have just started. I am mostly just soldering some headers onto a few of the boards so I can attach everything on a bread board before I solder everything together. I have started to program a little, but I am mainly exploring my options on how to achieve some specific things I will need. When I am finished, this tracking system should actually have some advantages over the $750 out of the box solution. For one, my system will include GPS (you might be able to add it on to the out of the box solution, but it will cost even more). This will make my system be more accurate and allow me to move it from place to place while staying accurate. 

My goal is for the following 8 steps to be all I need to do in order to start tracking an object:
  1. Wait for calibration and GPS fix (takes around 20 seconds for the ArduIMU to do this)
  2. Confirm that step 1 actually happened
  3. Set altitude within a certain margin of error. (To align you scope to the celestial north pole you must point it north and however many degrees up that your latitude is) The mount must start out completely level, this must be done manually on my mount with the bubble level built in to the mount.
  4. Set the right ascension and declination to "starting" position (the scope will be looking the celestial north pole after this step, and now the scope will be polar aligned)
  5. Calculate side reel time and get the initial coordinate system, repeating this step at a certain interval. (I will be using the equatorial coordinate system as I have an equatorial mount. This coordinate system moves based on time of day. Side reel time allows you to figure out where coordinate system currently is)
  6. Enter coordinates and go to location (my system will not initially be designed to have any kind of database connected to it. Instead I plan on looking up positions of stars before hand. Eventually I might try to include at least a small database, but they take up quite a bit of space since there are so many entries. I'm going to skip it for now)
  7. Once at the location, calculate speed needed to track the object, recalculate the side reel/coordinate system, move to new location, and engage motor (only one) at tracking speed. (Since we have polar aligned the scope, we should only need to move one motor as long as we aren't tracking something like the ISS)
  8. Check position using side reel time against ArduIMU sensors at a certain interval, and correct position and speed if necessary.