SUB-20 and LabView 7.1

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

Moderator: serg

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

SUB-20 and LabView 7.1

Post by brad »

Hello,

I want to use LabView 7.1 via .NET to development my application that will use the Sub-20. I have already ordered a sub-20 but haven't received it (just ordered last night). I installed "SUB-20-100923-x32.exe." I have a newer version of labview and used it to open the LabView SPI demo and then save the demo for LabView 7.1. I fixed a few minor problems (relinking the dll, etc), but there is still one error remaining. There is a .NET constructor called "Spi" with parameter "Ss_HHL" that is wired to the Sub20/SPI_Transfer_r ss_mode node -- see figure.
code screen capture
code screen capture
sub20_spi (Small).png (99.67 KiB) Viewed 40568 times
What is this "SPI" constructor? what dll is it attached to? when I add a new constructor and point to the sub20dnc.dll then I only get the objects "Sub20" "Sub20Enum" "SystemByteArray" and "SystemInt32Array".
.net constructor dialog box
.net constructor dialog box
sub20_constructor.png (7.32 KiB) Viewed 40568 times
Any thoughts?

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: SUB-20 and LabView 7.1

Post by brad »

Btw:
I just looked at the sub20dnc dll in LabView 8.0 and there is a "Spi" constructor. Why doesn't this show up in Labview 7.1? I do need to use LabView 7.1 for my application because it will be deployed in a location that only has license for 7.1.

thanks,

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

Re: SUB-20 and LabView 7.1

Post by serg »

hi Brad

I don't know why LabView 7.1 behaves differently. We didn't test the SUB-20 with LabView 7.1.
The Spi class is a just set of constants related to the SPI interface. Similarly the sub20 .NET component contains constants for fifo, pwm, adc, gpio etc. These classes contain just constatnts, no methods. So you can simply calculate(oring) the desired value and put it as a constant into your vi. You can find all the numeric vaues in the C header file located under C:\Program Files\SUB-20\inc\libsub.h. Here is SPI SS mode constants taken from this file

Code: Select all

/* SS Configuration for SPI Read/Write */
#define SS_CONF(SS_N,SS_MODE)	((SS_N)<<4)|((SS_MODE)&0x0F)
	#define SS_H		0x0F	/* ____/----- - - - */
	#define SS_HL		0x09	/* ____/-\___ _ _ _ */
	#define SS_HHL		0x0A	/* ____/--\__ _ _ _ */
	#define SS_HHHL		0x0B	/* ____/---\_ _ _ _ */
	#define SS_HHHHL	0x0C	/* ____/----\__ _ _ */
	#define	SS_HI		0x0D	/* ____/-- - -\__ _ */
	#define SS_L		0x07	/* ----\_____ _ _ _ */
	#define SS_LH		0x01	/* ----\_/----- - - */
	#define SS_LLH		0x02	/* ----\__/---- - - */
	#define SS_LLLH		0x03	/* ----\___/--- - - */
	#define SS_LLLLH	0x04	/* ----\____/-- - - */
	#define SS_LO		0x05	/* ----\__ _ _/-- - */
	#define SS_HiZ		0x08	/* xxxxxxxxxxxxxxxx */
So, in your case just connect constant value of 10(decimal) as a ss_mode

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: SUB-20 and LabView 7.1

Post by brad »

Thank you for the response and solution. I did some searching on the LabView forums and found this post:

http://forums.ni.com/t5/LabVIEW/LabVIEW ... d-p/566143

The original poster indicated a problem similar to mine and one of the responses discusses the issue and solution. I have copy & pasted the relevant section of the post for future reference.



<Begin quote from NI forum>


"The behavior you are seeing is related to how we display .NET static classes in the Select .NET Constructor Dialog Box. In LabVIEW 7.1.1 and LabVIEW 8.0, we did not display static classes in that dialog box but in LabVIEW 8.2.1 (I can't remember if it was LabVIEW 8.2 or 8.2.1) we actually showed the user the static classes. Thus in LabVIEW 8.2.1, you can bring up and see the Clipboard class in the Select .NET Constructor dialog, but you can't click OK because there are no constructors (i.e. which makes sense since the Clipboard class is a static class). In LabVIEW 7.1.1, you get the behavior of not seeing this class as shown in the attached LV 7.1.1 Constructor snapshot.

It is important to note that .NET static classes cannot be instantiated (i.e. you can't create objects but rather you directly access the methods and properties). To call static methods or properties, you
1) Drop down an invoke node or property node from the .NET palette
2) Right-click on the top-left terminal and select Select Class » .NET » Browse from the shortcut menu to display. Then browse to your .NET assembly (in this case it’s the System.Windows.Forms assembly) and choose your .NET class (in this case it’s the Clipboard class).

3) Choose a method or property (see the attached Select Object from 7.1.1 snapshot)


