04-17-2012 12:13 AM
Although I have a little bit of experience with labview I am fairly new to serial communication. I want to use my serial port and if needed a USB 6008 to control a digital potentiometer MCP4161. Unfortunately I don't have the budget to invest in other acquisition hardware so might have to work with what I have.
I see that it needs 3 inputs in order to change the resistance:
1) Clock in
2) Data read enable
3) The bits that correspond to wiper position (resistance).
I understand I can't get the clock output from the USB-6008? However is it possible to get this from the serial port? I could use a digital line on the USB-6008 as the read enable. The bits from the wiper position come from the serial port? (Does anyone have any suitable examples on this? I presume it would use VISA?)
Thanks in advance for your help. I think with a kick start I should be able to come up with a solution
04-17-2012 12:47 AM
04-17-2012 12:59 AM
Thanks Albert for your prompt suggestion.
Just to clarify. do you mean using two digital output lines? Could I just use one and send it high and low based on the frequency of my loop? (This is what you mean by software timing? ) Also with the output from the rs-232 port is there any examples you can point me to?
04-17-2012 08:07 AM
The SPI protocol requires 4 lines: Clock, MISO, MOSI, and Enable. If you are not reading data from a device then you can drop MISO. As Albert mentioned, you can use the "bit-banging" approach to create the clock and data out (MOSI) signal. The enable line can be a separate line.
I do not understand what you mean by serial out. The RS-232 lines have different voltages on them than what the digital pot would expect, since the voltages for SPI are not the same as for RS-232.
04-27-2012 03:09 AM
Hi, Finally understand what you mean. However I had a go at writing some code with little success
Attached is the code I wrote and the data sheet for the device I am trying to program. Any thoughts on where I could possibly going wrong would be helpful.
04-27-2012 03:53 AM
I did not check your complete program but the doubling of the data anyhow is wrong.
You best can do that where you write the outputs. Instead of writing out once write in an extra for loop inside the one you have now. the clock once straight and once inverted and twice the same data.
04-29-2012 11:14 PM
Once again thank you for your prompt reply. I dont completely understand your message and why looping through an array with digital values is different from looping through in a while loop and setting the values individually ? If this is what you mean?
So to make this process a little easier I improved the commenting on the code a little more. Also in the MCP data sheet I basically used the timing diagram on Pg 42 Figure 6.4. 16 bit SPI waveform mode 0,0. Relevant txt is from pg 45-49
I assume the first 6 bits are command bits and then the 7th bits is nothing and the final bit 0 is nothing (Dont understand why there are 9 bits in the diagram when it is only an 8 bit resistor).
So my pot is a 10k pot. When I run the code as is with a requested value of 6K its ok. But every other value is incorrect. I have a feeling it has to do with the order in which I am outputing each bit but again I am unsure what is wrong.
Thanks again for your help.
04-30-2012 05:57 AM
to give you an idea what I meant I changed your program but did not check it against the pot meter spec.
I expect some bits to be wrong because of my simplicity in converting your program but the idea makes it simpler.
One of the problems I had with the fact that the clock was not generated as a real clock in the beginning and the end.
This can better be solved by writing digital bits before and after the for loop that writes now.
anayhow it show what I mean.