Hi Ivo
I am writing a program to test different polar alignment methods using Platesolve2.
Currently the program prompts the user to use APT to take an image but it would be really useful if I could do this automatically.
Is there a way I can, from another program, get APT to take an image so I can automate this?
I know AstroTortilla did something like this.
Regards,
Guy
Automating with APT
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
Hi Guy,
You are right that there is an API to make external automation
So far it was not published, but I think that it will not harm to post it 
Here is short explanation of the APT API.
The connection is by TCP/IP socket, listening port 21701. In the log panel there are notifications when connection is made.
Here is explanation of the final form of the protocol. It is based on text commands and responses.
Command "S" (status) returns:
NCC - no camera connection
IDL - APT can accept commands
BUS - APT is busy
CAP - APT is capturing image in result of "C" command
E01 - unknown status
E02 - the camera has to be set in B/M dial mode. The status will be set to IDL after the E02 is read with "S" command from Client. This case happens when "C" command is sent, but exposure can't start
Command "C" (capture) - format C1XXX. XXX is the exposure duration in seconds. "1" is the binning (which works only in CCD mode) Returns:
E01 - Bad exposure duration parameter
E02 - Bad state - APT can't start the exposure because is busy or there is no connection to camera
E03 - Can't start exposure
ROK - the command is accepted. Wait a second or two and check the status to see if you will get E02, if the status is CAP or IDL everything is fine
Command "G" (get) returns
A string with the filename. The socket will provide the length of the string
Command "R" (remove). This deletes the last captured for AT image. Returns:
E01 - the file can't be deleted - most likely doesn't exist
ROK - the file is deleted
Edit: In APT 3.33 were introduced commands "P1" and "P2"
Command "P1" (stop guiding).
OK - the command is accepted.
Command "P2" (park scope).
E1 - No scope connection
E2 - Parking is not supported by the ASCOM driver
E3 - Can't park
OK - the command is accepted.
Edit: In APT 3.57 were introduced commands "GE", "GT" and "GR"
Command "GE" (Get current exposure number).
X - the number of the current exposure . 0 if no plan is running.
Command "GT" (Get total exposures count of the running plan).
X - the total count . 0 if no plan is running.
Command "GR" (Is there running plan).
Y/N - Y if an imaging plan is running.
Edit: In APT 3.86.1 were introduced commands "GI", "GFI"
Command "GI" (Get current Status).
String - Returns the current status as it is displayed in Status Panel.
Command "GFI" (Get current filter wheel position).
X - Returns the current filter wheel position or NWC if there is not connection to wheel.
If a command gets a result "USC" this means "Unsupported command".
Please note that there is no "DON" state. When the image is ready the state is set back to "IDL". When the image is ready APT sends through the socket "DON" to notify the Client that the exposure is completed and the file is transferred to the hard disk.
The flow should be close to this one.
1. Check status if it is IDL
2. Send C command
3. Wait a second or two and check if the status is CAP
4. Listen to get DON from the socket
5. Check if status is IDL
6. Get the filename and use the file
7. When the file is not needed send R to remove it
You are right that there is an API to make external automation
Here is short explanation of the APT API.
The connection is by TCP/IP socket, listening port 21701. In the log panel there are notifications when connection is made.
Here is explanation of the final form of the protocol. It is based on text commands and responses.
Command "S" (status) returns:
NCC - no camera connection
IDL - APT can accept commands
BUS - APT is busy
CAP - APT is capturing image in result of "C" command
E01 - unknown status
E02 - the camera has to be set in B/M dial mode. The status will be set to IDL after the E02 is read with "S" command from Client. This case happens when "C" command is sent, but exposure can't start
Command "C" (capture) - format C1XXX. XXX is the exposure duration in seconds. "1" is the binning (which works only in CCD mode) Returns:
E01 - Bad exposure duration parameter
E02 - Bad state - APT can't start the exposure because is busy or there is no connection to camera
E03 - Can't start exposure
ROK - the command is accepted. Wait a second or two and check the status to see if you will get E02, if the status is CAP or IDL everything is fine
Command "G" (get) returns
A string with the filename. The socket will provide the length of the string
Command "R" (remove). This deletes the last captured for AT image. Returns:
E01 - the file can't be deleted - most likely doesn't exist
ROK - the file is deleted
Edit: In APT 3.33 were introduced commands "P1" and "P2"
Command "P1" (stop guiding).
OK - the command is accepted.
Command "P2" (park scope).
E1 - No scope connection
E2 - Parking is not supported by the ASCOM driver
E3 - Can't park
OK - the command is accepted.
Edit: In APT 3.57 were introduced commands "GE", "GT" and "GR"
Command "GE" (Get current exposure number).
X - the number of the current exposure . 0 if no plan is running.
Command "GT" (Get total exposures count of the running plan).
X - the total count . 0 if no plan is running.
Command "GR" (Is there running plan).
Y/N - Y if an imaging plan is running.
Edit: In APT 3.86.1 were introduced commands "GI", "GFI"
Command "GI" (Get current Status).
String - Returns the current status as it is displayed in Status Panel.
Command "GFI" (Get current filter wheel position).
X - Returns the current filter wheel position or NWC if there is not connection to wheel.
If a command gets a result "USC" this means "Unsupported command".
Please note that there is no "DON" state. When the image is ready the state is set back to "IDL". When the image is ready APT sends through the socket "DON" to notify the Client that the exposure is completed and the file is transferred to the hard disk.
The flow should be close to this one.
1. Check status if it is IDL
2. Send C command
3. Wait a second or two and check if the status is CAP
4. Listen to get DON from the socket
5. Check if status is IDL
6. Get the filename and use the file
7. When the file is not needed send R to remove it
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Hi Ivo,
I'm making good progress. Just a couple of questions.
Looking at AstroTortilla it looks like the port number used is 21701 - and this works for me. Is that something that has changed on my PC?
Can you give me an example of a valid Capture command? I'm getting E01 'Bad Exposure Duration Parameter'
Also, how are other parameters such as ISO and quality selected?
Thanks,
Guy
I'm making good progress. Just a couple of questions.
Looking at AstroTortilla it looks like the port number used is 21701 - and this works for me. Is that something that has changed on my PC?
Can you give me an example of a valid Capture command? I'm getting E01 'Bad Exposure Duration Parameter'
Also, how are other parameters such as ISO and quality selected?
Thanks,
Guy
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
Hi Guy,
Just saw that description is not complete and fixed it. ISO can't be changed, by default is used the maximum supported value, but from Setting->Advanced you can define a lower value.
Example command is C1012 - C is capture, 1 is binning 1x1, 012 is exposure 12s
Just saw that description is not complete and fixed it. ISO can't be changed, by default is used the maximum supported value, but from Setting->Advanced you can define a lower value.
Example command is C1012 - C is capture, 1 is binning 1x1, 012 is exposure 12s
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
It was intended to send NCC, but maybe it got broken... I'll investigate the issue.
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
You are welcome 
I have checked the code... NCC is returned before the first attempt to take image. After that it returns IDL... I'll try to fix it for the next version.
BTW it will be great if you share info about your project ;)
I have checked the code... NCC is returned before the first attempt to take image. After that it returns IDL... I'll try to fix it for the next version.
BTW it will be great if you share info about your project ;)
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Hi Ivo,
What I was interested in is the different ways of using Plate Solving to help with quick Polar alignment.
The first method I'll try is the measuring the alignment error by moving in RA.
I thought I'd try that approach first and then there are others which I might try if I can work out the maths!
Guy
What I was interested in is the different ways of using Plate Solving to help with quick Polar alignment.
The first method I'll try is the measuring the alignment error by moving in RA.
I thought I'd try that approach first and then there are others which I might try if I can work out the maths!
Guy
Hi Ivo,
Just a quick update to say that all is working well.
The only variations from the API description above were:
- APT was listening on port 21701
- The first status request after connecting to APT must check if the camera is disconnected (NCC).
Otherwise a very easy to use interface.
Guy
Just a quick update to say that all is working well.
The only variations from the API description above were:
- APT was listening on port 21701
- The first status request after connecting to APT must check if the camera is disconnected (NCC).
Otherwise a very easy to use interface.
Guy
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
Thanks Guy! I have updated the description... (obviously had used old description
)
To be more detailed the first instance of APT uses 21701. If there is second one the port will be 21702...
To be more detailed the first instance of APT uses 21701. If there is second one the port will be 21702...
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
Hi Guy,
Didn't have time for that. Please remind me after the 3.00 release and I'll see how hard is to make it.
Didn't have time for that. Please remind me after the 3.00 release and I'll see how hard is to make it.
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
I am new with APT, but I am impressed by the great features of this wonderful software! So I would like to thank you for your work!
At the moment I'm writing my own little software for controlling a new ASI071C and a SONY A7 (mod) at the same time. The SONY is controlled via the serial port and some electronics (relay). The ASI071C should be controlled by APT and my little program communicates with APT via the TCP/IP socket connection. So far everyting works great: I can send commands for exposures and the ASI-Cam does what I want
.
But I recogniced two minor issues:
1. In the filename the value for the exposure time ist missing and I get the following name: ATL_2017-02-04_17-35-35_NGC598_s.fit
If I make a single shot the filename is correct: Single__2017-02-04_17-41-18_NGC598_3s.fit
2. Is there any possibility to stop an exposure by a command via the socket connection from an external program?
Thank you for your help!
At the moment I'm writing my own little software for controlling a new ASI071C and a SONY A7 (mod) at the same time. The SONY is controlled via the serial port and some electronics (relay). The ASI071C should be controlled by APT and my little program communicates with APT via the TCP/IP socket connection. So far everyting works great: I can send commands for exposures and the ASI-Cam does what I want
But I recogniced two minor issues:
1. In the filename the value for the exposure time ist missing and I get the following name: ATL_2017-02-04_17-35-35_NGC598_s.fit
If I make a single shot the filename is correct: Single__2017-02-04_17-41-18_NGC598_3s.fit
2. Is there any possibility to stop an exposure by a command via the socket connection from an external program?
Thank you for your help!
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
Hello BergAstro,
Many thanks!
I have investigated the problem and fixed it. Look for the correct exposure in the next version. As for the "Stop" command it is not supported yet - adding it into my ToDo list
Many thanks!
I have investigated the problem and fixed it. Look for the correct exposure in the next version. As for the "Stop" command it is not supported yet - adding it into my ToDo list
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Hello Ivo,
do you think is possible to add or extend an existing command in order to get more info about the progression of the plan? For istance C (n/m) could mean "capturing image n of m".
Happy new year an plenty of clear skies!
Giovanni.
do you think is possible to add or extend an existing command in order to get more info about the progression of the plan? For istance C (n/m) could mean "capturing image n of m".
Happy new year an plenty of clear skies!
Giovanni.
- Yoddha
- Site Admin
- Posts: 16290
- Joined: Thu Apr 17, 2014 3:48 pm
- Reputation: 837
- Location: Bulgaria
- Contact:
Hi Giovanni,
There are two parameters for external scripts that can do the job, or you have other idea?
%CurrExp% - the number of the current exposure
%TotalCount% - the total count of exposures to make in a plan
There are two parameters for external scripts that can do the job, or you have other idea?
%CurrExp% - the number of the current exposure
%TotalCount% - the total count of exposures to make in a plan
Clear skies,
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)
Ivo
May the weather be with you!
Astro Photography Tool (APT v4.80) - The Imaging Catalyst
My images (6 AAPODs, 1 Published)




