I have had a certain amount of success building my Oscillator. Here's a picture. It is way too big, and needs lots of optimization. I have something like 3 idler gears in there for spacing, and I'm sure I can improve on that when I get to the next model. The whole size of the thing is too large and piece heavy. There is also an awkward height between the bottom support and the middle support (6 holes). While I will definitely improve upon the design the bulk is handy because when it gets going this thing walks a lot.
But the best part is that I added some basic code to the ButtonMath program I had before so that the motor is directly controlled by the buttons on the NXT. After adding a display showing the speed (or at least the speed setting) I now have a frequency controller that can alter the frequency of the oscillator. It still doesn't get high frequencies. The motor does even make it past 900 deg/s (and that is at full battery) and the gearing is 25:1. So at best I can make it up to 62.5 Hz. The next step is to find an elastic string and the right length/tension so that I can get a fundamental frequency in the 12.5 range so that I can see multiple standing waves.
I figured I would post the code just in case I forget how to code it at some point. It is poorly commented . . . but that is because I am a bad programmer.
//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;
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();
}
}
But the best part is that I added some basic code to the ButtonMath program I had before so that the motor is directly controlled by the buttons on the NXT. After adding a display showing the speed (or at least the speed setting) I now have a frequency controller that can alter the frequency of the oscillator. It still doesn't get high frequencies. The motor does even make it past 900 deg/s (and that is at full battery) and the gearing is 25:1. So at best I can make it up to 62.5 Hz. The next step is to find an elastic string and the right length/tension so that I can get a fundamental frequency in the 12.5 range so that I can see multiple standing waves.
I figured I would post the code just in case I forget how to code it at some point. It is poorly commented . . . but that is because I am a bad programmer.
//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;
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();
}
}
Labels: leJOS
0 Comments:
Post a Comment
<< Home