Keil RTX RTOS: Real Time Linear Speed Controllers for Three Stepper Motors

This project implements a linear speed controller for three stepper motors. The motors runs independently and can have different or similar speed profile/angular acceleration. The firmware was implemented on Keil RTX RTOS, and it was run and tested on LCP2378 controller. The speed controller algorithm is based on this paper : “Generate stepper-motor speed profiles in real time” posted by David Austin [1].

Firmware

Main loop

/*-----------------------------------------------------------------
 *        Main: Initialize and start RTX Kernel
 *---------------------------------------------------------------*/
 int main (void)
 { 
  U32 volatile start; 
  /* Wait for debugger connection 0.3s*/                                                     
  for (start = 0; start < 1000000; start++) {;}  
  os_sys_init (init);         /* Initialize RTX and start init */ 
}

Init task initializes three tasks. Each task handles the speed control of a stepper motor

/*-------------------------------------------
 *        Task 1 'init': Initialize
 *------------------------------------------*/
__task void init (void) {

  FIO2DIR  = 0x000000FF;     /* P2.0..7 defined as Outputs  */
  FIO2MASK = 0x00000000;
  FIO2PIN  = 0x00000000;
  PINSEL10 = 0; 

  serial_init ();
  motors_parameters_init();
  motors_calculations();
	
  t_SMotor1= os_tsk_create(SMotor1,0);         /* start task  */
  t_SMotor2= os_tsk_create(SMotor2,0);         /* start task  */
  t_SMotor3= os_tsk_create(SMotor3,0);        /* start task  */
	
  os_tsk_delete_self ();
}

Firmware Download

The complete firmware can be downloaded from the link below:

https://github.com/fma23/RTX-RTOS-Embedded-Design-LPC2378/tree/master/Three-StepperMotors-Controller-RTX

If you like this posting or have any questions, please drop us a feedback in the comments section!

References

[1] David Austin, “Generate stepper-motor speed profiles in real time.” Retrieved from: https://www.embedded.com/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-profiles-in-real-time

[2] “Linear speed control of stepper motor.” Retrieved from: http://ww1.microchip.com/downloads/en/appnotes/doc8017.pdf

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.