Trying to make wall avoiding robot

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Hi everyone!

I've spent the past couple of days learning about microcontrollers and circuits and stuff like that. I made an LED flash with my little 12f629 and now I'm moving on to a bigger project - an object avoiding robot.

I've put together a circuit that looks just awful. I'm positive there's something wrong with it. If you are able to understand it and find an error, would you please help me out? I tried really hard to do this myself. I researched other similar projects, looked at the datasheets for the different components, etc.

I'm pretty sure I understand how to get this robot running, I'm just worried that if I put my design together without asking for help, it could blow up on me!

Without further ado, here it is:


Thanks for reading my post!
 

SgtWookie

Joined Jul 17, 2007
22,230
Well, besides being so messy that it's terribly hard to read, I don't know why you're trying to use two PIC12F629s instead of a more capable uC? :confused:

Don't get me wrong; that little PIC is great for little projects. But if you have two uC's, they'll have to be able to talk to each other to decide who's going to do what. You'll burn up all of your memory just trying to sort that mess out. Better to go with a more capable uC with more memory and I/O pins; something in the 16F series, like a 16F886 or 16F887. Lots of I/O pins, 8x more memory, and they have an internal clock - no need to fool around with crystals. Programmable with a PICkit 2.

Looks like you're thinking of using just two DC motors with H-bridge drivers. Don't know if you're planning on using PWM to drive them or what, but without PWM you'll have four possibilities: Off, Forward, Reverse, Brake. It really would be easier to control if you were using stepper motors.

Jameco has some inexpensive PF35T-48L4 "pancake" steppers that would work just fine on 6 volts. They're unipolar, so you could drive a pair of them using a ULN2803 Darlington IC. The ULN2803 has eight Darlington pairs in an 18-pin DIP.
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
My original idea was to have one 629 controlling the left motor, and the other controlling the right motor and the IR sensor. When the 629 with the sensor received input from the IR sensor, I would have had it send out a pulse from one of the legs to the other 629, which would give instructions to the h-bridge and hopefully pass those on to the motors.

I do have some atmega chips sitting around, and I think I've also got a programmer schematic that I could put together to program them, I think I'll go down that route instead of using 2 chips, it should be easier.

I looked into stepper motors too. I should probably get a few so I can learn how to use stepper motors, instead of using simple motors. A stepper motor seems to have much more maneuverability than a simple motor.

I'm also going to have to redo that schematic I posted above. Anyone got a tutorial on making a clean, easy to read circuit diagram? I've never been good at stuff like that. Once I figure it out though, I'll be back and hopefully someone will look at it for me.

Thank you for the tips, SgtWookie!
 

SgtWookie

Joined Jul 17, 2007
22,230
I don't know what software you're using for circuit layout. I've been using Cadsoft's Eagle Layout Editor for the last year. It's a bit quirky to learn, but powerful.

They have a free version available for download at their website:
http://www.cadsoft.de/
The free version is limited in the size of the board it'll produce (3"x4", 2 layers) and schematic pages (1 per board) but you can do quite a bit even with those limitations.

Here is a site that has a good tutorial:
http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=57&sipp=1&page=8
Read through it and follow along so that you get an idea how to use it.

Try to avoid having long, meandering traces; that makes a schematic confusing and hard to follow. A little "white space" is good between components, but at the same time, don't overdo it. The schematic you posted above has the components all jammed together, and then you tried to squeeze more items in.

The hand-drawn diodes don't have junctions marked (a junction is a small circle where three or four wires come together.) Without junctions, one has to assume that the wires aren't electrically connected.

Wires "hopping over" each other is an old standard, and not used anymore. If wires simply cross each other, they just cross without a "hump". If they're wired together, you place a junction.

Keep your wires running vertically or horizontally for now. Trying to run wires at odd angles or even 45° can make a schematic confusing in a big hurry.

Be consistent in the symbology you use. For example, resistors - in the US, they look like a triangle wave; in Europe they look like a rectangle. You can use either, but use the same symbol throughout.

Those stepper motors I suggested are quite a bargain if you buy 10 of them, and they're hard to beat for small robotics projects. I've seen them being sold elsewhere for several times Jameco's price.
 

blocco a spirale

