OnStep + ESP32 (WemosD2R32) + Motor Shield V3 + Wii Nunchuk


Guillermo Moncho
 
Edited

OnStep over ESP32 (WemosD2R32) + Motor Shield V3 for Arduino Uno + Wii Nunchuk

Hi!, I would like to add this configuration to OnStep.
ESP32 (WemosD2R32) and Motor Shield V3 for Arduino Uno is a very cheap combo to OnStep
Wii Nunchuk add a progressive telescope control.
 Enjoy it!

Thanks for the contribution to this great project and to this beautiful hobby.
https://www.youtube.com/embed/eVHMd18ACAg
https://www.youtube.com/embed/W1FSWNr1TMs
[youtube]eVHMd18ACAg[/youtube]
Files:
https://drive.google.com/drive/folders/1C6MUH68avHqFAwO6Ef513-WHIKdhWHP2?usp=sharing


Khalid Baheyeldin
 

This is just brilliant!

Ladies and gentlemen ... we have here something very different: a member who did his own port to a new low cost  board!

Guillermo started with very low cost, off the shelf components: no soldering!

The board is an ESP32 board ($9 with shipping) with a CNC shield ($6 with shipping).

He created his own pinmap, and modified OnStep to run on this very low cost solution!
There are 4 motor axes (so an additional rotator or focuser, one more than the MiniPCB or STM32).

I am really impressed!

Howard, Guillermo's changes really need to go into OnStep master. It already works!
The pinmap may require some tuning, and some added features get pins assigned.
The Nunchuck should be an optional feature, since not everyone has such a device.


Howard Dutton
 

On Thu, Apr 2, 2020 at 12:38 PM, Khalid Baheyeldin wrote:
Howard, Guillermo's changes really need to go into OnStep master. It already works!
The pinmap may require some tuning, and some added features get pins assigned.
Agree, designing a pinmap for the board combination might very well be a worth while en-devour, I'd really have to analyze it to be sure though.  ESP32 pin mappings can be very tricky and it's all too easy to make a mistake and assign a pin incorrectly where the boot state (HIGH/LOW) is critical or an input only pin being used for an output.  I'd have to look more closely and think about the trade-offs to really come up with something with universal appeal.  Perhaps a single micro-step mode control line (M0?) for Axis1 and 2.  Using only two pins that makes it easier to solder (if you really need it) and achieves the speedup with minimal hassle while saving pins.  For something like this where ultra low cost and minimal soldering is a priority perhaps TMC2130/etc. support shouldn't be considered a given.

The Nunchuck should be an optional feature, since not everyone has such a device.
My gut feeling for the Nunchuck is that it's not something I want to get into adding to OnStep.  Keep it modular and it's easy to port though


Khalid Baheyeldin
 

On Thu, Apr 2, 2020 at 05:05 PM, Howard Dutton wrote:
Perhaps a single micro-step mode control line (M0?) for Axis1 and 2.  Using only two pins that makes it easier to solder (if you really need it) and achieves the speedup with minimal hassle while saving pins.  For something like this where ultra low cost and minimal soldering is a priority perhaps TMC2130/etc. support shouldn't be considered a given.
You need to take that CNC shield into account. What pins does it connect to what.
If it hard wires something, the pinmap has to conform to that.

But Guillermo showed us something awesome: for a basic setup that includes WiFi (or was it only Bluetooth, no idea) and not much else, this is a very cheap, very easy to put together, and very functional controller.

If we can squeeze in some extra functionality with some extra pins, that is good. If not, it is still adequate.


Guillermo Moncho
 

That's right, in esp32 there is some critical pin needed for a right boot.  Others have some output level or are pulled during boot.

In this project I have only used a few pins, only pins for the drivers and I2C.  Please modify or remap everything you consider appropriate.  Best regards.

I started an encoder adaptation, but it is unfinished.  Please do not consider it in the code.


Peter Dulowsky <peter.dulowsky@...>
 

