To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1814
1813  |  1815
Subject: 
Re: time sampling under the rcx standard OS
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Wed, 21 Sep 2005 18:03:14 GMT
Viewed: 
6251 times
  
On Wed, September 21, 2005 11:49 am, Francois Bardet wrote:
Hi Steve,
As I'm quite new to BrickOS and to C programming, I'm sorry I'm not sure I
understood what you meant, neither how you do this :

Well, in BrickOS, my loops usually execute at
1kHz, so I usually just set
it to check the sensor, and set the motor every 1ms.  So it just keeps
checking the clock.

- Do you check the sensor at a higher rate, and only send a command to the motor
at 1kHz ?
- How do you get this command to be looping at 1kHz (I do not know yet how time
is managed within BrickOS) ?
- Is it better to run two tasks independently, one for sensor checking, and one
for motor command sending ?
Maybe you'd have a sample to show how you proces this ?

Thanks, best regards,

Francois


Here's a code byte from my LegWay code.

----
int MotorSpeedArray[32] =  {1,3,2,0}; // Speeds
// ...  later in the program...

if (sys_time>CheckTime)  // check system timer - is it time to check sensors again?
{
L1 = ReadSensor(SENSOR_1);
L3 = ReadSensor(SENSOR_3);

MotorSetting = (((L1 - CenterPoint1) * AdjustSpeed / 8 + 8) + ((L3 - CenterPoint3)
* AdjustSpeed / 8 + 8)) / 2;

// check boundry
if (MotorSetting < 0) MotorSetting = 0;
if (MotorSetting > 16) MotorSetting = 16;

CheckTime = sys_time + 1;
}

MotorRunningValue = ((sys_time) >> 1 & 7);
motor_a_dir(MotorSpeedArray[(MotorSetting + MotorRunningValue)>>3]);
motor_c_dir(MotorSpeedArray[(MotorSetting + MotorRunningValue)>>3]);
----

The first part looks at the system time (I think the function is get_sys_time_up()
in the latest version of BrickOS).  This function returns the current system time in
ms, so I just have it look at the sensor whenever the time changes.

The motor control is a bit harder to explain.  It takes in settings from 0 (full
forward) to 16 (full reverse) and creates a PWM for some percentage of 8 ms.

Steve



Message is in Reply To:
  Re: time sampling under the rcx standard OS
 
Hi Steve, As I'm quite new to BrickOS and to C programming, I'm sorry I'm not sure I understood what you meant, neither how you do this : (...) - Do you check the sensor at a higher rate, and only send a command to the motor at 1kHz ? - How do you (...) (19 years ago, 21-Sep-05, to lugnet.robotics.rcx.nqc)

10 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