This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RE: control a DC Motor using MOTOR CONTROL PWM in LPC1768

@ everybody(Erik, Per & ...)
it is very interesting for me to know how did you found that i am an electronic student???
and which school session, is finished at October (in my country)?
unfortunately internet is full of 'EXPERT TROLLs' instead of real 'engineers'.

Amir

  • can any managers of this forum move these posts to 'RE: control a DC Motor using MOTOR CONTROL PWM in LPC1768' topic??
    i don't know what happened to my topic and why this posts is in another topic??
    thanks

  • it is very interesting for me to know how did you found that i am an electronic student???

    well, you are. we all are 'students' even after leaving school.

    OK, the issue is that you post "Do you have sample codes for initial setup for Motor Control PWM?" which indicates that you want a fried pigeon to fly in through your window.

    If you are not a student, and can not perform the assigned task, you must talk to your supervisor, rather than post in a fdorum.

    Erik

  • Dear Erik
    as i said before:

    i had a brief review of MCPWM part in LPC1768 datasheet. but i think that part of datasheet isn't as good as i thought!!
    i decided to learn it using sample codes but unfortunately most of the codes have been written using CMSIS library.

    i asked about initial setup not whole pid controller! because i think that part of user manual is not as good as other parts(such as qei). i don't know why you have this judgement about me? if i want a fried pigeon to fly in through my window, i used CMSIS library instead of registers.

    They sleep half the time during their school sessions. Then they finally notices that they are expected to do different assignments to pass the course. Then they get really exited about the existence of Internet, hoping for a quick fix for their fix.

    we all (You, Per and I )know what we are talking about! we are all students but that is not what Per means.

    If you are not a student, and can not perform the assigned task, you must talk to your supervisor, rather than post in a fdorum.

    i am an electronics fan and i want to know about electronics because i think ihadn't learnt enough about microcontrollers during school. and i have no supervisor (to work for).
    and its my decision to choose where to ask and please tell me if keil.com is your property!
    this is an electronics forum and every body have right to ask. and i didn't forced anybody to answer me. and i wondered, why people(experts) talk in such an impolitely behavior.

    Goodluck Erik

  • I tried to google for code bundle lpc17xx - the first file I downloaded did contain code for MCPWM that did play with the registers.

     *   $Id:: mcpwm.c 5747 2010-11-30 23:45:33Z usb00423                       $
     *   Project: NXP LPC17xx Motor Control PWM example
     *
     *   Description:
     *     This file contains MCPWM code example which include MCPWM
     *     initialization, MCPWM interrupt handler, and APIs for MCPWM access.
    

  • and its my decision to choose where to ask and please tell me if keil.com is your property!

    I made no reference to asking specifically at Keil. I referred to "gimme code"

    'asking' is asking for help with what you have done and a specific problem with that, not "gimme code"

    Erik

  • thank you Per
    i downloaded the code bundle.
    i think that it is better to work with PWM + QEI to implement PID, instead of MCPWM. it is not easy to work with QEI (catch position and time)in MCPWM.

    as i asked before:

    but i don't know what's the effect of PID calculation's time waste during interrupt, on pid accuracy?(i want to refresh pid calculation every 50us and clock frequency of 1768 is 100 MHz)
    is it feasible to earn 50us refresh time?
    how much clock pulses were spent in a simple (without extra codes) interrupt?

    how can i find that how much clock pulses are spent in a simple interrupt.

    thanks

  • Using C/C++, you aren't intended to know exactly how many clock cycles an ISR is consuming.

    You can spend some time figuring out how large percent of the total CPU capacity that gets spent by a constantly ticking interrupt by checking how much it slows down a busy-looping main loop.

    But in the end, you normally set up a control loop where it doesn't matter what exact response time the ISR has, i.e the control loop is normally fine with getting one update every interrupt and the program is fine that each interrupt leave enough time for all other interrupts and for the main loop with a bit to spare for safety margin.

    If the jitter delay and execution time in the ISR will destroy your regulation performance, then you are running a too slow processor or expecting too much of the regulation.

    Exactly what RPM are you planning to run the motor, and exactly what position precision are you demanding?

  • OK got it!

    Exactly what RPM are you planning to run the motor, and exactly what position precision are you demanding?

    i decide to run the motor at 79310 encoder pulses per second and 34 encoder pulses precision.
    in other words, it must run at 34 pulses per 428 microseconds.

    i think there are two approaches :

    I. set PWM1->MR0 (lim register) to (428/2=214)microseconds and setup an interrupt at the end of cycle includes PID routine that adjusts 17 pulses per this pwm cycle.

    (this method has about 1/17 pulse error)

    II. set PWM1->MR0 (lim register) to 14 microseconds but setup interrupt for QEI ENCLK_Int(encoder pulses) that takes about 12.5 microseconds and change PWM1->MR1 (match register) using PID during this interrupt for the next pwm cycle.

    is it applicable to implement 2nd approach?
    thanks

  • Hi
    another question
    I have doubts about LER in PWM.
    assume that:

    LPC_PWM1->MR0=1000000;
    LPC_PWM1->MR1=500000
    


    and TC value is about 20 and it haven't been mached with 500000 !
    now if an interrupt occurs that contains:

    LPC_PWM1->MR1=200
    LPC_PWM1->LER =0x01;
    


    does the match occurs for MR1=200 or the program runs the match for MR1=500000 and uses the new value (MR1=200) for the next cycle?

    thanks