LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incrementing a 1D Array of Unsigned 8 Bit Integers

I have a fairly simple program to test DAC IC's. Currently I'm able to communicate to the IC via I2C protocol and I'm able to adjust the analog output by sending a 1-D Array of unsigned 8 bits (0-255). My goal now is to make this an automated program. The problem I'm facing is incrementing the array data by 1 bit until I reach 255, at this point the program will jump out of the for loop and increment the device ID establish communications with new device and and repeat test for incrementing bits from 0-255. 

0 Kudos
Message 1 of 8
(4,017 Views)

Post your VI.

 

You should be able to add +1 to the value in your array to increment it by one bit.

0 Kudos
Message 2 of 8
(4,015 Views)

I attached my vi...I'm trying to change the Data write controller to automatically update from 0-255

0 Kudos
Message 3 of 8
(3,999 Views)

You have several issues:

  • You should not be performing a Find, handle open, setting the bitrate, and closing the handle inside the innermost loop. These should all be done outside the loops. Both of them.
  • You have no execution depending between the write and the DAQ read. How do you know which one will occur first? Use the error wire to establish data dependency to make sure the DAQ read occurs after you write.
  • You have no delay between the write and the read. Surely you need to wait a certain amount of time. Use the Time Delay VI to insert a delay between the write and the read.
  • You are not actually incrementing anything. Are all array elements supposed to be incremented by 1, or just some of them? If it's all of them, then you can simply add the iteration index to the array to add 1 in each iteration. If it's just some, then you need to replace specific array elements with incremented values.
Message 4 of 8
(3,985 Views)

,

 

Thanks for your reply. I've attached my updated vi...tell me what you think

Download All
0 Kudos
Message 5 of 8
(3,965 Views)

You can use a couple of For Loops with autoindexing enabled to build the arrays based on the i iteration terminal.

0 Kudos
Message 6 of 8
(3,955 Views)

 and Raven Fan,

 

I appreciate your help, I got it working!

 

Now the next step for me is to plot the analog output on a graph but have it save the previous reading so at the end of the for loops the graph will look like stair steps similar to what I've attached. Any ideas on how to do this? The Y-axis will represent the amplitude and the X-axis will represent the bit value. I'm testing an 8 bit DAC so that gives me 256 bits to test. Any suggestions?

 

Again thanks for the help.

Download All
0 Kudos
Message 7 of 8
(3,939 Views)

By the way, there is no need to add 0 to a number.  You wind up with the same number! Smiley Wink

 

If you want to keep the history of past data points, you want a waveform chart, not a waveform graph.

 

If you want it to look stair-stepped, that is one of the porperties you can set for the plot on the chart.  Right click the chart and select properties.

0 Kudos
Message 8 of 8
(3,934 Views)