thrust8
asked on
Delphi, error message
hi all,
I encountered a problem While runing my program. Namely program shows error message:'invalid driver handle failed' then hangs up.
In a brief. Program is supposed to send every 15 ms an impulse via digital output of advantech card (card im trying to communicate with). Impulse range is 1 to 2 ms. Basis of servo control.
Problem has something to do with Timer. when event is assigned to Timer - problem occurs.
I cannot attach program files, guess i can send that only individually.
Thank you.
I encountered a problem While runing my program. Namely program shows error message:'invalid driver handle failed' then hangs up.
In a brief. Program is supposed to send every 15 ms an impulse via digital output of advantech card (card im trying to communicate with). Impulse range is 1 to 2 ms. Basis of servo control.
Problem has something to do with Timer. when event is assigned to Timer - problem occurs.
I cannot attach program files, guess i can send that only individually.
Thank you.
ASKER
This is where you can download Main program (servo_new): http://www.megafileupload.com/en/file/69418/servo-new-zip.html
(wait 24 seconds to download)
And here is DO_SOFT program of howto communicate with advantech:
http://myfreefilehosting.com/f/8005f9598f_0.1MB
(wait 24 seconds to download)
And here is DO_SOFT program of howto communicate with advantech:
http://myfreefilehosting.com/f/8005f9598f_0.1MB
i don't have any time to look for a needle in a haystack ...
just paste the code where you are getting the error.
run in Delphi and check "Stop on Delphi exceptions"
just paste the code where you are getting the error.
run in Delphi and check "Stop on Delphi exceptions"
ASKER
Truth be told, i dont know where im getting the error. Everythig compiles ok, right after running it shows the error.
this is Timer code:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not update_running then updateservo;
end;
and this is updateservo procedure:
procedure TForm1.updateservo; {every 18 - 20 msec : see timer}
{var myjoy: tjoyinfo; }
begin
if disableservocheck.checked then exit;
update_running := true;
{if stickbox1.checked then
begin
outvalue(1); {on}
delay(trackbar1.position*1 0);
outvalue(0); {off}
outvalue(2); {on}
delay(trackbar2.position*1 0);
outvalue(0); {off}
outvalue(4); {on}
delay(trackbar3.position*1 0);
outvalue(0); {off}
outvalue(8); {on}
delay(trackbar4.position*1 0);
outvalue(0); {off}
update_running := false;
end;
update_running is set as global variable
update_running: boolean;
how can i check 'stop on delphi exceptions'?
this is Timer code:
procedure TForm1.Timer1Timer(Sender:
begin
if not update_running then updateservo;
end;
and this is updateservo procedure:
procedure TForm1.updateservo; {every 18 - 20 msec : see timer}
{var myjoy: tjoyinfo; }
begin
if disableservocheck.checked then exit;
update_running := true;
{if stickbox1.checked then
begin
outvalue(1); {on}
delay(trackbar1.position*1
outvalue(0); {off}
outvalue(2); {on}
delay(trackbar2.position*1
outvalue(0); {off}
outvalue(4); {on}
delay(trackbar3.position*1
outvalue(0); {off}
outvalue(8); {on}
delay(trackbar4.position*1
outvalue(0); {off}
update_running := false;
end;
update_running is set as global variable
update_running: boolean;
how can i check 'stop on delphi exceptions'?
menu Tools / Debugger options / Tab Language Exceptions
change the following :
this will make sure that when you do get an error in the routine,
update_running flag will be set correct
change the following :
this will make sure that when you do get an error in the routine,
update_running flag will be set correct
procedure TForm1.updateservo; {every 18 - 20 msec : see timer}
{var myjoy: tjoyinfo; }
begin
if disableservocheck.checked then exit;
if not update_running then
begin
update_running := true;
try
{if stickbox1.checked then
begin
...
finally
update_running := false;
end;
end;
end;
ASKER
This is how i changed it:
procedure TForm1.updateservo; {every 18 - 20 msec : see timer}
{var myjoy: tjoyinfo; }
begin
if disableservocheck.checked then exit;
if not update_running then
begin
update_running := true;
try
........
finally
update_running := false;
end;
end;
end;
and still nothing.
'Stop on delphi exceptions' was checked all the time.
procedure TForm1.updateservo; {every 18 - 20 msec : see timer}
{var myjoy: tjoyinfo; }
begin
if disableservocheck.checked then exit;
if not update_running then
begin
update_running := true;
try
........
finally
update_running := false;
end;
end;
end;
and still nothing.
'Stop on delphi exceptions' was checked all the time.
what do you mean with hang.
Can you pause the process in delphi after hangup ?
Can you pause the process in delphi after hangup ?
ASKER
Right after doubleclick on .exe file, the program shows that error message, and is idle, I cannot do anything with it, and need to close application outside Delphi.
I can pause it in delphi.
I can pause it in delphi.
what does the stack show ?
use Ctrl-F3
it maybe in a initialization section of one of the units
use Ctrl-F3
it maybe in a initialization section of one of the units
ASKER
Shows 'process is not accessible'
lol, pause it first, then call stack
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
my bad..
_RDTSC((2044583639, 10140))
_ReadTSC(???)
ReadTSC(???)
ReadCycles((4,3550977806e+ 13, 159, 4,3553012965e+13))
ReadSeconds((4,3550977806e +13, 159, 4,3553012965e+13))
delay(1470)
TForm1.updateservo
TForm1.Timer1Timer(???)
Servo
_RDTSC((2044583639, 10140))
_ReadTSC(???)
ReadTSC(???)
ReadCycles((4,3550977806e+
ReadSeconds((4,3550977806e
delay(1470)
TForm1.updateservo
TForm1.Timer1Timer(???)
Servo
does anything work if you change the routine delay to
use sleep(xxx) ?
use sleep(xxx) ?
what i don't understand is, it looks like you want an accurate timer control
but you use 5 calls to accomplish this ?
you lose accuracy with each call ...
but you use 5 calls to accomplish this ?
you lose accuracy with each call ...
ASKER
sleep(xxx) changes nothing, tried that also.
5 calls, one for each servo. But I hope there is a better way to solve this. To update one servo at a time.
That program was originally designed to work with lpt. All i did was renewing HRTimer to todays standards and replaced outvalue procedure with the one i needed to communicate with advantech.
5 calls, one for each servo. But I hope there is a better way to solve this. To update one servo at a time.
That program was originally designed to work with lpt. All i did was renewing HRTimer to todays standards and replaced outvalue procedure with the one i needed to communicate with advantech.
um, i think debugging on your machine would be the solution
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and attaching the event