środa, 20 lipca 2022

OnStep controller based on Wemos D1 r32 (ESP32) and CNC v3 Part II

 


Automatic translation (Original)

    In the previous section ( Part I ) I described the quick implementation of a working OnStep controller based on the  Wemos D1 R32 (ESP32) and CNC3.

    Now I had some time for corrections and modifications, i.e. Part II. 

    I changed:

  1. Case housing Raspberry Pi (Astroberry) and OnStep
    • RJ45 ports with motor outputs
    • fastening to the tube for a screw thread 1/4
    • power switch and 12V power input 5.1 / 2.1
  2. RJ45 ports on a mount and RJ45 cable splitting the signal to RA and DEC motors
  3. RJ45 to 6 pin JST PH2.0mm cable for focuser
  4. Smart Web Server (SWS) on Wemos D1 Mini ESP32
  5. GamePad BT Magicsee R1 instead of Smart Hand Controller
  6. Astroberry and Indi server connected to OnStep via USB
  7. GOTO positioning and tracking adjustment in config.h

 New items:

Wemos D1 mini ESP32
5V step-down converter
RTC DS3231 module
Kradex Z78 case
Bluetooth GamePad R1

Useful links

Wiki OnStep

OnStep author's website  http://www.stellarjourney.com/  

Wiki WeMos R32 with CNC V3 Shield

Wiki Smart Web Server 

Wiki GamePad R1 Bluetooth

RJ45 housing and ports

I know that it would be nicer to print one of the many available enclosures on a 3D printer, but I would like to remind you that this is a budget project. I had this case at hand and its slightly larger size also solved the problem of connecting to the Raspberry Pi with Astroberry installed. A bit of cutting and soldering and the effect can be seen in the photo.   

Cables

Putting it all together was harder than I thought. The cables had to be easy to connect, but at the same time they had to behave properly during the rotation of the C4 (EQ3-2) assembly. A decision had to be made where to place the housing to minimize cable bending as the telescope moved. I chose to place the housing into the telescope tube. This keeps the cable to the focuser and the DEC motor stationary. Only the RA axis cable will have to withstand regular bending. Time will tell if the cable and RJ45 connector can handle it well.    


Smart Web Server and GamePad R1

   I was about to not connect the SWS anymore. Bluetooth connectivity with OnStep works acceptable, in addition, Indi on Astroberry provides many functionalities. But experience with the use of OnStep has shown that, unfortunately, a small adjustment is often required. Doing this on your phone in the OnStep app is a bit of a pain, especially without looking at the screen. That's why I got interested in GamePad. It was a bull's eye.

    It is very easy to use and handy. By the way, because it requires a Smart Web Server, I also have a wireless connection with a greater range than bluetooth. Additional advantages of SWS are the ability to connect more than one device at a time, a website, automatic connection to the WiFi network at home, and if it is not available, then issuing your own AP. No need to constantly restart the whole thing. All I had to do was provide a stable 5V. The one taken from the CNC was too weak. A Step-Down converter connected directly to the input 12V solved the problem.

Installing SWS for GamePad

Detailed instructions for installing SWS with GamePad support is  here . In short, you should:

  1. Download the SWS code from  GITHUB  by selecting Code -> Download ZIP
  2. Unpack to some directory and open in Arduino IDE
  3. Add in File-> Preferences "Additional Boards Manager URLs" value "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
  4. In Tools> Motherboard> Boards Manager to install ESP32 version 2.0.0
  5. Set in the menu Tools-> Board-> MH ET LIVE ESP32MiniKit and Partition Scheme-> No OTA (Large APP)
  6. Select the port that will appear after connecting ESP32 to USB (the number can be checked in the Device Manager)
  7. In the Extended.config.h file, turn on BLE_GAMEPAD ON and enter the MAC address of our GamePad in the BLE_GP_ADDR line. 
  8. Press "Upload" and wait for the message that it was successful.

New connectivity

Connectivity with OnStep can be provided in 4 ways.

1.  USB cable  connected to the Wemos D1 R32 port. In my case, this is how I connect to Astroberry on the Raspberry PI 4B, which is running the Indi server. 

2.  WiFi connectivity and control via IP port and Smart Web Server page. Very stable and works on multiple devices simultaneously.

