Editing PIC Stepper Motor Tester
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 222: | Line 222: | ||
== Microcontroller Program Design == | == Microcontroller Program Design == | ||
I no longer have the patience for assembly language. I have moved on to C in particularly BoostC, see link below. I like this compiler it has both a free version with some restrictions and a very reasonably priced full version. Writing in C should make the program fairly easy to read. Most of the design should be evident by reading the program, however a few notes here may help. | I no longer have the patience for assembly language. I have moved on to C in particularly BoostC, see link below. I like this compiler it has both a free version with some restrictions and a very reasonably priced full version. Writing in C should make the program fairly easy to read. Most of the design should be evident by reading the program, however a few notes here may help. | ||
− | see | + | |
+ | The idea is to put each activation sequence in a table and then step through that table and activate the corresponding port bits and thus stepper coils. The four wires can be activated in a total of 6 different ways, one table corresponds to each permutation. The particular table to use is set using the permutation command ( p ). | ||
+ | |||
+ | The series of wires to energize is specified in the arrays StepperStepsN where N is the number of the wire permutation. Each step just increments its way through the array wrapping around the the beginning and the end. | ||
+ | |||
+ | Commands are received via an interrupt driven routine, the main loop checks each time around to see if a complete command has been received. Because commands are only interpreted in the main loop all commands are ignored until the program returns to the main loop. The exception to this is the stop command which will terminate a g or x command and return to the main loop quickly. RS232 transmission is not driven by an interrupt and so during transmission from the pic no stepping takes place. Commands which do not result in motion execute very quickly, most of the time is for communications. | ||
+ | |||
+ | Currently drive to the motor is half step drive. This gives twice as many steps per revolution as is labeled on the motor. I plan later to let you select half step, full step or wave drive. See the links below for more information. | ||
==== Compiling ==== | ==== Compiling ==== |