Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:software:homelab:library:module:motor [2010/02/08 14:42] – Page name changed from en:software:homelab:library:module:motors to en:software:homelab:library:module:motor mikk.leinien:software:homelab:library:module:motor [2020/07/20 12:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Mootorid ======+====== Motors ======
  
-//Seotud mooduliga: [HW] [[en:hardware:homelab:motor]]//+//Related to: [HW] [[en:hardware:homelab:motor]]//
  
-Mootorite teek võimaldab juhtida kodulabori mootorite moodulit ja mootoreid, mis sinna ühenduvadOlemas on alalisvoolu-samm- ja servomootorite juhtimise funktsioonid+This library contains functions to control different HomeLab motorsThere are functions for DCstepper and servo motors.
  
-===== Funktsioonid =====+===== Data Types ===== 
 + 
 +  * **//prescale//** \\  PWM clock prescaler enumration data type. It determines the division factor of system clock. It is recommended to use the first two division factors. Options: 
 +    * //TIMER2_NO_PRESCALE// - Division factor not used. 
 +    * //TIMER2_PRESCALE_8// - Division factor 8. 
 +    * //TIMER2_PRESCALE_64// - Division factor 64. 
 +    * //TIMER2_PRESCALE_256// - Division factor 256. 
 +    * //TIMER2_PRESCALE_1024// - Division factor 1024. 
 + 
 +===== Functions =====
  
   * **//void dcmotor_init(unsigned char index)//** \\   * **//void dcmotor_init(unsigned char index)//** \\
-    Ühe alalisvoolu mootorikontrolleri juhtviikude seadistamine väljundiksParameetrid+    Initializes one of the DC motor controllersParameters
-    * //index// - Mootorikontrolleri numberVäärtus kuni 3.+    * //index// - Index of motor controller. 0 to 3.
  
   * **//void dcmotor_drive(unsigned char index, signed char direction)//** \\   * **//void dcmotor_drive(unsigned char index, signed char direction)//** \\
-    Alalisvoolu mootorikontrolleri juhtkäskParameetrid+    Drives one of the DC motor controllersParameters
-    * //index// - Mootorikontrolleri numberVäärtus kuni 3. +    * //index// - Index of motor controller. 0 to 3. 
-    * //direction//Mootori polaarsusVäärtus -1, 0 või +1. 0 puhul mootor seisabmuul juhul pöörleb vastavas suunas.+    * //direction//Motor polarity. -1, 0 or +1. In case of motor is stoppedotherwise it turns in given direction. 
 + 
 +  * **//void dcmotor_drive_pwm_init(unsigned char index, timer2_prescale prescaler)//** \\     Initializes one of the DC motor controllers for speed control. In addition, you can set the appropriate prescaler, depending on the frequency of the PWM's you need. Parameters: 
 +    * //index// - Index of motor controller. 0 to 3. 
 +    * //prescaler// - Clock prescaler selection. Interruptions can occur very quickly upset the program of work. For example, when the UH sensor is used, it is necessary to set the prescaler TIMER2_PRESCALE_8.  
 + 
 +  * **//void dcmotor_drive_pwm(unsigned char index, signed char direction, unsigned char speed) //** \\ 
 +Drives one of the DC motor controllers. Motor rotates in a predetermined direction and speed. Parameters: 
 +    * //index// - Index of motor controller. 0 to 3. 
 +    * //direction// -  Motor polarity. -1 or +1.  
 +    * //speed// - Motor speed.  0 to 255. 0 the engine is stopped and the 255 is the maximum possible speed. 
 + 
 +  * **//void unipolar_init(unsigned char index)//** \\ 
 +    Initializes one of the unipolar stepper motor controllers. Parameters: 
 +    * //index// - Index of motor controller. 0 or 1. 
 + 
 +  * **//void unipolar_halfstep(unsigned char index, signed char direction, unsigned short num_steps, unsigned char speed)//** \\ 
 +    Unipolar stepper motor half-stepping command. Functions is blocking as it is fulfilled as long as steps are done. Parameters: 
 +    * //index// - Index of motor controller. 0 or 1. 
 +    * //direction// - Directions of rotation. -1 or +1. 
 +    * //num_steps// - Count of half-steps. 
 +    * //speed// - Time of a single step in milliseconds.
  
   * **//void bipolar_init(void)//** \\   * **//void bipolar_init(void)//** \\
-    Bipolaarse mootorikontrolleri juhtviikude seadistamine väljundiks.+    Initializes bipolar stepper motor controller.
  
   * **//void bipolar_halfstep(signed char direction, unsigned short num_steps, unsigned char speed)//** \\   * **//void bipolar_halfstep(signed char direction, unsigned short num_steps, unsigned char speed)//** \\
-    Bipolaarse samm-mootori mootorikontrolleri pool-sammumise juhtkäskFunktsioon on blokeeruv ehk seda täidetakse seni, kuni soovitud arv samme on tehtudParameetrid+    Bipolar stepper motor half-stepping commandFunctions is blocking as it is fulfilled as long as steps are doneParameters
-    * //direction//PöörlemissuundVäärtus -1 või +1. +    * //direction//Directions of rotation. -1 or +1. 
-    * //num_steps//Pool-sammude arv+    * //num_steps//Count of half-steps
-    * //speed// - Ühe sammu tegemise aeg millisekundites.+    * //speed// - Time of a single step in milliseconds.
  
   * **//void servomotor_init(unsigned char index)//** \\   * **//void servomotor_init(unsigned char index)//** \\
-    Ühe servomootori juhtviikude väljundiks seadistamine ja taimer seadistamine PWM režiimiParameetrid+    Initializes one of a servo motor PWM signal generations units in ATmega128 timer 1PWM signal is 50 hz with high period of 1.5 ms ± 0.5 msParameters
-    * //index// - Servomootori numberVäärtus või 1.+    * //index// - Index of servo motor. 0 or 1.
  
   * **//void servomotor_position(unsigned char index, signed short position)//** \\   * **//void servomotor_position(unsigned char index, signed short position)//** \\
-    Servo-mootori juhtkäskKui juhitakse positsioneerivat servomootoritsiis muutub rootori asendkui lõputult pöörlevatsiis muutub pöörlemise kiirusParameetrid+    Servo motor pulse width control commandIf positioning servo motor is drivenits position is alteredif rotating oneits rotation speed is alteredParameters
-    * //index// - Servomootori numberVäärtus või 1. +    * //index// - Index of servo motor. 0 or 1. 
-    * //position//Rootori asend või pöörlemiskiirus (olenevalt mootorist)Väärtus -100 kuni +100. 0 on keskasend või peatumine.+    * //position//Position or rotation speed. -100 to +100. 0 corresponds to stop.
  
-===== Näide =====+===== Example =====
  
-Järgnev näide demonstreerib kõiki teegi funktsioone. Järjest seadistatakse mootorikontrollerid ja liigutatakse mootoreid.+The following program demonstrates the usage of DC, stepper and servo motors.
  
 <code c> <code c>
Line 43: Line 73:
 int main(void) int main(void)
 { {
- // Alalisvoolu mootorikontrollerite 0 ja 1 seadistamine+ // DC motors initialization.
  dcmotor_init(0);  dcmotor_init(0);
  dcmotor_init(1);  dcmotor_init(1);
  
- // Bipolaarse samm-mootori kontrolleri seadistamine+ // Bipolar stepper initialization.
  bipolar_init();  bipolar_init();
  
- // Servomootorite 0 ja 1 juhtsignaalide seadistamine+ // Servo motors initialization.
  servomotor_init(0);  servomotor_init(0);
  servomotor_init(1);  servomotor_init(1);
  
- // Üks alalisvoolu mootor pöörlema ühtpiditeine teistpidi+ // One DC motors drives forwardanother in backward direction.
  dcmotor_drive(0, -1);  dcmotor_drive(0, -1);
  dcmotor_drive(1, +1);  dcmotor_drive(1, +1);
  
- // Samm-mootori pööramine 100 kraadi ühele poole ja seejärel + // Rotating the stepper motor 100 steps in one direction 
- // 2 korda kiiremini teisele poole+ // and then back with twice the speed.
  bipolar_halfstep(1, 100, 50);  bipolar_halfstep(1, 100, 50);
  bipolar_halfstep(-1, 100, 25);  bipolar_halfstep(-1, 100, 25);
  
- // Servomootorite vastassuunda keeramine+ // Rotating servo motors in opposite directions.
  servomotor_position(0, -100);  servomotor_position(0, -100);
  servomotor_position(1, +100);  servomotor_position(1, +100);
Line 69: Line 99:
 </code> </code>
  
 +This example demonstrates the speed adjustments of a DC motor. 
  
 +<code c>
 +#include <homelab/module/motors.h>
  
 +int main(void)
 +{
 +        unsigned char speed = 0;
 +
 + // DC motors initialization
 +  dcmotor_drive_pwm_init(0, TIMER2_NO_PRESCALE);
  
 +  while(1)
 +  {   
 + speed = 100;
 +
 + // DC motors drives predefined speed and direction.
 + dcmotor_drive_pwm(0, 1, speed);       
 +  }
 +}
 +</code>
en/software/homelab/library/module/motor.1265632937.txt.gz · Last modified: (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0