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

Re: SUB-20 and LabView 7.1

Post by brad »

Definitely try to mass compile the labview directory:
Tools/Advanced/Mass compile
Labview 7.1.1f2 should be in the same directory as the initial 7.1 install, which by default is c:\program files\national instruments\labview 7.1
With the mass compile window, browse to the lv directory and then click the "Select Cur Dir" ... the mass compile process should take awhile (30-120 minutes?).

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

Re: SUB-20 and LabView 7.1

Post by brad »

I am able to communicate with my SPI slave device and now trying to optimize the speed :)

I am using the SUB20 to communicate to my spi slave, which in turn is controlling a set of solenoid valves. Each time I want to set valve states, I need to send 3 bytes to my spi slave.

I am able to send 3 bytes in ~ 180 milliseconds. Not too bad, but it turns out that the time is almost complete due to the SystemByteArray calls:

The "SystemByteArray" constructor takes 100 msec.

The "SystemByteArray.CreateInstance" (of ArrayObject) takes 50 msec.

Can you give me a bit more information about what these two calls are doing?

I see two possible ways of speeding this up.
1) move the two calls into the parent function that keeps sending the SPI messages. This will mean the array is allocated only once. I then need a method to modify the bytes, presumable with SystemByteArray.SetValue method.

2) I only need to send a total of 16 3-byte messages (1 for each valve). Could I pre-allocate all the 3-byte messages and then store the references in my parent function and send the appropriate reference into a sub-function that does the spi transfer? Is it possible to have more than 1 SystemByteArray? If so, what is the limit? how do they get cleared?


I see there is a SystemByteArray.Equals but it isn't documented in the .NET pdf.

thanks!

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

Re: SUB-20 and LabView 7.1

Post by serg »

hi brad!

The SystemByteArray is a container for the .NET System::Array class. I don't know why it takes so much time to create an array, probably because of the LV memory management. We use a default constructor. The CreateInstance simply initializes a .NET array by setting each item in a loop. I think your approach to reduce the time is correct. You can create as many SystemByteArrays instances as you wish.

Post Reply