Showing posts with label photoelectronics. Show all posts
Showing posts with label photoelectronics. Show all posts

Friday, December 14, 2012

A bit on IC chips, and a Dragon Headbot

At first in my self teaching of electronics.. I was completely unfamiliar of the IC chips available at Radio Shack, as well as Fry's Electronics, Willie's Electronics, and other stores in my home town. I knew the 555 timer ship was some sort of universally versatile little gizmo.. but had no idea how to wire it up. Similarly, when I read the package of "Octal inverter" I thought it was some sort of code generating chip for computers... something that used some sort of 8-bit (octo) ASCII code or something else completely over my head.

The Junkbots, Bugbots, Bots on wheels Book helped me out immensely! While I still at this time struggle to get a 555 timer to do what I want (I want it to do a short millisecond pulse of power each time I push a button.. but NOT stay on for the length of time it takes my slow Human speed finger to let go of it which is apparently hundreds of milliseconds even at my fastest), now I am an avid fan of the octal inverter. Lets talk about it a bit.
This is one of my favorite chips. Its SO useful! It can do so many things; from powering a motor that can reverse its power automatically, to switching things on and off, to other BEAM robotics related stuff like "Neural Nets" of a limited degree. Lets explain how.

Notice on the sketch there are up arrows and down arrows at the pin points. These are "data channels" symbols, which is a fancy way to say "either 1 or 0 goes in here or out here"; 1 being 5v, 0 being 0 volts. So yes, doing one to an input causes the connected output to do something as well, and they are in pairs 8 pairs, thus Octo.

Its called an Inverter because what it does is outputs the opposite of what was its input was! So you input in 5v, it puts out 0. You link one output to its neighboring input, and you can see more complicated things going on: 5V to channel 1= 0 volts at output, that 0 v gets sent to input of channel 2, it sends 5v at its output. Thus; a motor controller! Have one channel power 1 wire, another power the other wire, simply link them together, and one provides power, the other ground.. all from a single input of 5v (triggered by anything-- mechanical switch, etc)

Whats really neat is how it reverses... put 0 volts at the wire going to channel one, and now the wire that was power is ground, and the other channel is power!! and the motor is running the opposite direction.  Neat, huh? with just 1 wire and a jumper, you now have the equivalent of a DPDT relay wired to do the same thing... only there are 3 more pairs on the chip!

One thing to note though, is that the power output of these channels is not very high. Its more for data that driving motors, and this one in particuar is not a style designed for high milliamp loads (all that is locally available though). So, to make it a motor controller, you have to "gang up" multiple channels in parallel to have enough "push" to actually get it to go. To make the Headbot from the Junkbots book, it uses 3 pairs tied together to drive the motor, and the last pair as the "brains"

Remember how I said the more advanced robotics techniques can make these inverters "neurons"? This is how; take two linked together channels, and you have a loop of alternating on-off states. Wired directly, the voltage just zips back and forth too fast to mean anything... but add a resistor/capacitor to each side, and now there is a controlled delay (the time it takes the capacitor to fill up: stop hogging all the power, for the 5v to actually reach the input). Have each RC group of different values, and the two neurons can cycle like "bip-beeeep-bip-beeeep". How to make this into a 2 neuron  bug brain is rather ingenious: have the resistor of the RC groups be variable to external stimuli.. like a photo resistor that changes its resistance with light levels! NOW, if wired this way, the "beeep" will be "no light" cycle time, the "bip" will be "light hitting this one". Cross wire them so the left sensor makes the motor spin to the right, and what do you have?

A Headbot, that tracks LIGHT! it will scan left right left right, but time between the scan directions differing so that it drifts more and more towards a light. Then, when both sensors are full of light its just a rapid "bipbipbipbipbipbipbipbipbip" cycle, that keeps the eyes pointed at the light source. Move the light, and the head turns to track it. Wire the motor the other way, and now the headbot avoids light! Shift a light nearby it, it will flinch and look for the darkest spot (wear a black t-shirt, and it may be staring at you!). A brain. Of sorts.

