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 / 3033
3032  |  3034
Subject: 
Re: Handy Board PWM Routines
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 27 Nov 1997 08:56:55 GMT
Original-From: 
David Kott <dakott@kott.NOSPAMmy.domain>
Viewed: 
536 times
  
On Wed, 26 Nov 1997, Rick Moll wrote:


I would appreciate hearing from others who have played around with
the PWM code, or from those who have suggestions as to how the
PWM could be further improved to use more levels of PWM.

<snip>

        LDAA speeda ; rotate bits in motor speed
        ASLA            ;Rotate the speed bitmask one bit position.
        BCC  SPDoffA    ;Did we set the carry flag by shifting a "1" out
                        ;   of the MSB of the register?
        ADDA #1         ;We pushed a "1" out of the register, better
                        ;   put a "1" back into the LSB position.
        EORB #%00010000 ;This bit location toggles this motor on.
        BRA  SPDsetA
SPDoffA ORAB #%00010000 ;This bit location turns the motor off.
SPDsetA STAA speeda     ;Best keep track of the new bitcode, for the
                        ;   next iteration (in about 1 ms)

</snip>

(some comments added by myself)

<snip>

/* poke byte into "motor" to be output by PWM */
/* motor:  0x0e                               */
/* low bits of "motor" determine directions;  */
/* high bits determine on/off state.           */

</snip>

This code is from the handyboard's PWM interrupt service routine.  I
think, at first glance, that "speeda" is the value that you poke into that
memory location at the end of the LIB_R22.C motor control routine.  Note
that this is just one of the four service routines to control a given
motor.  The rest are similarly structured.  It is interesting to note
that, if one was so inclined, you could increase the resolution of the PWM
controller, and it's low end, by increasing the word size of the bitmask
to 16 bits, instead of the 8 bits currently used.  This would lower your
initial PWM average power, and your increment, to 1/16th or 6.25%

Now, one just has to keep track of two bytes for each motor.
Unfortunately, the bitspeed masks are right smack dab in the middle of the
variable space.

.
.
motorout        RMB     1 ; 21 ditto
speeda          RMB     1 ; 22 motor A speed
speedb          RMB     1
speedc          RMB     1
speedd          RMB     1
beeptone        RMB     2
.
.

One could either sacrifice the latter two motors to get the requisite
space, or add a second byte at the end of the variable space.  The latter
suggestion might involve a Pcode rewrite looking something like this:

        PSHB             ;Use the entire "D" register to shift the 16 bit
                         ;   speed bitmask about.  B needs to be saved.
        LDAA speeda      ; rotate bits in motor speed
        LDAB speeda2     ;This is our new lower byte of the 16 bit speed
                         ;   bitmask. (can be anywhere, not necessary to
                         ;   be adjacent to speeda)
        ASLD             ;Rotate the speed bitmask one bit position.
        BCC SPDoffA      ;Did we reset the carry flag by shifting a "0"
                         ;   out of the MSB of the register?
        ADDD #1          ;We pushed a "1" out of the register, better
                         ;  put a "1" back into the LSB position.
        STAB speeda2     ;Best keep track of the lower half of the new
                         ;   bitcode, for the next iteration (in about 1
                         ;   ms)
        PULB             ;Restore B... we need that value for
                         ;   bookkeeping.
        EORB #%00010000  ;This bitmask toggles this motor on.
        BRA SPDsetA
SPDoffA PULB             ;Restore B... we need that value for
                         ;   bookkeeping.
        ORAB #%00010000  ;This bitmask turns this motor off.
SPDsetA STAA speeda      ;Best keep track of the upper half of the new
                         ;   bitcode, for the next iteration (in about 1
                         ;   ms).

This is totally untested code.  I don't have my handyboard around to test
it.  Also, I haven't looked too closely at how reserving two more bytes at
the end of the variable space will affect the actual Pcode assembly
starting just below them.  Also, one now has to rewrite the lib_r22.c
motor interface routines.  No doubt there are other problems (execution
time?  Stack space?) that would crop up.  It may, ultimately, be better to
totally rewrite the routine;  my addition attempts to maintain fidelity to
the original code.

-d

Win95/NT - 32 bit extensions and a graphical shell for a 16 bit patch to
an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can't stand 1 bit of competition.  -UGU

P.S. don't know if I got sendmail.cf and aliases hammered out.  Reply to
dakott@alpha.delta.edu if it looks like I mailed from kott.my.domain



Message is in Reply To:
  Handy Board PWM Routines
 
I've recently been implementing a PD controller on the HB for use in a line following robot, and have been having some problems with instability, especially around the zero point. I was beginning to suspect that the 8 levels of PWM in the HB library (...) (27 years ago, 27-Nov-97, to lugnet.robotics.handyboard)

2 Messages in This Thread:

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

Custom Search

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