PSIM Code generation to calculate RMS and average values
Dear all,
I can see that PSIM does not support the inbuild avg and rms block for code generation.
Hence, I implemented it directly in CCS by manually written the code in PSIM generated .c file.
I was wondering if it is possible to implement a virtual clock inside the PSIM, which is dedicated to update the registers (assign to hold the RMS or average values) only at specific time intervals.
Thank you.
Best Answer
-
Hi Souradeep,
Average mode can only be used in simulation, but when the program runs in a CPU, we cannot set an average level to a hardware device, for example, you cannot set an average level to a PWM output. No hardware supports it.
If you want to set a sampling rate for a curtain routine, you can use some blocks that include sampling frequency, for example, PWM block, or ZOH block. When you use a PWM block, SimCoder uses PWM to cause interruption, when there are only ZOH or UDelay blocks for a specified sampling frequency, SimCoder uses a timer to causes an interruption.
Thanks,
Jiakai
1
Answers
-
Hi Souradeep,
Average mode can only be used in simulation, but when the program runs in a CPU, we cannot set an average level to a hardware device, for example, you cannot set an average level to a PWM output. No hardware supports it.
If you want to set a sampling rate for a curtain routine, you can use some blocks that include sampling frequency, for example, PWM block, or ZOH block. When you use a PWM block, SimCoder uses PWM to cause interruption, when there are only ZOH or UDelay blocks for a specified sampling frequency, SimCoder uses a timer to causes an interruption.
Thanks,
Jiakai
1 -
in addition to jaikai's comments if you integrate "1" the value of the integral will be the time that has passed. You can use resettable integral to just track the same period over and over again. if you are implementing c code you can use the c block to test your algorithm within PSIM simulation
0