Go Down

Topic: Developing a MATLAB/Simulink project with ARDUINO Mega2560 (Read 2075 times) previous topic - next topic

jack1994

Hello everyone! I am a Mechatronics engineering student and I'm new in the forum so I hope the section will be the correct one for this topic. Anyway, just to briefly introduce myself, my knowledge about Arduino platform is very poor but I would learn quickly, because it seems a very good solution for lots of ideas.

The project: I'm working on Artificial Neural Networks (ANN) applied to SOC estimation in battery packs and, after having developed and tested the project by means of MATLAB/Simulink softwares with good results, it is requested to me to perform the simulations (already completed in Simulink) with the help of an ARDUINO Mega 2560.
 
I have already installed the packages (both for MATLAB and for Simulink) to directly interface MATLAB and Simulink with my ARDUINO board.

In very few words: I have to send from MATLAB workspace to ARDUINO two dataset timeseries (which are the input of my neural network, generated by myself separately), then I have to process these timeseries with a Simulink-generated block (that simulates the Neural Network, created by the function 'gensim'), and finally I have to save as a plot (or similarly a vector of datapoint) the output of my Neural Network, that is obviously the estimated data for the SOC (State of Charge).
All the parameters have to be sampled at 0.1s and the simulation has to last about 1000s, but I can arbitrarly choose it.

Is it possible to process this kind of project serially? Any hint to develop it?

I have thought to program ARDUINO board in some way to implement the Neural Network Simulink block and then, when I send the timeseries to Arduino, it returns me the estimated output. Or is there any more convenient solution, like a "model-based" programming directly by means of Simulink?

Sorry if they are silly questions but I'm really new to Arduino and with the whole Informatic-world :smiley-roll-sweat: .
Thanks everyone for your help.  :)
 

jremington

The Arduino is generally used for sensing the environment and controlling simple devices.

Which of those tasks would it be doing in your project?

horace

in similar projects I would use the Arduino (or PIC24, dsPIC, PIC32) to sample real world data and transmit it (over serial communcations, WiFi, Ethernet, etc) to a Nerual Network ruuning on a PC which then displays the results

jack1994

The Arduino is generally used for sensing the environment and controlling simple devices.

Which of those tasks would it be doing in your project?
Thanks for your answers; anyway, the task in my project is just processing data that I send to ARDUINO by MATLAB/Simulink and then reading the processed data in MATLAB/Simulink.
The process I want to implement in ARDUINO is already developed in Simulink (and it uses NN).
I want to transmit and receive all the data over serial communication.


jack1994

how much data are you planning to send/receive per second?
I have to send and receive 10 samples per second, so I think it is largely feasible, isn't it?

in similar projects I would use the Arduino (or PIC24, dsPIC, PIC32) to sample real world data and transmit it (over serial communcations, WiFi, Ethernet, etc) to a Nerual Network ruuning on a PC which then displays the results
Anyway, Horace, this is exactly the task required to me, but in my situation data are all previously collected in MATLAB/Simulink thorugh a timeseries coming from some sensors on the model plant developed in Simulink.

horace

10 samples/second via serial line at 115200baud should be OK
once you get to 100s of samples per second you start to look at USB, ethernet or WiFi

jack1994

10 samples/second via serial line at 115200baud should be OK
once you get to 100s of samples per second you start to look at USB, ethernet or WiFi

Thank you, do you know if it is possible to program Arduino directly through Simulink just running my Simulink project in external mode, or something like this?

jack1994

Sorry, guys, I have another question for you. I succeed in running in external mode my Simulink plant in Arduino MEGA, but I can just process 3 arrays of 100 data each from workspace until the memory saturates and there is no way to compile the code.
How can I send all the data (3 timeseries arrays of 10000 elements each) from workspace to Arduino?
Thanks

horace

an Arduino mega with a ATmega2560 has 8Kbytes of SRAM so you should be able to define three arrays of 100 elements of a basic data type such as int or float.  What is the array data type?.  what is the error message from the compiler?
do you need to load 3 timeseries arrays of 10000 elements each at a time or could you send blcks of data for processing
perhaps you should move to a Rassberry Pi

jack1994

an Arduino mega with a ATmega2560 has 8Kbytes of SRAM so you should be able to define three arrays of 100 elements of a basic data type such as int or float.  What is the array data type?.  what is the error message from the compiler?
do you need to load 3 timeseries arrays of 10000 elements each at a time or could you send blcks of data for processing
perhaps you should move to a Rassberry Pi
Yeah, I succeed in compiling the code and run the project with 3 arrays of 100 elements. The arrays are MATLAB timeseries.

(do you need to load 3 timeseries arrays of 10000 elements each at a time or could you send blcks of data for processing?)
I can send blocks of data, also one element for each array (3 elements at a time) for processing and the data that I have to receive from Arduino is just 1 element at a time. How could I do this operation?
Thank you.


jack1994

Hey guys,
I've made some steps in the project development. I'll post here the arduino code I'm using for it.
I just want to send data x[0],x[1],x[2] and y and I want to read y2 that is generated by the code in the loop.
Any hint to do this?

(see attachment)

Go Up