I am trying to make a serial connection between Arduino and Simulink through Serial.
However, data received does not match data I send.
Arduino code
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
}
long K;
void loop()
{
K=millis();
Serial.write(K);
}
Pictures of connections
I work on normal mode
There's no way this much time is passed. And this issue stands on all binary data types.
Thanks for any help...
Attached a ZIP for ones who want to see Simulink model
You are only showing us one piece of the puzzle since there is no simulink code or diagrams attached to your post.
We can't help until you post them.
Quick tip, though, be careful about writing too much data to your PC too fast. If simulink isn't fast enough to parse all the data, you might get erratic behavior. Check this out - might help you.
After reading your linkk, I feel like the error may be on start-end bytes or using normal mode instead real-time, but it is still a very big area to look for. Honestly, I am still quite newbie...
Apparently Arduino does not send 32 byte data, even if it is defined long.
When converting, Simulink adds fills 0 binary value to the number so it gets bigger.
We should take uint8 values as char, define header and terminator, convert it to string and double.