Creating a Component from scratch – Linear Actuator (part2)

Following on from last weeks blog (click here), this post will overview the process for creating the operation of the linear actuator component.

As stated previously, the component itself utilises the motor base component for the basis of simulated movement. This macro provides movement along a particular plane, and in this example I have shown how the user can manipulate the shaft of the linear actuator along one of those particular planes.

Using a combination of multiple motor base components, the linear actuator could accommodate the user to rotate the component outside of a multiple of 90 degrees.

Firstly, the properties for the component are updated to accommodate this movement:



This properties panel shows that a “fixed list of text” controls have been added, which allow the user to select a text control, with an index. This index is then available to the component to indicate a user selected control. In this case, it is used to indicate the orientation of the linear actuator and in which axis the shaft is to be actuated.

Also, shown is the speed at which the uses wishes to actuate the shaft.

Next, a macro to control the actuation of the shaft is created. The summarised flow of this macro includes handles being defined for the body and shaft shapes. The shaft is then set as the target for the motor base component. This indicates that when the user invokes the motor to work, the shaft is the shape that will be moved.



The orientation property is then converted from a string variable to integer so that it is possible to use it in a switch statement.

The switch statement executes differing functions for the different selections the user can make in the list of text property “Orientation”. The speed value is inverted if the user has provided a negative number for a positive speed value when the plane that the shaft is to be moved is positive.

The property value for the motor base to indicate the axis of which the shaft is actuated is set. Values are used as the list of text available in the property are zero indexed and addressed using these indexes.

A parameter for the macro is then used to reverse the speed (and thus the direction) of the shaft if defined in the macro call. Finally the motor speed is set.

Next, the macro Ev_pinchange is written, so that when the user configures the state of the pins defined as “Inwards” and “Outwards”, the motor simulates accordingly.



Two cases are created for the two true cases of an XOR function of the two control pins. In any other case, the simulation is stopped and the shaft is stopped. The cases that call the ExtractRetract macro jump over the speed stop macro.

Finally, the Actuate macro is created. This is intended as a user-facing macro that is included in compilation for control of the linear actuator.



The user can pass a 0,1, or 2 to this macro with actions to stop, extend and retract the shaft respectively.

Now, the component can be created and included in the Flowcode library. This process was detailed in an earlier article titled “Chip component”. A slight modification to the process includes that the mesh files must be included in the component, and that the “Actuate” macro must be embeddable and available to the user.





That completes the very basic linear actuator component. There is a lot of extra functionality that could be added to this component regarding rotation of the component and axis of actuation.

Next week I will cover a new component, entitled “speed detection” using beam breaker components.


13,524 total views, 2 views today


Leave a Reply