This week’s entry covers another implementation under the same vein as the previous few posts of creating components.
The component started this week should provide the functionality to calculate the speed of a moving object in simulation.
The general premise of operation for the component will be that two beam breaker components will be imported, and used as timing gates for start and stop times of the objects speed. A display will be attached to show the calculated speed to the user.
Flowcode provides a large library of pre-existing callbacks and a full simulation API all integrated into the user interface and can be manipulated using Flowcode itself.
Examples of these are included in how this Flowcode component is created.
Firstly, the component flow will be set initially by a “pinchange” callback indicating that the beam breaker component has detected an object. This will start a timer at intervals that the user sets (effectively setting the resolution of the timer used to calculate speed). A user created variable will be incremented until a secondary “pinchange” callback is made and verified as the second beam breaker. Once that has occurred, the speed will be shown on the display.
Placement of the beam breakers is also available to the user in the form of a component property. This section will move components and set their sizes based upon what the user has selected.
Here you can see 2 beam breaker components were added, with a dashboard text component. Note the 3 added properties added in the properties menu. Beam length will set the length of the beam, and Beam distance will set the distance at which the beams are from each other.
Macros for the callbacks: “Property” (called when the user edits a property), “PinChange” (called when a pin state changes), and “Timer” (called when the API timer has elapsed).
To start, the macro Ev_property was created to move the beambreaker components to a fixed position relative to the display, and to the confines of the user specified properties on the panel.
You can see that the range of each beam breaker is set to the value given in the property created “Beam length”, and the position moved to on the Y-axis, is equal to the Beam distance divided by 2 as each are moved +- of the location of the display.
For the timer, this macro will handle the increments of time set in the user property.
Ev_pinchange will be a larger macro that, next week, will be filled to calculate the speed of the object based upon the time elapsed between each beam breaker pins changing.
Here is the Flowcode source files for this example: Speed Detector File
Next week, we’ll fill in the missing parts of this component, and provide samples of speed calculations.
13,394 total views, 2 views today