Questions by Artist on VEX Programing

I am new to vex, and i am working on a robot not for a competition but for an art gallery show i am in. The project i am working on is called Edmund the Pro Social Emu. Though its built out of bent medal and covered in wolly fabric, the flightless yet extremly engaging bird has a vex control chip and programing system inside its belly, to control a robotic movable neck. Its permenetly conected to a computer as the cable is built into its leg- as it goes about its purpose-to get people to hug it as much as possible.

The robot itself is working well, after i devoloped a good counter weight system, however i have to questions about advanced programing that you might be able to help with.

  1. Randomization- When the optical sensor is activated i want the neck to move in one of a series of programed movments, that are choosen randomly by the computer. Basically i want to be able to randomly select a varriable to choose. How do you do this in Easy C.

  2. Activation of video- behind the robot is a TV Screen that i want similarly to play a Short movie clip(the clips say Variations of “please hug me, i am a very huggable emu”). How do you get either easy C to do this, or get it to activate a seperate program to do this.

These are my two main questions. In addition i have worked limit switchs and maybe a bumper switch to be inside the fury body. When ever they are activated the robot assumes its beng hugged, and plays a video that says “Thank you, nice person”. This i have pretty well handled.

Thanks in advance for any help, for a person who hasn’t seriously programed since high school. VEX i think has a lot of potential for artistic uses, one that after this robot is done i hope to explore more.

Scott Hillman

PS After this show i am thinking of entering it into a battle bot competition to try really diffrent tactics with other robots. They never expect a robot that just wants to cuddle.

I am personally not aware of a randomization function integrated directly into EasyC. However, a simple “random” system you could make could be a simple if loop where everytime the controller loops it adds 1 to a variable. Depending on the number of random programmed movements you want you can have it reset this variable to 0 everytime it gets to the number of programmed movements. This way, everytime the controller loops (which is always happening when powered up) it is essentially changing the movement that would occur if triggered at that instant. By taking whatever the variable value is at when the optical switch is triggered, it can create your “random” effect.

As for the video activation, I’m not sure what you could do electronically. You could try using a servo that would just be located offboard to press play on a dvd player with the clips and just create the DVD in a way where it’ll cycle through the clips. Then just program the servo to swap from position a to position b (a being not touching the button, b being touch the button) and cycle it when you wish to play. It’s not the most efficient method by any means, but if you have all of this behind-the-scenes it’ll get the job done.

I hope this helps or at least gives you an idea. Feel free to PM me if you run into any issues. We’d love to see photos of the system you’ve developed, even though we’re part of FIRST it’s great to see different implementations of systems such as VEX and this sounds like a very interesting idea, and might even give some members of this community some inspiration as well. Good luck with the show!

There are few ways to generate truly random numbers on computers. There are lots of ways to get pseudorandom numbers. They’re pseudorandom because they in general are produced by an algorithm that is completely deterministic. Other factors in chosing a random number generator are range, distribution, and integer vs floating point. For your problem and using the VEX controller, integer is sufficient and you don’t need much range. Most algorithms you’ll find produce numbers from a uniform distribution. If you needed a Gaussian distribution, you’d need to do a little more work. But since it appears you’re just trying to fool humans, a uniform distribution sounds adequate.

A simple pseudorandom number algorithm that the VEX could easily handle is based on progressively squaring and truncating a number. Start with a seed, square it, and truncate so you preserve the low order bits. For an 8 bit case squaring gives you a 16 bit number. Throw away the upper 8 bits and keep the lower 8 as your random number. Use that random number to generate the next one in the same way, ad nauseum.

Other more complex arithmetical operations can prevent the zero problem such as adding a constant at each iteration. But this isn’t really any different than simply restarting with the original seed on detecting a zero. Once you generate a zero, you begin a cycle that will eventually repeat.

One problem most pseudorandom numbers share is that eventually, they generate a random number they’ve generated before. Since it’s used to generate the next one via a fixed algorithm, you end up with a cyclic series of numbers. If the cycle is long enough and has reasonable statistical properties, it may still be useful. It depends on the application.

A problem with some and particularly the simple one I mentioned above is that one of the possible random numbers is zero. Squaring zero gets you zero back from here to eternity. Sounds like a good movie title. :rolleyes: One way to avoid this is when you detect a zero, to chose a new seed for the next iteration. If the computer has a real time clock, that could be read to determine a new seed. Or on a PIC you could let a timer run freely and read it to get a new seed. Presumably, with different paths through the program and the “randomness” of the algorithm, you’d get a reasonable distribution of hits on the values from reading the timer. Depending on how often you needed a random number and the varibility of paths through your program, you could just read the timer to generate your randoms. However, you could be reading it quickly enough that you’d always have ascending sequences until the timer rolled over.

If you needed truly random numbers, you could use an analog input and read something like the thermal noise in a thermocouple or use radioactive source and count the radioactive decay events in a given time.

As to controlling your video source, I assume you’re using a VCR or DVD player. You could tap into the play button and substitute a relay that could be controlled by a digital output from the VEX controller. Probably void your warranty. :ahh: Another would be to buy or build a device that the VEX can control that generates the infrared remote signal. I have no idea if these are available commercially but certainly the components are readily available. I suppose yet another way would be use a solenoid that physically pushes the button and is controlled by the VEX. And I suppose some newer high end systems might actually have some kind of computer interface you could hack into.

If you want to delve further into random number generation, here’s a site with quite a few references that I just ran across this morning.

http://www.robertnz.net/

Welcome!

The random number thing was covered pretty well - just do math on a number and pick one of the digits to key on.

I’m not sure exactly how you intend to show Video A instead of B or C or D - i.e., how do you activate a video - but in EasyC, once you select which video to show, you simply activate a specific digital output to play it.

In other words, let’s say you had five videos on DVD, and five DVD players - to play video 1, connect a relay to digital output 1, have that relay simulate pressing the Play button. And so on. Expensive and cumbersome, tho.

The real issue comes down to figuring out a way to store and play different videos. However you’d do it manually, use the digital outputs to automate. Answer the first part and we can help figure out the second part.

Good luck,
Don

Alternatively, let’s say you have five videos on a c

One thing you could do to solve the DVD problem is to have a servo like miketwalker said, but instead of hitting the play button, push the next button. The way it would need to be, on the dvd is to has alternating chapters of ridiculously “background” music and then the speech. then having a counter for each chapter and when it reaches the maximum it would some how reset the dvd player.

This sounds like a cool and different way to use the vex system could you post a pic of the final product when you are done?