(Note You can invoke static methods if you have an instance - we know it's static and ignore the instance value passed in on the refnum)

Now before the 7.1.1 f2 patch, LabVIEW 7.1.1 would not display any of the .NET Framework 2.0 assemblies. After applying the patch you should see .NET 2.0 assemblies.

Also, you may notice that when trying to select the System.Windows.Forms 1.0.5000.0 assembly a prompt appears indicating the version of the assembly was prompted to a later version by the .NET runtime engine. The reason for this is because LabVIEW automatically loads the latest installed version of the .NET CLR. Just thought I would let you know. This just means you are always targeting the latest version of that assembly on your system.


<END QUOTE>

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

Re: SUB-20 and LabView 7.1

Post by serg »

Thank you for the info, brad
Did you try to apply this f2 patch to your LV7.1? Does it help?
By the way our constant container classes are not static, hovewer we do have static constants in the sub20 class. May be you can access those somehow. Here are some of them

Code: Select all

static int const SpiClk_250kHz=SPI_CLK_500KHZ;
static int const SpiClk_125kHz=SPI_CLK_125KHZ;
static int const SpiSS_H=SS_H;
static int const SpiSS_HL=SS_HL;
static int const SpiSS_HHL=SS_HHL;
static int const SpiSS_HHHL=SS_HHHL;
static int const SpiSS_HHHHL=SS_HHHHL;
For example, do you see the sub20.SpiClk_250kHz constant from inside the LV 7.1?
I can use these constants in LV 8.5 by choosing the "Connectivity->.NET->Property Node"
sub20prop.JPG
sub20prop.JPG (12.1 KiB) Viewed 40560 times
Unfortunately we don't have the LV 7.1 so I couldn't try this

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: SUB-20 and LabView 7.1

Post by brad »

Hello,

I am still waiting for my SUB-20 but spent a bit more time with the drivers. I can access the constants using the "Property" node and was able to display the numeric values of the SPI constants on my front panel in LV71. However, the overall behavior of the .NET interface is a little rough compared to when using LV 8.2. For example, LV8.2 seems to automatically convert the ".NET Constructor" into the ".NET Property" node if the SPI constants are selected. Additionally, LV7.1 tends to 'forgot' the install directory of the sub20dnc.dll and I often get dll not found errors on execution but LV8.2 doesn't have this problem. I copied the .NET dll into the same directory as the VI I am executing and LV7.1 behaves much better (ie it doesnt have trouble finding the dll when I execute the VI).

I upgraded to 7.1.1 and installed the f2 patch and the behavior is pretty much the same. Best advice I have is to copy the dll into the same directory and use the correct constructor/property/invoke object. I will try to provide an update once I get my hardware.

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

Re: SUB-20 and LabView 7.1

Post by xol »

Thanks for the info.
We are waiting to get results of your testings with HW.

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: SUB-20 and LabView 7.1

Post by brad »

Ok I got the hardware today. I am still having problems with using the Sub20 .NET interface in LV7.1.

I started LV7.1 and created a new VI. I dropped a ".NET Constructor Node" on the wiring diagram and the constructor dialog box appeared. I navigate to sub20dnc.dll and in the "Objects" window choose the "Sub20" under "Xdimax." I push OK and the wiring diagram comes back, however the .NET constructor icon still says ".NET" instead of "Sub20." In 7.1, the available constructors are not showing. I made figure comparing the behavior of LV7.1.1f2 and 8.2.1. In 8.2.1 the Sub20() constructor appears, but it doesnt in LV 7.1.1f2.

I am able to access the class properties via the ".NET Properties Node" in LV7.1.1f2, but this doesn't get me very far.

I am able to access the constructor methods of other classes in LV7.1.1f2, I just can't access the ones for sub20.
version_comp.png
version_comp.png (33.19 KiB) Viewed 40534 times

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: SUB-20 and LabView 7.1

Post by brad »

Update. I mass compilied my LV7.1.1f2 directory and the constructor node seems to work ok now. NI recommends mass compiling the directory after upgrading to 7.1.1f2, and I had forgot to do that.

I'll post again if the problem comes back.

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

Re: SUB-20 and LabView 7.1

Post by serg »

hi brad,
Thank you for the update.
I couldn't find the LV7.1.1f2 directory. I have installed LV7.1 on XP SP2, udated to 7.1.1 and finally applied the f2 patch, however I still cannot access the .NET component. I get the following exception when I try to execute the vi
exception.JPG
exception.JPG (27.1 KiB) Viewed 40516 times
But I got the LV7.1 working with the board by using a different approach. The sub20.dnc is a dual interface module, i.e besides the .NET interface it exposes a .NET predecessor - activex interface. In order to use this interface you have to create so called type library and use this sub20dnc.tlb file as a normal activex control. See the sub20.net document for details about creating the type library. So in case you still have problems try this method. I have attached my simple vi which uses the sub20dnc as an activex control.
gpio_activex.JPG
gpio_activex.JPG (13.49 KiB) Viewed 40516 times
Attachments
gpio_activex.zip
(6.74 KiB) Downloaded 2689 times

Post Reply