How are you supposed to send an array using the ActiveX SigmaStudioServer in Matlab, using the REGISTER_SAFELAOD_ARRAY method?
How do you send an array using the ActiveX server to connect to SigmaStudioServer in Matlab, using the REGISTER_SAFELAOD_ARRAY method?
I am absolutely flabbergasted that the following code excerpt does not work:
```
clc; clear; close all;
% Add SigmaStudio installtion directory to path
addpath('C:\Program Files\Analog Devices\SigmaStudio 4.7');
% Intantiate SigmaStudio server and invoke the interface
ss = actxserver('Analog.SigmaStudioServer.SigmaStudioServer');
ssServer = ss.invoke('ISigmaStudioServer');
% Query for existing values (this part works).
test = ssServer.REGISTER_READ_ARRAY("IC 1", 0x204C, 640);
% Send existing values back to same address (this part fails).
ssServer.REGISTER_SAFELAOD_ARRAY("IC 1", 0x204C, 4, test);
```
I get the following error:
```
Error using Interface.2942E58A_4461_410E_87B3_64152C81935F/REGISTER_SAFELAOD_ARRAY
Error: The parameter is incorrect.
```
software
ADAU1787
sigma studio 4.7
Integrated/Special Purpose A/D Converters
sigmastudioserver
matlab
server
array
Audio CODECs
sigma script
Show More
Noted a typo in the original post, I corrected it and it doesn't change the negative outcome:
```
% Changed 4 bytes to 640 bytes, as in the line above.
ssServer.REGISTER_SAFELAOD_ARRAY("IC 1", 0x204C, 640, test);
```
I have also tried all different combinations of `REGISTER_WRITE_ARRAY` and `REGISTER_SAFELAOD_ARRAY` etc.
Update -- solved it. For anyone looking later on:
In Matlab, you need to use this to properly format the array.
`feature('COM_SafeArraySingleDim', 1)`
And here's my hacky method to prep the array for export:
```
function y = prepForAdau(x)
nBytes = length(x) * 4;
y = uint8(zeros(nBytes, 1));
pIn = 1;
pOut = 4;
for n = 1:length(x)
val = x(n);
val = int32(val * 2^23); val = typecast(val, 'uint8'); val = fliplr(val); val = val';
y(pIn:pOut) = val;
pIn = pIn + 4;
pOut = pOut + 4;
end
end
```
See here for a longer explanation:
ez.analog.com/.../sigmastudio-server-matlab-register-write--what-s-missing
www.mathworks.com/.../92424-how-can-i-pass-arguments-to-an-activex-server-from-matlab-7-0-r14-as-one-dimensional-arrays
Hello mhenry,
Thanks so much for taking the time to come back and post this! This is not something I use much in my daily work and the few people who do are very busy so I have not had the time to chase down answer for you.
Dave T
Please log in to reply.