Announcement

Collapse
No announcement yet.

Changing speed of stepper motor based on analog input

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts


  • Changing speed of stepper motor based on analog input

    I am using a do-more BRX (BX-DM1E-18ED13) PLC to drive an integrated stepper motor (STP-MTRD-17038E). I am using the latest release of Do-More designer.

    I want to vary the speed of the stepper motor based on the analog input (0-10V) value. The stepper motor should continue to hold the previous velocity until new velocity value is updated based on the change in analog input value.

    The target velocity value is stored in D0. I have a continuously running routine containing MATH operation doing some scaling for the analog input value and storing the result in D0 (new target velocity). I was looking at the "AXSCRIPT" instruction and particularly "Raw Velocity" option. It looks like the velocity doesn't get updated and AXSCRIPT seems to use the old velocity value.

    Any suggestions for solving this?


  • #2
    You want to send D0 to $Axis1.TargetVelocity. The script value only gets read when it starts. After that it changes to the structure member. See the software help topic DMD0327.
    If you have an urgent issue, please contact AutomationDirect's Technical Support team.

    AutomationDirect.com Technical Support: 1(800) 633-0405 or (770) 844-4200 Email Tech Support

    Comment



    • #3
      For velocity modes, the instruction is just placing the axis into the appropriate mode and pre-filling the structure’s .TargetVelocity with a value, but velocity modes always use .TargetVelocity as the actual source.

      Comment



      • #4
        Bob O Do-more PE I tried moving the velocity value to $Axis1.TargetVelocity member in a seperate routine. It looks like its still using the same value.

        Let me explain more about the structure of my program:

        The "main" ladder code has four stages. Lets forget about the stuff that happens in first three stages, Not relevant here. In the fourth stage (main.S4), Based on the condition of a bit (C408), two Programs (ManualSpeed and BlendedMove) are run. (See Image-1)

        In the program "ManualSpeed", the analog input value stored in RX0 is scaled and converted into value that is used for setting velocity for Axis1. (See Image-2)

        The actual motion of Axis1 occurs in program "BlendedMove". I am using AXCONFIG and AXSCRIPT here to start the motion of the motor (See Image-3, Image-4 and Image-5)

        It looks like even though $Axis1.TargetValue is changing based on RX0, the current velocity of Axis1 always remain constant. This value is equal to value set in AXSCRIPT instruction (D30)

        Am I missing something here? Where should the moving of velocity value to $Axis1.TargetVelocity be done?
        Attached Files

        Comment



        • #5
          "Am I missing something here? Where should the moving of velocity value to $Axis1.TargetVelocity be done? "

          Not that I know anything about it, but it seems to me that if you want the velocity to change while the axis is moving you'd need to change $Axis1.TargetVelocity at the time you want the velocity to change. If you only want to set the velocity that will be used the next time AXSCRIP is activated then it seems that just changing D30 before AXSCRIP is activated should work.

          I don't know, I can imagine that using AXSCRIP might complicate things compared to AXVEL, though for all I know AXSCRIPT just calls AXVEL when it need it.

          Comment



          • #6
            Yes, you are missing a brain cramp on my part. The .TargetVelocity member is not live during AXSCRIPT. You can invoke velocity mode more than once or in a loop, and the input value is effectively live in that case.

            Click image for larger version

Name:	Velmode.png
Views:	102
Size:	24.9 KB
ID:	123560

            Comment



            • #7
              Originally posted by BobO View Post
              Yes, you are missing a brain cramp on my part. The .TargetVelocity member is not live during AXSCRIPT. You can invoke velocity mode more than once or in a loop, and the input value is effectively live in that case.

              Click image for larger version  Name:	Velmode.png Views:	22 Size:	24.9 KB ID:	123560
              Bob O oops! I missed that Note! Thanks for pointing out. Suppose, I were to use "Ramp to velocity" within a WHILE loop (Lets say Target velocity value stored in D0) and change D0 when RX0 (analog input changes) changes, does the Target velocity of Axis1 update accordingly? Or does it use the value of D0 when the loop was entered for the first time?

              I don't know how many velocity changes to expect, thus I can't chain multiple "Ramp to velocity" commands in the same AXSCRIPT.

              Comment



              • #8
                Originally posted by RockB View Post

                Bob O oops! I missed that Note! Thanks for pointing out. Suppose, I were to use "Ramp to velocity" within a WHILE loop (Lets say Target velocity value stored in D0) and change D0 when RX0 (analog input changes) changes, does the Target velocity of Axis1 update accordingly? Or does it use the value of D0 when the loop was entered for the first time?

                I don't know how many velocity changes to expect, thus I can't chain multiple "Ramp to velocity" commands in the same AXSCRIPT.
                Looping works. The parameter is refreshed each time.

                Comment



                • #9
                  Originally posted by BobO View Post

                  Looping works. The parameter is refreshed each time.
                  I tweaked the note:

                  Click image for larger version

Name:	AXSCRIPTRamp2VelNoteLoop1.png
Views:	68
Size:	18.0 KB
ID:	123566
                  There are 10 kinds of people in this world, those who know binary, and those who do not.

                  Comment



                  • #10
                    Originally posted by BobO View Post

                    Looping works. The parameter is refreshed each time.
                    Bob O I am still having trouble getting the velocity to change within the loop. My AXSCRIPT is configured as in image "Axis_velocity_1.PNG". I have a seperate program that is running continuously to update D20 (Target velocity parameter in AXSCRIPT) based on RX0 (analog input). (See image Axis_Velocity_2.PNG)

                    It looks like even though the D20 is updated continuously based on RX0, The actual velocity of the motor uses the first value of D20 when loop was entered. The actual velocity doesn't seem to change within the same loop even the value of D20 chnages inside the loop. For the new value to work, does AXSCRIPT have to renter into the loop?
                    Attached Files

                    Comment



                    • #11
                      You are block on X5, rather than spinning constantly. Per your script, I would expect it to wait for a high transition of X5, ramp to the target velocity, then wait for a low transition of X5, then stop hard, then repeat as long D100 != 0. You need to spin the loop without any blocking.

                      Comment



                      • #12
                        Originally posted by BobO View Post
                        You are block on X5, rather than spinning constantly. Per your script, I would expect it to wait for a high transition of X5, ramp to the target velocity, then wait for a low transition of X5, then stop hard, then repeat as long D100 != 0. You need to spin the loop without any blocking.
                        Bob O This works. However, I want the Axis to run only when X5 goes high and to immidiately stop when X5 goes low while adpating to any changes in the target velocity value. Is there a workaround for this?

                        Comment



                        • #13
                          Originally posted by RockB View Post

                          Bob O This works. However, I want the Axis to run only when X5 goes high and to immidiately stop when X5 goes low while adpating to any changes in the target velocity value. Is there a workaround for this?
                          Run AXSCRIPT each time you turn on X5.

                          In the script:
                          While(X5)
                          Ramp to Velocity D20
                          End While
                          Stop


                          I'm not sure how this is much better than using the AXVEL though.

                          Comment



                          • #14
                            Originally posted by BobO View Post

                            Run AXSCRIPT each time you turn on X5.

                            In the script:
                            While(X5)
                            Ramp to Velocity D20
                            End While
                            Stop


                            I'm not sure how this is much better than using the AXVEL though.
                            AXVEL seems like a much more easier and clean solution. Thanks for the suggestion

                            Comment

                            Working...
                            X