Third Program – Making the Motor Spin


Making the Motor Spin Step by Step


1. Select the Configure Axis block and the Position Hold block from the Motion menu and drag them into the Initialization portion of the Main Program block.


2. These five circles show which options we will be setting for this program. We know from the First and Second application how to set the Slot to the Local InoDrive Module. Now click the Axis option on the Configure Axis block.


3. The Axis option will launch the Axes Dialog box from which an axes profile can be established. You must select the Create New button unless you have already configured your Axes profile.


4. The Axis you are now creating must be named. You must also either choose a motor from our library or input your own information. For the Demo Case used to create this manual, this is an Electrocraft RPX40-250V24-100-S, so simply selecting this and clicking create is sufficient. If you cannot find the applicable motor navigate to the Axes Configurator either through this button on the bottom left or from your Account Dashboard.


5. Next choose “Sectors” for units of motor movement measurement. We will choose 8 sectors per revolution of the motor.
The motor’s position will be Off Regen, in which case the motor phase circuits are shunted to the drivers and the rotor is free to turn with only the drive train’s mechanical inertia and rotor’s magnetic induced EMF providing any holding force.


6. Now we are going to work on the Main Loop portion of the program and introduce some new blocks:

First is the blue Call Function block from the Program category.
Second is the light purple If Then Else block from the Logic category. If we click the Settings Icon on the block, we see the option to add conditionals to the block. Drag the mini Else onto the mini If and watch the regular block extend.
Third is green Variable block from the Math category.
Fourth is the blue Motor Command block from the Motion category.


7. Now lets add our Else part of the If Then Else block.
The Purple Motor Command block again.


8. Click on the red “Function” inside of the Call Function block. This will open a Functions dialog box which you will use to Create a New Function, by giving a name. Once you’ve chosen a name, here we’ll choose “CheckMotorFaults”, select it and see that it populates that name within this Call Function block.
The function “CheckMotorFaults” will be created in a Function block, and called by name here from within the Main Loop portion of the Main Program block.


9. Drag and drop the Function block into the workspace, notice that since it is referenced from within the Main Loop with the Call Function block, it does not need to be attached to the Main Program block. Any blocks placed inside of the Function block will be executed when called from the Main Loop.


Please Note: You may choose to put functions in other workspaces than your Main Workspace. Your workspace currently holds the Main Program block and the CheckMotorFaults Function block. Right clicking on Workspaces can open a new space. This may be just for a singular function, or for all of your functions. We will not utilize this within this small Project but it is helpful for sprawling programs’ organizational needs.


10. Check Motor Faults is a descriptive title for an important function. Blocks utilized are from the Math, Motion, and Logic categories.
First an If Else Then conditional block will be clicked into the Function block, select the Settings Icon to drag the mini Elseif onto the mini If. The Second block which will be the Get Motor Status Flag which should reference the Local slot, and get a faulted flag which returns true if there is a general module fault. Third place the Set Motor Operation block. This block will always be used in your motion programs as enable is required to be executed by your program logic before the motor connected to the selected Slot will be allowed to run. We will select Local motor drive in a Clear Faults operation.

The next portion of logic will be in the Else If position, Lets get the NOT block and place another Get Motor Status Flag block here as well.
The last block going into the Else If will be the Set Motor Operation block set to enable the local drive.


11. Observe all of the configured options.
You’ll be choosing the local Slot as the motor to be targeted for all blocks, as we are only working with one motor. Then choose corresponding options for the blocks as shown in red circles.
Now the function currently will operate as such: If the local slot has a faulted flag, it sets the local motor to clear the faults if possible. If the local motor does not have a flag enabled, it enables the motor. This function handles what to do if motor has faults, and it enables the motor, but doesn’t start the motor.


12. Let’s have this function report back to the main loop if it is ok to spin the motor, a clear yes or no to if our motor can operate.
Use the green Boolean Constant block to establish a variable that we can use later to set the motor’s status. Within this block lets have the block AND OR which works so that if both of the values within are True, then the Boolean type variable will be True. If either or these internal values are false, the variable will be false.
To now establish that variable, click the red word “variable”. This will launch the Variable Dialog Box. Click create new as this will be your first variable.


13. After clicking Create New button on the top left, this smaller dialog box gives us lots of options for the new variable.
Lets name it MotorOKToRun. Type – we will choose Boolean, and the initial value given will be false. Then select API accessibility level. Finally click the Create button.
You can double click the now listed variable in the Variables dialog box, or click the check box and then select button.

Since the API is useful to gather information, often Read/Write access is a good default to have. Perhaps there are specific circumstances which make only Read access or No access more appropriate for your custom application, please operate in your own best interest here.


14. Observe the full CheckMotorFaults function. This function checks the motor faults, enables the drive, and communicates via variable to the main loop if the program can continue.


15. The green variable block we placed earlier can now be selected, and “MotorOKToRun” will now be a listed variable that you may select.
Then configure both of the Motor Command blocks to both target the Local Slot. The first Motor Command block will Run the motor, while the second block within the Else portion of the logic will Stop the motor.
To review, the Main Loop will Call the Function “CheckMotorFaults”, and then if “MotorOKToRun” is True, it will run the motor. If “MotorOKToRun” is False, then it will stop the motor and nothing will happen as there is a fault.


16. Observe the full program. This will make the motor spin when the application is loaded onto the InoDrive


17. Send the program to the InoDrive by clicking the Build and Upload button. If you would like to save this program for your reflection or to build off of, now is the time to do so.


18. You may now either exit the Programmer or continue on to build your own application. Thank you!