Page 2 of 2

Re: VESC and Simulink in windows

Posted: 21 Dec 2016, 03:00
by michael_wintergarden
Hi,

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: https://se.mathworks.com/help/supportpk ... -mode.html
There are also some youtube-videos about Simulink and Hardware, e.g.: https://www.youtube.com/watch?v=QrteM1J4s2A

Re: VESC and Simulink in windows

Posted: 21 Dec 2016, 21:20
by yosoufe
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.

Re: VESC and Simulink in windows

Posted: 02 Jan 2018, 15:58
by yosoufe
I just made it with more outputs. the same block. has anybody used it at all? I would be grateful for a feedback