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 / 12552
12551  |  12553
Subject: 
TinyVM coding question
Newsgroups: 
lugnet.robotics, lugnet.robotics.rcx.java
Date: 
Fri, 22 Sep 2000 23:43:20 GMT
Reply-To: 
eric@+StopSpammers+ericharshbarger.org
Viewed: 
1821 times
  
Folks,

I have a question about TinyVM 0.1.3. I am working with the included
code (TestReceiver1.java) but have come across some interesting behavior
which I hope someone can explain (and offer a solution for).

I am tryying to write a simple program that allows the RCX brick to read
in 4 numbers (coords) from the IR port on the PC. I have the two talking
with one another just fine (I did not include the PC side code).

Once the numbers are read in, the RCX uses them to control the motors.
The motors are run until the Rotation Sensor determines a certain
distance has been travelled (based of some of the coords).

here's the trouble: to determine the distance, I'm having to monitor the
rotation in 1/16th revs... which is fine if I hard-code the coord values
in (as commented out -- and NOT using the Serial code), but when I DO
implement the Serial reading portion, the RawValue of the Rotation
Senosr never changes (it stays at about 406 or 407).

All the sections of the code work indvidually, but when I try to read
values in from the Serial the Rotation Sensor goes goofy. When not using
the Serial code, the Rotation sensor outputs for voltage Raw Values
(about 1023, 778, 356, 526).

Any ideas?

thanks for reading this much,

eric

ps: I'm on a Win95 machine, Pentium 200, 128 RAM

--
----------------------------------------------------------------------
Eric Harshbarger / eric@ericharshbarger.org / www.ericharshbarger.org

"Oh please, if people are going to start telling the truth around
here... I'm going to bed." - Jackie-O (Parker Posey, THE HOUSE OF YES)
----------------------------------------------------------------------

CODE:

import tinyvm.rcx.*;

final public class TestReceiver1 implements SensorListener {
static boolean motor_running = false;
static int total = 0;
static int prev_sensor_value;
static int curr_x = 0;
static int curr_y = 0;
static int index = 0;
static int[] coords = new int[4];


TestReceiver1() {
Sound.twoBeeps();
LCD.showNumber(8888);

for(int i=0;i<4;i++) {
byte[] pPacket = new byte[2];

while(!Serial.isPacketAvailable()) {
}

Serial.readPacket(pPacket);
LCD.showNumber((int)pPacket[1]);
coords[i] = (int)(pPacket[1]);
Sound.beep();
}

Sensor.S1.activate();
Sensor.S1.addSensorListener(this);

prev_sensor_value = getRotationIndex(Sensor.S1.readRawValue());

Motor.A.setPower(0);

moveMotor();
}

public void moveMotor() {

/*
coords[0] = 0;
coords[1] = 10;
coords[2] = 1;
coords[3] = 7;
*/

// LCD.showProgramNumber(coords[i*2]);
if (index < coords.length) {
if (coords[index] == 1) {
Motor.A.forward();
}
else {
Motor.A.backward();
}
}
}

public int getRotationIndex(int value) {
int v = (value > 650) ? (value > 900) ? 1 : 2 : (value < 450) ? 3 : 4;
return v;
}


public void stateChanged(Sensor src, boolean value) {
}

public void stateChanged(Sensor src, int value) {
int v = getRotationIndex(value);
LCD.showProgramNumber(v);
LCD.showNumber(value);
if (v != prev_sensor_value) {
curr_x++;
prev_sensor_value = v;
}
// LCD.showNumber(curr_x);

if (curr_x == coords[index+1]) {
Sound.twoBeeps();
curr_x = 0;
index += 2;

Motor.A.stop();
LCD.showNumber(4321);
for(int j=0;j<5000;j++) {
}
moveMotor();
}
}
public static void main (String[] arg) {
TestReceiver1 tr = new TestReceiver1();
}
}



Message has 1 Reply:
  Re: TinyVM coding question
 
(...) [...] I already responded to Eric via email, but for anyone else who might be interested, this bug was fixed in TinyVM 0.1.4. The current version is 0.2.2. Expect 0.2.3 tonight or tomorrow (due to a bug fix, having to do with assigning (...) (24 years ago, 23-Sep-00, to lugnet.robotics, lugnet.robotics.rcx.java)

3 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