File Exchange

image thumbnail

Dual Motor Control with TI LAUNCHXL-F28069M LaunchPad

version 1.3.0.0 (212 KB) by Antonin
Field-Oriented Control with TI LAUNCHXL-F28069M, BOOSTXL-DRV8301 inverters and 2 PMS motors

42 Downloads

Updated 27 Jul 2018

View License

This example shows how to use a closed-loop Field-Oriented Control (FOC) algorithm to regulate the speed and torque of a 2 three-phase Permanent Magnet Synchronous Motors (PMSM). This example uses C28x peripheral blocks and C28x DMC library blocks from the Embedded Coder Support Package for Texas Instruments C2000 Processors.
For newer versions and other hardware setup, check the shipping version of this example on this page: https://www.mathworks.com/help/supportpkg/texasinstrumentsc2000/examples/permanent-magnet-synchronous-motor-field-oriented-control.html
Required Hardware:
- TI LAUNCHXL-F28069M LaunchPad (http://www.ti.com/tool/LAUNCHXL-F28069M)
- 2 BOOSTXL-DRV8301 with a 3-phase brushless motor and a 12-24V power supply (http://www.ti.com/tool/BOOSTXL-DRV8301)
- 2 PMSM (i.e. 2MTR-DYNO setup http://www.ti.com/tool/2mtr-dyno)
More information on how the models have been created and how to use them in the following video:
http://youtu.be/ncM7N-hLKQM

Comments and Ratings (65)

Hello,

I would like to ask you for suggestion. Which Launchpad(F28379 or F2827) would be better to use along with the AB Encoder and also Endat Encoder with TIDM-1008 in order to control single motor? I saw F28379 is being used. Any other recommendation is welcome.

Regards
Sanjay

Especially the use of sensors would have been helpful for me. Sadly, this point is missing.

Sumit Patil

Thank you so much for giving me guidance Antonin, it's been of great help!

If I may I will just ask one last question, how could I make the model suitable for a 10 pole motor?

Thank you once again.

Anika

Antonin

Hi Anika,
Most welcome!
For a single motor using the DRV8301, you can check this page:
https://www.mathworks.com/matlabcentral/fileexchange/45124-motor-control-with-ti-launchpad
It's working with the F28027 Launchpad, but you can probably merge the 2 solutions to get the DRV8305 working on the F28069 Launchpad with your custom motor.
I hope it helps,
Cheers,
Antonin.

Hi Antonin,

Thank you for creating such informative videos.

Is it possible to use this model with a single DRV8301 and Thomas Power 250Z series motor (250ZC35/24)? I'd be most grateful if you could advise me please.

Anika

Krishna v

Hi Antonin,

Thanks for the video. Are the two BOOSTXL-DRV3801 driver boards powered by a single power supply? If so, what are the maximum current requirements for the DC power supply? 10 A / 20 A? Assuming that the voltage range required by the driver boards is 6-24 V?

Hi Venkatesh,

Thanks for your response.
Luckily, I solved the problem yesterday by changing the Matlab version from 2015a to 2018b. Then, the model was built successfully.
I hope the solution can help others.

Wentao

Hi Wentao,

Please connect to us at:
https://in.mathworks.com/support/contact_us.html

Thanks,
Venkatesh C

Hi Antonin,
Thanks for your video.
I have a problem during the implementation. When the simulation model is building, an error occurs as
-----------------------------------------------------------------------------------------------------------------------------------------------
### Generating code into build folder: C:\work\c28069pmsmfocdual\c28069pmsmfocdual_ert_rtw
### Invoking Target Language Compiler on c28069pmsmfocdual.rtw
### Using System Target File: D:\ProgramFiles(x86)\matlab2015a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
Warning: The data type "int8" uses a word size that is not available on the intended target.
Fixed-point signals using this data type will be put inside a larger word or multi words. When used,
extra software will be generated to force this larger word or multi words to emulate a smaller
word. This emulation is helpful when your prototype target and your final
production target are not the same. If the smaller word size does NOT exist
on the final production target, then consider increasing the word size to
one that is supported.
Warning: The data type "uint8" uses a word size that is not available on the intended target.
.
Warning: The data type "boolean" uses a word size that is not available on the intended target.
.
### Generating TLC interface API for custom data
### Initial pass through model to cache user defined code
### Caching model source code
...............................................................................
...............................
### Writing source file c28069pmsmfocdual.c
### Writing header file c28069pmsmfocdual_private.h
### Writing header file c28069pmsmfocdual.h
.
### Writing header file c28069pmsmfocdual_types.h
### Writing header file rtwtypes.h
### Writing source file c28069pmsmfocdual_data.c
### Writing header file rtmodel.h
### Writing source file ert_main.c
.
### TLC code generation complete.
.### Evaluating PostCodeGenCommand specified in the model
### Using toolchain: Texas Instruments C2000 Code Generation Tools v5.2.12 | gmake (64-bit Windows)
### Creating 'C:\work\c28069pmsmfocdual\c28069pmsmfocdual_ert_rtw\c28069pmsmfocdual.mk' ...
### Using toolchain: Texas Instruments C2000 Code Generation Tools v5.2.12 | gmake (64-bit Windows)
### Creating 'C:\work\c28069pmsmfocdual\c28069pmsmfocdual_ert_rtw\c28069pmsmfocdual.mk' ...
### Building 'c28069pmsmfocdual': D:\ProgramFiles(x86)\matlab2015a\bin\win64\gmake -B -f c28069pmsmfocdual.mk all
C:\work\c28069pmsmfocdual\c28069pmsmfocdual_ert_rtw>cd .
There should be no \matlab2015a\bin\win64\gmake。
C:\work\c28069pmsmfocdual\c28069pmsmfocdual_ert_rtw>if ""=="" (D:\ProgramFiles(x86)\matlab2015a\bin\win64\gmake -B -f c28069pmsmfocdual.mk all) else (D:\ProgramFiles(x86)\matlab2015a\bin\win64\gmake -B -f c28069pmsmfocdual.mk )
Error(s) encountered while building model "c28069pmsmfocdual":
### Failed to generate all binary outputs.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have tried many methods, but they don't work.
Noticeably, if 'Generate code only' is selected, the error will not occur.
My software information are as follows: MATLAB 2015a, CCS 6.2.5, controlSUITE 3.4.7, Win10.
Would you help me solve this problem?
Thank you.

Antonin

Hi Shaomu,
You can scale the ADC counts to engineering units. if you do so you would have to find the right fixed-point format for the units and adjust that fixed-point format as you operate on the signals or switch to floating point which is less efficient. While per-unit sounds complicated at first sight, it makes things much simpler and more efficient. The same algorithm can work for multiple motors by adjusting the per unit scalers, fixed-point format can stay the same throughout the model. The ranges of intermediate calculation results rarely change as multiplying a signal that ranges from [-1 to 1] by another signal ranging from [-1 to 1] leads to a result ranging from [-1 to 1]. If you use engineering units, you will have to switch to floating point to avoid complicated fixed-point format conversions. It's feasible but you will reduce the performance and you may lose accuracy in the results while multiplying large quantities with small quantities. Best is to learn how to work with per-unit, which is what I'm showing in this example.
I hope it helps,
Antonin.

Antonin

Hi Adam,

c2808pmsmfoc_ert shows how to use our eQEP block to decode optical encoder signals. c2808pmsmsim is also available and provides a simulation model if you have a simscape licence.
While using an optical encoder, absolute position is unknown at startup until you pass the index pulse. The following page explains how to calibrate the index pulse with respect to the back EMF of the motor.
I hope it helps,
Thanks,
Antonin.

Shaomu Zhu

Hi Antonin,
If I understand correctly, the function of the subsystem “Input Scaling” is to convert the measured ADC currents to the per-unit value. What should I do if I want to use the real value rather than per-unit value of the measured ADC currents? Is it feasible to directly use the data from the outputs of the two ADC blocks for that purpose? I am looking forward to your insights!

Adam Dwyer

Hi Antonin,

I would like to replace the Sliding Mode Observer (SMO) and calculate both Theta and Speed from the outputs of a c2806x eQEP module to use in the Park and inverse Park transformations for PMSM Vector/Field Orientated Control (FOC) of a PMSM. I have been trying to do this for some time, but have not been able to get it working. Any assistance would be much appreciated. I am using the same hardware that was used in the c28069pmsmfocdual_ert.slx example.
MATLAB: 2018a Embedded Coder 7.0
IDE: TI Code Composer Studio 7.4.0, Control Suite 3.4.9
MCU: LaunchXl-F28069M
Inverter: BoostXL-DRV8301
Motor: Teknic M-2310P-LN-04K (LVSERVOMTR)

Regards,
Adam

Shaomu Zhu

Thanks Venkatesh!

I have another question. I would like to know why the data type has been set for fixdt(1,32,17). I have noticed that the blocks provided by TI library are designed for 32-bit signed fixed-point number. But why is it important to have a Q value of 17? Is there any reason for that?

Hi Shaomu Zhu,

This is a sink block, meaning it can take inputs from user which will be applied to the hardware and the results are available at the hardware output. That is how this block works right now. There is no simulation capabilities of the PWM output at this point. You can implement your own PWM generation in simulation but keep in mind that this will drastically slow down the simulation execution time and should be reserved for observations over a short period of physical time.

HTH,
Venkatesh C

Shaomu Zhu

Hi Antonin,

Thanks for replying!
I have another question regarding ePWM block. I notice that there is no output of this block. I would like to know if it is possible to read or display the output of this ePWM block in Simulink?

Antonin

Hi Shaomu Zhu,

1. We use normalized units throughout the model for voltage, speed, currents, etc. So, the space vector generator outputs voltages in the range of [-1 to 1]. This needs to be converted to a duty cycle in the range of [0% to 100%], with 0 mapping to 50% duty cycle. The PWM block expects a compare value in clock cycles in the range of [0 to PWM_Counter_Period] which will eventually provide [0 to 100%] duty cycle. So, the range out of the SVGenDQ is [-1 to 1], after adding 1 it becomes [0 to 2], and after multiplying by PWM_Counter_Period/2, it becomes [0 to PWM_Counter_Period] which will give me [0 to 100%] duty cycle, done.

2. The way you describe your switching logic makes me think that you are trying to replicate in software what the PWM module does in hardware. You may want to investigate more on the PWM module before going further in that direction as it may force you to decrease the sample time of the model to a value that may not be reasonable. Nonetheless, if you want to force the logic of the PWM, you can do so by setting the "Continuous software force logic" on the ePWMA and ePWMB tabs of the ePWM block's mask. The "Add continuous software force input port" allows you to grow an input port to the ePWM bocks and force the logic based on your algorithm.

I hope it helps,
Good luck,
Antonin.

Shaomu Zhu

Hi Antonin,

I have some questions regarding the subsystem "PWM Scaling".

1. The inputs of this subsystem are the duty cycles. Could you please tell me why we should add 1 to the duty cycle and then multiply half of the PWM counter period?

2. I have built a control system where the MOSFETs are driven directly through on/off signals. However, I found out that the block "ePWM" is based on duty cycle. Is it possible to control the MOSFET directly based on on/off signals with the "ePWM" block? Or do I need to use another block to realize this? To make it more clear, for a conventional SVPWM, after the duty cycles are calculated, we use triangle waveforms for comparison to generate the on/off signals for MOSFETs. Why is it decided to input the duty cycles to the "ePWM" block not the final on/off signals? Which configurations should be done if the inputs are on/off signals instead of duty cycles?

Thank you!

Antonin

Hi Konstantinos Giannouloudis,

Our dual motor control example for F28379D LaunchPad is shipping with version R2018a of MATLAB. You need to install that version of MATLAB to get access to it. Here is the help page.
https://www.mathworks.com/help/releases/R2018a/supportpkg/texasinstrumentsc2000/examples/permanent-magnet-synchronous-motor-field-oriented-control.html

In the link above, replace "2018a" with your version to see the difference, note that the F20379D version is only present with MATLAB R2018a.

We are actively looking into supporting functions that are part of the CLB on the latest TI devices, but we don't have support for BiSS-C as of now.

I hope it helps, good luck,
Thanks,

Antonin.

Hello Antonin,

Congrats on your splendid work! I'd like to ask you 2 questions:

1. I noticed that there is an implemented model for 2 motor control with f28379D:

2 BOOSTXL-DRV8305 + LAUNCHXL-F28379D C2000 LaunchPad: c28379Dpmsmfocdual_cpu1_ert.slx, c28379Dpmsmfocdual_cpu2_ert.slx

in the c2000 examples webpage but I cannot find them via Matlab help to open them. Are they still available? How can I access them?

2. Is there any possibility of the Launchpad to be able to read absolute encoders with BissC protocol? The processor seems to be able, but I cannot see such inputs on the launchpad or blocks in Simulink.

Thanks!

Regards
Kostas

The comment below from myself can be ignored. Problem was solved :)

Hi,
I have the 2mtr-dyno kit with f28379d Launchpad and boostxl-drv8305 packs. I am trying to get my motors spinning using the c28379Dpmsmfocdual_cpu1_ert (and cpu2) Simulink files. Is this file designed to run immediately and make the motor spin by simply programming onto the board?
My motor creates a humming sound, jitters in the beginning, vibrates, gets warm, and the power supply outputs current (.2A to ~5A depending on voltage supplied) - but the motor does not spin.
Some relevant information:
- I do not have the instrument control toolbox, so I replaced the serial-receive "desired speed" output with a uint16 constant (trying values from 0 to ~32k).
- Through testing in external mode (after changing SCI modules so it can run) I noticed that the ADC outputs are only 0, ~1200, ~1600, or 4096, but not any other values. As soon as any significant current is flowing, the value saturates at 4096. Is this abnormal? I've tested the ADC pins on a simpler Simulink model and they do work properly, showing any value between 0 and 4096.
- 2 of the inputs into the ePWM blocks are similar waves in terms of magnitude and frequency, but the ePWM2 input wave is different - should it be this way?
- Using an oscilloscope I can see there are PWM waves outputting from MOTA, MOTB, MOTC on the board.
- Power supply is rated 15V, 20A
Any tips?
Thank you for your help,
-Cody

Antonin

Hi Wannadear,

It looks like you have a space in one of the paths used for the download that the dss tool from CCS doesn't like. It comes from the E:\ drive and the path starts with E:\Program (could be E:\Program Files\...)
I recommend that you remove the space in that folder. Either reinstall some tools in a path without spaces or save your model in a path without spaces, this should fix the problem.

I want to fix this problem.
warning: build attribute vendor section TI missing in
"C:/ProgramData/MATLAB/SupportPackages/R2017a/toolbox/target/supportpackages
/tic2000/rtlib/IQmath_fpu32.lib<IQ17atan2PU.obj>": compatibility cannot be
determined
warning: build attribute vendor section TI missing in
"C:/ProgramData/MATLAB/SupportPackages/R2017a/toolbox/target/supportpackages
/tic2000/rtlib/IQmath_fpu32.lib<IQ17cosPU.obj>": compatibility cannot be
determined
warning: build attribute vendor section TI missing in
"C:/ProgramData/MATLAB/SupportPackages/R2017a/toolbox/target/supportpackages
/tic2000/rtlib/IQmath_fpu32.lib<IQ17sinPU.obj>": compatibility cannot be
determined
warning: build attribute vendor section TI missing in
"C:/ProgramData/MATLAB/SupportPackages/R2017a/toolbox/target/supportpackages
/tic2000/rtlib/IQmath_fpu32.lib<IQmathTables.obj>": compatibility cannot be
determined
"### Created: ../c28069pmsmfocdual.out"
"### Invoking postbuild tool "Hex Converter" on "../c28069pmsmfocdual.out"..."
C:/ti/ccsv7/tools/compiler/TI-CGT~1.6/bin/hex2000 -i "../c28069pmsmfocdual.out" -o "../c28069pmsmfocdual.hex" -order MS -romwidth 16 -q
"### Done Invoking postbuild tool "Hex Converter" ..."
"### Successfully generated all binary outputs."

C:\ti\ccsv7\tools\compiler\ti-cgt-c2000_6.4.6\c28069pmsmfocdual_ert_rtw>exit /B 0
Downloading program to the target hardware...
### Build procedure for model: 'c28069pmsmfocdual' aborted due to an error.
The following error occurred during deployment to your hardware board:

Debug Server Scripting (DSS) error: js: Couldn't open file "E:\Program".

How do I fix this problem?

Antonin

Hi Balaji,

With the sensorless algorithm, you can actually plug the 3 phases of the motor in any random combination, your motors will spin. If you don't like the spinning direction, swap 2 of the motor phases.
The phase order is important if you use position sensors, like we do in other examples provided with the Embedded Coder Support Package for Texas Instruments C2000 Processors.
Zooming on the video will show you how we plugged our motors using the provided connectors.
I hope it helps,
Thanks,

Antonin.

@ balaji blaze; I'd try using the given "Wiring adapter from Molex mini-fit to encoder header and phase wires" and then connect the colored wires to the booster packs, with black connected to C. White to B, and red to A.

Try at you're own risk. I feel that's how you would do it. I am using the same kit, however have different motors. So can't conclusively say man. Just my thoughts

Does anyone know how to connect those motors to drv8301?? Im using a f28069 launchpad and drv8301 boosterpack but i dont know how to connect motor to that booster pack...

Please help me with this.
Thanks in advance

Sorted....

Hi Antonin and/or team.

Good video, thanks for the lucture! Quick question: On the video, the phase offset value (TBPHS) seems to be zero, however, in the example code there is a phase delay of 2.5 usec for the second phase and 5 usec for the third phase. Why?

Thanks, Laurence

Hi,

I have the model working fine on 2 PMSM, i wanted to spin a motor that has hydrodynamic bearings. I have implemented a
1.lock & align
2. Open Loop frequency ramp
3. Closed Loop
function. The motor spins fine in open loop, but when i switch to the SMO Closed Loop, the pump stops. I have taken a graph of the angles generated by the open loop frequency ramp and the SMO and the angles are very similar after a short while. I am not sure why the motor stops and cant click from open to closed loop. Any ideas?

Thanks
Dan

Hi,

Please verify if the encoder output i.e Quadrature signals eQEPA & eQEPB are available and are 90deg out of phase.
Please note, the eQEP peripheral takes input the Quadrature signals eQEPA & eQEPB and generates the QPOSCNT among other options. Verify the correctness of these signals before feeding to Microcontroller and configure the eQEP properly. You may also consider contacting Mathworks Tech support with the model that is not working for you.

Hey Venkatesh, thank you for your reply, I have tried that eQEP but it doesn't display the position or the counter when I connect the scope or the display block to its output, however when I connect it to the gpio34 I can see the LEDs are turning on or off , i just need to view the waveform of the encoder on scope in simulink.

Hi,

Please refer the library blocks for c2000 and eQEP block under the respective controller.
When you add this block and double click, you have many configuration options.
By default the position counter is output from the block.

Regards,
Venkatesh C

Hi Antonin
I am trying to connect my encoder with the microcontroller and I would like to display the output of eQEPA and eQEPB ( rotor position and counter) on simulink, is there a special block does the job?

Hi Antonin,

Sorry again, after 2 days, it was my resistor size i was using between GND and the GPIO that was too high. Thanks for all the assistance

Thanks
Dan

Antonin

Hi Daniel,

I'm glad you could fix your sync issues. FYI we are using dead-bands in our motor control to prevent shoot-through, that could be in your way if you try to get perfect synchronizations of your signals.

If a fault triggers on the DRV8301 (or DRV8305), the only way to clear it is via SPI messages to the DRV8301/05 chip, or power cycle of the DRV chip. A reset of the main CPU (that you could do with our watchdog block) won't clear the fault on the DRV8301/05.
In section 7.6.2.4 of the following document, you have to set bit 1 of register "IC Operation" (0x9) via an SPI command to clear the faults.
http://www.ti.com/lit/pdf/SLVSCX2

You can use our SPI Transmit block to do so. On the F28069M Launchpad, you have to use SPIA for the top booster pack slot and SPIB for the bottom one.

For SPIA, the SIMO, SOMI, CLK and STE pins have to set to GPIO 16, 17, 18 and 19 respectively in the configurations parameters (default).

For SPIB, the SIMO, SOMI, CLK and STE pins have to set to GPIO 24, 25, 14 and 27 respectively.

Section 7.5 of the SLVSCX2 doc explains the value that you need to pass via SPI.
Just pass a uint16 constant value to the SPI transmit, the value should be 0x6822 (write to register 0x9 with value 0x22).
Only do that when you are sure that you want to reset the fault.
You can use a triggered subsystem to only launch the SPI transmit when needed.
You can also use the SPI read to get more information from the DRV chip like, like the nature of the fault for example.
I know it sounds a little complicated, but it's actually pretty easy.
I hope it helps,

Good luck

Antonin.

Hi Antonin,

I have the PWM Phases of motor 1 and 2 exactly 180 degrees out of phase, I had some settings wrong in the sync configurations. I guess my only question is now about resetting the device if a fault it triggered. Do you have any advice on that?

Thanks Dan

Hi Antonin,

I have a few queries regarding the F28069M programmed in Simulink with two booster DRV8301. I am trying to run two PWM outputs 180 degrees out of phase from each other. I have set the second set of ePWM of 1,2,3 to be an inverted version of ePWMxA. When connecting the physical Phase A of each driver I get an almost 180 degree phase shift of signals. But when i zoom in on the DSO there is an exact 2us delay on the 1st Phase A. Im not sure how to eliminate this? can you provide some advice, do i need to disable the Protection Switching Characteristics?

Also have a question regarding how to reset the device via Simulink block, if the Fault protection has been tripped and the LED is on. I'm not sure how to reset the device when this happens? Is it as simple as disabling and re-enabling the GPIO 52 or GPIO 50 depending which one failed?

Hope you can help me. i can send you my modified .slx if that would help

Thanks

Dan

Hi Antonin,

I inverted the PWM for the second motor driver and when i scope it in Simulink, the PWM signals are perfectly 180 degrees out of phase. However, when i connect the PWM of the physical driver to a DSO, the PWM signals are still in phase with each other. Am i missing something, or should i be using the ePWM block settings to set the phase to be 180 degrees, rather than inverting the Ta/Tb/Tc signals prior to the PWM scaling.

Thanks
Dan

Hi Antonnin,

I'm working with model F28069M and 2 DRV8301, and when I try to compile the program in Simulink I get an error in the size of the matrices. The textual error is as follows:

--------------------------------------------------------------------

Error encountered while executing PostCodeGenCommand for model 'c28069pmsmfocdual': Index exceeds matrix dimensions.

Caused by:
Index exceeds matrix dimensions.

--------------------------------------------------------------------------

What do you think the problem is? Do I need to make any modifications?

That you recommend to me to include more since my project consists of controlling 3 motors maxon EC motor 397172 without brushes, connected in turn to sensors of effect hall for a exoskeleton of rehabilitation of wrist.

Thanks,
Nathaly

Hi Antonin,

Seems my first message didnt come through. I am running a pump that has two stators and one rotor, where the stators are 180 degrees out of phase from each other (one is a hot redundant). So i guess the PWM frequency needs to be 180 degrees out of phases. But i think i can run it as one motor with no need to have an 2nd ADC but have an inverse gain block on the PWM signals and route them to the second lot of PWM for the 2nd stator.

Do you think that will work?

Thanks
Dan

Hi Antonin,

I guess I dont need to sample the ADC of the second "motor" and i can just run 3 inverse gain blocks out of the PWM and output that to the second stator?

Thanks
Daniel

Antonin

Hi Daniel,

Are you talking about mechanical degrees? Electrical degrees? or out of phase with respect to PWM frequency?
In other words, do you want the shaft of the first motor to be 180 degrees out of phase from the shaft of the second motor? If this is the case, you have to do position control. You need to add a control loop on top of the current control loop similar to what we do with the speed control loop but based on position. That would make a good example.
What I explain in this video is how to de-phase the PWM signals so processing for the first motor and the second motor happen sequentially, it won't have an impact on the position of the shafts of the 2 motors.
I hope that answers your question, let me know otherwise.
Thanks,

Antonin.

Hi Antonin,

I have your dual example running very well for one motor on the F28069M and BoostXL-DRV8301. I want to try and run two motors exactly 180 deg out of phase. I have looked at the ePWM settings and they are a little confusing. I was wondering if you have advice on having both motors running with 180 deg phase shift between them. I have made many changes to the example to receive motor variables, speed variables and Ki, Kp and Kd variables. But I am stuck on the two motors out of phase and running correctly.

Thank you,
Dan

Antonin

Hi Sowmya,

CCSv7 can be used instead of CCSv6 (or v5), but you have to pretend that you are using CCSv6.
Run:
>> targetupdater
While prompted, select that you are using CCSv6, but point to the compiler that is installed in your CCSv7 folder or a compiler that is installed outside CCS, in this case, the tool will ask you the CCS path, point to CCSv7.
While creating models, in the configuration parameters, after selecting the right processor under Hardware Implementation, select CCSv6 under code generation, our tools will use CCSv7 for loading.
Note that we only use CCS for loading the compiled code onto the processor and for project generation in R2017a. Given this very limited dependency, the CCS version doesn't make much of a difference from a Simulink point of view.
QEP and CAN blocks can be used in this model.
I hope it helps,
Antonin.

Continuing from my previous ques,
I'd like to have QEP blocks as well as CAN blocks. Can these be added to the model ?

Hi Antonin,

I currently have a CCSV7 installed on my system. Would this demo still work?

Adam Dwyer

Hi Antonin,

Thank you for your exceptional reply. I really appreciate the time and effort you put into answering my question.

Best regards,

Adam

Antonin

Hi Adam,

Our support package supports all F28069 devices, you have to pick the correct linker command file to accommodate for the memory differences between the F28069, F28069M and F28069F devices.
I explain how to pick the correct linker for the F28069M device at t=6m00s (https://youtu.be/ncM7N-hLKQM?t=6m00s) in the above video.
We are using the LAUNCHXL-F28069M Launchpad, as far as I know, there is no LAUNCHXL-F28069.
I confirm that there are no memory issues if you pick the right linker command file.
We also have a shipping example spinning a motor on the F28069 which is available as a controlCARD (http://www.ti.com/tool/tmdscncd28069iso) if you are interested in this device. This controlCARD can be plugged on the DRV8312 kit, and the shipping example model "c28069pmsmfoc_ert.slx" listed on the following page supports that hardware setup.
http://www.mathworks.com/help/supportpkg/texasinstrumentsc2000/examples/permanent-magnet-synchronous-motor-field-oriented-control.html

I hope it helps,

Thanks,

Antonin.

Adam Dwyer

Hi Antonin,
Can you please confirm that you used a LAUNCHXL-F28069? This would be a launchpad F28069 without InstaSPIN-MOTION which I cannot find listed with TI.

I am interested in F28069 MCU as there appear to be memory issues when using the F28069M MCU with Matlab.

Best regards,

Adam

Antonin

Hi Diego,

Sorry for the late reply.
1) I added the +1 to make sure that we would avoid having a situation where CMPA = PRD for PWM as it creates special scenarios for the matching events on the way up and on the way down of the counter. I agree with you that it adds to the desired period and therefore is not ideal. I should revisit this to see if there is a better solution.
2) You are right, I corrected that mistake after I took the video and didn't update the video. I just added a document to the zip file that has the corrected picture. Thanks for notifying this problem, let me know if you find more

I hope it helps,

Antonin.

Diego

Hi Antonin,

thank you for this example, very useful for my needs.

I have two questions:

1) Why did you set in the ePWM Timer period field the PWM_Counter_Period+1 value? The f28069 reference manual says (pag. 252) that for up-down count Tpwm=2*TBPRD*Ttbclk, while for up or down count Tpwm=(TBPRD+1)*Ttbclk, so it seems that +1 is needed only in the latter two cases.

2) In the time diagram you show at minute 11:00, is the pwm 4/5/6 signal wrong? Because seems that pwm 1/2/3 is active high and pwm 4/5/6 also, but the latter three are shown as active low.

Xin Wang

T D

Has anyone managed to use BOOST-DRV8711 and F28069m launchpad to individually control H-bridges?

Paul

nice work

Simon Schad

Hi there Antonin and/or members of the C2000_expert team

I'd tried to run a testprogram on my TI Launchpad F28069M, but I have a Problem with the checkEnvSetup function. Point 1 to 3 are correct but at 4 and 5 I can't do any adjustments. How can i achieve the right placements?

>> checkEnvSetup ('ccsv5','f28069','setup')

1. Checking CCSv5 (Code Composer Studio) version
Required version: 5.0 or later
Required for : Code Generation
Your Version : 5.5.0
### Setting environment variable "TI_DIR" to "C:\ti\ccsv5"

2. Checking CGT (Texas Instruments C2000 Code Generation Tools) version
Required version: 5.2.1 to 6.0.2
Required for : Code generation
Your Version : 6.0.1
### Setting environment variable "C2000_CGT_INSTALLDIR" to "C:\ti\ccsv5\ccsv4\tools\compiler\c2000"

3. Checking DSP/BIOS (Real Time Operating System) version
Required version: 5.33.05 to 5.41.11.38
Required for : Code generation
Your Version : 5.41.11.38
### Setting environment variable "CCSV5_DSPBIOS_INSTALLDIR" to "C:\ti\bios_5_41_11_38"

