RCX Oscillator

Post your RCX projects, project ideas, etc here!

Moderator: roger

WalrusBrigade
New User
Posts: 14
Joined: Tue Feb 09, 2010 11:33 pm

RCX Oscillator

Postby WalrusBrigade » Tue Feb 09, 2010 11:48 pm

I'm a high school physics and when I changed schools I realized that my new school doesn't have some of the equipment my old school did. One item I don't have is an Oscillator with a variable frequency. I built one out of the NXT kits I have and got leJOS up and running so that I have the buttons controlling the motor speed. Unfortunately that only gave me two set-ups and I need four so I tried to do the same thing with the RCX. After getting leJOS on those bricks I ran into a problem controlling the motor speed since Motor.setPower() doesn't give me the same options that .setMotorSpeed() does for my NXT. I'm not a great programmer and am partial to leJOS since I've code basic code that works and it offers good button listeners that other programs don't (?). Does anyone know of an easy software solution that I'm missing?

I'll post the code for the NXT version to show what it is that I am doing.

Thanks for any responses, I'm really stuck on this one since the RCX only gives me 8 .setPower() options.

Martin

//This program is designed to directly control the speed of the motor using buttons
//to set the variable MOTORSP. Pressing right adds 1 to the motor speed, pressing
//left subtracts one and pressing enter adds ten. Each time the screen rewrites
//the motor speed.
import lejos.nxt.Button;
import lejos.nxt.ButtonListener;
import lejos.nxt.LCD;
import lejos.nxt.Motor;


public class MotorControl {
static int MOTORSP = 100;
/**
* @param args
*/
public static void main(String[] args) throws Exception {
LCD.drawInt(MOTORSP, 3, 7);
Button.RIGHT.addButtonListener(new ButtonListener() {
public void buttonPressed(Button b) {
LCD.clear();
MOTORSP += 1;
LCD.drawString("Motor Speed", 3, 6);
LCD.drawInt(MOTORSP, 3, 7);
Motor.A.setSpeed(MOTORSP);
}
public void buttonReleased(Button b){
}
});
Button.LEFT.addButtonListener(new ButtonListener() {
public void buttonPressed(Button b) {
LCD.clear();
MOTORSP -=1 ;
LCD.drawString("Motor Speed", 3, 6);
LCD.drawInt(MOTORSP, 3, 7);
Motor.A.setSpeed(MOTORSP);
}
public void buttonReleased(Button b){
}
});
Button.ENTER.addButtonListener(new ButtonListener() {
public void buttonPressed(Button b) {
LCD.clear();
MOTORSP += 10;
LCD.drawString("Motor Speed", 3, 6);
LCD.drawInt(MOTORSP, 3, 7);
Motor.A.setSpeed(MOTORSP);
}
public void buttonReleased(Button b){
}
});
Motor.A.forward();
Button.ESCAPE.waitForPressAndRelease();
}
}

WalrusBrigade
New User
Posts: 14
Joined: Tue Feb 09, 2010 11:33 pm

Postby WalrusBrigade » Wed Feb 10, 2010 3:00 am

Maybe I should have put this in "Software." Anyway, I think I'm going to go with a Pulse Width Modulation solution and hope that it works out ok. My next problem is that there isn't a .getSpeed() option for the RCX, which makes sense without a built in tachometer. I've got a rotation sensor that I can try to use to determine the rotation speed of the motor, but it only gives me a tach count, so it isn't as easy to use as I would like . . . I sound like a big whiner.


Return to “RCX Projects”

Who is online

Users browsing this forum: No registered users and 1 guest