3.  Bluetooth connectivity . Works, but requires pairing and re-pairing after restart. At least that's how it is with me.  

4. Wireless GamePad controller . If the MAC address of the device is correctly entered in the SWS configuration, then after switching on, its diode will flash blue for a while, when it goes out it means that the connection has been established. You should also activate the mode by pressing M and D simultaneously (the diode will blink once). From now on they work:

  • Joystick = N, S, E, W
  • Trigger up = Focuser -
  • Down trigger = Focuser +
  • A = Go to last location
  • B = Spiral search
  • C = Speed ​​reduction
  • D = Speed ​​increase
  • M = Park / UnPark (M is also an "emergency stop" of motors)

Summary of the second stage

The tests are still ongoing, but everything works quite stable and quite precisely. I will do the proper tests during my foray into the dark sky. 

wtorek, 19 lipca 2022

Kontroler OnStep oparty o Wemos D1 r32 (ESP32) i CNC v3 Part II




    W poprzedniej części (Part I) opisałem przyspieszoną realizację działającego kontrolera OnStep w oparciu o Wemos D1 R32 (ESP32) i CNC3.

    Teraz miałem trochę czasu na poprawki i rozbudowę czyli Part II. 

    Zmieniłem:

  1. Obudowa mieszcząca Raspberry Pi (Astroberry) i OnStep
    • gniazda RJ45 z wyjściami na silniczki
    • mocowanie do tuby pod śrubę gwint 1/4
    • włącznik i wejście zasilania 12V 5.1/2.1
  2. Gniazdo RJ45 na statywie i kabel RJ45 rozdzielający sygnał na silniki RA i DEC
  3. Kabel RJ45 na 6 pin JST PH2.0mm do focusera
  4. Smart Web Server (SWS) na Wemos D1 Mini ESP32
  5. GamePad BT Magicsee R1 zamiast Smart Hand Controller-a
  6. Astroberry i serwer Indi podłączony do OnStep po USB
  7. Regulacja pozycjonowania GOTO i śledzenia w config.h

 Nowe elementy:

Wemos D1 mini ESP32
Przetwornica step-down na 5V
Moduł RTC DS3231
Obudowa Kradex Z78
Bluetooth GamePad R1

Przydatne linki

Strona Wiki OnStep 

Strona autora projektu http://www.stellarjourney.com/  

Wiki WeMos R32 with CNC V3 Shield

Wiki Smart Web Server

Wiki Bluetooth GamePad R1

Obudowa i porty RJ45

Wiem, że ładniej by było wydrukować jedną z wielu dostępnych obudów na drukarce 3D, ale przypominam, że to projekt budżetowy. Tę obudowę miałem pod ręką i jej trochę większy rozmiar rozwiązał też problem połączenia z Raspberry Pi z zainstalowanym Astroberry. Trochę cięcia i lutowania i efekt widać na zdjęciu.   

Kabelki

Połączenie wszystkiego razem było trudniejsze niż myślałem. Kable musiały być łatwe do podłączania, ale jednocześnie musiały zachowywać się właściwie podczas obrotów montażu C4 (EQ3-2). Trzeba było podjąć decyzję, gdzie umieścić obudowę by podczas ruchu teleskopu zminimalizować zginanie kabli. Wybrałem umieszczenie obudowy do tuby teleskopu. Dzięki temu kabel do focusera i silnika osi DEC będzie nieruchomy. Jedynie kabel osi RA będzie musiał wytrzymać regularne zginanie. Czas pokaże czy kabel i złącze RJ45 dobrze to zniosą.    


