Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Functionality of NI-845x in Borland Builder

I've configured and run an NI-845x module to run for SPI communication.   As I need to send an array of databytes towards a component which is connected to the NI module, I've created a script to do so.   One of the commands it to transmit 100 bytes.  When I measure the signals when executing this script, the 100 bytes are transmitted as 51 bytes, a long delay (about 1ms) and then the continuation.  I've tested it with 200 bytes and then I get three times 51 bytes one time 47 (total of 200 bytes) and the gap delay between the byte sequences increases.   What's the cause of this and more important, how can it be avoided ???
 
0 Kudos
Message 1 of 20
(5,515 Views)
Hi Krisken,

In my time at school i had a similar problem, it had to do with how you specify the communication between your devices.
I think you are using the SPI advanced programming model, so i suggest you play around a bit with different settings.
If i remember correctly, in my case it had to do with the way i designed my master PIC microprocessor to send the bytes (512 bytes in my case)
He didn't waited long enough before sending the next byte. I'm not quite sure anymore but i think the way i had to work was by first checking if the
send buffer was empty and then sending. But i don't know if these low level settings are available in labview will have to check it out if you continue to have the problem.

Also i found in the software manual:

"When you use the SPI Advanced API, the first step is to create a script that
describes the communication between an SPI master and an SPI slave
device. Then you execute the script and read data if needed. The script size
is limited only by the amount of memory available on your PC. The number
of read commands, NI-845x SPI Script Write Read.vi, NI-845x SPI
Script DIO Read Port.vi, and NI-845x SPI Script DIO Read Line.vi
within each script is limited to 64."

So be sure that the number of read commands isn't greater then 64 in your script other wise this could be the problem.

Futhermore it might also be good to check your spi recieve device for timing errors if you had to program it yourself.

If after some more investigation, you still have troubles let me know and give me some more information about the recieving device.
But i think the problem is somewhere in the way you programmed it or in the fact that you have to many read commands in your script.
Good luck with your program!
Kind Regards,

Joris Donders
National Instruments
EMEIA GTM Lead for Semiconductor
www.ni.com/semiconductor
0 Kudos
Message 2 of 20
(5,503 Views)
Hello Joris,
 
I'm using indeed the advanced programming model.  I've been playing around with the settings but that doesn't seem to be the problem.
I've created a script with only 1 read/write command in it.   The command itself contains 100 bytes to send (it is for reading out an AD converter,
20 channels, one command byte and for the 4 next byte the value is returned, anoter command byte, ... )  So with one read instruction of 100 bytes the job should be easely done...    But there is an hickup after 51 bytes (a delay in which the AD converters, which is in autoscan, continues converting) and I loose the data of the conversions in this hickup.   If I split the command in two read commands of 40 bytes, I have the first command executing perfectly, the second one is done for 11 bytes (40+11=51) then I have the hickup and then the remaining bytes.  
It looks to me like a buffering problem of some sort just as if the NI module can't follow, needs some processing time and meanwhile disables the SPI clock, catches up and resumes.   The problem is that I can't afford this hickup time because my data is lost.
 
Kind regards,
 
Kris
0 Kudos
Message 3 of 20
(5,499 Views)
Hi Kris,

Ok, so i think i will have to look into this problem some more but normally when you have one command that performs a read write of 100 bytes you would also recieve 100 bytes. Reading and writing happens at the same time because it's like a big shift register in which the data loops, but i think you already know this.

What i want to ask you if you could look into the AD convertor's specifications. Some SPI slaves have a limited page size and therefore they require some internal transfer time between the pages. For example if the device has a page of 128 bytes and you write 128 bytes to it, it would need up to 5 ms until you could write again. I think it's rather strange that if you perform 2 read commands of 40 bytes he also hick's up at 11 the second time. Could be that that is because his internal page size is 51 bytes or something. Perhaps look into this idea and let me know which AD converter you are using.


Kind Regards,

Joris Donders
National Instruments
EMEIA GTM Lead for Semiconductor
www.ni.com/semiconductor
0 Kudos
Message 4 of 20
(5,493 Views)
Hello Joris,

About the reading and writing, I know that it happens at the same time.   The command I give for reading the registers is 100 bytes, but the string I send is the first byte is the command, after receiving, I have to send 4 dummy bytes to clock out the data and then the next byte can be a command again.   So when I put all these bytes in a string of 100 bytes and clock out this string, I have the receiving end of the 20 channels.  

As for the page size of the SPI slave, I must say I doubt it.  It has only one register where it dumps the data from the last conversion.   I"ve put the delay of the AD conversions sequence in a way that it nearly reaches the frequency when reading with one command meaning that the next conversion is done by the time that I read the next register.   If I put the sampling faster, then there is even loss of the data because the data is already overwritten by the next.  If I read to quickly I only get the status report that the data is not new, so I don't think it's an SPI slave issue.   There is even no handshaking forseen and I don't think that the SPI master would stop the SPI clock (which is what happens when the hickup occurs).

Kind regards,

Kris
0 Kudos
Message 5 of 20
(5,488 Views)
Hi Kris,

I am going to ask for some help about this in america because i am not able to investigate this problem here. Can you give me detailed information about the AD converter you are using.

