In general i would avoid uploading pre-build images since might be dangerous for some purpose. Some might try to upload the elf directly and expect to work out-of-the-box for their particular setup. Hence, these models are not intended for application purpose but rather for learning how to design in Simulink using different concepts. The fact that we target the motor control is just a coincidence.
Anyhow, please find attached the generated code for this lecture.
Hope it helps!
Very good lectures first of all. Good job!
I was trying lecture number 10 and I found my actual speed (measured using a tachometer) to be different from the displayed speed. could it be due to the number of poles? My motor has 4 poles. How can I fix this?
The motor used in the lecture has 2 pole pairs. So if your motor has 4 poles (N-S-N-S) which meas 2 pole pairs the speed should be identical.
Now, the speed Omega = 60*electrical_frequency/number_of_pole_pair so depending on your readout we may conclude what is the actual number of pole pairs of your motor.
Can you attach here the data sheet of your motor and your tachometer ?
I have retested MPC5744P example application which is available in the FreeMASTER Communication Driverlocated here: c:\NXP\FreeMASTER_Serial_Communication_Driver_V2.0\examples\SCI_driver_examples\MPC57xx\MPC574xP_EVB. The example project works correctly with "Kvaser Leaf Light" interface on 500kbs.
The MPC574xP_EVB project is created in S32 Design Studio for Power and by default is prepared for communication over UART, so the only thing what needs to be configured is communication channel to CAN in the freemaster_cfg.h file:
I am having trouble communicating to with the FreeMaster using CAN. I have a KVASER LEAF LIGHT V2 which is supposed to be compatible. Can anyone help with any troubleshooting steps please
Do you have a CAN bus termination 120 Ohms ?
Have your scanned to CAN for different bit rates. Please note that there is a difference between the speed set in the model and the one from FreeMASTER: https://community.nxp.com/message/992547?commentID=992547&et=watches.email.thread#comment-965260
Thank you for the reply. I have soldered the resistor for termination and have tried different baud combinations. I get the errors, ''No data received'' and ''Can not set CAN/LIN channel bitrate.
Since you have set the Simulink model to 500kB bit rate then the FreeMASTER should work with 1Mb assuming you are using the small development board as i did in the video.
The CAN interface looks like this:
Assuming the CAN HI/LO are connected correctly, have you powered the board with 12V by making the appropriate settings on the board? https://www.nxp.com/docs/en/supporting-information/DEVKIT-MPC5744P-QSG.pdf
If everything is fine up to this point, then perhaps we should check if the boards transmits something over the CAN. You can load the CAN demo: can_model_pnt.mdl and check with a CAN sniffer if you receive anything over the CAN with your adapter.
Hope this helps!
I have tried another thing. Without plugging in the controller and without loading any elf file I just plugged in my CAN adapter and tested connection on FreeMaster. It detects the CAN adapter and the driver but gives error ''Could not open the communication port''.
In the release notes and change.txt of the FreeMASTER 22.214.171.124 Jan 2 2018 it is stated that KVASER CAN Devices are supported, hence the customer can't initiate a connection between MPC5744P and FreeMASTER.
The MCP5744 CAN works because has been tested with a simple CAN application and the messages are received correctly by a can sniffer, but the FreeMASTER can't seems to be able to connect.
Do you know to tested the support and if there is any embedded application that can be used to verify the setup? A simple application that allows FreeMASTER to communicate with.
Thank you so much for the help and quick replies. I really appreciate it.
I could not get the freemaster to work with the lecture 10 files despite all the help so I went ahead to lecture 13. I have realised that the freemaster works on CAN as long as I use MOT and ELF file which is given by you. If I rebuild the code on my computer and use the updated MOT and ELF files, it stops working. I have made sure that I am using the correct paths but I have had no luck with it.
Are you sure you have this patch applied https://community.nxp.com/thread/451804#comment-916493 and S32DS for Power Architecture 1.2 GCC compiler ?
The only scenario plausible at this point is that one you compile the code with a newer compiler the application stops working properly.
Lets make it easier. please sent me your Simulink Model (to have your settings) and the Generated Folder after your press the Build button. I'll check it against mine for the differences.
I have now tested the can_model_pnt.mdl using a can sniffer and I can see messages coming from the board. However, connection with FreeMaster is still not working.
I noticed in the MPC5744P config block, you set the FreeMASTER CAN bus speed is set to 500K, but in FreeMASTER, you have it set to 1M. I confirmed that this is the same on my setup (FreeMASTER can't connect if you set the speed to 500K). Also, if I set the config block to 1M, FreeMASTER doesn't connect even if set to 1M. Is this a bug with the model config block?
Good catch jjacp
There is an issue with the toolbox. The same same toolbox supports 2 type of MPC5744P development boards. Between these 2 boards the CAN tranceiver is different - and we found that after the toolbox release. The idea is that the same timings set for MCU cause different CAN baud rates on the boards. In particual for the small MPC5744P DevKit the baud rate is going to double. That is why the model has the 500K and the FreeMASTER is set to 1M.
We choose to let it that way, assuming that customers will create their own designs with the MCU and will handle correctly the CAN tranceiver circuits. In that case you should get the same CAN baud rate as the one set in the MCU.
The alternative would be to have the toolbox to support different board characteristics. This is something we are thinking about too.
Hope this clarify your concerns.