VESC and Simulink in windows

General topics and discussions about the VESC and its development.
michael_wintergarden
Posts: 85
Joined: 10 Aug 2016, 16:14
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby michael_wintergarden » 21 Dec 2016, 03:00

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

yosoufe
Posts: 50
Joined: 18 Jul 2016, 11:26
Location: USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

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.

yosoufe
Posts: 50
Joined: 18 Jul 2016, 11:26
Location: USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

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
Attachments
library.zip
(114.26 KiB) Downloaded 101 times

robertoquintal
Posts: 4
Joined: 08 Oct 2018, 12:27
Location: Poland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby robertoquintal » 08 Oct 2018, 12:44

Hello Yosoufe,

nice S-Function, thanks a lot, although I have an issue with the values. I am using the VESC tool 0.87 to program my VESC and when I use your S-Funtion some of the values are not communicating correctly (see the attached screenshot)
For example the speed is "scaled" because I input a triangular signal from 3000 to 6000 erpm and I read very big values
And no battery voltage reading.

Thank you in advance for your help

Best Regards
Image

yosoufe
Posts: 50
Joined: 18 Jul 2016, 11:26
Location: USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby yosoufe » 08 Oct 2018, 16:36


robertoquintal
Posts: 4
Joined: 08 Oct 2018, 12:27
Location: Poland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby robertoquintal » 09 Oct 2018, 15:56

Hello again Yosoufe,

thanks for the reply,
so I was checking the UART protocol of the firmware the VESC Tool 0.87 installed to my VESC: Firmware Version 3.34, Hardware: 410
And I noticed in the Github that there are some differences since 2016, still I wonder if I found the correct order of packets because I don't seem to find the rpm which some how appeared (uncorrectly displayed) in my last post.
The Github code I am referring to is: https://github.com/vedderb/bldc/blob/43 ... nds.c#L164

And this is the part I think is associated to the structure, side to side with the BLDC_uart.cpp your S-Function uses:
Image

yosoufe
Posts: 50
Joined: 18 Jul 2016, 11:26
Location: USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby yosoufe » 09 Oct 2018, 16:09


robertoquintal
Posts: 4
Joined: 08 Oct 2018, 12:27
Location: Poland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby robertoquintal » 10 Oct 2018, 10:43


yosoufe
Posts: 50
Joined: 18 Jul 2016, 11:26
Location: USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby yosoufe » 10 Oct 2018, 13:04


robertoquintal
Posts: 4
Joined: 08 Oct 2018, 12:27
Location: Poland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Re: VESC and Simulink in windows

Postby robertoquintal » 11 Oct 2018, 12:31

Thank you Yosoufe,

I figured the changes out. Here I attach my version of the S-Function already working for the VESC Tool and Firmware 3.34
Image
Attachments
Simu_VESC_Firmware_3_34.zip
(344.43 KiB) Downloaded 36 times


[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests