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.

Pwm interrupt Microchip clarification

Status
Not open for further replies.
I am not getting how to implement the sine lookup table as per the document. Let us I use 0 - 255 array for sine look up table. So each element will be like 360/256 degrees apart or 1.40625 degrees
...Next step is let us say my encoder sends 1000 pulses for one revolution or 360. So for every count i have 0.36 degrees incremented. How should i match this 1.4062 with 0.36. I am confused. Can you please suggest. Should i go with approximation?
Not particularly a problem of look-up table. The basic point is to choose an angle unit to be used in your design. It could be e.g. 0.36 degree resolver resolution. Then you either use the same resolution for the look-up table or apply linear interpolation.
 

Ok i understand now. I created a look up table for 1000 entries for the encoder pulses. I am not getting the motor rotation. It just moves little bit and strucks. Can anyone help me. I am not sure where should I start debugging. Offline i simulated the code by giving a sinusoidal currents with 120 phase shift. I am getting the pdc registers the duty cycle values also in the form of sine waves. How should i proceed. Currently i am trying at 2khz pwm frequrncy.
 

You can save a lot of space by using the fact that sine waves are symmetric in two ways. In the range from 180 to 360 degrees, you can use the values from 180 to 0 degrees and negate them. Also the range from 180 to 90 degrees is the same as from 0 to 90 degrees.
Therefore you can have a table that is only the first quadrant of the circle. When going from 0 to 90 degrees you step forward through the table. When going from 90 to 180 you step back through the table. From 180 to 270 you again step forward but negate the value, and from 270 to 360 you step back and negate.
As for debugging, you probably need to break the problem down into manageable chunks to start with. I assume you know how to use the debug capabilities of the IDE. I really don't know your problem domain but I could imagine that you should start with (say) the encoder to make sure that you are reading the input pulses correctly - even when you are slowly turning the rotor by hand; then that you can get the counter to work; then look at the table lookup part using the counter. Next start with getting the PWM signal to be at 50% and then vary that correctly - forgetting about trying to do this very quickly. You can then connect the encoder part up to the PWM (still turning it by hand) to make sure that the PWM signal is being updated over the full turn of the rotor. If all that is working at slow speed then you can try to speed things up until it is working at the required speed.
What you are really doing is making sure that each step is based on a working foundation. If you add something and it stops the whole thing working then they last thing you changed will tell you where to start looking for the problem.
Susan
 

Thank you very much for giving valuable tips and sorry for late reply. It is valuable suggestion for sine look up table and i will implement the same. Regarding the encoder i could get the pulses.
Few clarifications i have are
A. Mechanical angle is different from electrical angle is mentioned in the document. Theta electrical = no of pole pair * theta mechanical. In this case if it is 4 pole pair then if mechanical angle is 0 electrical angle is 0. If mec angle is 30 then ele angle is 120. If mec angle is 360 then electrical angle is 1440 degrees. Is it correct? I am confused on this. As per the part number of the motor it says i have to receive 4000 pulses for revolution but i am receiving only 1000. I don't know why this is happening.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top