Subject:
|
Strange problem using 2 active sensors at the same time with 0.2.4
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Tue, 14 Nov 2000 23:42:46 GMT
|
Viewed:
|
1355 times
|
| |
| |
Hello
In a actual project, i'm using the following setup:
Input:
1 Rotation sensor (steering)
2 nc
3 Rotation sensor (distance measuring)
Output:
A drive motor
B nc
C steering motor
If more than one sensor is set to active, only the first (steering) one
can be used to read 'real' values. The reading from the second
(distance) rotation sensor are completely out of track toggling
'randomly' around the starting value. This behavior is independent of
the state of the motors but is influenced by the state of the sensors
(active || passive). A second current sink on one of the other sensor
ports disables the formerly working one. This behavior is independent
from the state of the batteries. I've tested it with freshly loaded NiMh
and with nearly empty NiCd (not with normal batteries) and also with two
other RCX's.
If i use legOS-0.2.3 from http://www.noga.de/legOS/legOS-0.2.3.tar.gz
with dsensor-new.c instead of dsensor.c everything works as expected.
now my question:
Is there a patches against 0.2.4 which solves this very strange problem
with active sensors?
Greetings Carsten Müller
------------------------- CODE for debugging
---------------------------------
/* Kleiner test für den Trycicle OfficeRunner
*
* Input:
* 1 Rotations Sensor (Lenkung)
* 2 NC
* 3 Rotations Sensor (Streckenmessung)
*
* Output:
* A Antrieb
* B Steuerung
* C NC
*/
#include <dmotor.h>
#include <dsensor.h>
#include <tm.h>
#include <conio.h>
#include <unistd.h>
#include <dsound.h>
#define CIRCUMFLEX 216 // umfang des Rades in mm (32077)
#define MM_PER_TICK (CIRCUMFLEX/16.0)
#define TURNTABLE_CIRCUMFLEX 56 // anzahl der Zähne :)
#define DEG_PER_TICK (360.0/TURNTABLE_CIRCUMFLEX/16)
volatile MotorDirection drive_direction = brake;
volatile MotorDirection turn_direction = brake;
int monitor_distance(int argc , char ** argv)
{
while(1){
cputw(ROTATION_3);
msleep(500);
}
}
int monitor_angle(int argc , char ** argv)
{
while(1){
cputw(ROTATION_1);
msleep(100);
}
}
int deg_to_ticks(int deg)
{
return deg/DEG_PER_TICK;
}
int cm_to_ticks(int cm)
{
return (-cm*10)/MM_PER_TICK;
}
wakeup_t wait_for_distance(wakeup_t ticks){
switch(drive_direction){
case fwd:
return ROTATION_3<=(int)ticks;
case rev:
return ROTATION_3>=(int)ticks;
case brake:
case off:
return 1;
}
return 0;
}
// move the robot to relative position cm
void move_to(int cm)
{
int ticks_to_go;
if(cm==0){
drive_direction=brake;
return;
}else if(cm>0)
drive_direction=fwd;
else
drive_direction=rev;
ticks_to_go=cm_to_ticks(cm);
ds_rotation_set(&SENSOR_3,0);
motor_a_dir(drive_direction);
wait_event(wait_for_distance,ticks_to_go);
motor_a_dir(brake);
drive_direction=brake;
}
wakeup_t wait_for_angle(wakeup_t ticks)
{
switch(turn_direction){
case fwd:
return ROTATION_1>=(int)ticks;
case rev:
return ROTATION_1<=(int)ticks;
case brake:
case off:
return 1;
}
return 0;
}
void steer_to(int deg){
int ticks_to_steer;
int act_tick=ROTATION_1;
int diff=0;
ticks_to_steer=deg_to_ticks(deg);
diff=ticks_to_steer-act_tick;
if(diff==0){
turn_direction=brake;
return;
}else if(diff>0)
turn_direction=fwd;
else
turn_direction=rev;
// ds_rotation_set(&SENSOR_1,0);
motor_b_dir(turn_direction);
wait_event(wait_for_angle,act_tick+diff);
motor_b_dir(brake);
turn_direction=brake;
}
int main(int argc, char **argv)
{
int ticks_to_go;
motor_a_speed(MAX_SPEED);
motor_b_speed(MAX_SPEED/3);
ds_active(&SENSOR_1);
ds_active(&SENSOR_2);
ds_active(&SENSOR_3);
sleep(1);
ds_rotation_set(&SENSOR_1,0);
ds_rotation_on(&SENSOR_1);
ds_rotation_set(&SENSOR_3,0);
ds_rotation_on(&SENSOR_3);
/* move_to(150);
sleep(1);
move_to(-150);*/
execi(monitor_distance,0,NULL,PRIO_NORMAL,DEFAULT_STACK_SIZE);
steer_to(60);
move_to(80);
sleep(1);
move_to(-80);
steer_to(0);
return 1;
}
|
|
Message has 1 Reply:
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|