05-13-2011 11:09 AM
Hi alanxie -
Have you read the Freescale document referenced at the beginning of the whitepaper? In section 1.4.3, it defines the CPHA=0 and CPHA=1 transmission formats explicitly and should provide answers to your questions. Additional information about timing is available in the Wikipedia article on the bus.
Also, here is the text of the VI documentation for "Timing info (ns).ctl":
"Contains bus timing parameters. All values are in units of nanoseconds, expept for SCLK Freq, which is in units of Hertz. Contents:
MOSI Setup - The data setup tiame for a bit written on the MOSI line
SCLK Freq - The frequency of serial clock pulses while transmitting bits
SCLK Hold - The "hold time" of the serial clock. This is the length of time that the clock is held for the slave device to be able to sample a bit written to the MOSI line. For example, when CPHA = 0 and CPOL = 0, this is the clock "high" time. When CPHA = 0 and CPOL = 1, this is the clock "low" time.
CS Lead - The time between assertion of a chip-select line and the first serial clock edge
CS Trail - The time between the last serial clock edge and deassertion of the chip-select line
CS Idle - The time between subsequent assertions of a chip-select line"
05-16-2011 08:27 AM - edited 05-16-2011 08:33 AM
I need to send 133 byte to a slave device. I am using the Digital Waveform library. I already read that the high-level Vi "send" transmitts only up to 64 bit and that I have to use the
low-level-Vis to build my own "send.vi". I took the high-level.vi as a reference but still wasn`t able to build a proper transmission.
I would be very grateful for any help...
05-16-2011 12:00 PM
Hi Katjk -
Here's an implementation that allows any number of bits per message. It takes an array of Digital Values Ring, which you can create from the connector on the VI. The length of the input array determines the length, in bits, of the message. It includes optional logic to do a sanity check on the input arrays; you may want to use that logic the first time you run a vector through the VI, then skip it afterward to make the VI run faster.
Here's a screenshot of the code in LV 2010, though the attachment was saved for LV 8.2:
When you look inside the LLB to drop this function on the palette, always grab the top-level VI. The first time you drop it, there'll be a search for your copy of SDW in user.lib, and probably some warnings that the dependency paths have changed.
05-17-2011 06:35 AM
Dear David, thank you so much for your reply!
I inserted the "Swap-any-length.vi" instead of the "Send-Mosi".vi into the DAQmx-CorrelatedDIO program.
The MOSI data takes an array of digital values ring. Does it mean I have to set all the bits manually that I want to transmit?( Ich have to transmit 133 byte!)
Is there any possibility to type in hexvalues?
05-17-2011 10:26 AM
Hi Katja -
I left that to you as a coding challenge. The VI I shared can be used in anyone's application. To make it more convenient for your software, you'll have to take your preferred instance of the "Interpret Data" VI and wrap it in a FOR loop to make it correctly interpret an array of integers. Since 1064 bits only divides evenly into an array of U8s, I recommend using the Byte instance of the VI to make it easier on yourself.
05-22-2011 01:59 PM
Hi David..thanks so much for your help!
I am able now to send any number of bits.....
I just have one last question....I need to make a pause( ms) of after a certain number of bits and then continue the transmission.
Could you give me a hint how to manage that?
Thanks in advance,
05-22-2011 11:47 PM
Hi Katja -
There could be lots of ways to do that, depending on exactly how your application has to behave. A pause of several milliseconds can be tough, because if you try to do it using waveform data you could create buffering problems for your program with really large waveforms, and if you try to do it with a retriggerable counter task the jitter of the Windows OS could affect the accuracy of your pause length.
Since you're doing correlated DIO on a DAQmx device, I would start by looking at the example programs in the NI Example Finder under "Hardware Input and Output > DAQmx > Generating Digital Pulses". Any of those code snippets can be used to create custom clocking behavior in place of the counter/timer code in the Serial Protocol Waveform examples. For instance, the Gen Dig Pulse-Retriggerable.vi example shows how to create a finite pulse train that can be regenerated over and over again. If you can find a way to provide that start trigger from a dependable source, it should let you define the behavior you need.
If you still can't figure it out, try posting in the Multifunction DAQ forum for help writing DAQmx code that works exactly the way you need it to. The people who monitor that forum are much better with DAQmx devices than I am these days.
06-01-2011 07:08 AM
I am new with LabVIEW and am trying to use this library in my first project. Can you tell me if this works with a nRIO that uses a NI 9401 module?
Also, in reading the article concerning this library I am uinsure about what the requirements are for SPI Timing and Bus Confgiuration. They look like clusters but what is the data that they are expected to contain?
06-01-2011 09:39 AM - edited 06-01-2011 09:39 AM
Hi Brian -
No, this library only works with Digital Waveform devices that use the NI-DAQmx or NI-HSDIO drivers. (Digital DAQ cards and High-Speed DIO cards.) The 9401 is a CompactRIO module, so you'll have to use a LVFPGA example to get SPI running on that platform. Try this one: http://zone.ni.com/devzone/cda/tut/p/id/9117
If you have questions about using your cRIO system, I would post them in the appropriate forum here: http://forums.ni.com/t5/Real-Time-Measurement-and/
Incidentally, the SPI Timing and Bus Configuration clusters are explained a few posts up in the thread, here: http://forums.ni.com/t5/Components/SPI-Digital-Wav
(Sorry about the dumb URLs. The post reply form freaked out and stopped creating hyperlinks for me, and I don't have the patience to edit the HTML directly. )