arduino - Speed Control in dc motor Stepper (motor: NEMA 17 ; driver: drv8825) [frequency regulation] -
i'm doing school project using few stepper motors driven drv8825 drivers (actually, overhead travelling crane), arduino uno. first of all, haven't got huge amount of money spend. now, problem this: going use pid control, through mpu6050 acc+gyro, control speed of motors (the load supposed firm possible during movements), , 2 ways change speed of stepper motor are:
1) through delay method, example:
for (i = 0; i<400; i++) { digitalwrite(steppinb, low); delaymicroseconds(500); digitalwrite(steppinb, high); delaymicroseconds(500); }
using method, arduino busy time, not able check continuously value of sensor, in order reach correct speed. because of this, can't use method.
2) through external regulation of drv8825's clock frequency, example using "voltage-frequency converter" (the variable voltage given "arduino pwm" + "low-pass filter") or using "astable multivibrator" ("astable oscillator") "digital potentiometer" change frequency. i've tried "voltage-frequency converter" method, didn't work due noises of circuit.
i'd me find out what's better way change stepper motor's speed continuously during program (and find better way make variable frequency, shown in point 2).
you using same time (500us) code below may suits (using arduino millis()
funcion):
unsigned long timerbefore = 0; //global variable int inc=0; void temporize(){ unsigned long timernow=millis(); if((unsigned long)(timernow-timerbefore)>=(500){ timerbefore=millis(); inc++; if(inc==1) digitalwrite(steppinb, low); if(inc==2){ digitalwrite(steppinb, high); inc=0; } } }
then can call function inside of for
without slave microcontroller code.
Comments
Post a Comment