VESC and Simulink in windows

General topics and discussions about the VESC and its development.
Posts: 85
Joined: 10 Aug 2016, 16:14

Re: VESC and Simulink in windows

Postby michael_wintergarden » 21 Dec 2016, 03:00


I think I don't really understand you. Maybe I'm wrong, I don't know.
I dont want to embarras you, but to make sure to understand I just want to explain something (I don't know if I'm right):

Wether you use external mode in matlab or not, you always have to generate C-code from your simulink model and upload it to your hardware (simulink is usually doing this automatically if you hit "Build Model").

This means, if you are creating a control-loop in Simulink, you always have to generate C-code of the loop and upload it to your hardware via bootloader (Simulink is doing this for you).
This means, your hardware can also run stand-alone after you uploaded the Simulink-generated C-code.

If you want to see how your control-loop performs, you can run Simulink in "External Mode" this means, you need to connect the USB to your Computer, Upload the Code to the hardware via Simulink and klick "Run" in order to start the code. Now you can see your actuall values etc. inside the Simulink model.
In order to update those values, you need to be in contact with your hardware via usb and this brings a (huge) time-delay with it. But the actual control loop is still running on your hardware and not on Simulink, am I right or wrong with that?

My question: If you run VESC in External Mode (VESC connected to Simulink), will the Control-loop also run slower? I mean the actual control loop is running on the hardware and not inside Simulink, right? Where does it say that it just runs with 0.005 second per cycle?

Here is more about Simulink and External Mode: ... -mode.html
There are also some youtube-videos about Simulink and Hardware, e.g.:

Posts: 47
Joined: 18 Jul 2016, 11:26
Location: Germany

Re: VESC and Simulink in windows

Postby yosoufe » 21 Dec 2016, 21:20

What i did here is defferent from what you are describing.

Here the control loop is executed on pc and simulink (if you implement any on simulink).

This block only communicates with the VESC according to usage. You should not use the build button. You should not run the simulation in external mode.

This is a very simple implementation of the UART communication (which benjamin has a tutorial on it) on simulink. Nothing more.

This can be seen as a debugging tab of the bldc tool software, but implemented in simulink.

There is no C code generation and upload to the vesc here. PC sends one of the setter comands (speed, current or...) then sends the get_values command and it receives the values and shows them on output. All these communication is via usb, or serial (UART). There is also another s-function inside, which slows down the execution as close as to the real-time.

There is no need of program upload to VESC here. I hope now it is more clear.

Posts: 47
Joined: 18 Jul 2016, 11:26
Location: Germany

Re: VESC and Simulink in windows

Postby yosoufe » 02 Jan 2018, 15:58

I just made it with more outputs. the same block. has anybody used it at all? I would be grateful for a feedback
(114.26 KiB) Downloaded 56 times

Return to “General”

Who is online

Users browsing this forum: No registered users and 4 guests