# Converting calculations to code

A project log for Robotic Flexor

A passive linear actuator based on a simple solenoid to recreate the flex motion of biological muscles.

Now that I have formula for finding the force I can put it into code, which will allow me to use different parameters for things like the size of the solenoid, the relative permeability of the core, the core mass, and so on. I can also plug in other functions in place of variables, which is particularly useful for finding the self inductance over time because it depends on the position of the core.

Test 1.

Using a python library called matplotlib, I am able to visualize the data, and make sure that it matches up with what I expect to see. In the code I use a series of functions to find the velocity over time based on the changing inductance. My prediction was that if I calculate the current needed to hold the core at a arbitrary position, and I plug it into the velocity function over time it should go from negative velocity to 0, meaning that it is being held in position. You can see that is exactly what happens.

Test 2

Now if I increase the holding current a smidge, I should see the velocity continue to go up, instead of plateauing. This is exactly what happens in the graph  below. This result is from just a .01 increase in current! Notice the little dip at the bottom showing the pull of gravity getting smoothed out.

Now I can use something like an arduino, and program it as a driver to take a position to move to and the time to travel, then with the calculations above, determine the current to move to the position. When / slightly before (to get smoother motion, or better power consumption) the position is reached, the current should be decreased again to the holding current.

## Discussions 