Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

motor feedback- an PIC detect the continuous changing pulse?

Status
Not open for further replies.

engkeat

Junior Member level 1
Joined
Aug 18, 2008
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,409
motor feedback

i m using an incremental encoder to feedback the speed of a dc motor. i am concern about the frequency of the pulse generate from encoder as i need a find a set point (desired frequency/speed) , the motor is used to lift up a load at a constant speed. during the lifting, torque required is changing, meaning voltage required is changing as well..so i need to control the voltage supplied to motor through the feedback pulses, i m using PIC as the controller. my question is that... can PIC detect the continuous changing pulse from the incremental encoder??? o do i need any converter?
 

Re: motor feedback

You can put output from encoder to interrupt pin and detect state change. So you can meassure time between pulses to get rpm and use PID algorithm for motor speed control.
You can also put timer on overflow on 1/10s and count number of pulses in that time period to calculate RPM. In this manner you will have time delay of 1/10s for feedback but in most applications that will not be an issue.

If you need help with PID i can give you an example in C for AVR.
 

Re: motor feedback

Here is the code for PID regulation

Code:
int last_error = 0;
bool bStop = false;
int iState;

int Kp = 10;
int Ki = 0.01;
int Kd = 50;

void PID (int refSpeed){
	int error;
	double PComp, DComp, IComp, PIDComp;
	int speed = ReadRPM (); //this function gets value of current RPM of motor

	error = refSpeed - speed;
	// Proportional component
	PComp = abs(error)*Kp;
	
	// Differential component
	DComp = abs(last_error - error)*Kd;
	last_error = error;
	
	iState += error;
	if (iState > PIDMax) iState = PIDMax;
	else if (iState < PIDMin) iState = PIDMin;
	
	IComp = Ki*iState;
	
	// PID component
	PIDComp = int(PComp - DComp + IComp);

	
	// Limit speed to max speed of H-bridge mode: 0xFF (255) 
	if (PIDComp > 255) PIDComp = 255;
	
	if (error > 1 && !bStop){
		SetMotorSpeed (PIDComp);
		}
	else {
		bStop = true;
		StopMotor ();
		}
}

I havent try this code yet cause i'm struggling with my encoder and uC board. It will need some fine tuning of Ki,Kd, Kp. Also you need to decide time of discretization, which means how often are you measure RPM and correct it, basically how often you call this function. As for compensation of friction you should try to measure it (if possible). If you do not compensate it, you will most certainly get oscillations while starting and breaking, if the load is noticeable :).
 

Re: motor feedback

Interesting, could you evaluate more about the motor driving? Are you using a integrated driver stage or builded it by using discrete component?
Also I've to build a similar system, powered with 12 V, my load will be approx 15 kg and I've to move it up to 100 m. At know I'm searching about the motor and I think to use some with high gear reduction ratio in order to achive some sort of blocking effect when the motor is into the stop mode.

Thanks
Pow
 

Re: motor feedback

Hi,

I'm using h-bridge with pwm control in form of 0-255 values for speed. So PID regulator will get RPM from encoder and compare it with referent speed and use control logic to match desired value.

As for your motor i think you will need some sort of mechanical break if your load will be constantly present. High gear ratio will be good idea as you will achieve higher torque values that is needed for lifting your load.

You will need to achieve constant current mode for speeding your motor to desired voltage/RPM, because momentum is related with current. On included pic you can see constant voltage curve that shows two motor modes. n0 is rotational speed that will be achieved if there is no momentum and friction. For lifting mode you will be stepping between two currents (to achieve smoother movement you need to make this interval as small as possible) while increasing voltage.

For braking you can use three types: generative, electro dynamical and counter-current mode (dont know exact English term, but it can be achieved by changing direction of current flow). Generative mode is useful when you lower your load as you will get recuperation of potential energy in form of electrical energy.

Hope it will help you a bit.

Well this is all theory, havent experiment with power electronics yet, but i would be very happy if you could share some of your experience. (When your project lives up a bit)
 

Re: motor feedback

