Write GPOI output 31 fault

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

Moderator: serg

Post Reply
Tubes4sale
Posts: 7
Joined: Thu Jan 28, 2010 7:15 am

Write GPOI output 31 fault

Post by Tubes4sale »

Hello,
When I use gpiowrite to activate ouputs, everthing works fine until ouput 30, when I use 31 I get the fault message (see picture).
When I use the hex value and code:
If Not Sub20.GPIO_Write(Val("&H" + GpioValue.Text), Val("&H" + GpioMask.Text)) Then
' AddInfoLine("failed, err=" + Sub20.GetLastError().ToString())
'End If
I can write output 31 ( hex 80000000).

Any idea what can cause the problem ?
Thanks,
Patrick

Image

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

Re: Write GPOI output 31 fault

Post by serg »

Hi Patrick,

It was a signed/unsigned conversion bug in the SUB-20 .NET component. Please update your sub20dnc.dll file from the attached archive.

Sorry for any inconvenience
Attachments
sub20.net-1.4.4.zip
SUB-20 .NET v1.4.4
(109.13 KiB) Downloaded 989 times

kenD4
Posts: 5
Joined: Thu Feb 10, 2011 1:53 pm

Re: Write GPOI output 31 fault

Post by kenD4 »

Hello,

I am also trying to use the GPIO port. I have noticed when I read data back that bit 31 seems to float so sometimes I end up with a negative number. Shouldn't the values being passed back and forth to the GPIO commands be UINT32???? Otherwise reading the values back becomes more difficult if you are only interested in a few bits. I have tried configuring and writing a 0 to bit 31. When I do so using a uint32 value i get an error back due to the data type. I did download the attached dll files.

CSMask = uint32(2^27); % CS is bit 27
ClkMask = uint32(2^24); % Clk is bit 26
DataMask = uint32(2^29); %data line bit 29
MSBMask = uint32(2^31);
OutMask = uint32(CSMask + ClkMask + DataMask + MSBMask) %don't add datamask if reading
InMask = uint32(CSMask + ClkMask + MSBMask)

success = sub20.GPIO_SetConfig(OutMask, OutMask); %first param value second is the bits
if ~ success
disp(sub20.GetStrError(sub20.GetLastError()));
end

Here is the error i get:
No method 'GPIO_SetConfig' with matching signature found for class
'Xdimax.Sub20'.

Thanks for your input!

Ken

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

Re: Write GPOI output 31 fault

Post by serg »

Hi Ken,

I can't reproduce your issue runing your code with the SUB-20 .NET v1.4.4. I just copied your code into the Matlab script added a couple of semicolons. It runs properly. Did you modify the NET.addAssembly to point to the correct SUB-20 .NET v1.4.4?

kenD4
Posts: 5
Joined: Thu Feb 10, 2011 1:53 pm

Re: Write GPOI output 31 fault

Post by kenD4 »

:oops: Maybe I am not updating the dlls correctly. Are there some instructions on which dlls go where? I have tried just pasting the dlls in the bin directory. I have also renamed and placed the .v4 dll in the v4 directory.

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

Re: Write GPOI output 31 fault

Post by serg »

Updating the bin/sub20dnc.dll from the sub20.net-1.4.4.zip archive should be sufficient. What Matlab do you use? I tried your code with the 2009a

kenD4
Posts: 5
Joined: Thu Feb 10, 2011 1:53 pm

Re: Write GPOI output 31 fault

Post by kenD4 »

2010a

kenD4
Posts: 5
Joined: Thu Feb 10, 2011 1:53 pm

Re: Write GPOI output 31 fault

Post by kenD4 »

I actually am getting a different error now. I cut and pasted only the section of code below.

CSMask = uint32(2^27); % CS is bit 27
ClkMask = uint32(2^24); % Clk is bit 24
DataMask = uint32(2^29); %data line bit 29
MSBMask = uint32(2^31);
OutMask = uint32(CSMask + ClkMask + DataMask + MSBMask) %don't add datamask if reading
InMask = uint32(CSMask + ClkMask + MSBMask)

NET.addAssembly('C:\Program Files\SUB-20\bin\sub20dnc.dll');
sub20 = Xdimax.Sub20();
success = sub20.GPIO_SetConfig(OutMask, OutMask); %first param value second is the bits
if ~ success
disp(sub20.GetStrError(sub20.GetLastError()));
end

This is the error I get now.

??? Error using ==> sub20test at 8
Message: A procedure imported by 'sub20dnc, Version=1.4.4.0,
Culture=neutral, PublicKeyToken=269bd6ead27849c4' could not be loaded.
Source: mscorlib
HelpLink:

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

Re: Write GPOI output 31 fault

Post by serg »

Try to do the following. Close all applications. Uninstall the SUB-20 software.
Install the SUB-20-110314 RC1 available here viewtopic.php?f=2&t=450. This package contains all the latest modules, therefore you don't need to update the SUB-20 .NET component after installation anymore. Try your script again. If you still have the same "cannot load" error try to use the SUB-20 .NET v4, i.e change the

NET.addAssembly('C:\Program Files\SUB-20\bin\sub20dnc.dll');
to
NET.addAssembly('C:\Program Files\SUB-20\bin\sub20dnc_v4.dll');

If it still doesn't work please provide me with the following
BTW What is your OS version, i.e 32 or 64 bit ?
If 64-bit what is the Matlab version i.e 32 or 64 bit ?
Thanks

Post Reply