Different types of stepper motors with different specifications are available in the market. The one used here is a 55SIM-25DAYG unipolar stepper motor rated at 12V DC, with a step angle of 7.5° per pulse as shown below. This stepper motor has five wires for connection to the circuit. Out of the five wires, four are coming out from the coils of the stepper motor and the fifth is the centre-tapped common terminal.
Correct identification and proper connection of these wires are important for successful assembly of the stepper motor. The unipolar stepper motor has two center-tapped coils. Their centre-tapped terminals are joined to make one common terminal. If you have a multimeter, adjust it in the 200-ohm range and check resistances between wires. The resistance between the common terminal and the rest of the coil terminals should be about 36 ohms, while the resistance between any two coil terminals should be about 72 ohms. Connect the coils to the output terminals of the driver circuit in sequence.
To make the project more user-friendly, colour codes of wires for the 55SIM-25DAYG stepper motor are shown in Table II. Note that for the same ratings, different manufacturers may have their own coil specifications.
This program consists of 14 M-files and four-figure files. However, only three main programs (parport.m, data_port_controller.m and data.m) have been explained and listed here. Matlab help files are very comprehensive. To get general help, type ‘doc’ command against ‘>>’ prompt in ‘command’ window.
Matlab has a toolbox called DAQ(data acquisition). The ‘dio = digitalio (‘adaptor’, ID)’ creates the digital I/O object (dio) for a specific adaptor and for the hardware device with device identifier ID defined with an integer or a string. The ID can be LPT1, LPT2
The above codes are defined in ‘parport.m’ program as given below:
Matlab comes with a ‘Guide’ tool. Guide (short for ‘graphical user interface design environment’) is similar to Visual Basic (VB) environment. We know that VB is an event-driven programming language which helps users to implement graphics interfaces.
The guide provides a set of tools for creating graphical user interfaces (GUIs). Just type ‘Guide’ against the prompt in Matlab command window. Select ‘Blank GUI’ option in the next window to launch Guide.
Using ‘Layout’ editor option from Guide, you can populate a GUI by clicking and dragging GUI components—such as axes, panels, buttons, text fields, sliders and so on—into the layout area. You can also create menus and context menus for the GUI. From the layout editor, you can resize the GUI, modify and align components, set tab order, view a hierarchical list of the component objects and set other GUI options.
The guide provides controls like push – button, slider, radio button, checkbox, edit text, static text, pop-up menu, list box, toggle-button, table, axes, panel, button group and ActiveX control. It even generates a skeleton M-file (plus figure file with a ‘.fig’ extension) which programmers can further use to link other events through ‘callback’ function. The callback may be an event after a mouse click on a button.
‘callback’ function is used in ‘data_port_controller.m’ program as given below:
‘checkbox1_Callback( )’ is a callback function executed while you check and uncheck the check boxes corresponding to LED1 through LED8 as shown in Fig.3.
Variables can be used without declaration:
Here, ‘handles.i1’ is a global variable. Every click on the checkbox makes ‘handles.i1’ toggled. ‘data’ is a script file which has only one line of code:
‘handles.data’ is a global variable which updates a new value and then ‘parport.m’ script file is executed to output the value at the parallel port. Script file executes a sequence of commands rather than accepting or returning parameters. For example, the file generated by Guide is not a script file but a function m-file. Examples of function file include most commands in Matlab, such as sine and plot.
Two more important commands are ‘set’ and ‘get.’ For example, ‘checkbox1’ value sets ‘handles.i1’ as follows:
In ‘stepper_controller.m’ file, the direction control variable returns the toggle state of ‘togglebutton1’ and gives the value to ‘handles.dir’ using ‘get’ command: