To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 21174
21173  |  21175
Subject: 
Re: LEGWAY software questions
Newsgroups: 
lugnet.robotics
Date: 
Fri, 15 Aug 2003 16:00:05 GMT
Viewed: 
1028 times
  
In lugnet.robotics, Steve Hassenplug wrote:
In lugnet.robotics, Kevin L. Clague wrote:
  I've got some questions about the LEGWAY software.

  Why is the motor speed array 32 entries instead of four?  Since the array has
4 groups of 8 identical values, couldn't you reduce the array size by shifting
the index to the right 3 bits?

hmm.  That's a good idea.  I wish I'd have thought about it.  That's going to
make all my programs shorter, now.  At least by 28 entries.  :)

Actually, one reason to have it that way is because it should process faster.  I
think.  Is it faster to lookup a number in a 32 element array OR shift 3 bits
and lookup in a 4 element array?  I really don't know.

It will process faster, and memory consumption is not a problem.  But if you
have the time.....


  Part of the index you use into motor speed array is sys_time & 7.  I do not
understand this at all.  I can only imagine that over time you try to force
migration from one motor drive state to the next.

This is the part that does all the work controlling the motors.
Between this array:
---
int MotorSpeedArray[32] = {1,1,1,1,1,1,1,1,
              3,3,3,3,3,3,3,3,
              2,2,2,2,2,2,2,2,
              0,0,0,0,0,0,0,0};

// motor speed 0-7 = forward, 0 = fast, 7 = slow
// motor speed 8 = stop
// motor speed 9-16 = reverse, 9 = slow, 16 = full
// 24 = float
---
and these lines
---
    MotorRunningValue = (sys_time & 7);
    motor_a_dir(MotorSpeedArray[MotorRunningValue + MotorA]);
    motor_c_dir(MotorSpeedArray[MotorRunningValue + MotorC]);
---

I understand the value of everything *except* MotorRunningValue which is a value
in the range of 0 to 7, which increments every millisecond.  But I don't
understand how it helps.


It's where I create my own PWM for the motors.  The start time for each pulse
remains constant.  I forget what that's called.  I guess that would be the
frequency.  But the duration of the pulse changes, depending on the value for
"MotorA" or "C"

So, you can set [MotorA] to a value between 0 and 16, and the resulting speed
will be between full forward, and full reverse, with 8 being stopped.

Clear yet?

Nope.  It would seem that over time, you move further down the array, until
MotorRunningValue goes to 0, and you start over....

This has the potential of moving you from forward, through stop, and then
reverse.  How does this help?


  I thought a lot about your explanation of why you don't need an absolute
center value.  You look at two readings of the EOPDs and determine the
difference.  If the difference is 0, then we are not falling.  If the difference
is non-zero then we are falling, and we turn on a motor to prevent this.  This
makes sense.  I'm guessing that you check the EOPDs every 50 ticks, rather than
more freuqently, so you can get a reasonable amount of difference in EOPD
readings.

The software does check the sensor every 1ms, and adjust the motors.  It also
does try to calculate a "center point" every 50ms.  It does this by looking the
previous center point, new sensor reading, and current motor speed.

If the sensor is different from the center point, the robot is falling.
If the sensor == the center point, but the motors are running (!=8) the robot is
not falling BUT, it is tilted, so it must speed up the motors.

All that fits into a couple calculations.

  When you fired up LEGWAY for me, you used the remote to reduce the amount of
oscillation due to the balancing process.  What value do you change in the code
to do this.  Is it the divide factor used to convert EOPD differences to motor
speed?

somewhere around this line:
    MotorSetting = (CenterPoint1 - L1) / 2 + 8;

I changed the /2, so it goes from *1/8 to *8/8 (I think)

That was my guess.


  When I download the legway code from your web page, it comes across as HTML,
and the end of lines are all gone, and the system includes are dropped, because
they start with < and end with >.  Could you please email me a copy of your
legway code (and any new versions of the code if you are willing.)

from the web page, you can "View>Source" and it will magicly look readable (then
save it)

I'll try it again.


I'll try to get the code with the IR stuff posted sometime.

Did I answer all your questions?

Steve

Thanks for the answers.

Kevin



Message has 1 Reply:
  Re: LEGWAY software questions
 
(...) Let me try with a couple examples. Given the above code, if you set MotorA=0, the motor direction will be set to 1 for the first ms (MotorRunningValue==0; 0+0=element 0 in array) and 1 for the second ms (MotorRunningValue==1; 0+1) and 1 for (...) (21 years ago, 15-Aug-03, to lugnet.robotics)

Message is in Reply To:
  Re: LEGWAY software questions
 
(...) hmm. That's a good idea. I wish I'd have thought about it. That's going to make all my programs shorter, now. At least by 28 entries. :) Actually, one reason to have it that way is because it should process faster. I think. Is it faster to (...) (21 years ago, 15-Aug-03, to lugnet.robotics)

5 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
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
2 hours ago
Custom Search

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