Check out my Headbot, since we're talking about them:
This little critter is called, roughly "The blue Eyed Dragon. It uses a solarbotics geared motor, mounted in its wheel as a base, and all of the "brains" are literally in the head. It behaves with surprising amount of behavior for something so simple, as seen in a video below.

Here you can better see why its called Blue eyed, and a Dragon. heh. I was in kind of an odd mood late at night when I finished this, and I noticed the InstaMorph holding the underside of the chip all nice and stable (don't want those jumpers bending and touching each other), once trimmed, looked a bit like an alligator/dragon head. so I went with it when it came time to place all the parts.  ...My only regret is putting the power switch in such an awkward spot.
Anyways, video time. I uploaded this on Youtube as well, as I plan to add some notations as it is acting up a bit.
I like how he can spot lights from across the room (the dim light was my computer monitor), and gets a little squeal going on when really close to the light (The motor is still cycling left/right very rapidly when it looks like its staring.. and the squeal is the motor oscillating at audible frequencies)
 
So, back to IC chips. The Octal inverter is the one I tinker around with most, as the 555 timer, even after reading up on a bit, is still a bit beyond my current level of understanding- in order to get it to actually behave like a timer. Another chip I tried out was the Audio Amp- which can also power a motor, or even a pair of motors dynamically- alternating the amounts of power to each motor as it tries to "equalize" the signal as it varies with the photoelectronic eyes. This is how the "Herbie" bots chase a light around on Youtube. But I cant really claim to understand how the amp does this.. at this time.
 
One of the IC chips I want to get to mess around with is a Clock.. or Shift Register type of chip. These are like the inverter, but cascade down the list of channels whenever something happens. I'll admit I mostly want this chip just so I can make my own knight rider Kitt light bar... or a cylon scanner... no really- a scanner- an array or LED's light up cylon like, sweeping left and right, and another array of light sensors watch for reflections, to know when something is too close... either to avoid it, ram it, or reach out and shove it away... that kind of thing.
 
Well, I'm apparently off into daydream land now, so lets end this before I gt TOO loopy.

Tuesday, December 4, 2012

IR Photoelectronics Learning

You remember the robot Eye I made earlier, right? This was after figuring out how a photo resistor works- varying the resistance it provides to a circuit, and, if balanced against another resistor going to ground, creates a variable voltage divider, meaning that the point in between the resistors will have varying voltage depending on the light hitting the Eye- making the Eye a simple and direct motor controller to make a "photovore" that chases a flashlight around.

Anyway, there are several other types of light sensing devices, and since I wanted to learn robotics and electronics, light sensors seem to be a very important thing to learn about.

After salvaging some photodiodes from an old mouse (the kind with a track ball in the bottom), and other photoelectronics I could recognize in other various old electronics (old TV remotes were an obvious choice), and buying some from radio shack now and then over the months, I now have a rather full assortment of gizmo's.. which I never really figured out how to work.

I followed instructions in the Junkbots book (the book that let me know where to find free goodies in "broken" stuff lying in closets and garages everywhere), I had made a "headbot" that spins in place following a light around, using some exotic "bicore" method that made the pulses of the motor going left-right-left vary according to the light hitting the two "eyes". Pretty cool, and worked just fine.. but I had no real idea how it worked. Not really.

So, tonight I dumped the photoelectronics drawer of my little tackle box shelves, and got to work... getting them to work. heh. I noticed that most of the parts were IR (infrared), so, obviously I needed an IR LED to trigger the sensors, right? I tried a TV remote, but I guess the pulses were very rapid or something, nothing seemed to work, so the first step was to build my very first IR remote control, to test these things and see how to make them work.

And here it is, in all its scratch built, "still trying to look cool" glory. I read on the data card for the IRLED's that the voltage to put to them was "1.7v MAX", so a single AA would do just fine. A momentary push button meant I now had my very own IR flashlight... that I couldn't see any light coming out of...
 




...but my camera could see it! Turns out that digital cameras use some kind of CCD light sensor to see and record the image, and this CCD was able to see slightly beyond Human visual spectrum... obviously! This rather bright LED was completely dark as I shot this pic.. Pretty neat!
 
So, with that done, I got to making a breadboard thing that I could aim the IRLED at to make it do something. So, I set up the board with a 5v relay, wired to show a red LED when it was off, and a green one when it got turned on. It was going to get turned on by the photo diode I chose getting hit by IR light.
 
It didn't work, all by itself. You can see the faint purple of the IRLED coming from the light, and bouncing off of the detector I was using, but the relay wasn't energizing. THIS was the "problems" I was dealing with previously in ever trying to put these neat little sensors to work. But today, I vowed to dig in and tinker with it!


I tried having the power the photo diode let through when light hit it power the base of an NPN transistor. Still nothing. Then I got my meters out. With the 6 volts coming from the blue power supply, and the .7 or so Voltage drop expected from the diode, there should be enough to energize the 5v relay, yet not enough was "getting through". In this picture, you can see that the power the diode is letting through is 3.5v or so, so its already about as high as it can go, but the transistor wasn't "turning on enough" to let the relay click on.


So I began thinking... maybe the relay is too power hungry for the diode or transistor to energize it? I knew the transistor was strong enough, as it had done it before on previous tests with other things, so I knew it was the photo diode not giving enough "oomph" as it were.
 
If the diode was doing all it could do, then the problem was to make it do what >>I<< wanted it to do, by somehow taking the power it was leaking though, and have it be enough to turn on the relay. So, I got a bit unoriginal, and had the diode enable the first transistor, which would enable a second transistor, hopefully making that small change at the beginning bigger and bigger each time I used the transistor to "amplify" the "signal" (Junkbots book taught me that a little "push" at the base means a BIG push through the transistor:: amplify)
 
So, with it all rewired, with a double chain of transistors, I wired up my meter to the final power output of the last transistor, leading off to the relay, far right. This pic shows, even with the ambient desk light, the feeble push from the photo diode was already resulting in 3v waiting at the relay. With more direct IR light hitting it, it should easily trip the relay on now.
 
 
Same light as before, but now with the IRLED adding to the punch, Success! I will admit to a little giggle of delight seeing that green light come on (and almost blow out with too much voltage going through it!!). Weird thing is, the voltage at the meter probe didn't really change much.. but the relay clicked... hrmm. Current maybe?
So far I have only been using variances in voltage to make transistors do things, and thought that the transistors let out more voltage as well.. but now think there may be more going on in there than that. Oh well, that's some learnin' for another time. Now its time to show off!
It may not look like much, but I love that it is all home made, self taught, and actually working! Not shown, but what I did later was add even more transistors the the amplify chain, to see if it would increase the actual range of the sensor's "sight" beyond the roughly 2 foot range it shows above. YUP! each transistor seems to add about a foot! This particular IR sensor is the best I played around with so far- its "view" being all around, as opposed to the other types that had to be a dead on hit with the light to do anything.
 
So this is another Queue card sketch on my file, and another gizmo I'm going to take off the breadboard and make into a purpose built device: "a wheeled Robot tester"; something I can just stick to the motors of a chassis/toy/home built Frankenstein creation, or whatever, put it on the ground, and use my remote to see if the motors are going the right way, the wheels are straight, if it pulls to the left or not, etc.


Friday, November 30, 2012

ELECTRONICS: Self taught beginnings.

I admit that the spinners I had built off of the solar engine instructions in the Junkbots... book were built off of instructions, and I really had little Idea of even how the solar engines worked at that point. so, I got a bit serious on discovering things on my own, so that I would know about them without trying to remember lessons learned by rote, or comprehend the paragraphs I just read on things I didnt fully understand yet- that was why I wanted hands-on personal experience.

So, where to begin? Transistors. I knew there were two basic types. NPN and PNP, each with varying performances and attributes, that could be looked up on datasheets online. But I had no need for trivia. I knew most things I build would be low voltage, trickle charged, or running off of a 9volt at most.

So, I set up my little power supply, set it to 3V, and placed an NPN transistor in the center, and put 3 jumper wires inline with the 3 rows the prongs were stuck into. I kind of figured that N stood for Negative, and P for Positive, so I tried putting + to the P part (middle pin), Then an LED to one pin to power, to ground, then the other side, until I got to a point where the darn thing switched the LED on and off with me pulling the middle pin out. I eventually figured out that the two side pins were basically like NO (Normally open) contacts on a relay (which I understood as an electrician), with the middle pin being the "coil". With that figured out I now knew that transistors were tiny little switches.
This is a re creation of my eventual "Eureka!" moment, of getting the transistor(lost between the jumper prongs) to "do its thing"
















Doing a little more "exploring and trying everything" I found out that the NPN transistor didnt really matter which way the current flowed through the ends (collector and base), and it was basically a "conductor". What was odd in my "try everything" was that with power to the base, and either side having the LED, the light would still come on... without anything on the other prong. I didnt know what to do with this little tidbit of knowledge (still cant think of any reason to), but the point is that now I DO know it, and its a part of my experience, not just something I read. So its with me now.

Next I looked into the "amplification" factor of transistors; how a weak change in the Base makes a BIG change in the mainline power flowing through the ends. Trying to keep robotics in mind, I used a photoresistor to drive a small motor at different speeds with different light levels. It didnt work very well by itself. The resistance was just too high for the 5V to push through the resistor AND drive the little motor. So I tried the photresistor as a variable current into the base of an NPN, to see if this "amplification" thing would do what I thought. It didnt. The resistor varied the current to the base, but this only resulted in an on, or off state to the motor, which did in fact drive now, just all the time, using the transistor as a pathway for the power.

It was time to do some thinking. I had read up in a "beginning electronics" book about "voltage dividers" and knew a bit about the ohms law theory of it all (electrician, remember); about how the voltage drops were divided up evenly along the different loads in a series circuit.  This gave me a little lightbulb moment: "maybe I dont adjust the current to the base, but rather the VOLTAGE!" I eagerly put the photoresistor from power to base, like it was before, only now added a 1k ohm resistor from that base to ground.. this should vary the voltage to the base as the resistance of the photresistor changes between its 10k ohm and 2k ohm range. It worked GREAT!

After making a system that worked, I then went on to make something to keep my interest going: I made a Robot Eye.
Point of note: it was built to look like an eye- with "neuron" blob solder joints, to tangled optic nerve wires- on PURPOSE. :) It is really as simple as a photoresistor, a NPN transistor, a 1k ohm resistor, and 3 color coded wires: Red= + voltage, Green= Ground, Black= Motor power lead.







Having a purpose to strive for made all the puzzling out less tedious. I now had an Eye that could vary the speed of a wheeled motor. Cross connect the eyes to the opposite motors, and the eye facing the light would make the opposite wheel go faster, making it follow/chase a light around.  THAT is the far off goal that keeps me at it!

Oh, how about a video of the Eye driving a wheel?

So yeah, progress was made rather quickly with simple level electronics aimed at doing something "neat". That wheel/geared motor, by the way, used to be a TrekBot.
http://www.mydeskpets.com/trekbot/
These are found at RadioShack, and are pretty much mass produced BEAM bots all in themselves. I bought a couple of these, played with them the prerequisite amount, then promptly tore them apart for parts, and a rather cool hubless wheel design.

I asked the People at DeskPets if it was ok to "hack" their toys, in order to make other things with them, and that I was intereted in making some of them into BEAM photovores instead of remote control. They replied that it was perfectly fine, they love BEAM hacking too, and even gave me the pinouts of the tiny chip inside that drives the H-bridges to fwd or reverse the wheels!!! That was above and beyond what I expected, those guys are awesome! and make some pretty cool gizmos, as well.

The SkitterBot, TrekBot, and TankBot are my favorite. I have bought (and frankenstein monster'ed) many of them over the months.