And if it's possible, can you also upload your vi and script that you use to get the information. If it's part of an complex program or something, could you then make a new vi which only does the reading of the 20 channels (so it only explains the problem and doens't contain any other stuff). If you can do this i can take a look at the vi perhaps i notice something and if not i can use it to provide america with the necessary stuff to investigate the problem.
Kind Regards,

Joris Donders
National Instruments
EMEIA GTM Lead for Semiconductor
www.ni.com/semiconductor
0 Kudos
Message 6 of 20
(5,479 Views)
Hello Joris,
 
As for the AD converter we're using, it's the ADS1258 (datasheet is accompanied).
 
As for the script, I'm not using labview but Borland C++ builder, but I can give you the script (it's an easy one).   One other remark, I'm using two NI-845x devices on the same computer (allthough it's on a different USB port).  Could that be a problem ?
 
As for the script :
 
            //----- Create a script handle to add script commands
            ni845xSpiScriptOpen(&(one_script));
            //----- Configure Polarity and Phase
            if (clockFalling)
                ni845xSpiScriptClockPolarityPhase(one_script, kNi845xSpiClockPolarityIdleLow, kNi845xSpiClockPhaseSecondEdge);
            else
                ni845xSpiScriptClockPolarityPhase(one_script, kNi845xSpiClockPolarityIdleLow, kNi845xSpiClockPhaseFirstEdge);
            //----- Configure clock rate
            ni845xSpiScriptClockRate (one_script, NI8451_SPI_DEF_CLOCKRATE);
            ni845xSpiScriptEnableSPI (one_script);
            ni845xSpiScriptCSLow (one_script, spi_chip_select);
            //----- Specify the data to be written
            for (count=0; count<20; count++)
            {
                send_buffer[count*5] = 0x30; // 0x20 for channel data read register and 0x10 for multiply read : read a channel
                send_buffer[count*5+1] = 0x00; // 0x20 for channel data read register and 0x10 for multiply read : read a channel
                send_buffer[count*5+2] = 0x00; // 0x20 for channel data read register and 0x10 for multiply read : read a channel
                send_buffer[count*5+3] = 0x00; // 0x20 for channel data read register and 0x10 for multiply read : read a channel
                send_buffer[count*5+4] = 0x00; // 0x20 for channel data read register and 0x10 for multiply read : read a channel
            }
            ni845xSpiScriptWriteRead (one_script, 100, send_buffer, &read_index);   // remark 1
            ni845xSpiScriptCSHigh (one_script, spi_chip_select);
            ni845xSpiScriptDisableSPI (one_script);
Remark 1 : this is the instruction where it goes wrong, that instruction reads 51 bytes, pauses and resumes.   If tried other things as well e.g. read 51 bytes, toggle the chipselect, but between the read operation and the toggling of the chip select, also this pause occurs.  If I write 50 bytes and toggle the chip select, it doesn't happen.
 
Kind regards,
 
Kris
 
 
0 Kudos
Message 7 of 20
(5,460 Views)
Hi Kris,

First of all Happy new year, hope you had some fun during the holidays.

Second, using 2 NI-845x devices on the same pc but different usb ports will certainly not help the situation so try to use your program with only one and see if the command still gives trouble.
But because you are using the borland C++ builder we can't know if that could be the problem. If you have the possibility to use our software please do so, that way you can check if it's hardware or software related. Normally it should not matter but who knows. Which devices do you use, is it the NI 8451 or ??
Kind Regards,

Joris Donders
National Instruments
EMEIA GTM Lead for Semiconductor
www.ni.com/semiconductor
0 Kudos
Message 8 of 20
(5,425 Views)
Hello Joris,
 
As for the holidays, I did my best.   I hope you had some fun as well besides problems Smiley Happy
 
Some more info : the hardware devices we're using is the USB6501-OEM which corresponds to the NI-8451.
I've disconnected one of the devices and disabled the initialisation of the device in the Software so the library doesn't know about the second module..   Result is still the same.
I've disconnected the slave components (well actually disconnected the USB6501-OEM from the hardware board so that no slaves were present at all : result is still the same.
What is the definition of "our software" ?   I'm using the dll which is accompanied with the device, but I couldn't find any other software were I can use the device or am I missing something ?
 
As far as I can see it now, I've narrowed it down to the DLL and one device, nothing connected and still the hickup when I execute the script mentioned above.
 
Kind regards,
 
Kris
 


Message Edited by krisken on 01-02-2008 07:45 AM
0 Kudos
Message 9 of 20
(5,422 Views)
Hi Kris,

Are you sure that you are using the usb 6501-OEM and not the usb 8451-OEM (the oem versions look like eachother) Cause the usb 6501 is a simple digital I/O module that does not work with the ni845x driver software (you have to use daqmx for this) so please check this in max.

If you are using the 6501 i don't know how it is possible that you can use the ni845x commands in your C++ builder together with the 6501. Only the usb 8451 is supported by the NI-845x software that you are using in your C code. So check if you are using the 6501 in max.
Kind Regards,

Joris Donders
National Instruments
EMEIA GTM Lead for Semiconductor
www.ni.com/semiconductor
0 Kudos
Message 10 of 20
(5,411 Views)