Joined Jun 18, 2008
1,546
One 629 would be fine to control 2 motors (I don't see the point of stepper motors in this application) and read 2 sensors. Why not run everything off 4.5V from 3 AA cells to simplify the power supply.
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
I'm in a bit of a hurry, so I'm just going to post this new circuit (not quite as bad as the first, still not great). I made it in eagle.



Will this make anything blow up? Will it work? Also, if I plan on using stepper motors, I'm going to have to add the stepper motor controller somehow.

Thanks again guys for all your help!
 

steveb

Joined Jul 3, 2008
2,436
Hi everyone!

I've spent the past couple of days learning about microcontrollers and circuits and stuff like that. I made an LED flash with my little 12f629 and now I'm moving on to a bigger project - an object avoiding robot.

Wow! you don't waste any time do you? I like your style! :cool:
 

hgmjr

Joined Jan 28, 2005
9,027
I'm in a bit of a hurry, so I'm just going to post this new circuit (not quite as bad as the first, still not great). I made it in eagle.



Will this make anything blow up? Will it work? Also, if I plan on using stepper motors, I'm going to have to add the stepper motor controller somehow.

Thanks again guys for all your help!
A couple of things are missing from your design that you need to consider adding. One thing you need to add is either the 6-pin or 10-pin ATMEL defined in-system programming header. Another thing missing is a pullup on the reset pin.

I take it that you have made a conscious decision to use the internal RC oscillator as your clock source rather than provide a crystal controlled oscillator.

hgmjr
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
A couple of things are missing from your design that you need to consider adding. One thing you need to add is either the 6-pin or 10-pin ATMEL defined in-system programming header.
I'm new to the Atmega - Is this a necessary part? How does it work? What does it do? Where can I get one?

EDIT: Is this part used to reprogram the chip after it's been soldered in to the circuit? If that's what it does, I won't need it because I plan on using a socket for the chip, then just taking the chip out and reprogramming it when necessary.

Another thing missing is a pullup on the reset pin.
I just did a little research on this, would a 10kohm resistor from the +6v to the reset pin work? What exactly this does, I'm not sure - but from what I read, it should do the job as a pullup resistor.

I take it that you have made a conscious decision to use the internal RC oscillator as your clock source rather than provide a crystal controlled oscillator.
Yes, I'd like to use the internal clock and not an external one.
___________________________

Other than the above, how does everything else look? Am I using the right resistors? Do I need those diodes, and are they connected properly? I'm pretty excited to try this thing out, but I don't want to start soldering together a machine that won't work.

Thank you all for helping!
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
You have Vss of the L298 connected to 9V. This will fry it. Absolute maximum is 7V. OTOH, Vs can go as high as 50v.

I don't know what the voltage specifications are for the Atmega, but I suspect the absolute maximum is 5.5v. A 6v sealed lead-acid battery might put out 6.4v when it's fully charged, which would fry your uC. You will need to use a low dropout regulator or DC-DC converter.

The Vss of the L298 should be the same as the Vcc of the Atmel uC. If you attempt to directly connect the two in Eagle, strange things will happen; as a signal can't have two names. (VSS and VCC). You can get around this by using a resistor 0f 0 Ohms or a wire jumper between VCC and the Vss pin of the L298.

You don't have the grounds (negative terminals) of the two batteries referenced to each other. Because of this, your Atmel uC might issue commands to the L298, but the L298's input levels won't be correct.

Try using V+, VCC and GND symbols instead of running your power rails all over the place. It will eliminate much clutter.
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
See below for the answers to your questions.

I'm new to the Atmega - Is this a necessary part? How does it work? What does it do? Where can I get one?

EDIT: Is this part used to reprogram the chip after it's been soldered in to the circuit? If that's what it does, I won't need it because I plan on using a socket for the chip, then just taking the chip out and reprogramming it when necessary.
The ATMEL-defined 6-pin header or 10-pin header is the means by which you can reprogram the AVR microcontroller without removing it from the circuit. You can do as you indicated if you socket the part. However, you run the risk of breaking off a pin or possibly damaging the device due to electro-static discharge (ESD) due to the additional handling. I would suggest that you add the programming header so that you have it if you ever decide to use it.

I just did a little research on this, would a 10kohm resistor from the +6v to the reset pin work? What exactly this does, I'm not sure - but from what I read, it should do the job as a pullup resistor.
A 10K pullup resistor is the value recommended by ATMEL. You may also consider adding a small normally-open momentary switch so that you can manually reset the AVR if needed.
Yes, I'd like to use the internal clock and not an external one.
___________________________
Use of the internal oscillator clock source is a reasonable choice if you have no function to perform that require any precision timing.
One thing to keep in mind is that using the internal oscillator brings with it one minor nuisance. If by accident the clock source selection fuse gets programmed to select an external clock, you find the AVR will stop operating and will not be programmable. Don't panic though, the AVR can be recovered by providing it with an external clock source long enough to reset the clock source selection fuse to the internal clock oscillator.

I learned that little trick from personal experience.
Other than the above, how does everything else look? Am I using the right resistors? Do I need those diodes, and are they connected properly? I'm pretty excited to try this thing out, but I don't want to start soldering together a machine that won't work.

Thank you all for helping!
I and other members are still in the process of reviewing the schematic. So far I have not seen any other glaring problems with your design.

As you get further along into the coding phase of your design, be sure to let us know if we can be of assistance. I have 3 years of AVR design and programming experience using the free assembly language and free C-language development tools and there are several other members who have even more than I.

I, for one, look forward to assisting you with your project.

hgmjr
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Here's the latest schematic (I tried using V+ and GND indicators instead of a battery, like SgtWookie suggested [I probably didn't do it right, though]):