Smart Web Server i GamePad R1

   Miałem już nie podłączać SWS. Łączność bluetooth z OnStep działa akceptowalnie, dodatkowo Indi na Astroberry zapewnia wiele funkcjonalności. Ale doświadczenie w czasie używania OnStep pokazało, że niestety często jest potrzebne dokonanie małej korekty ustawienia. Robienie tego na telefonie w aplikacji OnStep jest trochę uciążliwe, szczególnie bez patrzenia na ekran. Dlatego zainteresowałem się GamePad-em. To był strzał w dziesiątkę.

    Jest on bardzo łatwy w obsłudze i poręczny. A przy okazji ponieważ wymaga Smart Web Server-a, to mam też połączenie bezprzewodowe o większym zasięgu niż bluetooth. Dodatkowe zalety SWS to możliwość podłączenia więcej niż jednego urządzenia na raz, strona WWW, automatyczne łączenie się do sieci WiFi w domu, a jeśli jest niedostępna to wystawianie własnego AP. Brak konieczności ciągłego restartu całości. Jedyne co musiałem zrobić to zapewnić stabilne 5V. To brane z CNC było za słabe. Konwerter Step-Down podłączony bezpośrednio do wejściowego 12V rozwiązał problem.

Instalacja oprogramowania SWS dla GamePad-a

Szczegółowa instrukcja instalacji SWS z obsługą GamePadjest tu. W skrócie należy:

  1. Pobrać kod SWS z GITHUB wybierając Code -> Download ZIP
  2. Rozpakować do jakiegoś katalogu i otworzyć w Arduino IDE
  3. Dodać w File->Preferences "Additional Boards Manager URLs" wartość "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
  4. W Narzędzia>Płyta>Boards Manager doinstalować ESP32 w wersji 2.0.0
  5. Ustawić w menu Tools->Board->MH ET LIVE ESP32MiniKit i Partition Scheme->No OTA (Large APP)
  6. Wybrać port, który się pojawi po podpięciu ESP32 do USB (numer można sprawdzić w Menagerze Urządzeń)
  7. W pliku Extended.config.h włączyć BLE_GAMEPAD ON oraz wpisać MAC adres naszego GamePad-a w wierszu BLE_GP_ADDR. 
  8. Nacisnąć "Upload" i poczekać na komunikat, że się udało.

Łączność po nowemu

Łączność z OnStep można zapewnić na 4 sposoby.

1. Kabel USB podłączony do portu Wemos D1 R32. W moim wypadku tak podłączam do Astroberry na Raspberry PI 4B, na którym chodzi serwer Indi. 

2. Łączność WiFi i sterowanie przez port IP oraz strona Smart Web Server. Bardzo stabilne i działa jednocześnie na wielu urządzeniach.

3. Łączność Bluetooth. Działa, ale po restarcie wymaga kasowania parowania i ponownego parowania. Przynajmniej tak jest u mnie.  

4. Bezprzewodowy kontroler GamePad. Jeśli w konfiguracji SWS jest poprawnie wpisany MAC adres urządzenia, to po włączeniu, przez chwile jego dioda będzie mrugać na niebiesko, gdy zgaśnie oznacza to że nastąpiło połączenie. Należy jeszcze włączyć tryb wciskając jednocześnie M i D (dioda mrugnie raz). Od teraz działają:

  • Joystick = N,S,E,W
  • Trigger w górę = Focuser -
  • Trigger w dół = Focuser +
  • A = Idź do ostatniej lokalizacji
  • B = Wyszukiwanie spiralne
  • C =Zmniejszenie prędkości
  • D =Zwiększenie prędkości
  • M = Park/UnPark (M jest również „zatrzymaniem awaryjnym” silników)

Podsumowanie drugiego etapu

Testy jeszcze trwają, ale wszystko działa dość stabilnie i w miarę precyzyjnie. Właściwe testy zrobię podczas wypadu pod ciemne niebo. 



 


czwartek, 7 lipca 2022

OnStep controller based on Wemos D1 r32 (ESP32) and CNC v3 Part I

Automatic translation (Original)

   I decided to make a new OnStep controller based on the Wemos D1 R32 (ESP32) and CNC3. The controller based on the Arduino Mega + RAMPS clone works, but has performance limitations, which in practice results in  lack of precision during long position changes. Recently, on the OnStep website, it is written directly that it is too slow. ESP32 seems more promising. Additionally, it is small and requires almost no soldering and I had 2 weeks before going on vacation that I have to do it already :)

    Wemos D1 R32 (ESP32) + CNC v3 components are available for purchase immediately. Are cheap. I can also use some work from the Arduino Mega project.

 Components:

Wemos D1 R32 ESP32
Shield CNC v3
RTC DS3231 module

