Hi,
Previously, I worked on eCap and ePWM module in my previous thread and then I was successful to implement both modules. The task was to take input from the function generator as digital pulse signal having freq and duty cycle from eCap funtion and then copying or generating the same pulse with same freq and duty cycle through ePWM function. The code was working perfectly and I can see variables values PWM_Period & PWM_Duty in terms of TBPRD (for 10KHZ PWM_Period =15000 & PWM_Duty = 7500 respectively)....(Previous Work)
The Problem comes when I add the PID code routine from line 44-62 and line 293-314 in my code of previous work. Here i am not using any DCL library for PID simulation. For some background information, like in aurdino, Matlab or other microcontroller, the pid routine code is used commonly for pid simulation. Therefore, I added the pid routine code from line 44-62 & line 293-314 respectively in my code. The reason for adding pid routine code is to update the period & duty cycle both after pid while loop in terms of NEW_Period/NEW_Duty.
After resolving the building errors, I simulated the code on my hardware and check the variables again PWM_Period & PWM_Duty in terms of TBPRD. These variables are not updating and showing WRONG values. I change the knob from the function generator like from 10Khz to 20KHz but the PWM_Period & PWM_Duty variables are not updating themselves. Due to which, NEW_Period/NEW_Duty are also showing incorrect values. Probably, It may be possible mistake that the placement of pid routine in my code is not at the correct line position.

Please suggest accordingly.
Regards
Arsalan