4. Checking XDC Tools (eXpress DSP Components) version
Required version: 3.16.02.32 or later
Required for : Code generation
Your Version : NOT FOUND
The required version of XDC Tools is not found in $(XDCROOT)

5. Checking CCS (Code Composer Studio) version
Required version: 4
Required for : Automation and Code Generation
Your Version : NOT FOUND
The required version of CCS is not found in C:\ti\ccsv5\\cc\bin

6. Checking 2806x C/C++ Header Files version
Required version: 1.20
Required for : Code generation
Your Version : 1.20
### Setting environment variable "DSP2806x_INSTALLDIR" to "C:\ti\controlSUITE\device_support\f2806x\v120"

7. Checking Flash Tools (TMS320F2806x Piccolo(TM) Flash API) version
Required version: 1.00
Required for : Flash Programming
Your Version : 1.00
### Setting environment variable "FLASH_2806X_API_INSTALLDIR" to "C:\ti\controlSUITE\libs\utilities\flash_api\2806x\v100"

MW_c28xx_board.c", line 1: fatal error: cannot open source file "F2806x_Device.h"
1 catastrophic error detected in the compilation of "MW_c28xx_board.c".
Compilation terminated.

>> Compilation failure
gmake: *** [MW_c28xx_board.obj] Error 1

