Wednesday, February 2, 2011

DAY 11

Ah the day of Senorship!!! Spend pretty much the whole time integrating the sensors--RGB LED and LDR onto the proto-board. Without the proper value for the LED-RGB at 220 ohms and the LDR at 10K ohm, the RGB sensor unit wouldn't work properly, especially the blue and green reflections. Thus tweaking those 2 resistor units was of utmost importance. It took over a day to finish this proto-boarding. Red wire is power; Black is ground. Orange(for red), Blue, and Green wires are for the color leads, respectively.



Input pin 0 for LDR sensor, ie readadc or read the value from the LDR into the Pic14M. Input 1,2,3 are the Red, Green, and Blue. b0, b1, and b2 respectively, are the possible stored read-value from the LDR. w3 is the combined value of b0, b1, and b2. Color determinations are done comparetively, i.e. if b0>b1 and b0>b2 then red--this means the largest reflective color is red; thought green or blue reflection may store some values, but red would be the predominant color reflected into the LDR sensor as compare with the blue and green colors, which may still exist but comparatively is not the dominant valued color. To account for range of colors beyond red, blue, and green, w3 is created to deal with color values beyond the RGBs, i.e. any color value intensity lower than 250 or greater than 510. Please see below for the actual program for reference.




'Color Sensor LEDs RGB on outputs 1,2,3 USING PWM
'Read the CDs cell on ADC 4

Low 0,1,2,3,4,5 'Set all outputs to low to turn off RGB
pause 1000

main:

w3 = 0 'This is the sum of all channels
high 1 'Set the RED channel high turns it on
low 2,3
pause 50 'Give time for the LED to turn on
readadc 0,b0 'Read the value from the LDR
high 3 'Set the BLUE Channel ON
low 1,2
pause 50
readadc 0,b2 'Read the value from the LDR into a different variable
'Apply any necessary offset for the sensitivity of the LDR
high 2 'Repeat for the GREEN Channel
low 1,3
pause 50
readadc 0,b1
b1 = b1 - 30
debug
w3 = b0 + b1 + b2 'Find the sum of the 3 color channels
'sertxd ("w3 reading ",#w3,13,10)
if w3 > 510 then nocolor 'Cut on total intensity
if w3 < class="Apple-tab-span" style="white-space: pre;"> 'Cut on total intensity
if b0>b1 and b0>b2 then red
if b1>b0 and b1>b2 then green
if b2>b0 and b2>b1 then blue

goto main

nocolor:
sertxd ("nocolor",13,10)
pwmout 2,99,400 ;SET THE OUTPUT TO 5V
low 4,5
goto main

red:
sertxd ("red",13,10)
pwmout 2,99,0 ;SET THE OUTPUT TO 0V
high 4
low 5
goto main

green:
sertxd ("green",13,10)
pwmout 2,99,125 ;SET THE OUTPUT TO 1.5V
low 4
high 5
goto main

blue:
sertxd ("blue",13,10)
pwmout 2,99,250 ;SET THE OUTPUT TO 3V
high 4,5
goto main



Tuesday, February 1, 2011

DAY 10

This was a tough assignment creating the color sensor code and the color sensor circuit. Bardia had the pleasure of working on the infrared sensors ( it was really awesome that he made 2 IR sensors; that was very helpful for the competition). With the right resistors, around 10K on the LDR and 220 or the RGB LEDs, the circuit board flashes accordingly with different colored cards.


Making the board was another tough solderinng job.

Here the RGB sensor is processed by a Pic-14M. I will describe the programming in details once the proto-board soldering is done. Here's how the initial testing works. If the color sensor detect a large red reflection of the red card, then the indicator red LED flashes. When sensor picks up large green reflected surface, like th green card below, the green indicator LED flashes. Lastly, a blue reflecting surface will reflect a largely blue wavelength, that in turn will turn on both red and green indicator LEDs.









Thursday, January 27, 2011

DAY 9

Today I started the VEX programming. In a very short time, I was able do simple robotics manuever code. Most importantly, I got to do functions. I was able to measure and modularize my algorithm and program the bot to manuever through the maze, roughly without the encoder. Then using the encoder, the robot move more accurately and got into the box, the very first time!!! But no one was around to see it. Then everyone shows up to see it the second time but the battery was low so it didn't perform as well. I believe Shawn or Brian has the video.













'Color Sensor LeDs RGB on outputs 1,2,3 USING PWM
'Read the CDs cell on ADC 4
Low 0,1,2,3,4,5 'Set all outputs to low to turn off RGB
pause 1000

main:

w3 = 0 'This is the sum of all channels
high 1 'Set the RED channel high turns it on
low 2,3
pause 50 'Give time for the LED to turn on
readadc 0,b0 'Read the value from the LDR
high 3 'Set the BLUE Channel ON
low 1,2
pause 50
readadc 0,b2 'Read the value from the LDR into a different variable
'Apply any necessary offset for the sensitivity of the LDR
high 2 'Repeat for the GREEN Channel
low 1,3
pause 50
readadc 0,b1
b1 = b1 - 30
debug
w3 = b0 + b1 + b2 'Find the sum of the 3 color channels
'sertxd ("w3 reading ",#w3,13,10)
if w3 > 510 then nocolor 'Cut on total intensity
if w3 < class="Apple-tab-span" style="white-space:pre"> 'Cut on total intensity
if b0>b1 and b0>b2 then red
if b1>b0 and b1>b2 then green
if b2>b0 and b2>b1 then blue

