Git Product home page Git Product logo

simulink-arduino-serial's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simulink-arduino-serial's Issues

Serial communication problem

when I try to use this code with an arduino which has servo motor connected to it, I got servo motor turning randomly when I try to start or close the simulation!!

Get Float returns inf

I have tried your code to control a stepper motor through matlab, but I have a problem where the motor keeps running away all the time turns out the getFloat() keeps returning a inf number when not connected to anything. Im not sure where my problem lies here are the code that I used to recreate the problem.

`// Create a union to easily convert float to byte
typedef union{
float number;
uint8_t bytes[4];
} FLOATUNION_t;

// Create the variables you want to receive
FLOATUNION_t myValue1;
FLOATUNION_t myValue2;
FLOATUNION_t myValue3;
FLOATUNION_t myValue4;
FLOATUNION_t myValue5;
FLOATUNION_t myValue6;

// Create the variables to send
FLOATUNION_t send1;
FLOATUNION_t send2;
FLOATUNION_t send3;

void setup() {
// initialize serial, use the same boudrate in the Simulink Config block
Serial1.begin(115200);

}
void loop(){
// Get the floats from serial
myValue1.number = getFloat(); // Give your float a value
myValue2.number = getFloat(); // Give your float a value
myValue3.number = getFloat(); // Give your float a value
myValue4.number = getFloat(); // Give your float a value
myValue5.number = getFloat(); // Give your float a value
myValue6.number = getFloat(); // Give your float a value

// Do whatever you want here
Serial1.println(myValue1.number);
Serial1.println("GAE");
//Serial1.println(myValue1);

// Send some variables back
send1.number = myValue1.number+myValue2.number;
send2.number = myValue3.number+myValue4.number;
send3.number = myValue5.number+myValue6.number;

// Print header: Important to avoid sync errors!
Serial1.write('A');

// Print float data
for (int i=0; i<4; i++){
Serial1.write(send1.bytes[i]);
}
for (int i=0; i<4; i++){
Serial1.write(send2.bytes[i]);
}
for (int i=0; i<4; i++){
Serial1.write(send3.bytes[i]);
}
// Print terminator
Serial1.print('\n');

// Use the same delay in the Serial Receive block
delay(50);
}

float getFloat(){
int cont = 0;
FLOATUNION_t f;
while (cont < 4 ){
f.bytes[cont] = Serial1.read() ;
cont = cont +1;
}
return f.number;
}`

Implementation of Simulink-Arduino-Serial with Simulink Desktop Real-Time

Hi there,

Work done in this repository is commendable and useful for real-world applications

I am exploring the feasibility of incorporating the data acquisition method proposed in this repository through Simulink Desktop Real-Time. The current approach needs to be revised for higher data rates, such as 1000 Samples/Second.

Please see the thread below:

https://in.mathworks.com/support/search.html/answers/1436729-serial-input-from-com-device-via-stream-input-block-in-simulink-desktop-real-time-external-sldrt.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:slrealtime/development-computer-setup&page=1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.