Bored?

Posted by Tony K.

Student on team #292, PantherTech, from Western High School and DaimlerChrysler.

Posted on 2/4/2000 8:25 AM MST

If you’re bored, and your robot just hasn’t been listening to you today, try this:

'Add this to the top
p1_y VAR WORD
p2_y VAR WORD

'Add this to the ‘Custom Code’ section of the robot code:

RANDOM p1_y Min 0 Max 254
RANDOM p2_y Min 0 Max 254

(all this assuming your drive wheels are hooked up to pwm’s 1 and 2)

and in the serout…
p1_y.lowbyte, p2_y.lowbyte

Now, either make sure your robot is up on blocks and press reset!

I’d never actually recommend doing this… just for virtual fun… :^)

Posted by Jerry Eckert.

Engineer from Looking for a team in Raleigh, NC sponsored by .

Posted on 2/4/2000 12:27 PM MST

In Reply to: Bored? posted by Tony K on 2/4/2000 8:25 AM MST:

I think trying this experiment, even with the robot up on blocks, might be a very bad idea. You could end up with a rapid sequence of sudden changes in motor direction which could result in damage to your drive train.

BTW - the code given probably doesn’t do quite what you think it does.

The ‘MAX 254’ statement causes the stored result to be 254 whenever the 16 bit result is .geq. (greater than or equal to) 254.

The RANDOM statement uses the value contained in the variable as an input as well as an output, with the output value being a function of the input (i.e., for a given input, the output will always be the same). Depending on what output results from an input of 254, you will either (a) end up with a constant output of 254 or (b) repeatedly cycle through the same short sequence of values.

If you want a (relatively) random byte, remove the ‘MIN 0 MAX 254’ and either output or assign only one byte of the word result from RANDOM.

Jerry

: If you’re bored, and your robot just hasn’t been listening to you today, try this:

: 'Add this to the top
: p1_y VAR WORD
: p2_y VAR WORD

: 'Add this to the ‘Custom Code’ section of the robot code:

: RANDOM p1_y Min 0 Max 254
: RANDOM p2_y Min 0 Max 254

: (all this assuming your drive wheels are hooked up to pwm’s 1 and 2)

: and in the serout…
: p1_y.lowbyte, p2_y.lowbyte

: Now, either make sure your robot is up on blocks and press reset!

: I’d never actually recommend doing this… just for virtual fun… :^)

Posted by Tony K.

Student on team #292, PantherTech, from Western High School and DaimlerChrysler.

Posted on 2/4/2000 8:38 PM MST

In Reply to: Re: Bored? posted by Jerry Eckert on 2/4/2000 12:27 PM MST:

I knew that code was wrong. I’m not a pbasic guru :^)

And like I said, I’d never try it! :^)