This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Attempting to "code" using MATLAB R2013b or similar software (without writing code)

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hello! 

I am new to TI DSPs and find learning and programming pretty tedious and difficult. I'm trying to control 3 phase inverters (6 switches - for IM and PM machines) and also 2 phase switching legs with varying duty cycles and phase shifts (for power converters) using suitable PWM signals on the TMS320F28335 Delfino microcontroller with the Peripheral Explorer c2000 board.

Three basic functions that I want to implement are

1. Changing the frequency of the PWM output using an ADC input from a potentiometer on the board connected to pin A0 of the control card

2. Changing the phase shift of PWM 2A and 2B wrt PWM 1A and 1B and 3A and 3B wrt. 1A and 1B (etc.) to a suitable value

3. Applying a suitable dead time so as not to short any switching legs

I have configured matlab to do this since I still have major problems with coding. I've also tried SIMCODER (PowerSim), but in this program, the provision to change the switching frequency of the PWM as an input from the ADC is not available. Also, even without using the switching frequency variation, SIMCODER has problems in creating a sinusoidally modulated PWM signal.

I have 3 basic questions

1. Does anyone have any suggestions about software other than PSIM and MATLAB which can do this easily, without the need to code and also to be able to see the simulation of the whole system with the micro.. in the loop, so to speak. 

2. Can anyone share a basic project with code (in CCS V5 - that actually works!) to achieve these functions for the ePWM module, so that I can get an idea of things.. even one properly configured PWM pair will do, I can edit the code from there. It's a bigger problem to write from scratch without any prior experience. Right now I've tried to write code a few times, but I'm not comfortable with the coding environment and it takes a lot of time to get it right. I'm not sure I'll ever be able to do it on my own. I use CCS5 with XDS 100V2 and control suite and a blackhawk emulator, but I don't particularly understand all of it in a high degree of detail

3. Does anyone have any comments about the pros and cons about using MATLAB (embedded coder) and PSIM (simcoder) or any other software..

It would also be a great help if anyone could tell me if there is a "simulator" for the TMS320F28335.. a program which could show me what the board will do - at the pins and the LEDs etc. when a certain .out file is uploaded onto it.

