Using IR sensors

Hello all,

I am new to the VEX world, and have a few questions about it.

First- I want to use the Sharp GP series IR sensors (Analog and Digital) to provide obstacle avoidance in my Robot project. Can I use these sensors even though they are not part of the Vex kit?? If so, is there anything that I need to know before I use them??

Second- I want my robot to be completly autonomous, If i wanted to use my own C code so that I am not limited to just what the software provides, am I able to do so? If so how??

Third- Once I have a program already downloaded into the vex controller, how do I download a different one?? Because what it seems to me is that, when the controller is powered on, the previous program is running while I download the new one. Is there a way to stop the program that is already in there, while I download the new one??

first: unless the sensors have a male pwm port at the end, they would not work with VEX, and they wouldnt work with EasyC at all.

second: If you dont wantto use EasyC and want to use regular C, you can use MPLAB to program it (i think)

third: Well, as far as i know, EasyC does stop the previous program as soon as you say yes to “Program sucessfully compiled click ok to continue”. Also, i like to have a switch (bumper or limit) that ends the program. its not too hard, just an infinite while loop inside of the if then statement.

Im not sure what you mean by pwm male port?? What I do know that these sensors have is three connectors, one for power (+5v) one for ground, and one for the output value.

One thing that I should mention is that, when I connected these sensors to the Analog input ports of the controller, and opened the Online Window to see if they work, I found that the controller was in fact taking these inputs and outputing them on the online window screen. Does that mean they would work for me?

Ok so how do I get MPLAB?? And how do I start using this to program my robot? Also, would I still have all of the headerfiles and functions as that of the easyC? Or would I have to start from scratch?

the connectors on the end of the motor are male ports - male ports have something that sticks out at the end so it can plug into a female port - the microctroller uses female ports

PWM = pulse width modulation, it is the same wire that VEX motors and sensors use to connect to the microcontroller. (sry i could’t find a pic).

and i dont know about MPLAB, i personally haven’t used it yet, but our FRC team programmer used it, but for FRC (FIRST robotics competition) we did. every team gets MPLAB in the kit of parts although im not sure how to get it elsewhere.

the reason i dont think you can use the IR sensors is because EasyC isnt made to use them. It doesn’t have a function block for them. ALso there is no get_analog_input() function like there probably is in MPLAB.

EasyC = predefined functions.
Reg. C = do it ALL yourself.

Ok, how do I get information about how to get started using MPLAB? Should I post a new thread or do you any other suggestions?

Wow, you guys should read some basic electronics books.

The analog port will read voltage up to 5v.
Go get some Futaba PWM servo plugs. These are labeled female because they usually have a protective casing around the male pins. The plastic cover comes off. Most RC car hobby stores have them.

Like these

Then goto radio shack and get a breadboard. While you’re there get some 330 ohm resistors, a couple .1 uf mylar caps and a couple 1N4148 diodes. (you’ll need them at some point when experimenting). Connect the black wire to one strip(ground) and red to the other side (VCC or 7.2 volts) the white wire is the input/output connection depending how you have the port set in Easy C.

Go read this.

Then plug your (fill in analog senor) into the breadboard. Hook it up.

If you don’t know the slightest bit about electronics you could fry your controller.

Pretty much any sensor that outputs 0-5volts will work AND Easy C supports them I’ll have to look and post the code later.

And go get
Programming Robot Controllers by Myke Predko
Robot Programming : A Practical Guide to Behavior-Based Robotics by Joe Jone

BTW pushing the button on the programming connector box will stop anything thats running.

Ok bnadvornik,
First of all, why do I need the resistors?? I mean the current that these sensors output is about 50ma if im not mistaken, right?

So ok, lets say the vex controller does work with these sensors which im really hoping they do, what about the function that gets the analog input voltage? Is there a function built in, or will I have to write my own? I want to use a function like this to sense how close or far away the IR sensor is detecting the object.

Thank you in advance. this web site is great if you want to program your ir sensor. the ir sensor is the same thing as the line follower sensors so check out this website it might help. also this language for vex is easy i learn most of it in 2-3 months.

Huh? :confused:

You most definitely can use IR sensors, and you most definitely can program them using EasyC version 1.0 (and up). I’ve done it.

All you need to do is use LightSensor() blocks to get the value of the IR Sensor. As long as the IR Sensor is analog, the controller can’t tell the difference.

okay, thanks. i didnt know if the function blocks had to be identical to the sensor. also, the ir sensors that came in the botball kit from the nasa summer course my FRC team did had a space in the male pins for some reason. it looked like:

|| |
(the | are the pins and the - are to show the spacing.)
i dont know why though.

So I assume that the values from the IR sensors will be from 0 to 1023, right??

antually, in the programming you could either use an 8-bit ineger (0-255) or 12-bit (0-4096). i think that is right.