C:\Users\Apte\Desktop\Launchpad_Motor_Control\c28069pmsmfocdual_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2
Hello Antonin
I am getting this error while building PMSMFOC example for dual motor control using TI F28069M
C:\Users\Apte\Desktop\Launchpad_Motor_Control\c28069pmsmfocdual_ert_rtw>An_error_occurred_during_the_call_to_make
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.

Hi there Antonin and/or members of the C2000_expert team

I am using the TI Launchpad F28069M and a BOOSTXL-DRV8301 RevB to try and implement sensoreless dual motor control.

I have setup all files correctly between Matlab and CCSv5 and can easily program from Simulink to the target board without problems, and I confirmed this by changing the blinking LED frequency whilst confirming on the target board itself.

I have watched both videos on YouTube concerning the Simulink models for the F28027 Launchpad (single motor control) as well as the video for the dual motor control on the F28069M Launchpad board.

I have the following BLDC/PMSM:

1. Pole pairs: 11 (22poles/2)
2. Rs = 15ohm (phase to phase or 7.5ohm per coil)
3. Ls = 5mH (phase to phase or 2.5mH per coil)
4. Ke = 35v/Krpm (Voltage constant, measured as peak voltage, not RMS)
5. Kt = 0.23 N.m/Amp (Torque constant)
6. Max_motor_rpm = +- 500RPM (calculated from Ke and confirmed experimentally with other 3-phase driver)
7. Max expected current = +- 1.1A (dependent on modulation method I presume)
7. DC_bus_supply = 18.4Vdc

