Tuesday, November 22, 2011

PS Cockpit System - How to use steppers

For X-27 and X40 stepper motors visit this post: link

A stepper motor is a motor which moves the rotor in a step-by-step way. This effect is achieved by sequentially turning on different stator phases in order to pull rotor to that position.


The following picture is a simplified stepper motor diagram. It can be seen that there are 4 stator poles and 2 rotor poles. Real stepper motors have much more rotor poles.


PS Cockpit System is able to drive up to 9 unipolar stepper motors with 4 stator poles using the Stp/PWM/Other Outputs card. This means that we will use 4 outputs to energize the stator poles.

The number of rotor poles defines the steps of the stepper motor. Typical steps are 3.6°, 1.8° or 0.9° and they will give us the resolution of our indicator along with the operation mode of the stepper.

The unipolar stepper motor can be driven with to different modes:

In “Normal” mode the poles are activated in sequence A-C-D-F:


In “Half Step” mode the poles are activated in sequence A-(AC)-C-(CD)-D-(DF)-F-(FA)




As you can see the “Half Step” mode gives us the double of resolution for our indicators.

In example, one stepper motor with 1.8º steps will need 360º/1.8º = 200 steps to make a full turn in “Normal” mode and our indicator will have a 1.8º of resolution while in “Half Step” mode it will need 360º/0.9º = 400 steps to make a full turn and our indicator will have a 0.9º of resolution.

Resolution vs. synchronization

As the stepper motors are driven by energizing the stator coils or poles, we have to delay the outputs some time to let the rotor of the motor reach the position it should be in order to energize the next coil. The delay depends on the electrical characteristics of the motor, on the presence of static friction and on the external torque.

The PS Cockpit System uses timers to adjust the delay needed in each stepper motor.

So, if we set a timer of one of our stepper motor to 20ms, in “Normal” mode it will need 200 steps * 20 ms = 4 seconds to make a full turn, while in “Half Step” mode will need 400 steps * 20 ms = 8 seconds to complete a full turn.

If we are updating our cockpit with info from the sim, let’s say, every 200 ms, the indicator will always be out of synch.

Of course this is unacceptable for indicators which need speed and accuracy and so other way than the stepper motors has to be used.

Selecting the stepper motor

Ok. Too much theory for today. Let’s go for an example.

I’m thinking of driving the compass of my cockpit with a stepper motor because it needs a non-stop system as it has neither bottom nor upper limits.

As the resolution of the compass dial is 5º, I have selected one stepper motor with 1.8º of resolution that will give me a resolution of 1.8º in “Normal” mode and 0.9º in “Half Step” mode which can be acceptable.

Also I’m going to drive a light weight indicator, so 5 VDC will give me enough torque to move it.



I’m refreshing my cockpit each 200 ms from the data extracted of my sym, so it will give me between 10 to 20 steps of rotation each time the refreshing is done using between 10 to 20 ms for each step.

That means I can drive the compass in a range of 9º (10 steps * 0.9 º/step) to 36º (20 steps * 1.8º/step) between refreshes which sounds very acceptable for this instrument.

I’ve made the compass with the stepper in it:



Connecting the stepper motor

I have taken a look to the wiring diagram of the stepper motor and found the correlation coils of A-C-D-F and the common B-E of the Stp/PWM board of the PS Cockpit System:



I have chosen a 16I/O expander addressed with 010 on channel 0 of the PS Cockpit System to connect the Stp/PWM board to.


Configuring the stepper motor

Now we have to tell the PS Cockpit Software we have connected a stepper motor to the system. For that, go to PS Layout page and select I2C channel 0 and 010 expander and select a 16I/O expander type. The list of I/O will appear on the right of the page.



On the I/O dropdown list select “Output” and on the Function dropdown list select “Stepper”. Give a tag name for the stepper -I’ve obviously named “Compass”- and accept it. The software will fill the needed outputs automatically

The PS Cockpit software knows now it has a stepper motor in that location but doesn’t know what magnitude it has to show on it. To do this go to the F16 model page and select Steppers:



Select the I2C channel 001 and expander 001, click on the “Compass” label to see the dropdown list of all the steppers connected to that expander and select the tag of the desire stepper on the dropdown list. “Compass” in this case. Accept it and the number of the first output of the Layout page will be shown:


One “step” more and we are done: We have to configure the type of stepper and the values of the indicator. To do this click on “Stepper Config” label and the following page will appear:



The “Stepper Config” page shows all the data of the steppers and it will be used later to test the stepper. By now we have to see that the “Compass” tag and the related outputs are showed.

We can also put some values although we can change them when in test mode:
- Enbl: Click on the checkbox to enable the stepper.
- Mode: Select the desire mode to drive the stepper (Normal or Half Step)
- Total steps: Set the total steps of your stepper (i.e. 400 for 1.8º stepper in Half Step mode; 200 for 1.8º stepper in Normal mode; 100 for 3.6º stepper in Normal mode; 200 for 3.6º stepper in Half Step mode; …)
- Min. Value and Step: The relationship between the lower value of the magnitude and the step number. In this case 0º of the compass will be at step number 0.
- Max. Value and Step: The relationship between the upper value of the magnitude and the step number. In this case 360º of the compass will be at step number 400. This will give us a non-stop indicator.
- Step Tmr: The value of the timer in ms to wait the rotor of the stepper reach the correct position once a pole has been activated.

The test frame only will be available when in test mode.

Normally we set the maximum value of the magnitude and the maximum steps together. To change the rotation direction of the stepper set the maximum value of the magnitude at the minimum step.

Testing the stepper motor

Close the “Steppers Config” page and the “F16 Model” page and go back to the “I/O Layout” page. Click on “Test” command and on “Test Steppers” command:


The “Steppers Config” will be shown again and the “Test” frame will be now available:




For testing the stepper you have the following tools:
- Stepper nº: Select the desire stepper to test.
- Outputs: You can activate each output individually to test them.

- Step -: Move the stepper one step backward
- CCW: Move the stepper continuously counter clock wise
- Stop: Stops the stepper
- CW: Moves the stepper continuously clock wise
- Step+: Moves the stepper one step forward
- Offset: In case you are using “Half step mode” you can use this tool to select and intermediate value between steps.

With the above tools you have to move the indicator to the 0 value, in this case “North” and then click on the “Set Zero” command to let the software know how many steps will need to move in relationship with the magnitude.

Once the 0 is established, you can also use the following tools:
- Value: Set the value of the magnitude you want the stepper to go to and click on the “Go Value” command and the stepper will find the shorter direction to reach that value.
- Step: Set the value of the step you want the stepper to go to and click on the “Go Step” command and the stepper will find the shorter direction to reach that value.

You can also change the configuration of the steppers in the list.

The software will remember the position of the stepper even you if you exit from the application.

This video shows you how to test it. Sorry for the quality.


Regards,
Shep


No comments:

Post a Comment