Hello every one
I want to read 8 digital inputs at the same time in Simulink but the Simulink did not read at the same time.
some years ago when I used the Arduino library in Simulink there was a block that name was "Real-Time Pacer", I think this block was solving this problem.
but now I could not find this block in the library of Arduino in simulink.
A code could be like: int var1 = analogRead(aPin1); int var2 = analogRead(aPin2); int var3 = analogRead(aPin3);
Each reading takes some time.
Reading at exactly the same time calls for a lot of external electronics.
Thank you for answering
I will read by Simulink.
I am reading an absolute encoder. this absolute encoder has 10 outputs which I am reading through 10 inputs of Arduino in Simulink.
when I turn the encoder the outputs change. so if Simulink did not read all input at the same time the sum of the value of output will be rung for a short time and after it will be true. for example, assume now below output is on:
so the value of encoder is (01+02+04+08+016+032+064+1128+0256+0512) = 128
when i will turn absolute and assume next arrangemnet is as below:
now the value is 256
but because of not reading at the same time all input,
in a short time, Simulink read Pin7 = 1 and pin8 =1 so the output is 128+256=384 but after for example 0.1 sec the value goes to 256.
as I said before there was a block "Arduino pacer" and this block does this job. but now in the new version of the Arduino library, I don't find this block.
I think You've got it!
The only way to read "all inputs" at the very same time is reading an entire 8 bit port. 10 bits parallell reading, in an Arduino, looks impossible to me.
I don't know Simulink but it sounds like a simulator running on a Pc. What good is simulation if the microcontroller can't do the job fully?