I am having trouble setting up all the variables in Matlab for the c28069pmsmfocdual model. I am not sure that I am entering all the variables correctly. When I program the code to the target, the motor stays stationary, in other words it locks rotor position with a constant few hundred mA of current being supplied by the DC source.

I have entered the following for the variables:

% Processor Frequency
CPU_frequency = 90e6; %(Hz)

1..............................
% PMS Motor Pole Pairs
Pole_pairs = 11;
motor.rs = 7.5; % Stator resistance (ohm)
motor.rr = 0; % Rotor resistance (ohm)
motor.ls = 0.0025; % Stator inductance (H)
motor.lr = 0; % Rotor inductance (H)
motor.lm = 0; % Magnetizing inductance (H)
motor.base_voltage = 11; % Base peak phase voltage (volt), maximum measurable DC Bus(18.4V)/sqrt(3)
motor.base_current = 1.1; % Base peak phase current (amp) , maximum measurable peak current

2.....................................
motor.base_freq = 20; % Base electrical frequency (Hz)

3....................
% PWM Settings
PWM_frequency = 20e3; %(Hz)
PWM_Counter_Period = CPU_frequency/PWM_frequency/2; %(PWM timer counts)

4...................
% Speed Scalers
Speed_rpm_scaler = 60*CPU_frequency/Pole_pairs/2; %(Speed_rpm_scaler/number of speed counts = RPM)
Speed_per_unit_scaler = 200; %(+/-600rpm <=> +/-1 in Q format)
Max_ideal_measurable_speed = 200;
Speed_loop_delay = floor(60*PWM_frequency/Pole_pairs/2/Max_ideal_measurable_speed);
Max_measurable_speed = 60*PWM_frequency/Pole_pairs/2/Speed_loop_delay;
Speed_loop_to_PU_scaler = Max_measurable_speed/Speed_per_unit_scaler;

