06-15-2012 10:22 PM
Sorry for repeating same question here. I stucked by SPI with MCP4822 for one week. I tried so many ways. Still, I cannot control output voltage using MCP 4822 through SPI. I would like to clearify details to see if someone could help me out.
1. The Command of MCP 4822
From Datasheet, I got to know that MCP4822 is 16-bit DAC,which has 2 output DACa, DACb
bit 15: select DACa or DACb(0/1)
bit 14: Don't care
bit 13: Output Gain Mode, 2X or 1X(0/1)
bit 12: Output Power Down control
bit 11-bit 0: 12 bit voltage
So. if the command is 0B00101111 11111111(47 255), it means, I select DACa with 1X gain and output buffer disabled.
2. In my project, I would like to control bit11-bit0 on labview to get an ouput analog voltage. Here is my VI:
3. My confusing part is SPI send/receive VI, SPI data parameter. It is defined as 1D-array of U8. So. I convert binary to dec. Should I do this? Or I sould input array and each element is each bit in command.
Thank you everyone.
Solved! Go to Solution.
06-16-2012 12:56 AM
Did you give up already on the custom function method? If that example code worked then it should work with LabVIEW. I've done it with the quadrature encoder library and it worked perfectly. Just post your custom LIFA firmware files in the other thread and I can take a look at them.
Also, if you use descriptive topic titles it will be much more helpful to everyone.
06-16-2012 10:08 AM
Hi, I tried that. And write emails to the author still waiting for his reply....
NVM. I think I misunderstood the send/write SPI VI.
Thank you for advice. I am a rookie here.....
06-16-2012 10:31 AM
Are you implying that you got it to work?
06-16-2012 10:36 AM
Nope.........I think this is the most direct way. The official document gives so limited of each input. Just 1D array of 8-bit unsigned integer is the SPI data. Now , the question is,
if the data I want to send is like 01111 1111 1000 1111. What this array should be? Do you know any about this? I am not good at bit math. So it is a little bit tricky for me
06-16-2012 03:21 PM
Did the arduino code/library work correctly when using the test program? It yes, then you could try this new library that I made for LabVIEW. It is based on the arduino library for this device.
06-16-2012 03:28 PM
Nathan, I think command format is what I need! I will test it and give you the result soon! Thank you
06-16-2012 04:26 PM
Don't prematurely assume that my post is the final answer because I can't test it.
Also, don't just use the format function because there were other things wrong with your code. You should be able to use it like the example that I have included.
06-16-2012 09:28 PM
OK, I have tested it. The example run perfectly. What do you mean
Also, don't just use the format function because there were other things wrong with your code.
I tested through a Ossciliscope so there might be some noise. Also, I would like to add one LCD to show the output voltage.
Well, this is only the first component of whole project. If you are interested, I can tell you more about my project.
06-16-2012 10:32 PM
Hi, Nathan,
I have question here after reviewing your VI design. I understand MCP4822's 16-bit command format. Why you and MCP4822 library's author set the command one by one, instead of passing in a 16 bit command directly?