Skip to content

Instantly share code, notes, and snippets.

@hale
Created April 24, 2012 13:03
Show Gist options
  • Save hale/2479465 to your computer and use it in GitHub Desktop.
Save hale/2479465 to your computer and use it in GitHub Desktop.
CS2508: Walking Robot program in Interactive C
#define HALF_STEP 240L
#define STEP 400L
#define Q_STEP 120L
void main() {
right_fd( HALF_STEP );
left_bk( HALF_STEP );
msleep(100L);
step();
step();
step();
step();
step();
step();
msleep(100L);
right_bk( HALF_STEP );
left_fd( HALF_STEP );
}
void step() {
int first, second;
second = start_process( left_fd( STEP ) );
first = start_process( right_bk( STEP ) );
msleep(500L);
kill_process( first );
kill_process( second );
first = start_process( right_fd( STEP ) );
second = start_process( left_bk( STEP ) );
msleep(500L);
kill_process( first );
kill_process( second );
}
void right_fd(long step) {
fd(0);
msleep(step);
off(0);
}
void left_fd(long step) {
fd(3);
msleep(step);
off(3);
}
void right_bk(long step) {
bk(0);
msleep(step);
off(0);
}
void left_bk(long step) {
bk(3);
msleep(step);
off(3);
}
@hale
Copy link
Author

hale commented Apr 26, 2012

Half step is too long

@hale
Copy link
Author

hale commented Apr 26, 2012

rps = rotations per second

50 rps ---worm gear---> one tooth of the 24 gear per rotation = 50/24 = 2.08 rps ---8 gear---> 2.08*3 = 6.24 rps ---24 gear--->6.24 /3 = 2.08 --- 18 gear ---> 2.08 *1.33 = 2.76
rps

1 rot of 18 gear = 1.8 length of beam => 1 length of beam = 1/1.8 rotations = 0.55 rotations

2.76/0.55 = 5.01 => need 1/5.03 second for length of beam = 0.2 seconds

8-->24 rot/3
24-->18 rot*24/18 = rot * 1.33
overall ratio 1.33/3 = 0.4 slow down

borrowed black chain from another group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment