Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

SPI and C#


  • Please log in to reply
2 replies to this topic

#1 Vlastimil

Vlastimil
  • Members
  • 2 posts

Posted 31 July 2012 - 12:37 AM

Hello,

I have LabJack U12 and I try to send 5 bytes via SPI. I understand, there is method LabJack.Synch() for this. In attached file, I have code, I wrote. When I run this program, I get Invalid array size or value error. I do not understand where can be a problem, size of the array is 5 and I try to send 5 bytes.

The important lines in attached file are:

// Data to be send via SPI
private static int[] data = {1, 2, 4, 8, 16};
// Try to send 5 bytes via SPI.
int result = LabJack.Synch(ref ljID, demo, 0, 0, 0, 0, 0, 0, 0, data.Length, data);

Attached Files



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 31 July 2012 - 11:34 AM

The U12 driver is picky about the array you send, and expects an 18-element array with unused locations filled with zeros:

http://labjack.com/s...sers-guide/4.34

So try adding 13 zeros to your array.

#3 Vlastimil

Vlastimil
  • Members
  • 2 posts

Posted 01 August 2012 - 12:14 AM

Thank you, I did not read the note about array size. Now, it work without any problem:

// Data to be send via SPI
private static int[] data = {1, 2, 4, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// Try to send 5 bytes via SPI.
int result = LabJack.Synch(ref ljID, demo, 0, 0, 0, 0, 0, 0, 0, data.Length, data);



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users