goto main

nocolor:
sertxd ("nocolor",13,10)
pwmout 2,99,400 ;SET THE OUTPUT TO 5V
low 4,5
goto main

red:
sertxd ("red",13,10)
pwmout 2,99,0 ;SET THE OUTPUT TO 0V
high 4
low 5
goto main

green:
sertxd ("green",13,10)
pwmout 2,99,125 ;SET THE OUTPUT TO 1.5V
low 4
high 5
goto main

blue:
sertxd ("blue",13,10)
pwmout 2,99,250 ;SET THE OUTPUT TO 3V
high 4,5
goto main



Wednesday, January 26, 2011

DAY 8


Today I meet the "most successful chip ever". The 555 timer. The circuit took awhile to set up due to lack of parts. Finding that darn capacitor was difficult. Mainly, the I used the logic probe to check if all the connections flashed accordingly. This is was a side exercise to get us ready for the servos and signal conditioning. I had a little time to work on the oscilloscope project but the servos worked fine.




In additions, there were the motors and relay switches push button switch that needed to be look over.





Tuesday, January 25, 2011

DAY 7

Finalize Toy Hack:


Franken Chicken LIVES!!!!

Here's my initial program attempt:

main:

serout 0, N2400, (10,13)
serout 0,N2400, ("Press a key...")
serin 4,N2400,b1
serout 0,N2400,(b1)
if b1="a" then hot

goto main
hot:
serout 0, N2400, (10,13,"A is the Hot Key!")

high 1
pause 2000
low 1
pause 500
play 0,0
sound 2,(50,100)
sound 2,(100,100)
sound 2,(120,100)
pause 1000
goto main

Thursday, January 20, 2011

DAY 6

Interfacing Micro to Transistors:

Having already programmed the picaxe-08m using LEDs, switches, and LDR, it's not all that much different to programmed the toy-hacked. It turns out the Frank Chicken has only one large motor that controls all aspect of its geared movements of the beak and wings and legs. I was able to located the motor positive and negative connection and cut and re-solder a much longer wire set that runs up and to the back and down. I burned a side-hole so the wires can easily slip between the casing and I glue the wire down using hot glue.


Though it seems as simple as plugging those motor wires into the picaxe output pins. There is one more criteria for this to work. The pic only put out about few mA, not enough to run the motor. We can use a relay switch but that would be a over-kill. Relay switch is a robust circuitry for 2Amps and above. For my motor, I just need to increase my gain, so here the fabulous TIP102, darlington transistor works wonders. With this configuration I could achieve gains of 750 to a 1000, depending on the resistors. Now, I may begin programming the Franken Chicken.

......GRRRRRRRR

Music/Advance Motor Control:

I've also started playing with music and more advance motor controls. Instead of using switches or LDR as input to turn on the Franken Chicken, I use the serout Pic command that will command me to push a keyboard button and start up Franken Chicken. I simply added input, output devices to the darlington configuration.


Wednesday, January 19, 2011

DAY 5

Serial Bus:

Ah, at last, we make serial bus connectors for programming, a rare find these days because everything is going USB? A serial connection will give you a serial signal connection TX or RX versus parallel connection which will have far more communication pins used. To build this crucial programming device, we used 3 color wires solder the point of female 5, 3,2 sockets, i.e., ground, TX, and RX, respectively. This can be confusing especially if you are seeing either from the front side or the back side, do specify. So our serial connector is a RS-232 standard, i.e., logic 0 = 2.5-15V and logic 1 = -2.5 to -15V. This suggest that RS-232 voltages are inverted with respect to logic, so here logic 1 is low and logic 0 is high. Furthermore, the RS-232 bit rate is 9600.


Micro-Controller:

Now the fun begins! I was given a microcontroller PiC 12F683 or PicAxe 08m. It's got 4in, 4outs, 3ADC, and one infrared pin connections. Using breadboard and a couple of LEDs, I started making circuits for Picaxe programming. I programmed a series of LED flashes on and off at 1 second intervals.


I also implemented a switch to control the flashes. Lastly, I installed a LDR, analogue, sensor and control the LED flashes by covering/uncovering the LDR--it acts like a light switch of sort.I also implemented a switch to control the flashes. Lastly, I installed a LDR, analogue, sensor and control the LED flashes by covering/uncovering the LDR--it acts like a light switch of sort.



Dissect Toy:

Ah the real fun begins. I commence the dissection of the "Franken Chicken" The "violation" of the toy went smoothly. Removing the fur is perhaps the toughest part. Opening up the plastic casing for circuitry was a matter of 5 screws.