home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gossip.pyramid.com!olivea!spool.mu.edu!news.cs.indiana.edu!sgiblab!swrinde!cs.utexas.edu!gateway
- From: s3007048@mackay.mpce.mq.edu.au
- Newsgroups: comp.sys.amiga.programmer
- Subject: timer/parallel interaction vi CIA and real time routines
- Message-ID: <9211122252.AA07931@mackay.mpce.mq.edu.au>
- Date: 12 Nov 92 23:09:16 GMT
- Sender: daemon@cs.utexas.edu
- Organization: UTexas Mail-to-News Gateway
- Lines: 169
- NNTP-Posting-Host: cs.utexas.edu
-
-
- I am writing an application to control at stepper motor dependant on a
- frequency between 250Hz and 1088Hz. The sample routine shown below had
- overhead, and I wanted to reduce that overhead by compensation. I would
- time the contents of the loop, adjust the waiting times for that pulse,
- and run the loop using this value. I presumed it could be done as shown
- below, but I presume that the DoIO() that waits the time, does not
- interact well with the direct use of the parallel port. Has anyone
- done anything like this before? Has anyone written a real time (rather
- than process driven) timer routine? I would appreciate any help you
- could give me. Please email me at s3007048@mackay.mpce.mq.edu.au
-
- Thanx in advance...
-
- Regards,
-
- Mike.
- -----------------------------------------------------------------------------
- Internet: s3007048@mackay.mpce.mq.edu.au
- Phone: +61 43 841525
-
- "I have a cunning plan..." - Baldrick (Black Adder)
- -----------------------------------------------------------------------------
- Michael Glew - School of Math Phys Comp & Elec - Macquarie University
- -----------------------------------------------------------------------------
-
- ----cut-here---------8<-----------------------------------
- {
- ***************************************************************************
- ** Section: sample **
- ***************************************************************************
-
- This samples a section at a certain frequency for a certain amount of time
-
- NB: time will be a multiple of 0.4
- }
-
- procedure sample(freq:integer;time:real);
-
- var
- counter : integer;
-
- start,
- finish : TimeVal;
-
- iterations : integer;
-
- begin
- if (freq = 0) or (time = 0.0) then { no divisions-by-zero please }
- return;
- waitmic := round(500000/freq);
- iterations := round(float(freq)*time)-2;
-
- GetSysTime(TimerMsg,Start); {*START*}
- msg := GetMsg(winptr^.UserPort);
- {$A
- jsr -132(a6)
- move.w #$7fff,$dff09c
- move.w #$0008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10010000,$bfed01
- move.b #$ff,$bfe301
- move.b #%10000000,$bfe101
- move.w #$7fff,$dff09c
- move.w #$8008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10001111,$bfed01
- jsr -138(a6)
- }
- if waitmic>0 then begin
- with timermsg^ do begin
- tr_time.tv_secs := 0;
- tr_time.tv_micro := waitmic;
- tr_node.io_Command := TR_ADDREQUEST
- end;
-
- if DoIO(timerMsg)<>0 then
- errormsg("a problem occurred with the CIA timer")
- end;
- if msg<>Nil then begin
- control_routine;
- stop_sample:=true;
- return
- end;
- {$A
- jsr -132(a6)
- move.w #$7fff,$dff09c
- move.w #$0008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10010000,$bfed01
- move.b #$ff,$bfe301
- move.b #0,$bfe101
- move.w #$7fff,$dff09c
- move.w #$8008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10001111,$bfed01
- jsr -138(a6)
- }
- if waitmic>0 then begin
- with timermsg^ do begin
- tr_time.tv_secs := 0;
- tr_time.tv_micro := waitmic;
- tr_node.io_Command := TR_ADDREQUEST
- end;
-
- if DoIO(timerMsg)<>0 then
- errormsg("a problem occurred with the CIA timer")
- end;
- GetSysTime(TimerMsg,Finish); {*FINISH*}
- SubTime(Finish,Start);
- waitmic := 2*waitmic-round(Finish.tv_micro/2);
- for counter:=0 to iterations do begin
- msg := GetMsg(winptr^.UserPort);
- {$A
- jsr -132(a6)
- move.w #$7fff,$dff09c
- move.w #$0008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10010000,$bfed01
- move.b #$ff,$bfe301
- move.b #%10000000,$bfe101
- move.w #$7fff,$dff09c
- move.w #$8008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10001111,$bfed01
- jsr -138(a6)
- }
- if waitmic>0 then begin
- with timermsg^ do begin
- tr_time.tv_secs := 0;
- tr_time.tv_micro := waitmic;
- tr_node.io_Command := TR_ADDREQUEST
- end;
-
- if DoIO(timerMsg)<>0 then
- errormsg("a problem occurred with the CIA timer")
- end;
- if msg<>Nil then begin
- control_routine;
- stop_sample:=true;
- return
- end;
-
- {$A
- jsr -132(a6)
- move.w #$7fff,$dff09c
- move.w #$0008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10010000,$bfed01
- move.b #$ff,$bfe301
- move.b #0,$bfe101
- move.w #$7fff,$dff09c
- move.w #$8008,$dff09a
- move.b #$7f,$bfed01
- move.b #%10001111,$bfed01
- jsr -138(a6)
- }
- if waitmic>0 then begin
- with timermsg^ do begin
- tr_time.tv_secs := 0;
- tr_time.tv_micro := waitmic;
- tr_node.io_Command := TR_ADDREQUEST
- end;
-
- if DoIO(timerMsg)<>0 then
- errormsg("a problem occurred with the CIA timer")
- end
- end
- end;
-