LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Negative array index

This is the problem:

I am acquiring with the PCI P1002L from ICP-DAS.
Well, I am running it with NT so I have installed the board NT driver and DLL.

The present project was created in labWindows 6.0 but only with clasic controls.
This mean that you can debug it from both versions (this and previous version).

But it doesn't works with both versions. It works with the older (5.5) but not with newer (6.0). The pity is that I realised it very late, because I use a lot of
"Lab Style" controls in my application and it is very complicated to turn back to 5.5.

Like it works with LabWindows 6.0:
I can't acquire more than 3 channels!. When I try it, an error message appears: "Negative array index (-534509365)"
And the item that drives me
crazy is that the "array index" have a zero value!!!

Is there somebody that could help to me, please?
I am desperate.

Thanks.
0 Kudos
Message 1 of 5
(3,044 Views)
I have more questions than answers.
1. The CodeError.jpg file says that 4 errors occured, but it's scrolled down to the last two. What were the first two errors?
2. You say you can't acquire more than 3 channels. Do you know that the problem is the total number of channels and not just the channel number? Have you tried talking to channel 0x7 first to see if that works?
3. Have you looked at the return value of P100X_AdsPolling()? E.g.
WORD wPollingResult;
...
wPollingResult = P100X_AdsPolling(poll, 20);
4. Have you stepped into P100X_AdsPolling? Do you know that it's not corrupting memory?
5. Have you tried casting 20 as WORD or passing a WORD rather than a constant?
6. Have you stepped through the for loop where the error occurs and watched the value of i
and average?
7. What is the value of times when the error occurs?
8. Do you know if you need any delay between talking to channels?
9. Are you sure that you're not polling too fast on every EVENT_TIMER_TICK?
Sorry that this wasn't exactly a top 10 list.
0 Kudos
Message 2 of 5
(3,044 Views)
Hi,

Oh!, thanks for your long answer full of questions :-). I have tried to answer all your questions.

>>1. The CodeError.jpg file says that 4 errors occured, but it's scrolled down to the last two. What were the first two errors?

