This function has been using in the old code. Now, that we put a program in the new hardware we have a problem with data collection that is offset by some number. One probably reason is timing issues. Our delays range from 0.1 to 5 seconds - nothing extreme.
1 2 3 4 5 6 7 8 9 10 11
void delay(float elapse) // delay for elapse seconds
{
long i,j;
float delta=1.0e-3;
HANDLE timerobject;
i= (long)(elapse/delta); // interval in milisec
timerobject = CreateWaitableTimer(NULL,TRUE,NULL);
WaitForSingleObject(timerobject,i);
CloseHandle(timerobject);
}
1 2 3 4 5 6 7 8 9 10 11
void step_125(void) // this is Z-axis stepping motor
{
int i;
outbyte_isa(V_PORT_C,0x00);
for(i=0;i<STEPNUMBER;i++){
outbyte_isa(V_PORT_C,0x20); // toggle the 5th bit in port C
delay(0.1); // wait for 0.1 sec
outbyte_isa(V_PORT_C,0x00);
delay(0.1);
}
}
If I understand correctly (I am not sure) your application seems to depend on windows to tell it when the delay is over. If there is a good reason for this you should keep it, but otherwise you might want to check out the possibilities of std::thread and std::chrono to implement the delay in your program and thus keep it more independent of the operating system.