hello everybody, With a little patience I found a solution:
rpi = raspi('IP-ADRESS', 'pi', 'raspberry');
global A;
clear A;
n=20;
A = zeros(0,0);
global mcp3008;
global data;
global highbits;
global voltage;
for i = 1:n
clear mcp3008;
mcp3008 = spidev(rpi, 'CE0',0);
data = uint16(writeRead(mcp3008,[1, bin2dec('10000000'), 1]));
highbits = bitand(data(2), bin2dec('11'));
voltage = double(bitor(bitshift(highbits, 8), data(3)));
voltage = (3.3/1024)*voltage;
pause(0.1);
A =[A voltage];
end
My problem is now: how do I get this M-File in Simulink for a continuous voltage measurement. I have tried using interpreted Matlab function, but it always says that it didn't found my variables or the commands (for example writeRead). Does anybody know how you can run an M file form Simulink?
For the function block I of course removed "for i = 1:n" and "end" as well as the "rpi = ...." lines.
Thank you for your answers and helpful ideas in advance. Alex