5....................
% Hall Sensors Offset
Hall_position_offset = 0.57; %(per unit format: 1 <=> one electrical revolution)

6................................
SMO_params.Fsmopos = exp(-motor.rs/motor.ls/PWM_frequency);
SMO_params.Gsmopos = motor.base_voltage/motor.base_current/motor.rs*(1-SMO_params.Fsmopos);
SMO_params.Kslide = 0.15; %0.15; % Sliding control gain
SMO_params.Kslf = 0.1; % Sliding control filter gain
SMO_params.E0 = 0.5;

The variables that are listed under section "1" I "believe" to have setup correctly? The rest of the variables I am not sure of...

Could you explain the variables to me and how I might go about determining the correct values for my specific motor?

Thank you for your time in building this simulink model, makes integration between CCS and embedded coder in Simulink a breeze!

Hello Serkan Karadag,

From the error message it looks like you have not completed the installation steps successfully. Please run the targetupdater in the MATLAB command window and select the tool paths for the version of CCS you have installed.
Hope it helps.
Sumith

Hello Antonin i have some problems:

I got these problems in my diagnostiv viewer:

### Generating code into build folder: C:\Users\Karadag\Desktop\HIWI-Tätigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw
### Invoking Target Language Compiler on c28069pmsmfocdual.rtw
### Using System Target File: C:\Program Files\MATLAB\R2015a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
Warning: The data type "int8" uses a word size that is not available on the intended target.
Fixed-point signals using this data type will be put inside a larger word or multi words. When used,
extra software will be generated to force this larger word or multi words to emulate a smaller
word. This emulation is helpful when your prototype target and your final
production target are not the same. If the smaller word size does NOT exist
on the final production target, then consider increasing the word size to
one that is supported.
Warning: The data type "uint8" uses a word size that is not available on the intended target.
.
Warning: The data type "boolean" uses a word size that is not available on the intended target.
.
### Generating TLC interface API for custom data
### Initial pass through model to cache user defined code
### Caching model source code
...............................................................................
...............................
### Writing source file c28069pmsmfocdual.c
### Writing header file c28069pmsmfocdual_private.h
### Writing header file c28069pmsmfocdual.h
### Writing header file c28069pmsmfocdual_types.h
.
### Writing header file rtwtypes.h
### Writing source file c28069pmsmfocdual_data.c
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete.
### Creating project marker file: rtw_proj.tmw
..### Evaluating PostCodeGenCommand specified in the model
### Using toolchain: Texas Instruments C2000 Code Generation Tools v5.2.12 | gmake (64-bit Windows)
### Creating 'C:\Users\Karadag\Desktop\HIWI-Tätigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw\c28069pmsmfocdual.mk' ...
### Using toolchain: Texas Instruments C2000 Code Generation Tools v5.2.12 | gmake (64-bit Windows)
### Creating 'C:\Users\Karadag\Desktop\HIWI-Tätigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw\c28069pmsmfocdual.mk' ...
### Building 'c28069pmsmfocdual': C:\PROGRA~1\MATLAB\R2015a\bin\win64\gmake -B -f c28069pmsmfocdual.mk all
C:\Users\Karadag\Desktop\HIWI-T„tigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw>cd .

