LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Is this correct?

Solved!
Go to solution

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:

QQ截图20120615221621.jpg

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.

0 Kudos
Message 1 of 28
(8,102 Views)

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.

Message 2 of 28
(3,571 Views)

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.....

0 Kudos
Message 3 of 28
(3,571 Views)

Are you implying that you got it to work?

0 Kudos
Message 4 of 28
(3,571 Views)

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

0 Kudos
Message 5 of 28
(3,571 Views)
Solution
Accepted by Rocky1989

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.

Message 6 of 28
(3,571 Views)

Nathan, I think command format is what I need! I will test it and give you the result soon! Thank you

0 Kudos
Message 7 of 28
(3,571 Views)

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.

0 Kudos
Message 8 of 28
(3,571 Views)

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.

0 Kudos
Message 9 of 28
(3,571 Views)

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?

0 Kudos
Message 10 of 28
(3,571 Views)