I am looking at using the TCS230 Color Sensor Evaluation Kit from parallax.com on a project for my robotics class. I want to control it with the RC. Unfortunately, I have no idea how to wire it to the controller. Any help you can give me would be appreciated.
I havent looked at the datasheets but you should be able to qire them up via the digital inputs and digital outputs. Have you written any code to use it. All code for it will be written using PBASIC so you would have to write a C version of the code they give you to interface the sensor with the Basic stamp.
Um, it’ll be a bit of a pain to interface this to the RC, but not impossible.
The first step is understanding what this thing is giving you, which is a variable frequency square wave, frequency varies accoring to light brightness (Between about 8 and 24 kHz max at one scaling factor).
You first set two pins (s0 and S1) for the scaling factor. Likely these will be just jumpers to +5 or Gnd.
Then set two pins (S2/S3) to determine which “color” you are detecting. (For all 4 pins see the Taos sheet, Table 1)(You’ll set these by software, using digital outputs of the RC, and change them real fast)
So, you want to detect of the color is Green. Strobe through all four colors (one ‘color’ is clear) and measure the output (=brightness =frequency) for each color, then use math to figure out the percentage of red/green/blue/white (brightness overall) to get the color.
So there are two intelligent ways to interface this to the RC, in my not entirely humble opinion. The control of it should probably follow Don’s recommendations, but taking a reading from this might end up being more of a pain than you think.
First, directly mesuring a frequency of potentially atleast 12 kHz with the RC is generally difficult or problematic. If we had full access to the PIC’s pins, you’d just use a CCP pin or two and mesaure the period of the signal, but that’s sadly not possible on the IFI RC. So I think you have two options.
A. Use a frequency-to-voltage converter. This chip takes a frequency input, and outputs a voltage based on it. So you’d set it up so it puts out 5V at 10 or 12 kHz, and you’d take this output to one of the analog inputs on the RC.
Advantage: Much easier to code for. Mostly instantaneous value changes. Disadvantages: Yet another chip to wire up. Voltage range is going to depend on resistor and capacitor values, so the scaling will change between devices depending on the precision of your components. Also, it can be non-linear at the extremes of the range.
B. Use a very particular digital IO pin on the RC as a Timer1/3 clock input on the RC. 57 did this to measure the speed of our shooter wheel. Exactly one of the digital IO pins can be programmed so you can use Timer1 or Timer3 as a counter. I can provide more details if you’re interested in this solution.
Advantages: No additional circuitry required. Potentially better resolution than the 10-bit analog input. Disadvantages: Harder to code. Resolution will depend on sampling time. (Faster sampling == less resolution) The value you’re measuring will perforce be the average value of the frequency over your sampling period, not the instantaneous value. This may or may not be desirable.
The third option is to put the output on an interrupt pin and basically treat it like an encoder, but then your RC will be dealing with potentially a lot of interrupts. And as long as you’re just using one of these, I don’t think there’s a reason not to go with option B for direct wiring to the controller.
here is an e-mail I sent to an electrical engeineering friend of mine… maybe it willl give you a better idea of what I am trying to do. I am up to any suggestions.
For my class robotics project I am building an automated workcell. My design is to analyze and catalog different colored boxes.
This is how the system will work:
first the colored box enters the system, it lands on a conveyor belt.
That conveyor belt drops the box off at a staging area.
once on the staging area, I will use a Light-to-Frequency Sensor like this to identify what color the box is.
Next, an arm will pick up the box and place the box on the next conveyor
This conveyor will take the box and drop it off in a reptacle for its respective colored box.
I have attatched a picture of the CAD drawing of the project. I have updated the drawing but the princible is still the same.
I will be powering the conveyor belts and the arm with continuoous rotation servos like these.
I will be tracking the positioning of the arm with optical incremental encoders like these
I will be using a limit switch for other things like detecting if there is a box on the staging area.
So my problem is that I am having a hard time finding a microprocessor with enough inputs and/or outputs.
right now i have:
9 continuous rotation servos (1 digital input each)
1 limit switch (1 digital input)
2 optical incremental encoders (2 analog inputs, i think)
1 TCS230 light-to-frequency converter (6 digital inputs)
2 Leds (2 digital outputs)
Some of the microprocessors that I have looked at were basic stamp, sx, and IFI robotics’ microchip Robot Conctrollers(here and here)
I wanted to use a SX controller but I don’t think they have Analog I/O’s, I thought about adding more limit switches to replace the encoders. I like these chips because then I could make my own circuit board later on…
I think I could use IFI’s microchip robot controllers. Would be hard to get the TCS230 light-to-frequency converter to work with this?
Do you know of any other microcontrollers that I could use? Any suggestions would be appreciated.
thanks,
Nick DiCola
please ignore the mechanical faults of the design… I am still learning Inventor.
Firstly, encoders go to digital inputs, 2 for each encoder. Secondly, if you had 1 less servo, I think you could just use a Vex controller, provided you had a good way to interface the TCS. It looks like some of your servos could be paired up with a Y-cable. For instance, the two lifting that bar up and down will always need to turn the same amount in the same direction, so no reason they can’t be run through a Y-cable. So really, I’d recommend a Vex controller, as it’s more affordable than a full scale RC, which might be overkill for your application. Plus it can run in autonomous mode with no OI connected to it.
Lastly, you still have other options available to you for color sensing. Just googling color sensor came up with one other good option. And a CMUCam would work for color sensing as well.
A vex would work but if you wanted something that you owned and would be cheaper there are some nice PICs out there that would do what you need nicely.
You can get them directly from Microchip (http://microchip.com/). Also you can look into buying programmers and development board from SparkFun (http://sparkfun.com) if you want.