EasyC v4 Sensor Integration Help

Hello Vex Forum,
Today, I was trying to get my students to experiment with different sensors. We’ve previously been successful with the basics of the bumper switch, so I decided that I’d like them to try and test the line tracker. I had each student plug in a line tracker sensor into their own cortex that they were using. Within easyC they went to the ‘online window’ or the option where you can see the values differentiate live (whatever the exact name is…). When the students did this there values were each statically stuck between 46 to 48. Covering it completely with your hand would result in going up by only a single value, and uncovering it would return it to what it started as.

Thinking of what the issues were, I had the students try different line trackers, but they all did the same thing. While this continued to cause problems, I decided that perhaps the batteries were too low or perhaps malfunctioning (because the ROBOT light on the cortex was flashing orange, then to red). After replacing the battery, I was able to get the ROBOT light green- yet the line tracker problem only continued to thicken. Once it went green, the online value shot up to nearly 800! When it got close to an object, the value went to anywhere from the mid 500s to even the low 100s! My students and I have read over the Line Tracker Instructions provided by VEX, yet we are pretty clueless as to what the issue could be…

Our sensor integration issues didn’t end there however…
After, we tried using the ultrasonic range finder and the encoder. Based on the instructions, again provided by VEX- we ‘believe’ we plugged in the cords into the proper slots- yet the range finder would get us the ‘print-to-screen’ message about ‘echo’ and ‘not being able to ping’. What personally confused me is the message on here: http://content.vexrobotics.com/docs/instructions/276-2155-instr-0312.pdf
“In order for your robot to be able to read the sensor, you will have to reprogram the Microcontroller. Consult the supplier of your programming software, for more information…”.

At the end of our meeting today I updated the cortexes from version 3.23 to version 4.22. I’m not sure if this particularly would make the difference, or help at all- but I’m just looking for some help! It’s probably something really we’re either overlooking, or something… but today certainly threw us for a loop! Thanks for reading this! Anyone else with this issue???

-Steve

The line tracker works by detecting the amount of reflected IR light. It’s an analog sensor, the more IR light it detects being reflected the lower its digitized output will be, so what you were seeing sounds about right.

The cortex comes with a “default” program installed when it is new. This allows teams to be able to build and drive a robot without additional programming using EasyC or ROBOTC. The comment about having to reprogram the micro controller only means that the default code does not contain any programming for the ultrasonic sensor and you need to write that code using EasyC or ROBOTC.

So this was unnecessary, but still a worthwhile exercise.

The error messages you saw were probably related to using the wrong ports for the ultrasonic. EasyC defines 4 ports (9-12) to be outputs and 8 to be inputs (1-8) as the default (you can change this using the controller configuration dialog). You need to setup the Ultrasonic to use these. The EasyC sample uses ports 1 and 11, port 11 will be the input to the ultrasonic (out from cortex) and cause the ping, port 1 will be the echo back into the cortex.

Should the values really be that high? On the instructional sheet for the line tracker it refers to values between 0-255. When testing online, is a battery required? or can it be entirely powered through USB?

Oh, makes sense! I was thinking programming the microcontroller meant flashing it, or some kind of different update to it. Thanks for your help! I didn’t even think to test the example code!

Hmmmm… I did read that these ports should be used. I’m fairly certain that we did try these specific ports. I’ll have to try the sample and see if it works. Perhaps we didn’t initialize, or start the sensor correctly?

I don’t have the instructions around to look at, however, much of this information has become obsolete as the VEX system has evolved over the last few years. For example, we almost exclusively use the cortex now but many instruction sheets still reference the older PIC v0.5.

I think what was written assumed 8 bit A-D (analog to digital) conversion, that is, lowest level at 0 and highest at 255. EasyC uses either 10 bit or 12 bit conversion conversion depending which of the two versions of GetAnalogInput is used. So, the range you are using is probably 0 to 1023.

Sensors need the battery connected and turned on, powering the cortex using just the USB cable does not work. The battery voltage is regulated to 5V and then used as power for the sensors (the red wire of the 3 wire cable). The micro controller inside the cortex (there are actually two) is powered from a different 5V source to the sensors which is why either USB or the main battery can be used.