Thanks for your reply, well, actually I'm going to test the first prototype, motor have a high gear-ratio reduction value in order to sustain the load when the motor is stop. Actually with the gear reduction I've a slowly movement (approx. 1 m every 40 s), load is approx 15 kg and start / stop is did by a couple of relay (interleaved).
Load position (from 0 to 100 m) is controlled by using a multiturn absolute encoder. To start the motor actually I've to simply close the relay and to stop simply open it.
Actually with the load and some compensation (basically I can stop the motor some amount before the real position, of course this value is different from up and down movement due to the gravity effect) into the start and stop event I've reach a repeatibility into the positioning of 0.1/0.3 mm which is enough about this application.
Of course this solution is more simple and cheaper (no brake, no control card is needed then no PID tuning) but has a drawback due to the maximum speed.
Actually the motor speed is fixed and I've now a request about to speed up the motor of three time than the actual speed. As a first approach I will work around the gear reduction ratio and see if this is enough to retain the load when the motor is not moving.
 

Re: motor feedback

Another drawback is, that you will burn out your motor if you are using standard DC motor. while motor is not moving, current (that is needed to compensate 15kg of load without moving) flows through motor, producing heat.
 

Re: motor feedback

ScOe said:
Another drawback is, that you will burn out your motor if you are using standard DC motor. while motor is not moving, current (that is needed to compensate 15kg of load without moving) flows through motor, producing heat.

This can't occour due to the high gear reduction ratio that I've used but I've to check if the load will stay in position also with the new gear ratio due to the request for greater speed than the actual one, may be or not (I've to check) the need to use a brake.

Bye
Pow
 

Re: motor feedback

Well the gear ratio will only produce more torque with same power on motor as P=T*w - where w is rotational speed. So if speed is 0, torque is 0, and you have load momentum to compensate. So you will probably be around 0 speed but not 0. And for that you need to put more power to motor to get torque that is equal to momentum of load (Mt=m*g*r) - where m is mass, g is gravitational acceleration and r is radius from center of output rod axis. (mass on the pully, if that is correct term).
So T=Mt means load is hanged on certain height. If T < Mt, load is falling down, respectively.

That is of course in ideal condition where inertia, friction and all other losses are 0. If construction doesnt allow usage of mechanical break, you should consider other kind of motor than std DC ...
 

Re: motor feedback

That is of course in ideal condition
Yes, and that's why the consideration is apparently meaningless for the said application. The gear ratios, that achieve self-locking can be read from mechanical engineering textbooks for different gear types. Of course, if the gear ratio is too low, you need a brake.
 

Re: motor feedback

The gear ratios, that achieve self-locking can be read from mechanical engineering textbooks for different gear types.

Hrm, very interesting .. i'm ME and never heard about gear box that would achieve self locking and actually be usefull... i know about screws and lead and ball screw mechanism but they are used for linear translations and that would not be usefull on 100m application.

Than again, i didnt specialized in mechanical designs but it is strange i never heard about that.

Ok i have just surfed the net for self locking gearbox and got to this as i already told ...if it self lock it is not usefull ...

Self-locking is the inability of a gearbox to be driven backwards by its load. In other words, self-locking gearboxes cannot be driven from the output shaft, either through a power source or an external torque load. The ability for a gearbox to lock is related to its efficiency. The higher its efficiency, the less likely it is to lock. Because worm reducers are generally less efficient than other gear types, they are often used where locking is desirable.

A rule of thumb is that higher ratios may lock, however, there are too many factors that can influence the ability for a reducer to lock, including: ratio, lube type, load applied, service factor, in-service time, ambient temperature, input speed, altitude, other external loads applied, etc.

When it comes to utilizing a gearbox as a holding or braking device, there is more gray area than black and white. Application concerns have been witnessed where a 60:1 to 80:1 single reduction worm reducer was utilized in a lifting application without a brake. After several cycles, the load can start to creep downwards.

Because of the uncertainties with locking gear sets: NO GEARBOX SHOULD BE CONSIDERED SELF-LOCKING
 

motor feedback

Worm gears are actually often used for lifting applications, although they have a poor effciency, because of their self-locking capability. In the said application, the friction moment of the DC motor can also achieve self-locking with higher efficiency gears, but I admit, that it may be unreliable, so there should be a another braking mechanism if the lift is required to hold the position without power supply. Burn out of the motor isn't a real risk, however.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top