C:\Users\Karadag\Desktop\HIWI-T„tigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw>if "" == "" (C:\PROGRA~1\MATLAB\R2015a\bin\win64\gmake -B -f c28069pmsmfocdual.mk all ) else (C:\PROGRA~1\MATLAB\R2015a\bin\win64\gmake -B -f c28069pmsmfocdual.mk )
/bin/cl2000 --compile_only --large_memory_model --cla_support=cla0 --silicon_version=28 --define="LARGE_MODEL" -i"/~SupportFiles/DSP280x_headers" -i"/~SupportFiles/DSP280x_headers/include" -i"/include" -v28 -ml --float_support=fpu32 -DMODEL=c28069pmsmfocdual -DNUMST=3 -DNCSTATES=0 -DHAVESTDIO -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DRT -DSTACK_SIZE=1024 -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DRT -DSTACK_SIZE=1024 -DMODEL=c28069pmsmfocdual -DNUMST=3 -DNCSTATES=0 -DHAVESTDIO -IC:/Users/Karadag/Desktop/HIWI-Tätigkeit/02_Matlab_Beispiel2/c28069pmsmfocdual_ert_rtw -IC:/Users/Karadag/Desktop/HIWI-Tätigkeit/02_Matlab_Beispiel2 -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -IC:/MATLAB/SupportPackages/R2015a/texasinstrumentsc2000/toolbox/target/supportpackages/tic2000/src -IC:/PROGRA~1/MATLAB/R2015a/toolbox/target/extensions/processor/tic2000/include -IC:/PROGRA~1/MATLAB/R2015a/toolbox/rtw/targets/common/can/blocks/tlc_c -IC:/MATLAB/SupportPackages/R2015a/texasinstrumentsc2000/toolbox/target/supportpackages/tic2000/inc -I/F2806x_common/include -I/F2806x_headers/include -IC:/PROGRA~1/MATLAB/R2015a/toolbox/shared/can/src/scanutil --output_file="MW_c28xx_board.obj" "C:/Users/Karadag/Desktop/HIWI-Tätigkeit/02_Matlab_Beispiel2/c28069pmsmfocdual_ert_rtw/MW_c28xx_board.c"
Das System kann den angegebenen Pfad nicht finden.
gmake: *** [MW_c28xx_board.obj] Error 1

C:\Users\Karadag\Desktop\HIWI-T„tigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2

C:\Users\Karadag\Desktop\HIWI-T„tigkeit\02_Matlab_Beispiel2\c28069pmsmfocdual_ert_rtw>An_error_occurred_during_the_call_to_make
Der Befehl "An_error_occurred_during_the_call_to_make" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

Can you help please?

Hello Antonin,
I would to ask you for a help with my problems regarding the compilation of the simulink scheme. It always ends up with saying this: Debug Assertion Failed!
Program: C:\ti\ccsv5\tools\compiler\c2000_1\bin\cI2000.exe
File:isctype.c
Line:56

Expression: (unsigned)(c+1)<=256

And then there is the diagnostic viewer, which is always telling me the same:
INTERNAL ERROR: C:/ti/ccsv5/tools/compiler/c2000_1/bin/cl2000 aborted while
processing file C:/ti/c28069pmsmfocdual/c28069pmsmfocdual_ert_rtw/MW_c28xx_board.c

This is a serious problem. Please contact Customer
Support with this message and a copy of the input file
and help us to continue to make the tools more robust.

gmake: *** [MW_c28xx_board.obj] Error 2

I am pretty sure, that I have gone through all the installation and validation steps correctly, but I simply can´t solve this great obstacle. Could you please help me? Thank you very much for the answer.
Martin
PS: I´m using MATLAB R2015a

Antonin

Dear Myroslav Shysh,

Yes, it is possible to control and monitor multiple launchpads at the same time.
You would have to program them one by one. Once this is done, you can plug all of them together. Each of them should give you a different COM port, which you can use to communicate to the respective board.
This would be using serial communications (over USB). The FTDI chips on the launchpads allow the baudrate to work at 5.625Mbps on the F28069, and 3.75Mbps on the F28027.
At these rates, you can send and visualize signals updated at 20kHz. You can use the method described in the following link:

http://in.mathworks.com/matlabcentral/fileexchange/45124-motor-control-with-ti-launchpad

The catch is that the host model can only afford a refresh rate of ~30ms. To be able to visualize data @20kHz, read 600 values at once on the serial receive block of the host model with a sample time of 30ms. Treat this vector as a frame to tell Simulink that these values came sequentially and display the frame on a scope. This allows you to visualize data changing @20kHz over serial via the USB cable plugged to your board. I will publish an example once I find the time as I realize this is a little tricky. In the meantime feel free to send an email to c2000_expert@mathworks.com, I can send models showing the trick.
I hope it helps,
Antonin.

Hi Antonin!
I have few questions:

1. Is it possible to control and monitore more than one TI F28069 or F28027 LaunchPad connected to PC from MATLAB/Simulink(for example: to control 4 or 6 drives)?
2. Which communication will be used in this case?
3. Is it possible to update and send desired values(velocity/position/etc) directly from Simulink in "Real-Time"?

hassan raza

nice example

Updates

1.3.0.0

Fixed a factor of 2 error in the speed calculation

1.2.0.0

Updated the description with hardware part numbers and links to vendor pages

1.2.0.0

converted the PWM diagram to pdf

1.2.0.0

Added the video link to the description.

1.1.0.0

Switching to MLL as this example could be used later as a shipping example

MATLAB Release Compatibility
Created with R2014b
Compatible with R2014b to any release
Platform Compatibility
Windows macOS Linux
Communities

c28069pmsmfocdual