Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

control digital potentiometer SPI

hello 🙂

 

I need to control digital potentiometer AD8402 with NI USB6008, so it will be write operation. I understand USB6008 can't generate clock output for SPI and someone suggests that I should use Arduino for controlling digpot and use labview for user-interface but it seems inefficient.

 

I read this thread that have similar problem with me and it says to use RS232 but I still have no idea how to do it.. 

 

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Rs-232-digital-potentiometer-using-SPI-and-US...

 

I attached the code I wrote, the data sheet for the device I am trying to program, and a code I found on the web

 

I really appreciate any kind of advice and help

thank you

 

 

 

Download All
0 Kudos
Message 1 of 14
(5,930 Views)

Hi

You don't need a clcok generator but you can build a clock signal on a second line.

In fact when you double the output bits, you can have a clock high and low for each bit by another digital output.

 

In this way with two lines you can output all you want at he speed you want (not as fast as you like maybe but fast enough.

So no daq assistant vi's but simply build two digital waveforms and output them with the same speed (e.g. by writing two bits out in a for loop for the complete train of bits)

greetings from the Netherlands
0 Kudos
Message 2 of 14
(5,926 Views)

thank you for your prompt answer Albert.Geven

  

Another question, how do I synchronize 10-bit serial output digital potentiometer with 12-bit USB6008?

 

thank you

0 Kudos
Message 3 of 14
(5,924 Views)

Sorry but that makes no sense to me. What 10-bit serial output are you talking about? And are you referring to the 6008 analog input's 12-bit resolution? Since you are only using a couple of lines of the digital port, I don't see how 12 total lines is relevant either. And in either case, you said you were going to just write to the device.

0 Kudos
Message 4 of 14
(5,900 Views)

Hi Dennis

the format data of AD8402 is two address bits and followed by eight data bits. So everytime the clock loads data is consist of 10-bit serial register. However USB6008 is a 12-bits device. Someone told me that the bits count in every device of the system should've been at same value in order to send the data

I'm sorry if this is confusing you, idk how to explain my point well enough

thanks

0 Kudos
Message 5 of 14
(5,896 Views)

It is a serial interface. Your 10 bits of data is clocked in one bit at a time - from a single data line and a single clock line. Where do you see parallel data lines? The fact that the 6008 has more lines than you can use is irrelevant. You might want to spend a bit of time researching exactly what an SPI interface is.

0 Kudos
Message 6 of 14
(5,889 Views)

hi dennis,

I have the idea of clocking one bit at a time, to make the clock of labview as master and digpot as slave configured correctly from same line

what if I use IC timer N555 to generate the clock instead? Will it work?

 

I worked on the programming but I haven't got the correct signal setting, any advice would be very helpful

thankyou

 

0 Kudos
Message 7 of 14
(5,853 Views)

You can only do software timed DO with the USB-6008. That means it will not respond to any hardware clock, whether generated by the DAQ device or by the 555.

 

It appears that the AD8402 SPI port is static, not dynamic.  So you could possible do everything wthe the USB-6008 DO lines.  To meet the setup time requirements the data values will need to be written before the clock transitions. So it will take three DO writes for each serial bit, plus possibly one or two extras for the CS line. The specification for the USB-6008 indicate that the software times AO can update a maximum of about 150 Hz. The DO update rate is not specified but is probably similar. Because it is software timed there will be timing jitter on the order of milliseconds or longer. At that rate you could send one complete update to the AD8402 in about 0.21 seconds.  If this is fast enough for your system, then the USB-6008 may be used.

 

I would put all three signals, CS/, Clock, and SDI, into one DO task and write all three with one write.  You triple task method will not work because of the software timing and is much more complicated than is needed.

 

Lynn

0 Kudos
Message 8 of 14
(5,836 Views)

Hi lynn,

 

I'm getting a bit idea of what you mean and try to follow your suggestion but I still don't know to put all of them into one write.

 

I found great example of using SPI in labview, but I'm not sure if it can be applied with USB60xx. What LPT is for?

 

Also, I quite not understand about the wiring, where should I put A, B, Wiper, and SDI pin into the USB?

 

Thank you very much

 

 

0 Kudos
Message 9 of 14
(5,807 Views)

That appears to use a parallel port, which most computers no longer have.  It is also not in a recommended style.  The use of stacked sequence structures and local variables is discouraged.  I do give it good marks for documentation.

 

On the USB-600x you can write to several digital lines simultaneously by writing an integer value to the port.  So you could assign CS/ to bit 0, Clock to bit 1, and data (SDI) to bit 2. The first write would have b00000001 to set the CS/ high. Then b00000000, b00000100, b00000110, b00000100, ...  This series of four bytes written to the DO port would set the data bit high then take the clock high while keeping the data bit high and then take the clock low again. The data bit could be changed with the last of those bytes for the next cycle. After the last data has been written write a b00000001 again to take CS/ high.

 

Lynn

0 Kudos
Message 10 of 14
(5,799 Views)