matlab >NET functions

All about Sub-20 Multi Interface USB Adapter USB to I2C, SPI, GPIO, RS232, RS485, Ir, LCD

Moderator: serg

Post Reply
wanxiang
Posts: 5
Joined: Thu Apr 07, 2011 6:34 am

matlab >NET functions

Post by wanxiang »

Hi:
Is there any manual or function list about the matlab .NET functions?

I found only a few examples avaliable on the forum. Is there anyway I can get the full function list?

Thanks

serg
Posts: 143
Joined: Mon Aug 31, 2009 9:17 pm

Re: matlab >NET functions

Post by serg »

Hi wanxiang,

The entire list of methods along with sample code is available in the SUB-20 .NET component manual document which is included in the standard SUB-20 software installation package. I have attached one for your convenience. Please note that the .NET component is just a wrapper around the main SUB-20 interface library. If you need more detailed information please refer to the SUB-20 User Manual document http://www.xdimax.com/sub20/doc/sub20-man.pdf
Attachments
sub20net.pdf
(83.56 KiB) Downloaded 1086 times

wanxiang
Posts: 5
Joined: Thu Apr 07, 2011 6:34 am

Re: matlab >NET functions

Post by wanxiang »

Thanks for your quick reply.

Now receive some error information from I2C.
The error code from getlasterror is 0. But acctural error code seems to be 11(I2C error)

I also get the I2C status, it is 0xE1(Arbitration lost in start).

Now I connect the SUB-20 to a scope directly and I can't see any output from SUB-20.

Any idea? These are my matlab code:

TransferSize=1;
asminfo = NET.addAssembly('C:\Program Files\SUB-20\bin\sub20dnc.dll');

sub20 = Xdimax.Sub20();

% simulate do { ... } while(0) loop
for k=0:0

% Open first available SUB-20 device
if ~ sub20.Open(0)
break;
end

% Configure
if ~ sub20.I2C_SetFrequency(100000);
break;
end

i2c_buff=NET.createArray('System.Byte',TransferSize);
i2c_buff.Set(0,hex2dec('2a'));

%sub20.I2C_IssueStart();
% Set GPIO12 to logical '1'
if ~ sub20.I2C_Write( hex2dec('01'), hex2dec('01'), 1, i2c_buff)
break;
end

info = sub20.I2C_GetStatus();

%sub20.I2C_IssueStop();
end

err = sub20.GetLastError();

% Close SUB-20 device
sub20.Close()

if err > 0
fprintf('Error %d\n', sub20.GetLastError() )
error('Error!')
end

Thanks

wanxiang
Posts: 5
Joined: Thu Apr 07, 2011 6:34 am

Re: matlab >NET functions

Post by wanxiang »

By the way, even I use subtool, I also receive similar error
I2C.jpg
I2C.jpg (87.46 KiB) Viewed 11940 times

xol
Site Admin
Posts: 241
Joined: Sat Aug 29, 2009 8:04 am

Re: matlab >NET functions

Post by xol »

You have not selected Slave Address to read/write.
Try to run I2C Scan to see slave devices available on the Bus.

Post Reply