Welcome, Guest. Please login or register.

Username: Password:

Author Topic: Change code to support LV8729 1/64 microstepping for mega2560  (Read 1925 times)

kaito83

  • Full Member
  • ***
  • Posts: 47
    • View Profile

Hello Thomas,

I decided to modify your code to support 1/64 microstepping.
That's what I've done so far:

AstroEQ.cpp:
Added new case to drv882x
Code: [Select]
                case 64:
                    // 1/64
                    modeState[SPEEDNORM] = (( HIGH << MODE2) | (  HIGH << MODE1) | ( LOW << MODE0));
                    // 1/8
                    modeState[SPEEDFAST] = ((  LOW << MODE2) | ( HIGH << MODE1) | (  HIGH << MODE0));
                    break;

And modified this line
Code: [Select]
    if ((driverVersion == A498x) && microstepConf > 16){
        return false; //invalid value.
    } else if (microstepConf > 64){    < from 32 to 64
        return false; //invalid value.

UploaderGUI.pde:
And changed the utility uploader gui: populateMicrostepDropdown cycle from 6 to 7, to show the 64 micro stepping.

Code: [Select]
  Map<String,Integer> populateMicrostepDropdown (int driver) {
    Map<String,Integer> entries = new LinkedHashMap <String,Integer>();
    entries = new LinkedHashMap <String,Integer>();
    for (int j = 0; j < 7; j++){
      int mode = (int)pow(2,j);
      entries.put(""+mode+" uStep",mode);

The problem is the EEPROM write or the read goes bad.
When I change the microstep 64 the utility read back wrong values after flash, with 32 step is ok.

My 1/32 axis/rev:9216000, with the double(18432000) maybe is to big the address?
I just tried to double the motor gear ratio to get the same value, and also got the same issue.

UPDATE!!!


The problem is the SyntaString.syntaEncoder cannot handle big numbers like 18432000, I guess cannot read back the values/or write to eeprom
When I changed the motor gear ratio to 7, and the aVal is 16128000, and the config read back was ok.

Settings :
motor:0.9
motor gear ratio:8
worm gear ratio:180
aVal: 18432000


Regards Tamas
« Last Edit: May 22, 2023, 19:52:25 by kaito83 »
Logged

TCWORLD

  • Administrator
  • *****
  • Posts: 809
    • View Profile
    • AstroEQ
Re: Change code to support LV8729 1/64 microstepping for mega2560
« Reply #1 on: May 22, 2023, 21:46:14 »

Welcome to the wonderful world of integer precision :)

The values in the synta protocol are maximally 24bit, which limits them to circa 16million. This is unfortunately not something I can control - increasing the size would only be possible by changing the protocol and all programs which speak it.

There are also other considerations as well. As these numbers get larger, the step rate gets higher and higher. There reaches a point where the MCU simply cannot keep up. In hindsight using multiple MCUs (one for each motor, plus a main controller) would probably helped here, but the goal of AstroEQ was to make non-Goto mounts able to talk to the PC as simply as possible.

Both of these are the reason why I never added 64 ustep modes to the firmware - it's really beyond the capabilities of the controller, and precision can be better acheived using higher gear ratios.
Logged
Tom Carpenter (AstroEQ)

kaito83

  • Full Member
  • ***
  • Posts: 47
    • View Profile
Re: Change code to support LV8729 1/64 microstepping for mega2560
« Reply #2 on: May 23, 2023, 07:58:32 »

Thank You Thomas the clear anwser!
Logged