Many thanks!

  • Hello,
    I'm not the best to answer #1 and #3 (I suggest you post in the C2000 forums) but for the others:

    #2: Have you checked out controlSUITE? There are several ePWM examples that can be used with CCS.

    There is no F28335 device simulator. We have no plans to add one. We are removing simulator support with CCS (CCSv6 does not come with any).

    Thanks
    ki
  • Could you link to the C2000 forum, please?

    Thanks for your answer. I have controlSUITE, as I mentioned before. I did manage to write some code yesterday, but I still am looking to make this easy by automation, using embedded coder or simcoder. It is not easy or practical to remember all those registers and interrupts and access protocols..
  • I will move this to the C2000 forum where the experts there can provide more suggestions

    Thanks
    ki
  • Hi Devraj,

    Devraj Dutt said:
    1. Does anyone have any suggestions about software other than PSIM and MATLAB which can do this easily, without the need to code and also to be able to see the simulation of the whole system with the micro.. in the loop, so to speak. 

    There are no other softwares other than MATLAB for automated code generation. Also, Matlab has complete support only for CCS v3.3 which is not even available now. My suggestion would be to go for core coding techniques for C2000 family. This will ensure you to have complete control over peripherals like ePWMs and ADCs.

    Devraj Dutt said:
    2. Can anyone share a basic project with code (in CCS V5 - that actually works!) to achieve these functions for the ePWM module, so that I can get an idea of things.. even one properly configured PWM pair will do, I can edit the code from there. It's a bigger problem to write from scratch without any prior experience. Right now I've tried to write code a few times, but I'm not comfortable with the coding environment and it takes a lot of time to get it right. I'm not sure I'll ever be able to do it on my own. I use CCS5 with XDS 100V2 and control suite and a blackhawk emulator, but I don't particularly understand all of it in a high degree of detail

    Here's a link for the workshop: http://processors.wiki.ti.com/index.php/C2000_Archived_Workshops#C2000_Delfino_Multi-Day_Workshop_-_Revision_8.1_November_2010_.28ExpKit_F28335.3B_CCSv4.2.3B_DSP.2FBIOS_5.41.29

    Devraj Dutt said:
    3. Does anyone have any comments about the pros and cons about using MATLAB (embedded coder) and PSIM (simcoder) or any other software..

    As I mentioned above, using matlab will not give you complete control over prime peripherals and hence core coding is always suggested.

    Devraj Dutt said:
    It would also be a great help if anyone could tell me if there is a "simulator" for the TMS320F28335.. a program which could show me what the board will do - at the pins and the LEDs etc. when a certain .out file is uploaded onto it.

    There's no simulator as such but you already have a kit; that is enough.

    Regards,

    Gautam

  • Hello Devraj,
    First, I am surprised to hear that Simcoder has problems generating code for sinusoidal PWMs. That is one of the main functions that you need to do in power engineering and motor control. I will forward this to the president of PowerSIM to see what his response is to this. In general I have found PSIM to be very capable of doing these kinds of tasks.
    Next, have you considered using VisSim? In my opinion, this might be the best solution for you. Having used both tools, I would say that VisSim is first and foremost a code generator which also does simulation. In contrast, I would say that PSIM is first and foremost a simulator, which also does code generation. They both do similar functions, but it is just where the emplasis is placed in the product design. The code generated by VisSim is very tight (within 5% of an experienced C programmer according to their claims), and actually quite legible.
    Best Regards,Dave
  • Thanks, Dave, for offering to write to the resident of PSIM, but I'm not really sure how that will go! PSIM is brilliant for simulations, as you said. It simulates my PWM switching signals (with microcontroller), a 3 phase inverter bridge receiving those signals (connected to a DC bus) and the electric machine itself, fed from the legs of this bridge perfectly. However, for code generation, it messes up. I want to change the frequency and amplitude of the sinusoidal carrier using the ADCs on the peripheral explorer, but with PSIM code, the ADC conversion is not correct since I get modulated values only at certain positions of the potentiometer and at some other points, I get no modulation at all. I haven't tried VisSim, but I don't think my university has a license and getting a license is going to be too complicated. This is the first time I have met someone who uses it.

    Gautam, other than MATLAB, the program called PSIM's capabilities are pretty cool. I recommend you try it at some point. For more simpler code generation, it works very well. Thanks for you comments and the student guide, though. I have the teaching guide from TI and it is pretty cool as well. The only problem being that you actually need to code and not export from a simulation.

    In the end, I did write c code to do what I need to, but thank you, for trying to help! I earlier wrote that I would post the code, but on second thought, I prefer to email someone directly in case anyone needs it!

  • Gautam, other than MATLAB, the program called PSIM's capabilities are pretty cool. I recommend you try it at some point. For more simpler code generation, it works very well. Thanks for you comments and the student guide, though. I have the teaching guide from TI and it is pretty cool as well. The only problem being that you actually need to code and not export from a simulation.

    I've used PSIM but as you said in any case I've to write the code!


    In the end, I did write c code to do what I need to, but thank you, for trying to help! I earlier wrote that I would post the code, but on second thought, I prefer to email someone directly in case anyone needs it!

    Sounds Great!

    Goodluck & Regards,
    Gautam
  • Hi Devraj,

    I did contact the CEO at PowerSim about this issue.  His reply is copied below:

    "Regarding the ADC question, it is true that in SimCoder, the capability to change the switching frequency dynamically with an ADC input is not there. At the moment, all switching frequencies are fixed. We will consider having the variable switching frequency function in the future.  Regarding the second question, ...SimCoder can generate sinusoidal modulated PWM signals with no problem. For example, we have an example “3-ph sine wave with SCI monitoring.psimsch” that does exactly that."

    I checked, and this example is included in the standard install of PSIM, so you should have it.

    With regard to VisSim, you can download a full featured version for 60 days for free that does code-gen.  This might be enough for your needs.  Visual Solutions (which is the parent company behind VisSim) was recently acquired by Altair.  I know they are pretty university-friendly, so it might be easier than you think to get a license at your university.  I really think it would be in the best interest of your university to investigate this.  "Model-to-code" is the wave of the future.  I think it will eventually do to C coding what C coding did to assembler.

    Best Regards,

    Dave

     

  • Hey Dave

    Thank so much! I daresay, I would like to be in touch with PSIMs CEO myself! That is so brilliant that you know him and I'm not sure how, but thanks for asking on my behalf :)

    The switching frequency constraint is confirmed, then.. About the thing with sinusoidally modulated PWMs, the thing is, if I use only one PWM module, sinusoidally modulated via ADC input (with scaling and math operations), it works. If I use a 3 phase PWM, the problem I get is this: I get a sinusoidally modulated waveform at only one end of the potentiometer. If I rotate the potentiometer a bit, towards the other end, the modulation stops and I get a constant PWM. And it is not only me. This is for a project that more than one group in my class is doing and I have heard of the same issue from two other teams. So, I'm kind of convinced that its not just me.

    Thanks for the VisSim suggestion. I'm going to try it out, perhaps in the vacations (electrical master programmes are generally notorious for keeping people mighty busy, even during the vacations). However, I shall also talk to my professors if I like VisSim. It shall be a brilliant addition to the lab, if it can automate any required kind of code.

    And yes, model-to-code is indeed the future. To say the least, it is much more convenient. I daresay that I do not feel comfortable with using CCS and that its interface is not in the least user friendly. I'm just not convinced that electrical engineers (people who work with power electronics/machines) should need to invest so much time and energy in figuring out registers and somesuch. Model-to-code will make this a much smoother and more seamless transition. And with the advantage of being able to simulate with the real model in the loop.. what would you call that? Model-in-loop? :)

    Thanks again and best wishes for Christmas and new year!
    Devraj