create new tag
view all tags

Solutions to Exercise 7: Stepping motors

Exercise 7.2 - 7.3: The different stepping modes

The solutions to this exercise are very similar to the solution to the traffic light exercise. Again a table with values for the 4 stepping motor phases is used and the program itself implements a state machine which runs through the table and sends currents through stepping motor coils as defined in the table. The following code snippet shows the function that sends out the signals to the coils for the single phase forward mode. For the other modes only the table must be changed. For half step modes the size of the table doubles and the function must loop over 8 half steps instead of 4 full steps as shown in this example.


The solutions of all the different modes are collected in this tar file:


Exercise 7.4 User control through command line arguments

This exercise is a combination of all exercises before with the addition of user control through command line parameters.It is a lot more complex! It uses the getopt_long system library function (check this out with man getopt_long to understand the details) to parse the command line arguments the user enters.

I just give you the solution for study. Of course you are invited to try it on real hardware.


-- Uli Raich - 2018-11-20


Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng step.png r1 manage 36.7 K 2018-11-20 - 14:27 UliRaich  
Unknown file formatgz step.tar.gz r1 manage 1.5 K 2018-11-20 - 14:32 UliRaich  
Unknown file formatgz stepper.tar.gz r1 manage 1.5 K 2018-11-20 - 14:37 UliRaich  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2018-11-20 - UliRaich
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback