Notifications
Clear all

[Solved] Stepper Motor Feedrate Issues.

30 Posts
4 Users
1 Reactions
1,240 Views
(@hackinspock)
Member
Joined: 8 months ago
Posts: 12
Topic starter  

@will Gotcha. I'll keep multistepper as is then. In the meantime, I separated the speed calcs out into a separate function that can be called in the setup(). This way, all I will have to do is refer to the ith index of the array and feed that into the jth stepper's .setSpeed(). kuperSpeed is set globally btw. It was initialized as float kuperSpeed[NUM_KEYFRAMES-1] (although there are 4 positions, there are only three speeds total).

void computeSpeed(){
  for(int i = 1; i < NUM_KEYFRAMES; i++)
  { 
    kuperSpeed[i-1] = 0;
    for(int j = 0; j < NUM_STEPPERS; j++)
    {
      float currSpeed = abs(kuper[i][j]-kuper[i-1][j]) / exposureTime;
      if(currSpeed > kuperSpeed[i-1])
      {
        kuperSpeed[i-1] = currSpeed;//sets the max speed of the ith keyframe for all steppers
      }
    }  
  }
}

 

This is what my non-blocking function looks like now:

short currentKeyframe = 0;//global keyframe position. Keeps value the same even when paused

void runMocoNonBlocking(){ //TEST 3 replace i with currentKeyframe. WORKS(ISH). Purpose is to save position even after pause
  if(stepper1.distanceToGo()!=0 && stepper2.distanceToGo()!=0 && stepper3.distanceToGo()!=0)// && stepper4.distanceToGo()!=0)// && stepper5.distanceToGo()!=0)
    camera.run();//this should be called as much as possible
  else{
    if(currentKeyframe < NUM_KEYFRAMES){ //change back to i=1 if testing with delta
      for(short j = 0; j < NUM_STEPPERS; j++){
        targetPos[j] = kuper[currentKeyframe][j];
        if(currentKeyframe>0)
          steppers[j].setSpeedStepper(kuperSpeed[currentKeyframe-1]); //don't override first keyframe speed
      }
      camera.moveTo(targetPos);
      currentKeyframe++;
    }
    else
      currentKeyframe = 0;//only for looping. Replace this with a "finished" message
  }
}

 

I'll look into adjusting the frequency of run() commands by adding the while loop tmrw. I'll let you know how it goes. Thanks for the help as always.

This post was modified 8 months ago by HackinSpock

   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 4 years ago
Posts: 2603
 

Posted by: @hackinspock

In the meantime, I separated the speed calcs out into a separate function that can be called in the setup(). This way, all I will have to do is refer to the ith index of the array and feed that into the jth stepper's .setSpeed(). kuperSpeed is set globally btw. It was initialized as float kuperSpeed[NUM_KEYFRAMES-1] (although there are 4 positions, there are only three speeds total). 

Excellent idea, but I'm curious why you only store 3 speeds ? I would assume that you'd need one for each of the 4 legs between observation points.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@hackinspock)
Member
Joined: 8 months ago
Posts: 12
Topic starter  

@will 

Considering that speed is calculated by the delta between positions: (nextPos - currentPos / exposureTime), if there are 4 positions, there can only be three speeds right?

A - > B

B - > C

C - > D

There's an underlying assumption I should have mentioned that the very first keyframe will be the "starting position." As in, before the movement begins, all steppers will move to there starting position (or zero pos). This is different than "home," because home is the true zero of all axes whereas the "zero pos" is the first position of all steppers. Does that make sense?

This post was modified 8 months ago by HackinSpock

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 5 years ago
Posts: 8047
 

@hackinspock I am a photographer, and use a lot of hi tech gear. There is no doubt @will is the expert on the stepper, but I may be able to bridge the gap between the tech and the user. Why don't you post ALL the code, maybe some photos of the rig? It wouldn't hurt to explain what you are tryingto do from an end user perspective without a bunch of technical assumptions.

Your github link does not work.

What is the buffering ability of your camera, mine is 31 RAWs but several factors can reduce that.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@hackinspock)
Member
Joined: 8 months ago
Posts: 12
Topic starter  

@zander 

Hi there! Hopefully this link will work:
https://github.com/HackinSpock/Motion-Control-Software

The intention is to export an animation file done in Modo with a custom python script to generate a kuper ASCII file. I'll cull the file and reformat it into a matrix of steppers to positions.

Let me try to give an example. If I have an animation file with 5 seconds of footage, that would be 120 keyframes (5 seconds * 24frames/second), therefore 120 positions for the steppers motors to reach successfully. The in-betweens will be pretty small (few mm/degs at a time), but strung up in succession will result in the desired animation.

To perform motion control (at least how I understand it), the exposure time per frame will dictate the feedrate. I'm currently under the assumption that it will take 1 second to save a RAW image locally to the camera to make testing easier. So in this example, if I do a 1-second exposure and have a 1-second save, that's approximately 2 seconds to expose and save the frame. Furthermore, the exposure is taken while the steppers move, so each frame has motion blur.

The feedrate is the delta between the future and current position divided by the exposure time. So if we're going between 0-50 steps in 2 seconds, that would be 50steps/sec. Hypothetically, if each frame will take 2-seconds, then the entire movement (animation) would be completed in 240 seconds / 4 minutes.

I'm using a canon eos 5d mark 3. Hoping to save RAW images locally onto high speed CF card (still need to figure out which one to purchase). Lenses are nikkor primes (28mm, 35mm, & 50mm respectively). I have a stepper that will handle focus pulls (focus pull keyframes will be set manually with jog box that's currently a work-in-progress).

Here is some photos of the rig. PT head with track motor and focus pull motor (4 steppers). Then a 3-axis model mover (yaw, roll, pitch).

Track will be 9 meters.

IMG 5932(1)

 

 

IMG 5945(2)
This post was modified 8 months ago 6 times by HackinSpock

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 5 years ago
Posts: 8047
 

@hackinspock Github link still not working. I did a search on HackinSpock but don't see the Motion-Control-Software repository. I see a few others, most forked (5 out of 7) from others work.

I am curious about your location, are you in a school, or do you have a business where you are developing this?

I don't know any of the software packages you are using.

Assuming the focus pull is standalone, we are left with a 3 axis stepper controller. That is something Will might get his head around, BUT I think you are trying to use either off the shelf software or open source (modified by you???) and if that is the case it is highly unlikely anyone here can be much help. I might be way off, but I do see that you have forked repositories so I wonder what level you are at, hobbyist, or professional developer in a specialized field?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@hackinspock)
Member
Joined: 8 months ago
Posts: 12
Topic starter  

@zander

Sorry about that. Just made the repository public. This is for my college thesis.

I've built a custom electronics enclosure that handles x16 stepper drivers. I use a 74HCT595 level shifter to expand the # of I/O on my teensy 4.1 to accommodate the x3 signal wires per stepper driver (step, dir, & enable). I got this working really well.

I'm just modifying multistepper to accommodate fixed travel times.

The more I think about it, it's possible that grouping my focus pull motor to my overall camera group might be mucking up my speed calcs that Will and I have been discussing. I'll separate it for now on.

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 4 years ago
Posts: 2603
 

Posted by: @hackinspock

Sorry about that. Just made the repository public. This is for my college thesis.

Then the project should be totally comprised of your personal effort.,

 

Anything seems possible when you don't know what you're talking about.


   
Ron reacted
ReplyQuote
(@hackinspock)
Member
Joined: 8 months ago
Posts: 12
Topic starter  

@will Fair enough. I just hit this roadblock, and was confused how to continue. But I see your point


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 12 months ago
Posts: 354
 

@hackinspock 

Posted by: @hackinspock

Considering that speed is calculated by the delta between positions: (nextPos - currentPos / exposureTime), if there are 4 positions, there can only be three speeds right?

A - > B

B - > C

C - > D

I've been assuming that the key positions (or keyframe) are the linear positions of each servo; One position per servo. The software that generates the keyframes produces relative positions from the current position. I've also assumed that the starting (or "home") position of all the servos is zero. 

As I understand the algorithm, starting from standstill, each servo is moved to the next keyframe position and stops. After all servos have arrived, a picture is taken. While the picture is saved to external storage (on a separate thread), the servos are moved to the next keyframe, which must complete within 2 seconds.

Is this correct?

The one who has the most fun, wins!


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 12 months ago
Posts: 354
 

@will 

Posted by: @hackinspock

My confusion still stems from the continued use of the Multistepper moveTo() function. If we call the moveTo function after all these calculations, we're essentially just going to end up overriding them. (This is the default moveTo() function. This has not been modified)

Yeah, this is a problem I didn't take that into account.

When I make errors like this I know I have to make a software test harness to get a better understanding of the library behavior. so that's what I'm going to try to do now.

 

The one who has the most fun, wins!


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 5 years ago
Posts: 8047
 

@tfmccarthy You must not have noticed the OP is using us for homework but now he sees the error of his ways.

https://forum.dronebotworkshop.com/motors/stepper-motor-feedrate-issues/paged/2/#post-49783

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 12 months ago
Posts: 354
 

@zander 

Posted by: @zander

You must not have noticed the OP is using us for homework but now he sees the error of his ways.

I did not.

As it turns out, I have a need for a servo test harness for my kinematics robot arm, so I can redirect my efforts there.

I will look forwards to his results.

Thanks for the "heads up."

The one who has the most fun, wins!


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 5 years ago
Posts: 8047
 

@tfmccarthy I don't think he will be posting much of anything now, but he is certainly free to post the finished result. You could follow his progress on github, link is a few posts back. I am not github trained but I think if you install the desktop version of github then clone his repository to your github, you will get notified of updates. Not sure if that is true, but that is what I think I see.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 12 months ago
Posts: 354
 

@zander 

Well, it was a mistake. We all make them. I hope he will post his results here out of curtesy, but I won't be hunting for it elsewhere. I have my own mistakes to make.

The one who has the most fun, wins!


   
ReplyQuote
Page 2 / 2