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 / 21176
21175  |  21177
Subject: 
Re: LEGWAY software questions
Newsgroups: 
lugnet.robotics
Date: 
Fri, 15 Aug 2003 17:09:36 GMT
Viewed: 
1060 times
  
In lugnet.robotics, Kevin L. Clague wrote:
In lugnet.robotics, Steve Hassenplug wrote:
In lugnet.robotics, Kevin L. Clague wrote:
  I've got some questions about the LEGWAY software.

  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.

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?

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 the eighth ms (MotorRunningValue==7; 0+7 element in array), then
MotorRunningValue will be set to 0, and it will start over.

So, the table would look like this:
MotorSetting = speed for 1ms slice of time
0 = 1,1,1,1,1,1,1,1  // full forward for 8ms, repeat
1 = 1,1,1,1,1,1,1,3  // forward for 7 ms, stop for 1ms, repeat
2 = 1,1,1,1,1,1,3,3  // stop for 2ms
3 = 1,1,1,1,1,3,3,3
4 = 1,1,1,1,3,3,3,3  // running for 50%, stopped for 50% or 1/2 speed
5 = 1,1,1,3,3,3,3,3
6 = 1,1,3,3,3,3,3,3
7 = 1,3,3,3,3,3,3,3  // running very slow.  Full speed for 1ms, stop for 7ms
8 = 3,3,3,3,3,3,3,3  // stopped
9 = 3,3,3,3,3,3,3,2  // slow reverse
10= 3,3,3,3,3,3,2,2
11= 3,3,3,3,3,2,2,2
12= 3,3,3,3,2,2,2,2  // 1/2 speed reverse
13= 3,3,3,2,2,2,2,2
14= 3,3,2,2,2,2,2,2
15= 3,2,2,2,2,2,2,2
16= 2,2,2,2,2,2,2,2  // reverse all the time

And if you just want to float the motors:
24= 0,0,0,0,0,0,0,0

It will never go forward, through stop, then reverse with a single motor
setting.  Because MotorRunningValue goes from 0 to 7 (eight steps) and there are
eight steps in each section of the array.  Lucky?  well, maybe.  :)

understand, yet?

Steve



Message has 1 Reply:
  Re: LEGWAY software questions
 
(...) <snip> (...) Yes. Thanks. Your PWM wavelength is 8ms, MotorA or MotorC chooses the first of the 8 entries used for the ON part of the wave. The MotorRunningValue walks you through the other 7 entries (the remainder of the wavelength). (...) (...) (21 years ago, 15-Aug-03, to lugnet.robotics)

Message is in Reply To:
  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)

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