These are the same errors, exactly the same: LabWindows fails in a NON-FATAL RUN-TIME ERROR and ask to me if I want or . The same error item at "Run-Time Errors Window" appears each time I click on , until I click on . (At this example I clicked on three times and then once on


>>2. You say you can't acquire more than 3 channels. Do you know that the problem is the total number of channels and not just the channel number? Have you tried talking to channel 0x7 first to see if that works?

Yes, I thought that maybe the board documentation was wrong, and I tried exactly you say. The channel acquisition order was 7, 4, 5, 6. It failed at channel 6 then.


>>3. Have you looked at the return value of P100X_AdsPolling()? E.g.
WORD wPollingResult;
>>...
>>wPollingResult = P100X_AdsPolling(poll, 20);

I have looked at this now, and the result is always 0, that corresponds to P100X_NoError (p100X.h)


>>5. Have you tried casting 20 as WORD or passing a WORD rather than a constant?

I have tried both of them: casting 20 as WORD
- (WORD) 20
and passing a WORD constant,
and the result is the same.


>>6. Have you stepped through the for loop where the error occurs and watched the value of i and average?
>>7. What is the value of times when the error occurs?
Yes, it stop at first, when the i value is 0 and average is 0.000. I mean that NEVER does the operation inside

(average+=poll[i]/20) correctly
Furthermore, I say NEVER because times has the value of 1.


>>8. Do you know if you need any delay between talking to channels?

The documentation board doesn't point this feature, and I think that it would be something so important that it would point this if the feature would exist.
Anyway, I send you board library documentation in pdf.


>>9. Are you sure that you're not polling too fast on every EVENT_TIMER_TICK?

Do you mean that, probably, the acquisition is very slow and labwindows try to launch another EVENT_TIMER_TICK before that previous acquisition finishes?
I think it isn't, because I put the Timer Control interval at 5 seconds, and the problem not disappears.


>>4. Have you stepped into P100X_AdsPolling? Do you know that it's not corrupting memory?
How can I know this?


Remmember that I can run the same project with LabWindows 5.5 but not with LabWindow 6.0.
Any idea/question more?, thanks again.
0 Kudos
Message 3 of 5
(3,044 Views)
1. >>>>4. Have you stepped into P100X_AdsPolling? Do you know that it's not corrupting memory?
>>How can I know this?
I see now that P100X_AdsPolling is in the DLL from ICP-DAS, so you can't step into it (without the source code). But you can still check if memory is corrupted: in your last message you already checked that average = 0 and i = 0. Since these are after poll[], I was looking to see if they were corrupted. average=0 after the P100X_AdsPolling call is a good sign that P100X_AdsPolling isn't corrupting memory (a function operating on a passed array is more likely to corrupt memory immediately after the array) but you can try an average value other than 0 to verify it.

WORD wP100Xreturn;
...
wP100Xreturn = P100X_SetChannelConfig(0x07, 0x01); //Rango +-5v
if (wP100Xreturn != P100X_NoError)
return wP100Xreturn;
// set average to arbitrary value to make sure
// that P100X_AdsPolling doesn't change it
average=123.456;
wP100Xreturn = P100X_AdsPolling(poll, 20);
// put a breakpoint on the if() and check
// that average = 123.456
if (wP100Xreturn != P100X_NoError)
return wP100Xreturn;
average = 0;
// check average again

2. While at the breakpoint immediately after P100X_AdsPolling, right-click on poll[] and select View Variable Value. Does it have twenty values that look right?
3. It's curious that the LabWindows calls this a non-fatal error. That means it's willing to continue. Select break every time you're prompted and check average and i, then continue. Does i increment up to twenty? Does the average look good?
4. I didn't see a limit on the number of channels in the board library documentation. Have you asked ICP-DAS?
5. Does the project still run under LabWindows 5.5? You said the project was developed in 6.0. I thought you couldn't run it in 5.5. Have you tried rebuilding it in 5.5 before debugging it?
6. If it still under 5.5, is it on the same PC or a different PC? If different, is it the same version of Windows?
0 Kudos
Message 4 of 5
(3,044 Views)
Hi again,

>>I see now that P100X_AdsPolling is in the DLL from ICP-DAS, so you can't step into it (without the source code). But you can still check if memory is corrupted: in your last message you already checked that average = 0 and i = 0. Since these are after poll[], I was looking to see if they were corrupted. average=0 after the P100X_AdsPolling call is a good sign that P100X_AdsPolling isn't corrupting memory (a function operating on a passed array is more likely to corrupt memory immediately after the array) but you can try an average value other than 0 to verify it.
...
>>2. While at the breakpoint immediately after P100X_AdsPolling, right-click on poll[] and select View Variable Value. Does it have twenty values that look right?

Well, I forced average to 123.456 before AdsPolling and, it mantained this value after this.
And, poll[] array had twenty right values (I know what is the voltage applied to this channel).
Like you told me, I forced average to 0 before the for loop and it had the 0 value before execution launched the for loop.
I think P100X_AdsPolling isn't corrupting memory, then.


>>3. It's curious that the LabWindows calls this a non-fatal error. That means it's willing to continue. Select break every time you're prompted and check average and i, then continue. Does i increment up to twenty? Does the average look good?

Yes!!!!!!!!!!, I increment up to twenty (well 0 to 19, you know), and the average is all right at every step!!! And, when the loop finishes, start another EVENT_TIMER_TICK (I know this because the 'times' variable has the value 2)


>>4. I didn't see a limit on the number of channels in the board library documentation. Have you asked ICP-DAS?

Oh!, I am sorry, I gave you an inapropiate manual. This one is the apropiate one. You can see, for example, at page 4:
"PCI-1002H/L provides 32 channels s-e analog inputs or 16 channels differential analogs inputs which are jumper selectable..."


>>5. Does the project still run under LabWindows 5.5? You said the project was developed in 6.0. I thought you couldn't run it in 5.5. Have you tried rebuilding it in 5.5 before debugging it?

To avoid errors, I do the next:
- I deleted the 'p100xACPR_dbg.cdb' and 'p100xACPR_dbg.exe' files and the 'cvibuild.p100xACPR' folder.
- I marked the 'Build->Mark All for Compilation' option at Project Window
- I click the 'Build->Create Debuggable executable' otion at Project Window. The debuggable executable creates without problems.
I debugged it and the application behaviour is the same than before.


6. If it still under 5.5, is it on the same PC or a different PC? If different, is it the same version of Windows?"

The PC is the same, under the same Windows version (NT). I mean that I have both versions installed at a time.



I became surprised when I reproduced the 3rd item because I thought that average not got the correct value, Do you think it can be a good trail?
0 Kudos
Message 5 of 5
(3,044 Views)