To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 3225
3224  |  3226
Subject: 
Re: encoder function
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Fri, 6 Feb 1998 07:31:05 GMT
Original-From: 
Thomas Hauri <HAR@TWI.nospamCH>
Viewed: 
2038 times
  
Hi all

I have written some routines to measure frequencies from 30Hz to 30kHz.
I'm posting this with an attachement because several people have ask me
already for these routines.

To Fred:
You can add these routines to the ftp server or anywhere on the handyboard hp
if you want.

The encoder function pages say that for the fast encoder, the refresh rate
is only 1 KHz.  That is it can make only 1000 increments in a second.  If
I have an encoder that has a change rate on the order of a micro second,
is there any reasonable way to use the encoder routines with it, or is
there anything else I could do to use the  8 MHz (I think) clock of the
6811 for this particular encoding procedure.

  Description:

Here are my routines zipped for DOS.
The asm-files were written on a mac using an editor with tabs of 4 spaces and
saved
in DOS format. If you load these files
into an editor on the PC
you might get wrong tabs. With WinEdit on PC you can set the spacing to 4 and
everything works just fine.

I do not have any manual in english because so far everything is written in
german,
sorry :(((

But I can give you some instructions on how to use the programs.
There are two icb-files to measure a pulsewidth with the TIC ports 2 & 3.
--> pw_tic2.icb   /  -.asm
--> pw_tic3.icb   /  -.asm

Each of them has two global variables (pulsewidth2, pulse_done2 for TIC2, or
pulsewidth3, pulse_done for TIC3).
In the example below you can see how to use the routines:

while(1){
    get_pulsewidth3(0);
    while(! pulse_done3) {
        defer();
    }
    fehler = korrektur + pulsewidth3-servo7_pulse_length/2;
}

After calling get_pulsewidth3(0) the asm-routine triggers and measures ONE
pulse
one TIC3. The argument has no effects
on the routine. The pulsewidth can vary from about 35 microsecs up to 32ms. If

shorter the routine will overread the pulse, if

longer the internel counter will overflow and give you a false reading.
With the global variable pulse_done3 you can find out wether the measuring has

finished or not as shown above.
Now you can read the pulsewidth with the global variable pulsewidth3.
Be careful measuring pulsewidth smaler than 100us because the proportional
error
rises.

To measure a wavelength with the supplied program (wl.icb /-.asm) you need to
call
the asm-routine get_wavelength(0).
After that you can trigger the end of a measurement with the global variable
wavelength. As long as this variable is equal to
0 nothing has been measured. As soon as it reads anything else than 0 that
value is
the measured wavelength. You can
measure wavelength from about 35 microsecs up to 32ms. Same problems as above
with
the proportional error.
There is only one routine for the TIC3 sofar, but it is really easy to change
the
routine to use it with any other Timer Input
Counter.

So, that's it.....

Hope you can use these routines.

Tom


--
MIME ATTACHMENTS DISCARDED:

1.  Content-Type: application/x-zip-compressed; name="handy.zip"
    Content-Transfer-Encoding: base64
    Content-Disposition: inline; filename="handy.zip"
    Content-Length: 11676



Message has 1 Reply:
  Re: encoder function
 
Tom, it seems that your routines measure frequency but Yoni wanted to count transitions. Yoni, the approach is similar to what Tom has done in that you must use the timer input channels to get high frequencies. In the TCTL2 register, set the input (...) (27 years ago, 7-Feb-98, to lugnet.robotics.handyboard)

Message is in Reply To:
  encoder function
 
The encoder function pages say that for the fast encoder, the refresh rate is only 1 KHz. That is it can make only 1000 increments in a second. If I have an encoder that has a change rate on the order of a micro second, is there any reasonable way (...) (27 years ago, 5-Feb-98, to lugnet.robotics.handyboard)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR