F28004x Code Generation + DSP Oscilloscope - Digital input and output issue
Hi,
I am trying to perform a simple test using Code Generation feature in PSIM v2023.1. However, I am facing issues to make it work that is why I am addressing here to see if you can help me understand what I am doing wrong.
As input I have two external square signals (Sig 1 and Sig 2) of equal amplitude, 130kHz and 50% duty cycle both with a fixed 20% delay between them. As output I want to perform XOR operation. The inputs are assigned at GPIO 6 and 7, while output is GPIO 12. In addition, I am setting SCI communication to double check what is happening inside the DSP with the DSP Oscilloscope utility. Schematic is depicted here below and .psimsch is also attached in .zip folder.
Simulation results are good as expected (left figure) where the phase delay between both inputs Sig1 and Sig2 is reflected at the output XOR. However, running the generated code in TMDSCNCD280049C DSP card I am not able to get the same results. Please check oscilloscope capture (right figure) where yellow and blue are Sig 1 and Sig 2 accordingly and purple represents XOR output where it is clear that it is not working.
Neither DSP Oscilloscope is working. Despite the SCI connection with the DSP has been performed correctly data integrity is low and the scope is not showing anything. I tried at different baud rates still the same issue.
I would like to know what I am doing wrong, maybe some configuration issue? As I said, PSIM simulation is working fine while real hardware test is not giving any good results.
Thanks in advance!
Regards, Denys.
Answers
-
Hi, Denys,
There is a big difference between computer simulation and hardware target run: Timing limit.
From your schematic picture, I can see, you have set the sampling rate at 20MHz.
F28004x DSP speed is only 100MHz. Your code requires F28004x to finish the XOR calculation, as well as all the overhead of the ISR within 5 DSP cycle. This is impossible on real hardware target.
Sincer the F28004x hardware target has not time to finish your desired computation, you won't get correct waveforms on hardware, and hence, you won't get correct waveforms on DSP oscilloscope.
In computer simulation, there is no such timing restriction. You may have desired waveform.
Your attached zip file is corrupted. I can't unzip it.
Sincerely,
Rhonda
0 -
Hi @Rhonda
Thanks for your reply.
You are right, for some reason the .zip is corrupted. I attached it again here below.
I understand your point on timing limit and it makes all the sense for me. However, I tested again with 2MHz sampling and still getting the same results. The XOR operation is only correct in simulation, and, as soon as I load the code on my F28004x I am not able to get the expected results. Moreover, I keep facing near zero data integrity in DSP Oscilloscope utility.
Can the ZOH sampling be removed at all? I understand the need in analog signals, but why it is used in digital ones?
The data integrity issue would be solved increasing the baud rate? If yes, do you know which would be the maximum I can set?
I would appreciate if you can test the code in your own hardware to help me solve the issue. I expect the DSP being more than capable of reading 130kHz phase shifted digital signals and performing in a correct way the XOR operation.
Awaiting your answer and thanks in advance.
Regards, Denys
0 -
Hi, Denys,
In F28004x, a sample frequency 20kHz and higher may cause interrupt timing problem.
In your schematic, if you add a block "Interrupt Time", you will be able to measure how long it takes for your ISR to finish all its tasks.
If you do not use ZOH, the reading of the digital signal would in the "main loop" section. This section is for the lowest priority tasks. It is executed when no ISR are running. Therefore, the reading time would be unpredictable.
It is unusual to measure such high frequency (130kHz) digital signals with F28xxx DSPs. What is your reason for doing it?
If you want to measure/calculate something else from those two waveforms, there might be other options to achieve your goal.
Do you want to generate two 130kHz signals with deadtime between them? If you utilize PWM blocks, the deadtime can be specified in those PWM blocks.
Sincerely,
Rhonda
0 -
Hi @Rhonda
Thanks for your reply.
I am performing a custom control whose inputs are 2 signals from the circuit. Not going into much detail, the principal idea resides in the fact that the control dynamically changes based on the phase difference between those 2 inputs. Thus, the easiest way I have found to extract the phase difference parameter is through the XOR operation.
You have shown me that my idea is nearly impossible with the F28004x, at least of lowering the frequency of the input signals (which is not the option for my application). However, I would like to think that it can still be implemented inside the DSP and not in an external hardware.
I was wondering if you can help me replicate the same idea but in another way. I am open to any other suggestion you may have.
Maybe some sort of capture features to take the rising and falling edges of both input signals, calculate the phase difference and based on that generate a PWM analogous to the XOR operation (the only consideration here is that the XOR output is x2 frequency of the inputs)?
I am quite new into PSIM SimCoder and I would be grateful if you could give me a hand.
Awaiting your answer.
Regards,
Denys
0 -
Hi, Denys,
Usually, the phase of two signals can be measured with capture function in DSP.
However, in your case, if the signal frequency is 130KHz, each cycle (360 degrees) only has 7.69usec.
If you want the resolution to be 10 degrees (very coarse resolution), you have only 0.21usec.
F28004x may capture those two signals, but it may not have sufficient time to handle and process the phase.
0 -
Hi, Denys,
Here is an example measuring the phase of two input pulses.
However, for your case, with the frequency at 130KHz, much higher than this example (10kHz), we do not think it would work.
0 -
Hi @Rhonda
I appreciate your answers.
Can you share the Test2SigPhase file for an older version of PSIM. To open your schematic it requires me to have v24, unfortunately my licence suite only displays v23 as the last one I can download.
Awaiting your answer.
Regards,
Denys
0 -
-
Hi @Rhonda
Thanks for the schematic.
I have reviewed your proposal and it performs the function I wanted. I have tried to replicate the same for my hardware target F28004x. Despite in your F2837x configuration it works fine, I am not able to perform the simulation for F28004x as I get the following error message:
According to the PSIM Simcoder manual, I see that my target hardware has even more capture sources, so I don't understand this error.
Could you help me with it? Maybe I am configuring something incorrectly. Enclosed here the .zip file with the schematic files.
Thanks in advance!
Regards,
Denys
0 -
Hi, Denys,
The code generated with your PSIM schematic works on target. This is good.The simulation of this schematic generates an error signal. This is a bug. I have contacted the development team, and they will fix it for future PSIM versions.
Sincerely,
Rhonda
0 -
Dear @Rhonda
I see that even if the simulation is not working I can still generate the code.
How did you verified the results? I have tried to output through SCI and check in PSIM > DSP Oscilloscope but I get blank output.
If you can explain me how to do it I will be very thankful.
Greetings,
Denys
0 -
Hi, Denys,
Which "output" do you want to see on PSIM's DSP Oscilloscope?
This oscilloscope can only display the variables inside the DSP memories. It can't show the waveform outside of the DSP. The waveforms at the GPIO ports are outside.There are example and tutorial video and document. They explain how to use this function. Please use PSIM"s "Help >> Index" and search with the keyword "SCI" or "oscilloscope".
Sincerely,
Rhonda
0