Using Fischertechnik Sensors with the VEX Cortex

From ROBOTC API Guide
< Tutorials
Revision as of 15:13, 7 May 2012 by Bfeher (Talk | contribs)

Jump to: navigation, search
Tutorials → VEX Speaker module


VEX Speaker
The VEX Cortex is an incredibly powerful and versatile microcontroller. Part of what makes it so versatile is the basic 3-pin system (Power, Signal, Ground) it uses for inputs and outputs.

When coupled with a powerful programming language like ROBOTC, the VEX Cortex allows you to connect all types of third-party sensors (and actuators) with little or no effort. Taken from the VEX Wiki, any analog sensor can be connected to the Cortex as long as its characteristics align with the following:

  • Output voltage range: 0.0 v to 5.0 v.
  • Must not exceed -0.5v to +5.5v.

Likewise, any digital sensor can be directly connected to the Cortex as long as its characteristics align with the following:

  • Provides 0.0 to 0.6 volts for a low and 2.5 to 5.0 volts for a high.
  • Must not exceed -0.5v or +5.5v.
All of the basic Fischertechnik sensors meet these qualifying characteristics, making them perfect candidates for use with the VEX Cortex!

Analog Sensors Example: Fischertechnic Photoresistor

Based on the VEX Cortex Schematic, the SIGNAL line in the ANALOG INPUTS bank is closest to the USB Port in the center of the Cortex, with the +5 VOLTS line next, and finally the GROUND line. The Fischertechnic analog sensors only have two output pins, and we’ll be connecting them to the SIGNAL and +5V lines.

Schematic


In the picture below, we used the connector pins that come with the Fischertechnik system to connect the photoresistor to male-to-male jumper cables, which can be plugged directly into the Cortex. Note that with these basic analog sensors, polarity does not matter; it only matters that you use the SIGNAL and +5V lines on the Cortex.

Tut fischertechnik 3.jpg


With the sensor properly connected, configuring it in ROBOTC is no more difficult than any of the official VEX sensors. In the Motors and Sensors Setup, on the VEX 2.0 Analog Sensors 1-8 tab, give the sensor a name and choose from Potentiometer, Light Sensor, or Line Follower for the sensor type. Any of these three types will work, as they are set up to return the raw A-to-D (Analog-to-Digital) values from the sensor. The Gyro and Accelerometer sensor types perform additional calculations on the raw sensor data, making them inappropriate choices for a basic analog sensor like the photoresistor. The VEX Light Sensor is the most similar to the Fischertechnik photoresistor, so it’s the logical choice.

Tut fischertechnik 4.png



Example Code

Sound Test:

task main()
{
  //Basic "Play Sound" commands
  PlaySound(soundBeepBeep);
  wait1Msec(200);
 
  //Intelligent "Play Sound" command
  //Delay until sound is done playing
  PlaySound(soundFastUpwardTones);
  while(bSoundActive)
  wait1Msec(1);
 
  //Play a tone:
  //First Parameter: Frequence in Hz
  //Second Parameter: Length to play in 1/100th of a seconds (50 = .5 seconds)
  PlayTone(440, 50);
  wait1Msec(500);
 
  //Play a Sound File (need to use the File Management to Upload First)
  PlaySoundFile("1.wav");
  wait1Msec(1000);
}