how to program onstep into arduino mega 2560


clambert24@...
 

Hi all.
please forgive me but i am a complete newb and novice at programming etc, but i am in need of desperate help. 
i am building my own telescope (https://www.instructables.com/Autoscope/) and i require to program and upload configuration files to my Arduino mega 2560 to get it to work. 
the onstep files i need are on this website https://www.instructables.com/Web-based-IOT-System-for-Telescope-Control/ and the files are on a google drive to be downloaded. 
the problem is, i have downloaded all the files, but then havnt a clue on how to upload/program them onto my arduino board as it keeps on coming up saying that there are errors etc. 
im even willing to pay someone to help program it for me, lol. 


 

I do not believe an Arduino Uno or similar board will work.  The MKS Gen L board, which I believe is based on the same processer (ATMega2560), does work.  Please let us know the specific make/model of the board you are using.


John Petterson
 

That version of OnStep at that address is very very very old (v1.1g).  I would strongly recommend loading the latest software (take the beta version, it is well tested and solid).  See this web page for help configuring and building it for your hardware: https://onstep.groups.io/g/main/wiki/11217

The Mega2560 and RAMPS board are not the best but they are certainly serviceable.

If you post the errors you are getting you can get some help with each of them. But first read the Wiki, it will tell you what libraries you need to download and add to your Arduino environment to get that working


clambert24@...
 

im using the mega 2560 as mentioned in my 1st post


clambert24@...
 

ok, so i didnt realise it was a very old version i was trying to use. 
so if i just downloaded say the beta version and loaded that into it, should that work? or would i need additional files etc. 
is there also a way to see if my arduino already has files loaded into it?


George Cushing
 

Go to the Wiki for RAMPS  & MKS Gen L. Not sure about the latest Beta, but v 3.16 should load. Get the Mega and the RAMPS 1.4 friendly first before diving into the rest of that Instructable. Good luck


clambert24@...
 

OK, so I downloaded 3.16, but upon opening the folder, it has multiple other files inside, (see attached pic)
Do I just click on the file that says onstep.ino and load that?  What are the other files for? 


George Cushing
 

OnStep.ino is a sketch most of the other files, libraries and sketches run inside or are called by OnStep.ino. So yes,  OnStep.ino is opened in the Arduino IDE. The IDE has to be able to find the supporting files and sub-directories.

You can get OnStep with the GitHub app or download the zipped file. I'm not sure that you can just copy and paste the file structure.


Khalid Baheyeldin
 

So you have an Arduino Mega2560.
That is a supported board, but it also needs a RAMPS 1.4 or 1.5 shield, in order to connect the StepStick drivers that will drive the stepper motors.

Use release 4.24, since it is the latest stable version.

The process of downloading OnStep, compiling it, and uploading it to the board is described fully here:

https://onstep.groups.io/g/main/wiki/3915


clambert24@...
 

OK, so just had an idea, am I right in saying that all the configuration and settings etc are saved in the config.h file? 
If so, would it be possible to install the latest version of onstep and then override the new config.h file with the old config.h file that has settings etc already saved into it? Would that work? 
Only reason I'm asking is because I don't fully know my telescope parameters .


Khalid Baheyeldin
 

On Wed, May 5, 2021 at 09:55 AM, <clambert24@...> wrote:
am I right in saying that all the configuration and settings etc are saved in the config.h file? 
If so, would it be possible to install the latest version of onstep and then override the new config.h file with the old config.h file that has settings etc already saved into it? Would that work? 
That depends on which version of OnStep the old Config.h is from.
In any case, it is best to manually edit the new Config.h with the values specific to your mount.
That way, the defaults from the new Config.h are in effect.

Only reason I'm asking is because I don't fully know my telescope parameters .
You mean you have Onstep running on it, but you don't remember the values?
If you attach the old working file, we can help with that.


clambert24@...
 

OK. No I haven't got it working at all and having trouble uploading it and I have been told its a very old version I obtained. Hence why I asked if I can use a config.h file that someone else has previously written. And I don't know the telescope parameters as I have built it from files /3d printing etc. 


Khalid Baheyeldin
 

You need to be specific so we can give you the right answers.

I assume from your wording that you got a mount from someone, and it is already running OnStep, but an old version.
Is this correct?

Can you get the Config.h from that person you got the mount from?
If so, then attach it to a message.

Otherwise, a lot of educated guesses are needed, e.g. by inspecting the mount, the gears/pulleys, and the motors.


"Guilherme Vênere
 

Khalid, i think the mount he's talking about is the one from the Instructables link he sent on the first email:


The design uses a split ring fork mount with 3D printed parts. I guess in order to find the values for using in the config he would need to count the teeth in the split ring wheel and the reduction from motor to the gear connected to ring. 

The instructable seems to be from 2018, and the other link he provided is from a super old OnStep version (1.1 I think) and i don't think the config would be compatible. Maybe just copying the step size entries if they were there in 1.1, but the best thing is to get the actual values from the mount itself

Guilherme 

On Wed, May 5, 2021 at 11:44 AM Khalid Baheyeldin <kbahey@...> wrote:
You need to be specific so we can give you the right answers.

I assume from your wording that you got a mount from someone, and it is already running OnStep, but an old version.
Is this correct?

Can you get the Config.h from that person you got the mount from?
If so, then attach it to a message.

Otherwise, a lot of educated guesses are needed, e.g. by inspecting the mount, the gears/pulleys, and the motors.


John Petterson
 

On Wed, May 5, 2021 at 01:19 PM, Khalid Baheyeldin wrote:
You mean you have Onstep running on it, but you don't remember the values?
If you attach the old working file, we can help with that.

Kahalid and George,  I downloaded the distribution that he linked to earlier in this thread.  The designer of the scope he is building used OnStep v1.1g and claims to have made some modifications to it.  I did not even start looking at what might have been modifications, it is so out of date.  I originally recommended he load the beta version and go form there.  But he seems to have less of a software comprehension than I thought.

So this is a new build, there is no working device or software, and he needs basic instruction. Both George and I have pointed him to the same OnStep page about the Mega2650/RAMPS builds.   The config.h file does not exist, there are a bunch of different config*.h files.  The configMega2560Alt.h is very different form today's config.h.  It may be better to just start from scratch in working out a configuration file:

// -----------------------------------------------------------------------------------
// Configuration for legacy OnStep "Alternate pin-map" (Mega2560)
// *** this is for backwards compatability with older OnStep systems ***

/*
 * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and
 * join the OnStep Groups.io at https://groups.io/g/onstep
 *
 * See the Pins.MiniPCB.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK ***
 *
*/

#define Mega2560Alt_OFF   //  <- Turn _ON to use this configuration

#ifdef Mega2560Alt_ON
// -------------------------------------------------------------------------------------------------------------------------
// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES --------------------------------------------------------------

// Default speed for Serial1 com port, Default=9600
#define SERIAL1_BAUD_DEFAULT 9600

// Mount type, default is _GEM (German Equatorial) other options are _FORK, _FORK_ALT.  _FORK switches off Meridian Flips after (1, 2 or 3 star) alignment is done.  _FORK_ALT disables Meridian Flips (1 star align.)
// _ALTAZM is for Alt/Azm mounted 'scopes (1 star align only.)
#define MOUNT_TYPE_GEM

// ST4 interface on Pins 47, 43, 45, 49.  Pin 47 is RA- (West), Pin 43 is Dec- (South), Pin 45 is Dec+ (North), Pin 49 is RA+ (East.)
// ST4_ON enables the interface.  ST4_PULLUP enables the interface and any internal pullup resistors.  default=_OFF
// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk.
#define ST4_OFF
// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used.
// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds...  In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.)
// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds...  In this mode [E] selects prior and [W] next user catalog item.
// [N] to do a Goto to the catalog item.  [S] for Sound on/off.  The keypad returns to normal operation after 4 seconds of inactivity.  ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses.
// Finally, during a goto pressing any button aborts the slew.  If meridian flip paused at home, pressing any button continues.  default=_ON
#define ST4_HAND_CONTROL_ON

// use separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON
#define SEPARATE_PULSE_GUIDE_RATE_ON

// Guide time limit (in seconds,) default=0 (no limit.)  A safety feature, some guides are started with one command and stopped with another.  
// If the stop command is never received the guide will continue forever unless this is enabled.
#define GUIDE_TIME_LIMIT 0

// RTC (Real Time Clock) support, default=_OFF. Other options: RTC_DS3234 for a DS3234 on the default SPI interface pins (and CS on pin 10, optionally wire the SQW output to the PPS pin below.)
#define RTC_OFF
// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor.  Sense rising edge on pin 21 for optional precision clock source (GPS, for example), default=_OFF
#define PPS_SENSE_OFF

// PEC sense on Pin 2 use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for Analog operation (on Pin A1,) default=_OFF
// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 2.92V
// With either index detection method, once triggered 60s must expire before another detection can happen.  This gives time for the index magnet to pass by the detector before another cycle begins.
// Ignored on Alt/Azm mounts.
#define PEC_SENSE_OFF
// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index
#define PEC_SENSE_STATE HIGH

// switch close (to ground) on Pin 3 for optional limit sense (stops gotos and/or tracking), default=_OFF
#define LIMIT_SENSE_OFF

// light status LED by sink to ground (Pin 9) and source +5V (Pin 8), default=_ON.
// _ON and OnStep keeps this illuminated to indicate that the controller is active.  When sidereal tracking this LED will rapidly flash
#define STATUS_LED_PINS_ON
// lights 2nd status LED by sink to ground (Pin 7), default=_OFF.
// _ON sets this to blink at 1 sec intervals when PPS is synced
#define STATUS_LED2_PINS_OFF
// lights reticule LED by sink to ground (Pin 44), default=_OFF.
// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness
#define RETICULE_LED_PINS_OFF

// Sound/buzzer on Pin 42, default=_OFF.
// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer.
#define BUZZER_OFF
// Sound state at startup, default=_ON.
#define DEFAULT_SOUND_ON

// optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF (limited testing done)
// can be turned on/off with the :Te# and :Td# commands regardless of this setting
#define TRACK_REFRACTION_RATE_DEFAULT_OFF

// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF
#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF

// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF
#define REMEMBER_PAUSE_HOME_OFF

// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT --------------------------------------------------------------------------------
#define REMEMBER_MAX_RATE_OFF        // set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF
#define MaxRate                   96 // this is the number of micro-seconds between micro-steps default setting and can be adjusted for two times lower or higher at run-time
                                     // minimum* (fastest goto) is around 32 (Mega2560,) default=96 higher is ok
                                     // * = minimum can be lower, when both AXIS1/AXIS2_MICROSTEPS are used the compiler will warn you if it's too low

#define DegreesForAcceleration   5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration
                                     // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled.
#define DegreesForRapidStop      1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration
                                     // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled.

#define BacklashTakeupRate        25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall,
                                     // too slow and the mount will be sluggish while it moves through the backlash
                                     // for the most part this doesn't need to be changed, but adjust when needed.  Default=25

                                     // Axis1 is for RA/Az
#define StepsPerDegreeAxis1  12800.0 // calculated as    :  stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360)
                                     // G11              :  400           * 32          * 1               *  360/360              = 12800
                                     // Axis2 is for Dec/Alt
#define StepsPerDegreeAxis2  12800.0 // calculated as    :  stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360)
                                     // G11              :  400           * 32          * 1               *  360/360              = 12800
                                     
                                     // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2.  Ignored on Alt/Azm mounts.
#define StepsPerWormRotationAxis1 12800L
                                     // G11              : (12800*360)/360 = 12800

#define PECBufferSize           824  // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240)
                                     // for the most part this doesn't need to be changed, but adjust when needed.  824 seconds is the default.  Ignored on Alt/Azm mounts.

#define MinutesPastMeridianE      30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30.  Sometimes used for Fork mounts in Align mode.  Ignored on Alt/Azm mounts.
#define MinutesPastMeridianW      30 // as above, if on the West side of the pier.  If left alone, the mount will stop tracking when it hits the this limit.  Sometimes used for Fork mounts in Align mode.  Ignored on Alt/Azm mounts.
                                     // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this!  
                                     // If you don't remove these lines Meridian limits will return to these defaults on power up.
#define UnderPoleLimit            12 // maximum allowed hour angle (+/-) under the celestial pole. OnStep will flip the mount and move the Dec. >90 degrees (+/-) once past this limit.  Sometimes used for Fork mounts in Align mode.  Ignored on Alt/Azm mounts.
                                     // If left alone, the mount will stop tracking when it hits this limit.  Valid range is 7 to 11 hours.
#define MinDec                   -91 // minimum allowed declination, default = -91 (off)  Ignored on Alt/Azm mounts.
#define MaxDec                   +91 // maximum allowed declination, default =  91 (off)  Ignored on Alt/Azm mounts.
                                     // For example, a value of +80 would stop gotos/tracking near the north celestial pole.
                                     // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but
                                     // that can be easily worked around by doing an alignment once and saving a park position (assuming a
                                     // fork/yolk mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky)
#define MaxAzm                   180 // Alt/Az mounts only. +/- maximum allowed Azimuth, default =  180.  Allowed range is 180 to 360

// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------
// Axis1: Pins 35,37 = Step,Dir (RA/Azm)
// Axis2: Pins 24,22 = Step,Dir (Dec/Alt)

// Reverse the direction of movement.  Adjust as needed or reverse your wiring so things move in the right direction
#define REVERSE_AXIS1_OFF            // RA/Azm axis
#define REVERSE_AXIS2_OFF            // Dec/Alt axis

// Stepper driver Enable support is always on, just wire Enable to Pins 23 (Axis1) and 36 (Axis2) and OnStep will pull these HIGH
// to disable stepper drivers on startup and when Parked or Homed.  An Align or UnPark will enable the drivers.  Adjust below if you need these pulled LOW to disable the drivers.
#define AXIS1_DISABLED_HIGH
#define AXIS2_DISABLED_HIGH

// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use.  During low rate guiding (<=1x) the axis stays enabled
// for 10 minutes after any guide on either axis.  Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops.
#define AUTO_POWER_DOWN_AXIS2_OFF

// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// If used, this requires connections M0, M1, and M2 on Pins 29,27,25 for Axis1 (RA/Azm) and Pins 30,32,34 for Axis2 (Dec/Alt).
// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, TMC2208, TMC2130 (spreadCycle,)
// TMC2130_QUIET (stealthChop tracking,) TMC2130_VQUIET (full stealthChop mode,) add _LOWPWR for 50% power during tracking (for example: TMC2130_QUIET_LOWPWR)
#define AXIS1_DRIVER_MODEL_OFF      // Axis1 (RA/Azm):  Default _OFF, Stepper driver model (see above)
#define AXIS1_MICROSTEPS_OFF        // Axis1 (RA/Azm):  Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32)
#define AXIS1_MICROSTEPS_GOTO_OFF   // Axis1 (RA/Azm):  Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2)
#define AXIS2_DRIVER_MODEL_OFF      // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above)
#define AXIS2_MICROSTEPS_OFF        // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking
#define AXIS2_MICROSTEPS_GOTO_OFF   // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos
// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . .

// Stepper driver Fault detection, just wire the driver Fault signal to Pins 39 (Axis1) and 38 (Axis2), default=_OFF.
// other settings are LOW, HIGH, SPI.  The SPI interface (on M0/M1/M2/Aux) can be used to detect errors on the TMC2130.
#define AXIS1_FAULT_OFF
#define AXIS2_FAULT_OFF

// ------------------------------------------------------------------------------------------------------------------------
// FOCUSER ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------
// A9,A8 = Step,Dir
#define ROTATOR_OFF                  // enable or disable rotator feature (for any mount type,) default=_OFF (de-rotator is available only for MOUNT_TYPE_ALTAZM.)
#define MaxRateAxis3               8 // this is the minimum number of milli-seconds between micro-steps, default=8
#define StepsPerDegreeAxis3     64.0 // calculated as    :  stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360)
                                     // Rotator          :  24            * 8           * 20              *  6/360                = 64
                                     // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree)
                                     // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360
#define REVERSE_AXIS3_OFF            // reverse the direction of Axis3 rotator movement
#define MinAxis3                -180 // minimum allowed Axis3 rotator, default = -180
#define MaxAxis3                 180 // maximum allowed Axis3 rotator, default =  180

// FOCUSER1 ---------------------------------------------------------------------------------------------------------------
// A11,A10 = Step,Dir
#define FOCUSER1_OFF                 // enable or disable focuser feature, default=_OFF
#define MaxRateAxis4               8 // this is the minimum number of milli-seconds between micro-steps, default=8
#define StepsPerMicrometerAxis4  0.5 // figure this out by testing or other means
#define REVERSE_AXIS4_OFF            // reverse the direction of Axis4 focuser movement
#define MinAxis4               -25.0 // minimum allowed Axis4 position in millimeters, default = -25.0
#define MaxAxis4                25.0 // maximum allowed Axis4 position in millimeters, default =  25.0

// FOCUSER2 ---------------------------------------------------------------------------------------------------------------
// A13,A12 = Step,Dir
#define FOCUSER2_OFF                 // enable or disable focuser feature, default=_OFF
#define MaxRateAxis5               8 // this is the minimum number of milli-seconds between micro-steps, default=8
#define StepsPerMicrometerAxis5  0.5 // figure this out by testing or other means
#define REVERSE_AXIS5_OFF            // reverse the direction of Axis5 focuser movement
#define MinAxis5               -25.0 // minimum allowed Axis5 position in millimeters, default = -25.0
#define MaxAxis5                25.0 // maximum allowed Axis5 position in millimeters, default =  25.0

// THAT'S IT FOR USER CONFIGURATION!

// -------------------------------------------------------------------------------------------------------------------------
#define FileVersionConfig 1
#include "Pins.Mega2560Alt.h"
#endif


clambert24@...
 

Hi John. 
Many thanks for looking into my problem , but yes you are correct I basically have zero software programming experience unfortunately.  I'm an electrician by trade and very good at building etc and following wiring diagrams hence why I have enjoyed building this telescope,  and when it came to the software side of things, if I'm honest I just thought it would be simply a case of uploading all relevant files etc to the electronics as someone has programmed and done it before . (Obviously my mistake) so I would be very grateful for any help received.  


John Petterson
 

Okay, here is my recommendation now.

Read the Wiki.  There is a lot or information there.  Start at the top go though the pages.  You have what is called a fork mount as far as this controller is concerned - an ALTAZ mount that is tilted to align the zeinith with the pole, so keep that in mind.  You can ignore all the pages on other board combinations in the construction part of the Wiki, but read the first couple (simple and solderless breadboard) as they will give you good information.  There is  a lot of information about how to set up the Arduino environment and where to get all of the other libraries you will need.

Under addons and accessories, you will need at least one of those to control your OnStep or else you can do it through the USB on the Mega board with the OnStep Ascom driver and a PC.  I have not built one of those Mega based controllers, perhaps someone who has one can comment on what is best for that board. 

You will have to evaluate the gear ratios on the two axes to work out the steps per degree that is needed to tell the controller how to move.  Read the wiki, come back with questions.  The files at the link you posted are showing the defaults so I do not think they are modified for this telescope design.

The solution is not going to be a plug-n-play like you hoped, but many people have these running and there is support to get it going.


John Petterson
 

One note to lift some concern - what is required to get this to work is not programming.  It is configuration of parameters.  You just have to learn what parameters and how to set them, and the Wiki will fill in most of that information for you.


clambert24@...
 

You sir are a massive help, and I appreciate everything you have said and I shall definitely look into what you have said. 
Also on a side note, I forgot to say that I have a raspberry pi to directly connect to the Mega to hopefully connect it to the Internet etc and to control it by using stellarium.  I have hopefully already managed to set that up easier and would then just need to get them to talk to each other. 
Looks like I have got some studying to do and try to work things out.