On Fri, Apr 3, 2020 at 02:07 AM, Khalid Baheyeldin wrote:
But Guillermo showed us something awesome: for a basic setup that includes WiFi (or was it only Bluetooth, no idea) and not much else, this is a very cheap, very easy to put together, and very functional controller.
I really like the idea that Guillermo had :) Well done. 


Howard Dutton
 

On Thu, Apr 2, 2020 at 05:07 PM, Khalid Baheyeldin wrote:
But Guillermo showed us something awesome: for a basic setup that includes WiFi (or was it only Bluetooth, no idea) and not much else, this is a very cheap, very easy to put together, and very functional controller.
When running OnStep on the ESP32 Bluetooth is available with no additional components, which is enough to get the job done as you can then control from the Android App etc.


Howard Dutton
 

On Thu, Apr 2, 2020 at 09:58 PM, Peter Dulowsky wrote:
I really like the idea that Guillermo had :) Well done. 
Agree... this really has the potential to be a replacement for the MKS Gen-L.


Lloyd Simons
 

I was gifted a Vixen Super Polaris mount last summer and have been hoping to convert it to goto via OnStep for a while now. I have zero experience soldering PCBs so I was a bit hesitant to dive into this project. But then last week Guillermo posted this configuration that requires minimal soldering and has the potential to be a full featured controller for minimal investment. I thought this looked like a perfect place for me to start (thanks Guillermo and Howard!).
 
I have read through the site and the wiki and plan to use components similar to what others before me have completed :
 
Nema 17  steppers (0.9A, 0.9°) PN 17HM150904S with 3:1 GR (48t and 16t pulleys) operating with 1/32 microsteps
LV8729 drivers (I have the 220 ohm version so I was going to start with Vref at 0.5V ie 0.9A*50%*1.1) to give me about 0.45A
The Wemos D1R32 ESP32 board and CNC shield from Gulliermo's build (less than $20 US including tax and shipping from US suppliers).
I updated the OnStep version shared by Guillermo with my settings from Howard's spreadsheet and it compiled without error. I have yet to upload this to the board.
I do not plan to use the Nunchuk feature at this time. 
 
I had a couple of questions. Guillermo soldered wires for M1, M2 and M3.  Since I wasn't planning on using SPI drivers, do I need to do this? Can I just use the appropriate jumpers for 1/32 microsteps?
 
Do I need to remove the 10K pullup resistor on the CNC board? Being a noob I am not sure what either of these modifications are for.
 
I understand this is still an "experimental" board at this point and that there may be some bugs associated with it, but for such a minimal investment, I couldn't resist. I appreciate all the work that has been done on this project and any help you can offer. 

Lloyd


Khalid Baheyeldin
 

If I were in your shoes, I would wait until the pinmap is revised by Howard, and merged into OnStep.
Starting work on this board now may mean that you may need to modify the wiring later, which may be hard (depending on what the changes are, and how you did them)

In the meantime, the MKS Gen-L works well, and has been used by many people.
It requires no soldering.
It has the advantage of supporting 2 focusers, and two heaters as well.


Lloyd Simons
 

Thanks Khalid. That makes sense. I'll be waiting for my pulleys for a while. I might give the MKS a try when they arrive.

Lloyd


Guillermo Moncho
 
Edited

Hi Lloyd Simons, 
First of all, thank you for appreciating my contribution, like Howard, Khalid and Peter.
10k resistor must be removed. A pull-up to 5v will cause a boot failure. Esp32 is not 5v tolerant unlike Esp8266.
At the moment OnStep firmware needs a M1, M2 and M3 (or SPI), I thing for differents velocities (guide and tracking). Code can be modified to do not use M1 to M2, it is a opinion. I am sure Howard can clarify this better than me.
Best regards
A, 


Lloyd Simons
 

