To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1279
1278  |  1280
Subject: 
Re: Rotation Sensor Values
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 25 Jul 2000 00:12:27 GMT
Viewed: 
1629 times
  
I figured you would be glad that I was not running 0.2.4. I cannot get it to
compile correctly, so I use 0.2.3 instead. The two full programs are below, in
case you wanted to see them in full.

Andy

----This one does not work----

#include <dsensor.h>
#include <unistd.h>
#include <conio.h>
#include <rom/lcd.h>

#include <dlcd.h>

int main(int argc,char **argv) {
ds_active(&SENSOR_2);
ds_rotation_on(&SENSOR_2);
ds_rotation_set(&SENSOR_2,0);
lcd_number(SENSOR_2,sign,e0); //show the starting number
lcd_refresh();
while(1){
lcd_number(SENSOR_2,sign,e0);
lcd_refresh();
delay(50);
return 0;
            }
}
----This one does----

#include <dsensor.h>
#include <rom/lcd.h>

int main(int argc,char **argv) {
ds_active(&SENSOR_2);
ds_rotation_on(&SENSOR_2);
ds_rotation_set(&SENSOR_2,0);
while(1){
    lcd_number(ROTATION_2,sign,e0);
    msleep(50);
}
return 0;
}


In lugnet.robotics.rcx.legos, Luis Villa writes:
On Mon, 24 Jul 2000, Andy Gombos wrote:
Hee, Hee. It was 0.2.3, not 0.2.4.

phew :) Had me scared there for a while. I'll probably still take a look
at it later- I just didn't want to have caused a bug so soon after
starting to apply patches.

Luis

Here is the code snippet that setup and read
the values. The current(working) code takes out the refresh, and changes the
delay to msleep.

        ds_active(&SENSOR_2);
ds_rotation_on(&SENSOR_2);
ds_rotation_set(&SENSOR_2,0);
while(1){
    lcd_number(ROTATION_2,sign,e0);
            lcd_refresh();
            delay(50);
}
return 0;

Andy
In lugnet.robotics.rcx.legos, Luis Villa writes:
On Mon, 24 Jul 2000, Andy Gombos wrote:
I added back in the display code, and left out the lcd_refreshes. Then I • got
a
proper counter. I wonder why the refresh was throwing the reading off.

That's a good question. Is this the latest tarball? If so, there have been
some modifications to the refresh loop, and this may indicate a bug in
them. In other words, it could be the double sets of lcd_refresh()
and not the actual reading that was bad. Could you post both sets of code,
so that we can take a look at them?
Luis


In lugnet.robotics.rcx.legos, Andy Gombos writes:
Well, I do not know if I have to have code to display the values. I do • not
get
anything on
screen when I run this code. If I put a loop, and with every loop, the • sensor
value is being displayed, then I get the values mentioned before. I run • the
initialization steps also, and still get the bogus values.

Andy
In lugnet.robotics.rcx.legos, Luis Villa writes:
On Mon, 24 Jul 2000, Andy Gombos wrote:

I was reading about rotation sensors for legOS for a new robot, and
thought I'd try it out. So, I made a simple program that would show
rotation sensor values on the display. What I got was not what I
expected. I have never used the rotation sensors in legOS before, so • I
do not know if this behavior was expected. Anyway, I got values of
9999, -9999, 64, and -64 (more that once). I think that these values
correspond to the RAW values that I got from switchinf quadrants in
the sensor. Are these the expected values, or are you supposed to get
0,1,2, -5,2, like in the regular lego firmware?

Andy-
Have you set up the rotation sensors correctly? You need to do a few
things before you get reasonable values for the rotation sensor.

1) use ds_active(&SENSOR_1) to turn on the sensor.
2) use ds_rotation_on(&SENSOR_1) to turn on the rotation processing in • the
kernel.
3) use ds_rotation_set(&SENSOR_1, int X) to set the sensor to X. I • believe
that the default for this is undefined, so unless you use rotation set • at
least once, you could easily get an undefined value > 9999 or < -9999.

Once you've done all that, what you should see is just a counter, • noting
the number of sixteenths of rotations that have occurred. (i.e., when • the
counter reads 16, one rotation will have occurred.)

Hope that helps- please let us know if you still have problems-
Luis

-----------------------------------------------------------------------

    "Summertime... and the living is easy...
    fish are jumping and the cotton is high...
    So hush, little baby, baby don't you cry."
-Ella

-----------------------------------------------------------------------



-----------------------------------------------------------------------

    "Summertime... and the living is easy...
    fish are jumping and the cotton is high...
    So hush, little baby, baby don't you cry."
-Ella

-----------------------------------------------------------------------



-----------------------------------------------------------------------

    "Summertime... and the living is easy...
    fish are jumping and the cotton is high...
    So hush, little baby, baby don't you cry."
-Ella

-----------------------------------------------------------------------



Message has 2 Replies:
  Re: Rotation Sensor Values
 
Ack! You are still having problems with 0.2.4? I thought your problem was with the compiler, and not legOS? <flips through old Andy Gombos posts on lugnet> Is this still the merge-map problem? I figured out the situation, and fixed it in CVS. Sorry (...) (24 years ago, 25-Jul-00, to lugnet.robotics.rcx.legos)
  Re: Rotation Sensor Values
 
(...) Yes. It will only display two counter readings, then stop! See the "return 0;" statement. It is inside the while (1) loop. Take it out of the loop, and I am shure this one will also work. At least with 0.2.4 it does. (...) Here the return (...) (24 years ago, 25-Jul-00, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: Rotation Sensor Values
 
(...) phew :) Had me scared there for a while. I'll probably still take a look at it later- I just didn't want to have caused a bug so soon after starting to apply patches. Luis (...) ---...--- "Summertime... and the living is easy... fish are (...) (24 years ago, 24-Jul-00, to lugnet.robotics.rcx.legos)

16 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
    

Custom Search

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