In order to keep things simple as a first 'big' project, I'd like to try and follow these guidelines:

-Use DC motors (easier for me to figure out, they don't require extra pieces. I would like to figure out how to use them in the future, though.)
-Use a socket for the Atmel chip (I'd like to try the programming header, but I'm using a cheap home-made programmer that I found on the web, I don't think it supports a programming header[http://chiip.descrambler.de/index.php/Programmer])
-Use BASCOM for the code (I don't actually know how to do 'real' coding - like C and whatnot - but I have played with basic style code in the past)

I plan on starting the code today once I get home, I'll keep this thread updated.

I really appreciate everyone helping out, It's just awesome to see how nice everyone is here!

Thanks for your kindness!
 

SgtWookie

Joined Jul 17, 2007
22,230
It's getting a bit better. :)
I like using the power/ground symbols in supply2.lbr the best. I should've spelled that out previously.

In Eagle, on the toolbar to the left, you'll see what looks like two European resistor symbols, both have "R1" and "10k".

The resistor with the black "R1" is the "Name" button; allows you to change the "name" of parts by left-clicking on them - actually, it changes the reference designator of an individual component, or the signal name or node name of a wire/trace/pad. There should not be duplicates of these values, unless they are on supply/ground connections.

The resistor with the black "10k" is the "Value" button; allows you to change the "value" of parts. This is handy for documenting values like resistance, capacitance, and inductance of discrete components, or the part numbers of items like diodes, transistors, and other semiconductors or ICs.

It is generally a bad idea to place components on top of wires, or wires on top of components, or touching/crossing the names or comments of components. Doing so can easily create ambiguity and confusion for the people trying to interpret your schematic. I'm referring to D1 thru D4 at the moment. I suggest that you line them up, away from the signal lines.

I'm afraid that R1 won't do for a voltage regulator. Note that the reference designator (Name) is overlapping the outline of the L298.

Also, in general, you want the inputs to a circuit to be on the left, and the outputs on the right.

D5 thru D8 could be all oriented the same.
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
OK, I've followed SgtWookie's guidelines and have another schematic, I'll probably use it to piece together the final project (I think this one is the best):




I also wrote up the code in BASCOM that should get the thing running (not sure which way the motors will move when this code runs, I'll have to test):
Rich (BB code):
$regfile = "m8def.dat"                            'set chip type
$crystal = 8000000                                'set clock frequency to 8mhz
$baud = 19200                                     'use baud rate
$hwstack = 32                             ' default use 32 for the hardware stack
$swstack = 10                                     ' default use 10 for the SW stack
$framesize = 40                               ' default use 40 for the frame space




Config Portc = Output                             'configure PORTC and PORTD
Config Portd = Input

Do
Portc.0 = 1                                     'get motors going forward
Portc.1 = 1
Portc.2 = 1
Portc.4 = 1

If Portd.0 = 1           'if IR Receiver sends signal to 
                              'PORTD.0 then do the following

Portc.2 = 0
Portc.4 = 0                 'reverse motors and turn, go back to start
Portc.3 = 1
Portc.5 = 1
Wait 1
Portc.3 = 0
Portc.2 = 1
Wait 1
Portc.5 = 0
Portc.2 = 0
Portc.2 = 1
Portc.4 = 1
End If
Loop
I'm pretty sure that everything is correct.

I'm ready to build, but I haven't ordered the parts yet.

Again, thanks to everyone who's replied to this thread. I'm really grateful that so many people are willing help a noob!
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, you still have problems.

You're trying to "regulate" voltage to the uC and the L298 using resistors.
That's not going to work. They both need regulated voltages. If you fail to provide properly regulated voltages to them, you won't get anywhere except to the trash can to toss the parts out when their smoke has been released.

[eta]
I just threw together a portion of your schematic, attached.

Try going forwards from there. It's a bit neater from what you're working with.

I swapped out the blocks you had for the motors with wire pads. Connectors would be more appropriate, but I don't know what you have to deal with.

The IR LED and sensor should be components, not merely blocks.

Every component you place in the schematic, you'll have to order or wire. Best to choose something you're pretty certain you can order in the first place, and will also do the job.

You still need a voltage regulator for Vcc.

You could probably run the whole thing from a single 9V battery; use the raw 9V for Vs, and regulate the rest with nice big caps to isolate the transients on the other side of the Vreg.
 

Attachments

Last edited:

Thread Starter

Qaptian

Joined Oct 27, 2008
37
OK, you still have problems.

You're trying to "regulate" voltage to the uC and the L298 using resistors.
That's not going to work. They both need regulated voltages. If you fail to provide properly regulated voltages to them, you won't get anywhere except to the trash can to toss the parts out when their smoke has been released.
OK, I am now using only one 9v battery, and I added a 5v regulator instead of a resistor to regulate the Vcc current on pin 9 of the l298 - this should (hopefully) give 9v to the motors, and 5v to the l298, then 5v to the atmega, correct?



I just threw together a portion of your schematic, attached.
Thanks for taking the time to do this! It helped me to be a little bit neater (at least I think so, you'll have to decide for yourself - it might still be a little messy)

The IR LED and sensor should be components, not merely blocks.
I was able to find the LED component, but I couldn't find the piece for my IR receiver - so I made one out of blocks again :|.

You still need a voltage regulator for Vcc.

You could probably run the whole thing from a single 9V battery; use the raw 9V for Vs, and regulate the rest with nice big caps to isolate the transients on the other side of the Vreg.
I added the 5v voltage regulator into the circuit and connected it to both Vcc on the l298 and Vcc on the atmega - this should power both of them, right? I don't think I need resistors, because 5v isn't high enough to kill the l298 or the atmega chip.

Also, a quick question - why did you add a capacitor from Vcc to GND on the atmega? I don't understand what it does. I'm not sure why there's one on the other chip either; again from Vcc to GND - the datasheet told me to put one there, so I added one.

Thanks for the schematic and tips, SgtWookie!
Thanks for your help, too, hgmjr!

I feel like we're making some progress. Either that or I keep making design changes that just create more problems :confused:
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, I am now using only one 9v battery, and I added a 5v regulator instead of a resistor to regulate the Vcc current on pin 9 of the l298 - this should (hopefully) give 9v to the motors, and 5v to the l298, then 5v to the atmega, correct?
Yes - but you've put a VCC symbol on the input to the regulator. That's going to "bite" you when you try making a board. VCC should be on the output side.

Also, you can't just keep the IR LED powered all the time. You need to compare what the "off" signal level return looks like to the "on" signal level return. Otherwise, you won't be able to compensate for ambient lighting/heat.

(link omitted to save space)

Thanks for taking the time to do this! It helped me to be a little bit neater (at least I think so, you'll have to decide for yourself - it might still be a little messy)
Well, you're still running power/ground wires all over the place, instead of using the symbols from the supply library. Using the symbols eliminates all of that clutter, and makes the schematic far easier to read.

I was able to find the LED component, but I couldn't find the piece for my IR receiver - so I made one out of blocks again :|.
You can make your own symbols. I found several IR receivers in the telefunken.lbr; I just threw it in so you could see how it looked.

I added the 5v voltage regulator into the circuit and connected it to both Vcc on the l298 and Vcc on the atmega - this should power both of them, right? I don't think I need resistors, because 5v isn't high enough to kill the l298 or the atmega chip.
5v is fine - but you need caps on the input and output of the regulator. You also need a fuse, so in case you make a boo-boo when wiring things, you blow the fuse instead of turning the board into a flaming pile of rubble.

Also, a quick question - why did you add a capacitor from Vcc to GND on the atmega? I don't understand what it does. I'm not sure why there's one on the other chip either; again from Vcc to GND - the datasheet told me to put one there, so I added one.
They're typically referred to as "bypass capacitors", and may be shown as either .1uF or 100nF. They help a great deal in "transient suppression"; reducing noise on the voltage supply. Without them, voltage right at the IC could fluctuate wildly. You want the cap as close to the VCC and ground pins of the IC as possible.

Anyway, see the attached.

I don't know if your IR receiver will put out a digital or analog signal. If it's digital, you'll use a digital input. If it's analog, you'll have to figure out how to use the ADC of your Atmel. I've never used one, so I'm not much help there.

But right now, there are three analog input pins that aren't connected; AGND, AREF, AVCC. If your IR receiver's output is analog, you'll have to figure out what to do with those.
[eta]
Small addition needed: a diode (a 1N4004 will work fine) between the V+ symbol and the intersection where C3 is connected to the VIN line of the regulator. This will prevent the motors from draining C3.
[eta]
Updated schematic & image to reflect the above change
 

Attachments

Last edited:

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Sorry I haven't replied in a while; I've been trying to program the atmega with this. I can't get it to work, I'll just buy a programmer.

On to the show!

Yes - but you've put a VCC symbol on the input to the regulator. That's going to "bite" you when you try making a board. VCC should be on the output side.
Does the regulator work by taking V+ and regulating it to 5v for VCC, while still letting 9v flowing through Vs on the l298? I find this part confusing.

Also, you can't just keep the IR LED powered all the time. You need to compare what the "off" signal level return looks like to the "on" signal level return. Otherwise, you won't be able to compensate for ambient lighting/heat.
How do I compare these two? Will I have to connect the LED to a pin on the micro and then send different pulses through the pin to make it either high or low in order to compensate? (Is that what D9 is?)

5v is fine - but you need caps on the input and output of the regulator. You also need a fuse, so in case you make a boo-boo when wiring things, you blow the fuse instead of turning the board into a flaming pile of rubble.
Is the piece called '1A SLOWBLOW' the fuse?

Also, while I'm talking about the schematic, I noticed that D1-D4 connect from GND to the Outputs, but then don't connect from the Outputs to Vs. Could I add that in by placing a V+ and renaming it Vs? (Look at the new schematic below, this will make sense)

I don't know if your IR receiver will put out a digital or analog signal. If it's digital, you'll use a digital input. If it's analog, you'll have to figure out how to use the ADC of your Atmel. I've never used one, so I'm not much help there.
I think it's digital, the datasheet I've been reading for it says that the "Demodulated output signal can be directly decoded by a microprocessor." I assume this means it's a digital output, and can be read by the microchip.


Here's another schematic, with a few changes:

-I added a V+ symbol to the diodes (I remember looking at someone elses schematic, and the diodes were connected from GND to the outputs, then the outputs to V+. Maybe they don't need to be connected there?)

-I added a 10kohm resistor from the reset pin on the atmega to the VCC - as suggested by hgmjr (still not sure what it does - maybe it's optional, too?)

This is starting to get REALLY complex - I like it :cool:.

 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Sorry I haven't replied in a while; I've been trying to program the atmega with this. I can't get it to work, I'll just buy a programmer.

On to the show!
Don't let things like that slow you down ;)
As long as you're going to buy a programmer, make plans to incorporate in-situ programming for this project. Otherwise, the pins remaining vs insertions/removals ratio is not in your favor! (see attached)
Does the regulator work by taking V+ and regulating it to 5v for VCC, while still letting 9v flowing through Vs on the l298? I find this part confusing.
Yes, it does. V+ was just "tapped off" after the switch, but before D10. D10 does more than just keeping the motors from discharging C3; it also protects the regulator in case you connect the battery backwards. :eek: Connecting the battery backwards would instead result in F1 blowing right away, because D1 thru D8 would be forward-biased; creating nearly a dead short across the battery. But, using another diode between the battery and the fuse would cause a loss of around 1v. If you really want reverse polarity protection, you could get that by using a P-ch MOSFET right after the switch; source towards the switch pin 2, drain before the V+ symbol, and gate tied to ground. That way, connecting the battery in reverse would just result in an open circuit after the switch.

How do I compare these two? Will I have to connect the LED to a pin on the micro and then send different pulses through the pin to make it either high or low in order to compensate? (Is that what D9 is?)
D9 is the IR LED. Sorry, didn't re-Value it like you did; I just left the part number in the Value field. I was a bit tired when I slapped it together.

Basically, you'll have the IR LED off, and take a reading from the IR receiver to get the ambient IR radiation reading. Then turn the IR LED on, and take another reading. If they're about the same, then there isn't anything for the IR to reflect from. But, if it's significantly higher, either the receiver is "seeing" the IR LED directly, or the IR is reflecting back from something.

Is the piece called '1A SLOWBLOW' the fuse?
Yes. That's the "Value" field. F1 is the Name, or reference designator.

Also, while I'm talking about the schematic, I noticed that D1-D4 connect from GND to the Outputs, but then don't connect from the Outputs to Vs. Could I add that in by placing a V+ and renaming it Vs? (Look at the new schematic below, this will make sense)
I was tired and in a bit of a hurry - I forgot to add that back in. It's preferable to simply place another V+ than connecting it to your VS pin on the L298. Notice how less "cluttered" the schematic looks with the use of the supply and ground symbols - you can see at a brief glance where the signals are going.

I think it (the IR receiver) is digital, the datasheet I've been reading for it says that the "Demodulated output signal can be directly decoded by a microprocessor." I assume this means it's a digital output, and can be read by the microchip.
Hmm, OK. Can you make us privy to the datasheet? I'm thinking now that it's one of those 38kHz units. If so, you'll either see a return, or no return. That might get dicey, because IR LEDs can have quite a range.

Here's another schematic, with a few changes:

-I added a V+ symbol to the diodes (I remember looking at someone elses schematic, and the diodes were connected from GND to the outputs, then the outputs to V+. Maybe they don't need to be connected there?)
No, they do need to be connected to V+. I simply forgot to add it.

-I added a 10kohm resistor from the reset pin on the atmega to the VCC - as suggested by hgmjr (still not sure what it does - maybe it's optional, too?)
It's not optional! If that pin goes low, your uC will be continuously resetting.

But, you didn't connect it to VCC, you connected it to V+. This is not good, because the voltage at V+ is not regulated. While the 10k resistor will limit current to <1mA, and that input may be clamped to VCC (limiting the maximum voltage on the pin) it would be far better to connect it to VCC instead.

This is starting to get REALLY complex - I like it :cool:.
It's not that complex - yet ;)


Looks like you did good ;) (with the exception of the V+ on the 10k pullup...)

Note that I connected the IR receiver to pin 12, which is both an analog input (AIN0) and PD6. I haven't even looked at the datasheet for that uC, but I suspect that you can configure that pin via software to either read analog levels via an ADC or logic levels. You or someone else will have to confirm that. If that is indeed the case, better to leave it there.

One thing you may have to do is flash the IR LED at different intensity levels to get some kind of distance information. You might do that by using a couple of adjacent pins with different value resistors to lower the IR LED's intensity. With the right combination of resistors, you could get four levels of intensity with just two pins and two resistors.

However, since I don't know what the specifications of your IR LED are offhand, it's a tad difficult to come up with some decent values.
 

Attachments

Last edited:

Thread Starter

Qaptian

Joined Oct 27, 2008
37
I've got the datasheets on the IR Led and the IR Receiver (WARNING: Those are links to .pdf files!)

But, you didn't connect it [the reset pin] to VCC, you connected it to V+. This is not good, because the voltage at V+ is not regulated. While the 10k resistor will limit current to <1mA, and that input may be clamped to VCC (limiting the maximum voltage on the pin) it would be far better to connect it to VCC instead.
Fixed the above, also added a 6 pin ISP Header - I think I've got it connected properly (It looks nice, too!)

One thing you may have to do is flash the IR LED at different intensity levels to get some kind of distance information. You might do that by using a couple of adjacent pins with different value resistors to lower the IR LED's intensity. With the right combination of resistors, you could get four levels of intensity with just two pins and two resistors.
Could I use PWM instead of resistors? Or does that only work on motors?

Here's the updated schematic:



EDIT: I noticed that if I were to plug in a programmer to the ISP Header, both the L298 and the micro would receive power from the programmer. Should I add a switch between the VCC pin and VCC on the L298 to turn off the L298 while the micro is programming? (Would it matter if it did get power though, because the motors would still remain OFF?)

I also noticed that VCC on the RESET pin of the micro is an arrow and not a circle. Does that mean anything?
 
Last edited:
Top