Thanks Guillermo for the clarification. If Howard is planning on adding this configuration to OnStep I think I should take Khalid's advice and wait for those changes. However, the CNC shield is only a few bucks so.... I may try to experiment.


Howard Dutton
 

On Thu, Apr 9, 2020 at 04:23 PM, Guillermo Moncho wrote:
First of all, thank you for appreciating my contribution, like Howard, Khalid and Peter.
10k resistor must be removed. A pull-up to 5v will cause a boot failure. Esp32 is not 5v tolerant like Esp8266.
Good to know.

At the moment OnStep firmware needs a M1, M2 and M3 (or SPI), I thing for differents velocities (guide and tracking). Code can be modified to do not use M1 to M2, it is a opinion. I am sure Howard can clarify this better than me.
Best regards
M0, M1, M2, M3 are not by any means required.  On the slow Mega2560 having some sort of mode control is a big deal and often needed to cover the full range from fine motor control during tracking to high slew speeds.  The ESP32 is fast enough to usually get the job done without mode switching.


Howard Dutton
 
Edited

Guillermo,

The following is your pin-map minus the Wii controller stuff.

Here are the issues I see:
  • Aux2 providing MISO for Axis1&2 should be ok, but other purposes it was assigned to it will not work since it is an input only pin.
  • Aux8 will not work for any of the purposes it was assigned to since it is an input only pin.
  • Axis1_M2 and Axis2_M2 will not work, they are input only pins.

// -------------------------------------------------------------------------------------------------
// Pin map for CnC_shield Version 3 (with WeMos D1 R32)

#if defined(ESP32)

// The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported)
#define Aux2                 39     // [input only 39] {was 4} ESP8266 RST control, or MISO for Axis1&2, or Axis4 EN support
#define Aux3                 21     // Dew Heater 1, Home SW for Axis1, or I2C SDA
#define Aux4                 22     // Dew Heater 2, Home SW for Axis2, or I2C SCL
#define Aux7                 13     // {was 39} Limit SW, PPS, etc.
#define Aux8                 36     // [input only 36] {was 25} OneWire, Status LED, Status2 LED, Reticle LED, Tone, etc.

// Misc. pins
#ifndef OneWirePin
  #define OneWirePin       Aux8     // Default Pin for OneWire bus
#endif
#define ESP8266Gpio0Pin      27     // {was 26} ESP8266 GPIO0 (Dir2)
#define ESP8266RstPin      Aux2     // ESP8266 RST

// The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset
#define PecPin               39     // [input only 39] {was 36}
#define AnalogPecPin         A0     // PEC Sense, analog or digital (GPIO36)

// The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED
#define LEDnegPin          Aux8     // Drain
#define LEDneg2Pin         Aux8     // Drain
#define ReticlePin         Aux8     // Drain

// For a piezo buzzer
#define TonePin            Aux8     // Tone

// The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency
#define PpsPin             Aux7     // PPS time source, GPS for example

#define LimitPin           Aux7     // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking

// Axis1 RA/Azm step/dir driver
#define Axis1_EN             12     // [must be low at boot 12] Enable
#define Axis1_M0             18     // {was 13} Microstep Mode 0 or SPI MOSI
#define Axis1_M1             19     // {was 14} Microstep Mode 1 or SPI SCK
#define Axis1_M2             34     // [input only 34] {was 23} Microstep Mode 2 or SPI CS
#define Axis1_M3           Aux2     // SPI MISO/Fault
#define Axis1_STEP           26     // {was 18} Step
#define Axis1_DIR            16     // {was 0} Dir
#define Axis1_DECAY    Axis1_M2     // Decay mode
#define Axis1_HOME         Aux3     // Sense home position

