Subject:
|
Re: LEGWAY software questions
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Fri, 15 Aug 2003 15:17:13 GMT
|
Viewed:
|
1025 times
|
| |
| |
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.
> 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]);
---
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?
> 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)
> 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 to get the code with the IR stuff posted sometime.
Did I answer all your questions?
Steve
|
|
Message has 1 Reply: | | Re: LEGWAY software questions
|
| (...) It will process faster, and memory consumption is not a problem. But if you have the time..... (...) I understand the value of everything *except* MotorRunningValue which is a value in the range of 0 to 7, which increments every millisecond. (...) (21 years ago, 15-Aug-03, to lugnet.robotics)
|
Message is in Reply To:
| | LEGWAY software questions
|
| Steve, I've got some questions about the LEGWAY software. I've read it many times, and spent many miles on the road to and from BrickFest reading the code. Why is the motor speed array 32 entries instead of four? Since the array has 4 groups of 8 (...) (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
|
|
|
|