Case 
Stepper motor driver LV8729 2 pcs and A4988 1 pcs
DC 2.1 / 5.5 socket and a few meters extension cord for this plug
bistable rocker switch


A few links

OnStep group website

Wiki page 

Project author's website  http://www.stellarjourney.com/  

Wiki: The WeMos R32 with CNC V3 Shield

Thread about LV8729 adjustment

Realizations by assembly

Useful thread about LV8729


Connecting to the CNC

CNC v3 was created to support 3D printers. But OnStep has very similar needs: support for several stepper motors by stepstick controllers, connecting devices via serial and I2C ports.

Here's what I connected in the current version of the controller: 

1. Two LV8729 controllers to control telescope's RA / DEC axis motors and A4988 to control the focuser.

    Jumpers for setting microstepping are led out under the controllers. The speed is determined by applying voltage to the appropriate stepstick pin, i.e. by shorting the appropriate jumper. For LV8729 I set 64, for A4988 16. Calculator, for example hereAnd here is the description of LV8729.

2. RTC DS3231 module for operating the clock on the I2C link 

The page describing the connections suggests to give up the clock, but I already had it from the previous project, so I connected it. It is enough to properly connect to the I2C output and set the module model in config.h (at the configuration generation stage). 

Power

To work, the controller needs voltage in various ranges for the microcontroller and the CNC. 12V is in both of these ranges. I have a 5A power supply and a 9AH battery, so I chose this power supply. I connected everything to the 5,5 / 2,1 plug on the housing. 

Parameter Configuration and Generator

The OnStep configuration is stored in the config.h file. Manual modification is tedious. Fortunately, there is a configuration generator page from which you can generate our file. The procedure is as follows:
  1. In the excel document (download here) you need to set the parameters of the drives.
  2. The data must be filled in on the Configuration Generator page  . Some must be copied from the fields listed in excel.
  3. Press "Generate"
  4. Replace the downloaded file with the config.h file in the OnStep directory.
  5. That's all point 7 in the chapter below.
Several values ​​need to be explained.
    
    Excel:
  1. Stepper-Steps - the number of steps per revolution of the stepper motor. I have 200. 
  2. AXIS1_DRIVER_MICROSTEPS - microsteps set for tracking to RAMPS. For me 32. 
  3. GR1 - gear ratio on gears or planetary gear. For DEC, I have 60 teeth out of 20, which is a value of 3. For RA, I have 40 teeth out of 16, which is a value of 2.5.
  4. GR2 - the number of full revolutions of the telescope micromovement knob for 360 degrees rotation of the telescope tube in a given axis. If you do not find these parameters for your assembly in Net, it only remains to measure it empirically. For example, set the tube vertically (a spirit level will be useful) and rotate it until it reaches the level. Then you need to multiply it by 4. For my CG-4 these are: RA = 130, DEC = 64
  5. SLEW_RATE_BASE_DESIRED - expected tube speed in fast mode (in ° / s). If you give too high a value, the equipment may not be able to cope or the motors will work loudly. At the moment I am giving 1. It seems to me a good compromise between volume and speed.

    Generator:

  1. MICROSTEPS_GOTO - microsteps for fast motor movement. For me 2.
  2. Automatically Start Tracking  - useful when we test the motors and we do not have the ability to control the telescope's movements yet. But then it's better to turn it off.
    Additionally, I changed in the generated config.h:
    • MFLIP_SKIP_HOME  to ON, thanks to which it does not return to the starting position when changing the position at a long time
    • PIER_SIDE_PREFERRED_DEFAULT on EAST. I perform the tests on the balcony and I prefer the telescope to always be positioned on one side of the mount, in my case the eastern one.

Installing the software

Detailed instructions for installing OnStep on ESP32 + CNC3 are  here . In short, you should:

  1. Install the Arduino IDE
  2. Download the OnStep code from  GITHUB  by selecting Code -> Download ZIP
  3. Unpack it to some directory and open OnStep.ino in IDE
  4. Add in File-> Preferences "Additional Boards Manager URLs" the value "https://dl.espressif.com/dl/package_esp32_index.json" (if there was something, add a comma)
  5. In Tools> Board> Boards Manager to install ESP32
  6. Set in the menu Tools-> Board-> ESP32 Dev Module
  7. Select the port that will appear after connecting the board to USB (the number can be checked in the Device Manager)
  8. Overwrite the config.h file generated in the chapter above.
  9. If you do not have a library for RTC DS3231 by default, you will get an error. Go to Sketch-> Include library-> Manage Libraries and search for 'RTC by Makuna' on the list of available libraries and install.
  10. Press "Upload" and wait for the message that it was successful.

Communication

There are 4 ways to connect to OnStep.

1.  USB cable  connected to Wemos D1 R32 port. In my case, this is how I connect to Astroberry on the Raspberry PI 4B, which is running the Indi server. 

2.  WiFi connectivity . Requires the ESP8266 microcontroller to be connected to the serial port on the CNC. I have not implemented it at the moment.

3. Bluetooth connectivity . Since bluetooth is on ESP32 it works without any additional work. Yes, you can connect applications on your phone and computer. It works very stably  

4.  Ethernet port . I did not explore this solution because it was not practical for me. Details are in the OnStep Wiki.

Control

The best description is here . A few comments from me. ASCOM Driver is required for Windows. Then programs such as Stellarium, Cartes du Ciel or Sky Planetarium run. The driver allows you to handle the connection via a USB cable or via bluetooth.
But parking, unparking, star calibration or four-way arrow correction is impossible or only partially possible with these applications. Most importantly, OnStep needs to set the date and location to work properly. Since I do not have a GPS module, you have to start with the OnStep application on the mobile phone first. There, first set the time and perform the first offsets and calibrations. The control applications on the computer are free of charge, they are payable for the phone (except for the aforementioned OnStep).

Scenario:
  1. OnStep start (a few seconds after starting you hear a click from the motor)
  2. Searching for a bluetooth device called OnStep and connection (it works fine for me if I delete the remembered connection every time I restart OnStep and search again) 
  3. Launching the OnStep application on Android (if the device was restarted, it is better to kill the application and restart it after BT connection)
  4. You need to configure the connection type once in the application. Select the three dots in the upper right corner and click Connection.
  5. There, it is also worth setting "Observing Sites" to your geographic position.
  6. Setting the time and date in the "Initialize / Park" menu
  7. Next, you can select the position in this application or switch to, for example, Stellarium Mobile in the PLUS version (it cost about PLN 40, payment in the application). It will work on the same bluetooth connection. Once set, it will remember the settings. Here you can see the position of the telescope, you can also indicate a new position on the map.  
  8. If the telescope begins to diverge with the indicated target, you can always switch to the OnStep app. Use the Tracking option to correct and update the display.
  9. Sky Safari 6 PLUS works similarly to Stellarium (unfortunately it also costs about PLN 36). One note here: do not turn on the time setting, because it will set the time shift incorrectly. I haven't figured out why yet.

Case

    I had little time so I applied what was at hand. The housing from the food storage box turned out to be the perfect start. I only added a 5.5 / 2.1 power socket, a switch and led out the cables to the motors (in the future there will be a change to RJ sockets. Of course, it is worth thinking about the method of attaching the telescope tripod to the leg. I used two Velcro straps.  



Summary of the first stage

The controller is working. My budget (OK, very low budget) astrophoto set: Celestron C6n (150/750), SVBony SV105 planetary camera for the finder and T7C compatible with ASI120 for planetary photos gives me a lot of joy at the moment. The holiday was successful. 

Next steps to do / describe 

  1. At first I was thinking about resuscitating the Smart Hand Controler, but I just ordered the GamePad bluetooth from this Bluetooth GamePad Option description .  
  2. GamePad requires Smart Web Server based on additional ESP32. Best in the D1 mini ESP32 version, although others are also suitable.
  3. Replacement of cables for motors on RJ45 with rigidly fixed ports on the assembly. Choosing RJ45 over RJ11 or RJ12 is conscious. A much larger selection of sockets and cables, and for a much lower price.
  4. Connecting Onstep to Astroberry on Raspberry Pi. The USB connection is already working. This allows applications to connect to the Indi server on the Raspberry Pi.
  5. The use of PHD2 operating on Astroberry for guiding, i.e. correction of following the movement of the observed object.
  6. New handy case, housing OnStep and Raspberry Pi. The Kradex z78 was on hand .