// Axis2 Dec/Alt step/dir driver
#define Axis2_EN             12     // Enable
#define Axis2_M0              2     // {was 13} Microstep Mode 0 or SPI MOSI
#define Axis2_M1              4     // {was 14} Microstep Mode 1 or SPI SCK
#define Axis2_M2             35     //
[input only 35] {was 5} Microstep Mode 2 or SPI CS
#define Axis2_M3           Aux2     // SPI MISO/Fault
#define Axis2_STEP           25     // {was 27} Step
#define Axis2_DIR            27     // {was 26} Dir
#define Axis2_DECAY    Axis2_M2     // Decay mode
#define Axis2_HOME         Aux4     // Sense home position

// For rotator stepper driver
#define Axis3_EN             -1     // Enable
#define Axis3_STEP            2     // Step
#define Axis3_DIR            15     // Dir

// For focuser1 stepper driver
#define Axis4_EN           Aux2     // Enable
#define Axis4_STEP           19     // Step
#define Axis4_DIR            15     // Dir

// For focuser2 stepper driver
#define Axis5_EN             -1     // Enable
#define Axis5_STEP            2     // Step
#define Axis5_DIR            15     // Dir

// ST4 interface
#define ST4RAw               34     // [input only 34] ST4 RA- West
#define ST4DEs               32     // ST4 DE- South
#define ST4DEn               33     // ST4 DE+ North
#define ST4RAe               35     // [input only 35] ST4 RA+ East

#else
#error "Wrong processor for this configuration!"

#endif


Howard Dutton
 

Here is a re-design that addresses all issues I know of, there is one concession relative to the MaxPCB3 pin-map/feature support and that's due to GPIO0 not being present.  This causes a trade-off where the optional MISO from TMC drivers is no longer available.  Instead this uses Aux2 for the Axis2 CS pin to allow TMC2130 etc. stepper drivers.  Supporting these drivers makes sense for the sae reason as with the RAMPS boards because they are available off the shelf with SPI pins up which simplifies wiring them in though this isn't "point to point" wiring like the RAMPS but rather a bus type layout for two drivers only (Axis1 and Axis2.)

Note: I don't have this hardware and am only working from what I read/see, this may or may not have problems...

// -------------------------------------------------------------------------------------------------
// Pin map for CnC_shield Version 3 (with WeMos D1 R32)

// Notes:
// Serial2: will need to be re-mapped to GPIO13 (RX) and GPIO5 (TX) in the HAL
// SPI for TMC drivers: GPIO32 (MOSI), GPIO33 (SCK), GPIO15 (CS Axis1) on WeMos D1 R32 PCB are more difficult to wire into but optional. GPIO18 (CS Axis2) is on top.

#if defined(ESP32)

// The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported)
#define Aux2                 18     // ESP8266 RST control, or Axis2 CS support
#define Aux3                 21     // Home SW for Axis1, or I2C SDA {assuming default SCL/SDA pins are present}
#define Aux4                 22     // Home SW for Axis2, or I2C SCL
#define Aux7                 39     // Limit SW, PPS, etc.
#define Aux8                 23     // {was 25} OneWire, Status LED, Status2 LED, Reticle LED, Tone, etc.

// Misc. pins
#ifndef OneWirePin
  #define OneWirePin       Aux8     // Default Pin for OneWire bus
#endif
#define ESP8266Gpio0Pin      27     // {was 26} ESP8266 GPIO0 (Dir2)
#define ESP8266RstPin      Aux2     // ESP8266 RST

// The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset
#define PecPin               36     // [input only 36]
#define AnalogPecPin         A0     // PEC Sense, analog or digital (GPIO36)

// The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED
#define LEDnegPin          Aux8     // Drain
#define LEDneg2Pin         Aux8     // Drain
#define ReticlePin         Aux8     // Drain

// For a piezo buzzer
#define TonePin            Aux8     // Tone

// The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency
#define PpsPin             Aux7     // PPS time source, GPS for example

#define LimitPin           Aux7     // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking

// Axis1 RA/Azm step/dir driver
#define Axis1_EN             12     // [must be low at boot 12] Enable
#define Axis1_M0             32     // {was 13} Microstep Mode 0 or SPI MOSI
#define Axis1_M1             33     // {was 14} Microstep Mode 1 or SPI SCK
#define Axis1_M2             15     // {was 23} Microstep Mode 2 or SPI CS
#define Axis1_M3           Aux2     // SPI MISO/Fault
#define Axis1_STEP           26     // {was 18} Step
#define Axis1_DIR            16     // {was 0} Dir
#define Axis1_DECAY    Axis1_M2     // Decay mode
#define Axis1_HOME         Aux3     // Sense home position

// Axis2 Dec/Alt step/dir driver
#define Axis2_EN             12     // [must be low at boot 12] Enable
#define Axis2_M0             32     // {was 13} Microstep Mode 0 or SPI MOSI
#define Axis2_M1             33     // {was 14} Microstep Mode 1 or SPI SCK
#define Axis2_M2             18     // {was 5} Microstep Mode 2 or SPI CS
#define Axis2_M3           Aux2     // SPI MISO/Fault
#define Axis2_STEP           25     // {was 27} Step
#define Axis2_DIR            27     // {was 26} Dir
#define Axis2_DECAY    Axis2_M2     // Decay mode
#define Axis2_HOME         Aux4     // Sense home position

// For rotator stepper driver
#define Axis3_EN             -1     // Enable {enable pin disabled so focuser/rotator doesn't impact main axes EN state}
#define Axis3_STEP           17     // {was 2} Step
#define Axis3_DIR            14     // {was 15} Dir

// For focuser1 stepper driver
#define Axis4_EN             -1     // Enable {enable pin disabled so focuser/rotator doesn't impact main axes EN state}
#define Axis4_STEP           19     // {was 19} Step
#define Axis4_DIR            14     // {was 15} Dir

// For focuser2 stepper driver
#define Axis5_EN             -1     // Enable {enable pin disabled so focuser/rotator doesn't impact main axes EN state}
#define Axis5_STEP           17     // {was 2} Step
#define Axis5_DIR            14     // {was 15} Dir

// ST4 interface
#define ST4RAw               34     // [input only 34] ST4 RA- West
#define ST4DEs                2     // {was 32} ST4 DE- South
#define ST4DEn                4     // {was 33} ST4 DE+ North
#define ST4RAe               35     // [input only 35] ST4 RA+ East

#else
#error "Wrong processor for this configuration!"

#endif


Guillermo Moncho
 

Hi Howard, 
I will be Happy to test it, but I only have two drivers at the monent (LV8729). I am waiting for others from  Aliexpress but shippings are clogged due this global scene
Best regards


Howard Dutton
 
Edited

On Fri, Apr 10, 2020 at 09:13 AM, Guillermo Moncho wrote:
I will be Happy to test it, but I only have two drivers at the monent (LV8729). I am waiting for others from  Aliexpress but shippings are clogged due this global scene
It is not required to use TMC SPI drivers with this pin-map.  LV8729, etc. should work but without micro-step mode switching (more to it but lets leave it at that for now.)

I found an open license CnC V3 PCB design here:
https://github.com/staticboards/sb-cnc-shield

Thus I created this to help guide us (slight differences from some other Cnc V3 boards but appears similar enough for our purposes.)  The yellow rectangles are the shunt positions to couple the Axis3 and Axis4 Dir signals and to couple Axis4 Step to IO19.  Note that SCL and SDA on the shield are NOT really SCL and SDA since those pins are only present on the WeMos D2 R32 board.  Also only present on the WeMos D2 R32 are IO15, IO33, and IO32 which are used for SPI (AXIS1 CS, SCK, MOSI):


Howard Dutton
 

The master branch OnStep now has experimental support for this new pin-map.


Lloyd Simons
 

Excellent Howard! I hope to be able to test this out soon. With the LV8729 drivers I have do I need to jumpers on the board for the desired microsteps or is that handled by the software alone? Thanks so much for all of the work!