LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving values from VISA Serial Read to an array

Are you using that array later in the program?  I am just thinking your code could be simplified to this:

for(i=0; i<=99; i++)
{
    printf("%f\n", read_adc()*5.0/256.0);
}

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 21 of 24
(1,031 Views)

@crossrulz wrote:

Are you using that array later in the program?  I am just thinking your code could be simplified to this:

for(i=0; i<=99; i++)
{
    printf("%f\n", read_adc()*5.0/256.0);
}

Yeah I use the array to find the amplitude, and frequency. And also to graph the waveform.

0 Kudos
Message 22 of 24
(1,030 Views)

@JÞB wrote:

That explains a bit.

 

    printf("\r\n%f", (array[i]*(5.0)/(255.0)))

should be

    printf("%f\n", (array[i]*(5.0)/(256.0)+(5.0)/(512.0)))  //Assuming Vref=5V and 8 bit ADC (yes, you need to a 1/2lsb!) and printf now ENDs with the expected termination character rather than having it in the middle like that.


So I made the changes and did notice a few things. I have 2 read palletes in my code and the first one is for the array of values and the second one is for the amplitude, and frequency. So when the first read is executed, the array still only stores around 46 values. After that the second array with the amplitude and frequency is executed. After that is completed the values in just the second array disappear after a few seconds and when i try to flip the boolean switch to stop the program i get a "timeout experied before operation completed" error. 

0 Kudos
Message 23 of 24
(1,028 Views)

@engineerbeginner wrote:

@crossrulz wrote:

Are you using that array later in the program?  I am just thinking your code could be simplified to this:

for(i=0; i<=99; i++)
{
    printf("%f\n", read_adc()*5.0/256.0);
}

Yeah I use the array to find the amplitude, and frequency. And also to graph the waveform.


Inside of the pic?  That analysis should be done in your LabVIEW code.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 24 of 24
(1,026 Views)