LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi,

 Hi,
    This is regarding the head tracker problem again. I have attached my code.
I tested the software with the headtracker again and the problem doesnt go. I did set user_seln==1 as u mentioned in your previous mail
 
The thing is when i put the lines
}        /*closing brace for if(birdframeready)*/
ProcessSystemEvents;
GetCtrlVal (mpanel, MPANEL_DATAFLOW, &user_seln);  
        }while(user_seln==1);           /* loop until selection is 1*/
    
the head tracker data flows and again i just cannot access the uir.
 
Also if i put the lines as
 
ProcessSystemEvents;
GetCtrlVal (mpanel, MPANEL_DATAFLOW, &user_seln);  
         }          /*closing brace for if(birdframeready)*/
}while(user_seln==1);           /* loop until selection is 1*/
i get the error    
NON-FATAL RUN-TIME ERROR:   "NEW2.c", line 248, col 8, thread id 0x000003DC:   Local 'user_seln' was referenced before being initialized.
 
I have tried a few other things but i still cannot access the uir. once data starts flowing in. The contol mode of the button DATAFLOW is set to hot. I think that is right.
Could u suggest something
0 Kudos
Message 11 of 18
(1,912 Views)
Hi,
    I tried using the timer callback to get the headtracker working. however the program stays on the uir screen and no data output takes place. i does not hang. there is a toggle switch i have used to set data flow(DATAFLOW).i wonder if it because i have set the timer to 8 ms. I have attached a copy of my code
 
Also i have set the control mode for DATAFLOW as hot.
do u think it is the timer set to 8 ms that is causing the problem,
waiting for a reply
 
0 Kudos
Message 12 of 18
(1,907 Views)

With reference to program2

The first solution you have posted is the right one: user_seln is filled with a proper value at every iteration of the loop. In your second solution, if birdFrameReady is not true the variable is not filled with any value when tested in the while clause, so the compiler warns you for this. You could avoid this warning inizializing user_seln to 0 when declaring it, but in your aplication you do need to test the button at every loop iteration so you need to run the first structure of code.

Which type of button is MPANEL_DATAFLOW? Since it's probable that your loop is quite long lasting, you may not find the button in the correct state when you test it if you use a standard button: I suggest you use a toggle button instead, so that its state is maintained once pressed and whenever the program has time to test it, it finds it in the right state. Of course you will need to reset its state when exiting the loop with SetCtrlVal (mpanel, MPANEL_DATAFLOW, 0);

 

With reference to program11

Is MPANEL_DATAFLOW the button to which GETHEADTRACKERDATA callback is associated? If so, you need to test its value to start acquisition only when it is true (a toggle button fores a EVENT_COMMIT event every time its state is changed!).

Looking at the code it's not simple to detect what's happening: you may need to place  breakpoint inside the timer callback on birdStartFrameStream row so that if the timer is running the correct way the program will break when acquisition is enabled.

In my opinion you should place acquisition stopping routine outside the timer callback: the way it is structured now, it will execute birdStopFrameStream and birdShutDown at every execution if timerflag is 0!

Try this different approach:

GETHEADTRACKERDATA (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
static char pathname[MAX_PATHNAME_LEN], dirname[MAX_PATHNAME_LEN];
int status;
   
int user_seln, sts;

if (event == EVENT_COMMIT)   { 
  GetCtrlVal (panel, control, &sts);
  if (sts) {
    HidePanel(panel2);  
    GetCtrlVal (panel2, PANEL_2_SAVEDATA, &fileFlag);
    if (fileFlag) {  /*Save data is fileFlag is enabled*/
      GetProjectDir (dirname);
      status = FileSelectPopup (dirname, "datafile.txt",
                               "Datafiles (*.txt)", "DataFile Storage",
                                VAL_SAVE_BUTTON, 0, 1, 1, 1, pathname);
      datafilestream = fopen (pathname, "w+");
      DisplayPanel (mpanel);
  }
  else {
    birdStopFrameStream(GROUP_ID);   /*Stops streaming of bird data frames*/
    birdShutDown(GROUP_ID);
    // Add all necessary instructions to stop the acquisition

  }
return 0;
}

Message Edited by Roberto Bozzolo on 06-13-2006 09:18 AM



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 13 of 18
(1,899 Views)
Hi,
   I was using a binary switch before this . now i have replaced it with a toggle switch. i have set the initial stateo f the toggle switch to ON. Again the same thing happens. data flows out of the headtracker and i can see the data changing on the numeric indicators on the uir... however i cannot access any button on the uir. . This is the way my code looks now.
 
}
ProcessSystemEvents;
GetCtrlVal (mpanel, MPANEL_DATAFLOW, &user_seln);  
         /* end if frame ready routine */
}while(user_seln==1);           /* loop until selection is 1*/
SetCtrlVal (mpanel, MPANEL_DATAFLOW, 0);
Also my headtracker is running at 120Hz(8.3 ms). Coulds that be the reason for it. I am not really intrested in interrupting data flow in between. What i am looking for is to set offset correction at a paricular point when the data is flowing. I mean once i think the X,Y,Z coordinates are appropriate during data flow i should be able to able to press the command button for OFFSETCALLBACK. Once i think i want to stop it i should be able to press the command button for OFFSETSTOPCALLBACK to interrupt offset correction.
I will try working with the timer code again and let u know.
Thanking you for all your help
 
0 Kudos
Message 14 of 18
(1,881 Views)

Hi,

    Also as i was mailing u i thought of using this idea using C programming. Although it would not use labwindows i could still achieve offset correction.

int i=0

do{

//instructions for initialising the headtracker

if(i=2000)

{

//instructions for offset correction

}

//instructions for printing value to screen

i++;

}while(user_seln==1);

since the headtracker streams data at 120 Hz or 8.3 ms each time it executes do loop it will be incremented by 1. so by i=2000 it would give operator about 16 sec to set the headtracker at correct postion before offset correction starts. Also the offset correction would be set only once at i=2000. Do you think it is a good idea. However it still doesn't solve the problem of gaining control over my uir.. and using the switch DATAFLOW still if of no use. I still have to try my above mentioned code as i would be in my lab by evening. However could u suggest some more modifications on the same. The only thing i feel using it is that it would not be user friendly.Do you have something in labwindows that could better it 

Kunal

 

0 Kudos
Message 15 of 18
(1,876 Views)
Kunal, look at the sample project I add: it clarifies some possible structures for your acquisition loop (an actual loop with ProcessSystemEvents vs. acquisition with a timer). I have added some comments as to where the code for communication with the headdtracker should go: this should guide you in debugging your code.
You could also try setting a conditional breakpoint on your while loop condition and step-through your code in case user_seln == 1.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 16 of 18
(1,871 Views)
Hi,
   Its finally working. Thanks a lot Roberto for your help. I guess i was going wrong on one of the command buttons i had set. I sed the processsystemevents one to build my application. Really appreciate it. Thanks again
kunal
0 Kudos
Message 17 of 18
(1,854 Views)
Unfortunately I have not had much free time the last few days, but nice job getting to a solution Roberto. 
To follow up on a few things, the 8mS acquisition cycle will cause the same kind of problems in a user loop as it does when called by a timer, so no that was not the problem.  It looks like the timer version of the program had the exact same issues as the loop version.  Moving the initialization and shutdown outside the timer loop and changing the button control type probably would have fixed the timer version as well.  Anyway,  I'm happy to see you got it working kunal, and that you could work through the process here on this forum without getting too frustrated (I hope).  I also hope the solution you found works well for you. 
 
Good Luck
0 Kudos
Message 18 of 18
(1,829 Views)