Hello,
I am attempting to use the .NET interface in Matlab to read the GPIO pins. I have been successful in using the GPIO_SetConfig and GPIO_Write (confirmed by reading the settings with the SUB-20 tool); however, when I call the GPIO_Read function the variable I pass it does not appear to update when I toggle the GPIO line(s).
My first attempt was:
GPIOin = 0;
if ~sub20.GPIO_Read(GPIOin)
sub20_close_handle_error(sub20);
end
Matlab did not complain using this data type despite it nativity being a double in Matlab and the SUB-20 .NET component manual calls for a ByRef Int Value, but the variable did not change from 0 despite pulling the configured GPIO input line high.
Second attempt:
GPIOin = System.UInt32;
if ~sub20.GPIO_Read(GPIOin)
sub20_close_handle_error(sub20);
end
This caused Matlab to generate the following error: "No method 'GPIO_Read' with matching signature found for class 'Xdimax.Sub20'."
What is the correct way to use GPIO_Read from Matlab?
Thanks very much,
- Mark
GPIO_Read and Matlab .NET interface
Moderator: serg
Re: GPIO_Read and Matlab .NET interface
Hello Mark,
The correct way to read GPIO pins is the following
See the C:\Program Files\SUB-20\sample\.NET\matlab\gpio.m for more information
The correct way to read GPIO pins is the following
Code: Select all
% Read all input pins to the 'val' variable
[success val] = sub20.GPIO_Read(0) ;
if ~ success
break;
end