01-12-2017 05:51 PM - edited 01-12-2017 05:51 PM
I made a few more mods. So Jeff added in some error handling (which was needed). I cleaned some things up and a few other things.
1. No real need for the Wait in there. You have a 10 second timeout on your VISA Reads. So let the VISA Read limit your loop rate.
2. Replace your Stop Switch with a Stop Button. It makes a lot more sense and can reset itself when read (a feature called Latching).
3. Change your array to be of numeric instead of strings. This way you are not constantly reconverting all of the previous measurements.
My main curiosity is that you have a dt of 300us (what you claim to be your sample rate), but your wait was 333ms. That is a large difference and I think the dt is wrong (I don't see serial data getting out that fast).
01-18-2017 02:30 PM
Sorry for the late reply but the array only stores 46 values and I'm not sure why it does that. I wanted to save 100 values but not sure how to go about it.
01-18-2017 02:37 PM
@engineerbeginner wrote:
Sorry for the late reply but the array only stores 46 values and I'm not sure why it does that. I wanted to save 100 values but not sure how to go about it.
Need to see code...
01-18-2017 02:45 PM
Don't have access to labView right now but check out the vi posted by user Jeff Bohrer at the bottom of the first page. Thanks!
01-18-2017 02:48 PM
I also tried out your version but it still oly stores around 45-46 values in the array 😞
01-18-2017 03:14 PM
@engineerbeginner wrote:
I also tried out your version but it still oly stores around 45-46 values in the array 😞
After the 45-46 values get stored what happens?
Does the vi quit with an error? what error?
Does the vi continue to run? What is received from the reads? Are you sure? did you display the strings as \codes or in Hex? What are you expecting from the device on the other end? Is the compiler generating that many messages?
01-18-2017 04:31 PM
It does keep running but after a few seconds all the values disappear and after a while an error message pops up. The last time I checked the error I believe it was a timeout error. I have not displayed the code in \codes or in Hex but I plan on doing so tomorrow. On the ccs complier at the other end my code is something like this:
int i, array[100];
for(i=0; i<=99; i++)
{
array[i] = read_adc();
}
for(i=0; i<=99; i++)
{
printf("\r\n%f", (array[i]*(5.0)/(255.0)));
}
01-18-2017 04:48 PM - edited 01-18-2017 04:50 PM
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.
01-18-2017 05:26 PM
Alright I will try that out and update you tomorrow. Thanks for the reply!
I used (5.0/255.0) because that's what was mentioned on the PIC developmental kit I was using about how to get the voltage values from the adc readings.
01-18-2017 05:50 PM
@engineerbeginner wrote:
Alright I will try that out and update you tomorrow. Thanks for the reply!
I used (5.0/255.0) because that's what was mentioned on the PIC developmental kit I was using about how to get the voltage values from the adc readings.
They should know better! there are 256 steps from 0 to 5 volts assume your actual voltage is 1/2 way between two steps rather than on the edge..