Telescope mount
LX200 protocol: East is negative libnova: East is positive
Contents
Links
- A3967 Datasheet
- Easy Driver schematics
- INDI protocol
- STM32vlDiscovery schematics
- STM32F100 pin layout etc
- STM32 M3 reference manual
- Newlib stubs
- Positional astronomy
- Motion profiles why s-curves
- Telescope pointing
- Motion Profile Calculations
- ChibiOS/RT
- soundstepper lx200 emulator commands
Captain's Log
Previously
- Installed the Code sourcery arm Lite gcc compiler (only 32 bit version, had to install ia32-libs)
- Got the STM32 firmware installed (used a script i found on the internets)
- Got timer working (make sure you first enable the system clock for the device, even for IO ports during pin setup)
Stardate 20121123
- The Makefile didn't work for Newlib (it went unnoticed since all the examples didn't use newlib functions).
- You need a stub file for newlib containing target-specific functions (eg. _write).
- Another problem was that my link step didn't use gcc but ld. gcc can find the correct lib itself (given that you add -mthumb -cpu=cortex-m3). This resulted in the use of BLX calls to newlib functions without bit 0 of the destination set. On Cortex-M3, with only thumb mode available, this causes a crash.
- I tested using GDB. To use 'call' with strings as parameters, malloc and free needed to be linked. So I briefly allocated some bytes in main.
- UART uses polling at the moment.
Current status: Now, I can access the UART using standard C library functions like printf. I also gained some insight into how the Firmware libraries work. While not a big fan yet, I'm slightly more convinced than previously that it might be worthwhile, esp. for initialisation.
Stardate 20121125
- Modified stubs to work with interrupts
- Wrote a sample CLI program that can do some useless things.
Current status: Mostly done playing with UART/Newlib. Now it's time to reintegrate the Stepper motor code (using firmware lib?), and make it do things with the UART command line.
Stardate 20121127
- Expanded the CLI with some motor control commands
- reintegrated TIMER3 initialisation and cleaned it up a (tiny) bit
- Changed interrupt source from update event (timer reaches ARR) to CC3 (compare value has been reached) so I can change things after the stepper pulse is sent
- Rewrote the timer interrupt
- Discovered I can crank up the testmotor voltage to 24V, much better torque (12V unipolar motor).
- Perhaps current setting of the driver is not correct.
Current status: I can control the motor using minicom: change speed, direction, query position. It can't stop yet, though.
Stardate 20121130
- Major breakthrough: Rewritten the entire timer IRQ so that it accepts commands from main through a FIFO.
- Each command is a motion segment (accelerate, cruise, stop)
- Debug pin shows IRQ length to be ~ 3us on idle, 25us while accelerating
- The algorithm is not perfect: when calculating the position change for an acceleration from 400steps/s to 4000steps/s at 400steps/s^2, I get 17800 steps (in 9s time). However, measurements show that the actual value is 2033 ticks off. This will have to be investigated further, but it's most likely a rounding error.
Current status: Trapezium profiles can be entered by hand. Next a compiler for these things has to be written.
Stardate 20121202
- Trapezoidal profiling added
- Improved the accuracy
- Got the second timer working (on PA2, direction is PA1)
- Dissected the Polaris mount. The motors attached are PF42-4813G: 20Ω, 315mA per phase. Gearbox is 1:120.
- The motors of the SkySensor are PF42-48G: 100Ω, 90mA per phase, Gearbox is 1:300.
- For R.A I have to turn the knob 10 times to move 1h
- For DEC, 4 turns equal 10°.
- Added the second EasyDriver board
- The DMD-2 is now officially declared dead. I cut the R.A. cable and soldered a second connector on it.
- Connected the setup with the telescope mount.
Current status: Great progress today, I can now begin testing with the telescope. Movements are very slow, even at max speed (~4000 steps/sec). Maybe stall speed is higher when full stepping is selected? BTW, for normal RA tracking, I calculated 128 microsteps/s would be needed... tested this and it goes rather smooth.
Stardate 20121203
- Performed some quick tests. At vmin/vmax/a = 1200/3000/600 the dec motor works repeatably, with 50° = 921570 steps
- HA motor shows some slippage (how???) UPDATE: This is not slippage of the mount, but of the HA ring
- RA is ~ 721200 steps/h
Stardate 20121207
- libnova compiles without a problem (well, there was this gnu lib extension in the tm struct that gave a problem)
- Linker errors turned out to be caused by a wrong ordering of the libraries (libnova uses math functions so the correct order is -lnova -lm)
- a hardfault was caused by a failed malloc while trying to print a double (decreased some buffer sizes).
- 100k size, flash is getting full...
- LX200 protocol spec is full of weird shit, either bugs or badly designed.
Stardate 20121209
- Got a preliminary version of the lx200 protocol to compile on the STM32
- to install the INDI server, sudo apt-get install indi-bin
Stardate 20121214
- I turned the timer code for the stepper motor into a C++ class, cleaned it up and added full documentation. It's rather clean code by now.
- There was a slight "gulp"-moment when I compiled the code: Code size had increased dramatically, even though I ditched most of the extra code (the LX200 emulator was gone, e.g.). With everything else removed, I arrived at around 115KB, with the emulator included I even came 36KB short! Finally I managed to reduce it by including the G++ compiler options
-fno-rtti -fno-exceptions
. Those features are real memory hogs, turning it of reduced the code size from 115KB to 36KB. I guess I'll have to live without them ;-). - Some errors have slipped into the code, a bug hunting session should clear this up.
Current status: A small step towards code cleanup has been taken, once I get the STM32EasyDriver class working, I can focus on the LX200 code again.
Stardate 20121215
- The EasyDriver class has been tested and works flawlessly as far as I know.
- The driver class has been tested on multiple timers and channels.
- MS1, MS2 and enable pins have been connected on the DEC motor. Functionality has been added to the class to control those pins.
- Step size can be changed on the fly without affecting the speed. While pretty cool, I discovered that step size has no effect on the stall speed. I hoped that with full steps I could achieve a higher stall speed (due to increased torque), but unfortunately this is not the case.
- I moved the CLI test code to a seperate file,
cli.cpp
. It has been thoroughly cleaned up and it now uses the EasyDriver class.
Goals
- To modernize the stepper controller of my telescope mount and make it interface a modern PC
- To gain an understanding in celestial coordinate systems
- To improve my electronics insights and confidence
- To better understand modern MCU design, in particular the Cortex-M3
- To dissect the INDI protocol and evaluate its capabilities and applications
- To have fun doing all of the above
Ideas
Make the controller's only interface USB, then make a dedicated remote control.
TODO
- Trapeziunprofiel motorsnelheid.
- UART driver schrijven.
- FTDI interface met STM32 bord.
- INDI protocol uitvlooien.
- Snelheid meten van de stappenmotoren met huidige controller.
- ADC driver schrijven.
- Joystick uitlezen.
- DIN connectoren zoeken voor motoren telescoop montering.
- Trigonometrie.