Trying to make wall avoiding robot

SgtWookie

Joined Jul 17, 2007
22,230
I hate to tell you this, but your wiring job isn't even close to the schematic I posted! :confused:

You DID get the 220uF cap right. :) Unfortunately, the 1N4004 diode is placed incorrectly.

You need a junction below where V+ connects to R4 and pin 8.

R6 goes away.

The IR LED's anode gets connected directly to Vcc.

The Pin 3 output of the 555 timer gets connected directly to one of the MOSFET gates.

It's really best to do these things when you're not tired. As it is right now, there are a lot of errors.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Maybe it´s my fault, but why do you keep posting a blurred miniature of something, and a 1x1 pixel gif?
I can see them just fine. There is likely a routing problem in the Internet between where you are and his image hosting site; ImageShack.
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, I've updated my older version just for the purpose of sorting out the 555 timer and the LED drive thing. I haven't made a number of the other changes, however I think you'll find this version easier to read than where you are at the moment.

I don't have that IR Receiver in my libraries, so I'm just leaving the one I have in there for now.

Note how I labeled the wires on the Atmel, and at the gates of the MOSFETs.
You probably don't have the 2N7000 MOSFETs in your libraries; I had to add them to one of mine.

N-ch MOSFETs are generally depicted in schematics with the source down, gate to the left, drain up.

555 timers put a rather heavy load on Vcc when the output changes states. There is a brief moment in time when both the upper and lower side output transistors are conducting, which constitutes a direct short across the supply. A larger capacitor is needed to filter out those momentary "blips".
[eta]
Updated the schematic; moved V+ and D12 to the left side of the 555 timer, which reduced clutter a tad.

Added wallrobot2.sch
 

Attachments

Last edited:

Thread Starter

Qaptian

Joined Oct 27, 2008
37
OK, I've updated my older version just for the purpose of sorting out the 555 timer and the LED drive thing. I haven't made a number of the other changes, however I think you'll find this version easier to read than where you are at the moment.
Yes, the one you posted above was very helpful, thanks! I ended up copying it exactly the way it is above into the schematic below.

I don't have that IR Receiver in my libraries, so I'm just leaving the one I have in there for now.
If you'd like, I can post the one that I used. I can also post the 2n7000's that I used.

N-ch MOSFETs are generally depicted in schematics with the source down, gate to the left, drain up.
This small piece of information was incredibly helpful! I had been searching the web for this answer, but couldn't find it. Thanks!

OK, I've attached the newest version of the schematic. I copied the mini 555 circuit exactly as you had it in yours, SgtWookie.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
I'm afraid that your libraries and schematics won't help me very much; I won't be able to read them with this older version of Eagle. Thanks for the offer though.

The gates of MOSFETS on the left follows the "rule of thumb" that inputs come from the left side of the schematic, and outputs go to the right.

Note that P-ch MOSFETS should be shown with the source towards the top of the schematic, drain towards the bottom, gates to the left. You usually have to flip them around and mirror them to get the orientation correct.

Note also that I have moved the V+ and D13 (D12 in my schematic) to the left of the 555 timer. This is a tad bit more in keeping with inputs/sources on the left, outputs on the right. It also reduces clutter on the right just a bit.

You need a junction above C10, next to pin 8 (V+) of the 555 timer.

Note that I used IC1-P2 and IC1-P3 to label the signals going to the gates of the MOSFETs from the uC. This helps to eliminate any possible ambiguity (or duplication) that may arise if you attempt to subsequently label another wire as P2 or P3 from another IC. It also quickly identifies (from the MOSFET end) as to exactly where the signal is coming from.

Now to correct a mistake I made when I was tired:
The wire pads need to have their VALUE fields copied into their NAME fields, and the VALUE fields blanked. I'd forgotten about this. If you don't do this, when you go to create your PCB, you'll only see PAD1, PAD2, etc on the PCB, which will be pretty meaningless. "BAT+" is far more helpful than "PAD5", don't you agree? ;)
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Note that P-ch MOSFETS should be shown with the source towards the top of the schematic, drain towards the bottom, gates to the left. You usually have to flip them around and mirror them to get the orientation correct.
We aren't using this type of MOSFET, correct? I just want to make sure before I flip them around.

Note also that I have moved the V+ and D13 (D12 in my schematic) to the left of the 555 timer. This is a tad bit more in keeping with inputs/sources on the left, outputs on the right. It also reduces clutter on the right just a bit.

You need a junction above C10, next to pin 8 (V+) of the 555 timer.

Note that I used IC1-P2 and IC1-P3 to label the signals going to the gates of the MOSFETs from the uC. This helps to eliminate any possible ambiguity (or duplication) that may arise if you attempt to subsequently label another wire as P2 or P3 from another IC. It also quickly identifies (from the MOSFET end) as to exactly where the signal is coming from.
I fixed these up in the new schematic.

Now to correct a mistake I made when I was tired:
The wire pads need to have their VALUE fields copied into their NAME fields, and the VALUE fields blanked. I'd forgotten about this. If you don't do this, when you go to create your PCB, you'll only see PAD1, PAD2, etc on the PCB, which will be pretty meaningless. "BAT+" is far more helpful than "PAD5", don't you agree? ;)
I added a couple of 2 pin jumpers there instead of pads, did the same thing for the battery. I'm thinking I'll be able to use one of these in conjunction with one of these to make things a little neater on the PCB.

Have we gotten everything sorted out? I don't see any major problems (then again, that's why I'm here in the first place).

Here's another picture of the schematic:
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Re: P-ch MOSFETs
We aren't using this type of MOSFET, correct? I just want to make sure before I flip them around.
Correct, you are not using any P-ch MOSFETs at this point in time. That was just a FYI kind of thing.

re: Note that I used IC1-P2 and IC1-P3 to label the signals going to the gates of the MOSFETs
I fixed these up in the new schematic.
Ahhh, it looks like instead of labeling the wire, you changed the VALUE field of the MOSFETs!
Ok, on the MOSFETs - if those are not TO-92 type MOSFETs, you will need to change the package type, or replace them with a different symbol.
After you make sure the package type is correct, change the VALUE field of the MOSFETs to 2N7000.
Then make sure the wires on the gates have the proper Name/wire label (IC1-P2 and IC1-P3).

Also, on your AVR header - change the "PIN5" label to either "IC1-P1" or "/RESET", and allow it to change the signal everywhere in the schematic.

I added a couple of 2 pin jumpers there instead of pads, did the same thing for the battery. I'm thinking I'll be able to use one of these in conjunction with one of these to make things a little neater on the PCB.
OK, that's good. I suggest that 2mm is the smallest spacing that you'll want to fiddle with. You'll have to be very careful with spacing when your drilling holes - if you're making the PCB yourself.

Have we gotten everything sorted out? I don't see any major problems (then again, that's why I'm here in the first place).
Did you notice that you still have R4 and D9 connected to the AVR on pin 14?
The AVR really isn't capable of driving that IR LED directly; I think it's limited to 25mA source/sink. The LED is rated for up to 100mA current, but even in the 555 driver circuit, the most you'll put through it is 48mA. You really don't want it to be emitting full brightness anyway, or the receiver would be seeing walls 20 feet away. That's the reason for the uC-selectable IR LED current.
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Ahhh, it looks like instead of labeling the wire, you changed the VALUE field of the MOSFETs!
Ok, on the MOSFETs - if those are not TO-92 type MOSFETs, you will need to change the package type, or replace them with a different symbol.
After you make sure the package type is correct, change the VALUE field of the MOSFETs to 2N7000.
Then make sure the wires on the gates have the proper Name/wire label (IC1-P2 and IC1-P3).
The above are actually correct in my schematic, it's just that everything is so close together, it looks like I messed something up. I should also be using the right kind of MOSFETs, because I downloaded a pack off the internet and I used the TO-92 from the pack when building this part of the schematic. I'm attaching the file I used (transistors.lbr) which had the MOSFETs in it - I think it may work on your version. Here is the site I grabbed that file from.

Also, on your AVR header - change the "PIN5" label to either "IC1-P1" or "/RESET", and allow it to change the signal everywhere in the schematic.
Good call, I changed this and it makes more sense than just having "PIN5".

OK, that's good. I suggest that 2mm is the smallest spacing that you'll want to fiddle with. You'll have to be very careful with spacing when your drilling holes - if you're making the PCB yourself.
I really had wanted to make my own PCB, but I don't have the right kind of printer, and I don't want to mess with chemicals that could be dangerous :eek:. I plan on making the files required to get a pcb made at www.batchpcb.com

Did you notice that you still have R4 and D9 connected to the AVR on pin 14?
The AVR really isn't capable of driving that IR LED directly; I think it's limited to 25mA source/sink. The LED is rated for up to 100mA current, but even in the 555 driver circuit, the most you'll put through it is 48mA. You really don't want it to be emitting full brightness anyway, or the receiver would be seeing walls 20 feet away. That's the reason for the uC-selectable IR LED current.
Yeap. I added the LED back in thinking I might want to try controlling it with PWM in the future. If it's not going to work, though, I'll just take it out.

Here's an updated schematic, should be a little easier to understand than the last one.
 

Attachments

Thread Starter

Qaptian

Joined Oct 27, 2008
37
I made a post earlier and it looks like it didn't show up? How odd.

Anyway, I basically fixed all the problems and have another schematic.

I left the LED on pin14 of the micro to try out some PWM at a later point in time. Also, the 2n7000s I used came from a pack I grabbed off the internet - they are the TO-92 version, I did a double check. They just look a bit different.

If my other post shows up, just ignore this one.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
I made a post earlier and it looks like it didn't show up? How odd.
That happens to me too. I'm in FL, and this board is hosted in the UK, I believe. Even a small glitch in the network is enough to send posts to the bit bucket.

Anyway, I basically fixed all the problems and have another schematic.

I left the LED on pin14 of the micro to try out some PWM at a later point in time.
You won't get much out of it for one, and for another it'll be taking up precious space on your PCB, which you're rapidly running out of. If you want to be able to drive it hard, you'll need to use a MOSFET to sink the current. Right now, with the 330 Ohm resistor, you'll be able to put about 11mA through it. Also, unless you can match frequencies with the IR receiver frequency, and adjust PWM within that frequency range, you won't get very far with it.

Also, the 2n7000s I used came from a pack I grabbed off the internet - they are the TO-92 version, I did a double check. They just look a bit different.
You mean a library, I'm sure. OK. Beware of libraries that you didn't create.

It's up to you if you want to leave the other LED/etc in there. Space is going to be tight.
 

Dave

Joined Nov 17, 2003
6,969
I made a post earlier and it looks like it didn't show up? How odd.

...

If my other post shows up, just ignore this one.
That happens to me too. I'm in FL, and this board is hosted in the UK, I believe. Even a small glitch in the network is enough to send posts to the bit bucket.
Apologies guys, the post is now on the forums. We are trialling some anti-spam measures and it sometimes gets a little keen and flags up innocuous posts. Qaptian, you are inside the filtering thresholds which is why your post was filtered. Wook, you are outside of the filtering thresholds so should never be filtered - if you have posts not showing up on the forums please let me know and I will investigate. Thanks.

I will have another play around with the settings. Once again apologies for the inconvenience.

Dave
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
I decided to take the extra LED out, if it's not going to be very powerful, there's no need for it. I'm working on the PCB and looking for parts right now, I'll post more when I start assembling stuff (could take a while, if this gets expensive. But I'm ready to wait.)

Here's the final schematic:

Two things have me a little worried about it, though: R2 - on the IR Receiver, and the D14 - the IR LED. I'm just wondering if R2 is really necessary? If it's only getting +5v, but it's rated for 6v and 1.5mA of current, couldn't I just remove it? I think that's the wrong size resistor, anyway. I'd need a 1k ohm resistor if I calculated correctly. Now about D14 - is it connected correctly? Do we modulate the GND to get different intensities? I don't understand why it's connected the way that it is.

Here's a mock PCB that I made with some eagle plugins, in case anyone's interested.


Note: As I find out which parts I need, I'll be referencing them to the schematic. If they aren't the same, I'll be changing them - so this PCB could end up having different parts on it than the final version.

Thank you for all the time and thinking you put in to helping a noob out, SgtWookie!

Thanks for being such a great admin, Dave!
 

SgtWookie

Joined Jul 17, 2007
22,230
I decided to take the extra LED out, if it's not going to be very powerful, there's no need for it.
OK, that's fine. It would be difficult for a n00b to drive it anyway. ;)

I'm working on the PCB and looking for parts right now, I'll post more when I start assembling stuff (could take a while, if this gets expensive. But I'm ready to wait.)
Well, the parts really shouldn't be very expensive. Just a wild guess, but you could likely get everything from someplace like Digikey for under $30.

Here's the semi-final schematic:
(snip)
Two things have me a little worried about it, though: R2 - on the IR Receiver, and the D14 - the IR LED. I'm just wondering if R2 is really necessary? If it's only getting +5v, but it's rated for 6v and 1.5mA of current, couldn't I just remove it? I think that's the wrong size resistor, anyway. I'd need a 1k ohm resistor if I calculated correctly.
Take a look at the datasheet for the IR receiver. Page 1, lower right corner. "Typical Application Circuit". So, change R2 to 100 Ohms, and add a 4.7uF capacitor between R2 and the receiver's VCC pin.

Now about D14 - is it connected correctly? Do we modulate the GND to get different intensities? I don't understand why it's connected the way that it is.
Q3 provides the ground path for the IR LED. It's gate is turned on and off by the 555 timer circuit, which will need to be "tuned" to the IR receiver's frequency by adjusting R8 when the assembly is complete; somewhere between 34kHz and 40kHz depending upon which receiver you get.

R9 provides a default low current level through the IR emitter when Q3 is turned on. If more IR is desired, Q1 and/or Q2 can be switched on by outputting logic 1's (high voltage level) on IC1-P2 (PD0) and IC1-P3 (PD1).

In all, four different light output levels will be available; this was sort of explained a few posts back. The light output of an LED is roughly porportional to the amount of current flowing through it. The higher the current flow, the brighter the output - up to the rated limits.

Being able to select the intensity of the IR emitter gives you the capability of rudimentary range measurement. By having the robot turn in a circle, it could make a decision on which way to go by selecting a direction where the IR returns were the weakest.


Here's a mock PCB that I made with some eagle plugins, in case anyone's interested.
Interesting. Where did you find the plugins?

Note: As I find out which parts I need, I'll be referencing them to the schematic. If they aren't the same, I'll be changing them - so this PCB could end up having different parts on it than the final version.
Of course. You'll also find as you are laying things out that you may need to change packages for resistors, caps, etc - to perhaps bridge over several traces, or fit in a very compact space.

[eta]
Try to make your "rail" traces pretty wide; say .032" to .06". Otherwise, they will act as fuses when power is applied. :eek:

Capacitor notes: your capacitors that are over 1uF will likely be aluminum electrolytic, as they provide large values in a comparatively small space. However, use capacitors with a voltage rating at least twice the voltage expected to be seen in the circuit it's attached to; this is a "rule of thumb". For example, those caps attached to V+ will need to be rated for at least 18V; those on Vcc will need to be rated at least 10V. If you attempt to use capacitors that are rated too close to the in-circuit voltage, they will have a very short life.

The Polygon tool is great for "copper pour". You can change the NAME of the polygon to GND, and it will then become a ground plane for the entire side of the board. Clicking the "Ratsnest" tool will cause the polygon to fill. Use 0.010" for the width of the polygon. Try an Isolate value of 0.016" or 0.024"
 
Last edited:

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Take a look at the datasheet for the IR receiver. Page 1, lower right corner. "Typical Application Circuit". So, change R2 to 100 Ohms, and add a 4.7uF capacitor between R2 and the receiver's VCC pin.
I got myself so far into the datasheet looking for info that I didn't even bother with page 1. I need to look harder next time! I changed this - it should be fine now.

R9 provides a default low current level through the IR emitter when Q3 is turned on. If more IR is desired, Q1 and/or Q2 can be switched on by outputting logic 1's (high voltage level) on IC1-P2 (PD0) and IC1-P3 (PD1).
I understand now. Since electricity takes the path of least resistance, we use the MOSFETs as bridges that can be opened or closed with resistors on the other end smaller than 330ohms.


Interesting. Where did you find the plugins?
I followed this tutorial - I ended up using POV-ray to render the final image. The ULP file was in the Eagle folder of Program Files for me. There are a few parts that don't get rendered - but the main ones usually show up.

Try to make your "rail" traces pretty wide; say .032" to .06". Otherwise, they will act as fuses when power is applied. :eek:
I'm not sure where to change or check this in eagle. I looked through design rule check and also looked through the autorouter options - I couldn't find anything for rail traces. I only changed the 'Routing Grid' - I set it to 8mils for batchpcb.com usage.

Capacitor notes: your capacitors that are over 1uF will likely be aluminum electrolytic, as they provide large values in a comparatively small space. However, use capacitors with a voltage rating at least twice the voltage expected to be seen in the circuit it's attached to; this is a "rule of thumb". For example, those caps attached to V+ will need to be rated for at least 18V; those on Vcc will need to be rated at least 10V. If you attempt to use capacitors that are rated too close to the in-circuit voltage, they will have a very short life.
Will do, thanks for the tip!

The Polygon tool is great for "copper pour". You can change the NAME of the polygon to GND, and it will then become a ground plane for the entire side of the board. Clicking the "Ratsnest" tool will cause the polygon to fill. Use 0.010" for the width of the polygon. Try an Isolate value of 0.016" or 0.024"
I did this - it seemed to automatically avoid pads and traces when I covered the whole PCB with it. Now for another question - do I put the copper pour on the top of the PCB, the bottom of the PCB, or both sides of it? Will the people over at batchpcb know that I want there to be "copper pour" on my PCB?

Here's another sort-of final schematic:

 

SgtWookie

Joined Jul 17, 2007
22,230
I got myself so far into the datasheet looking for info that I didn't even bother with page 1. I need to look harder next time! I changed this - it should be fine now.
It's easy to overlook things like that. But for future reference, try to remember to look at the "Typical Applications" sections, if provided. They may just save you lots of grief later.

Re: MOSFET switches:
I understand now. Since electricity takes the path of least resistance, we use the MOSFETs as bridges that can be opened or closed with resistors on the other end smaller than 330ohms.
Yes - sorry I didn't explain that better before. My fault!

Re: 3D rendering of board:
I followed this tutorial - I ended up using POV-ray to render the final image. The ULP file was in the Eagle folder of Program Files for me. There are a few parts that don't get rendered - but the main ones usually show up.
Very interesting, and quite handy. Thanks for the link!

Did you manually set up the parts placement on the board beforehand, or did you use a utility program/ULP to do so?

Re: Try to make your "rail" traces pretty wide; say .032" to .06".
I'm not sure where to change or check this in eagle. I looked through design rule check and also looked through the autorouter options - I couldn't find anything for rail traces. I only changed the 'Routing Grid' - I set it to 8mils for batchpcb.com usage.
OK, you need to change this using the Change tool. It looks like a wrench on the menu bar to the left. Click on Change, then select Width - and select the width you want.

If a rail trace goes between the pads of a DIP IC, you're usually "stuck" with .016" traces, unless you can figure out a better routing. If it doesn't go between a DIP's pads, you can almost always go to .032" or larger. The big concerns are the V+ traces; and VCC traces where large caps are involved. The narrower that "rail" traces are, the more resistance they'll have.

Re: 2x cap voltage rating
Will do, thanks for the tip!
You got it ;) That "rule of thumb" holds for many other things, too - size your resistors for 2x the wattage, MOSFETs/BJTs for 2x the voltage/current, diodes for 2x the voltage/current, etc.

Re: polygon "copper pour":
I did this - it seemed to automatically avoid pads and traces when I covered the whole PCB with it. Now for another question - do I put the copper pour on the top of the PCB, the bottom of the PCB, or both sides of it? Will the people over at batchpcb know that I want there to be "copper pour" on my PCB?
They'll only put stuff where you tell them to put it.
If you can connect everything just using the bottom side of a board, then do that; leave the other side with no copper; just text/solder masks/etc.
If you need to use two sides, then do so.
You might consider NAMEing the bottom side polygon as GND, and the top as VCC; that way you'll have a power rail on each side if you need to.
 

Thread Starter

Qaptian

Joined Oct 27, 2008
37
Did you manually set up the parts placement on the board beforehand, or did you use a utility program/ULP to do so?
(this was in reference to the eagle 3d plugin)

I setup the PCB in eagle, put all the components on it, then ran a ULP file which created another file that I opened up in POV-Ray, which then rendered the image.

I've been busy working on this PCB and sourcing out places to get parts, digikey is where I'm buying the main components.

I'm also working on changing the V+ and VCC rail sizes. I noticed a problem, though. At one point, a trace goes straight then forks out in two directions. Is this 'legal' in the world of electricity? Here's a pic if I'm not making sense (The problem I see is circled in yellow):




Now that I think about it, I guess this is done properly - it just didn't look right at first.
 

SgtWookie

Joined Jul 17, 2007
22,230
I fiddled around a bit with the add-in. Interesting.
I've been busy working on this PCB and sourcing out places to get parts, digikey is where I'm buying the main components.
OK. Make sure you make any necessary adjustments to your schematic's component packages and triple-check the board before you submit it. If you don't, you're likely to wind up with a $20 green coaster.

I'm also working on changing the V+ and VCC rail sizes. I noticed a problem, though. At one point, a trace goes straight then forks out in two directions. Is this 'legal' in the world of electricity? Here's a pic if I'm not making sense
It's absolutely legal, and you are making perfect sense.

It looks like you have a lot of room. Make the traces wide. Easier to make the traces wide now, than try to repair them later. :eek:

Note that when you select a new width in the "Change" tool, you will have to click on every segment of a trace to change it's width. Any time a trace changes direction, that's a new segment.
Now that I think about it, I guess this is done properly - it just didn't look right at first.
It's OK. :)
 

Alberto

Joined Nov 7, 2008
169
Since the bridge will reverse the polarity to the motors to obtain the two directions, then you are shorting the output with your diodes. You cannot use diodes as clamp connected in that way. You will burn the controller and your motors will never move! Use a RC filter connected in parrallel to the motors! And remove all diodes!
 

Alberto

Joined Nov 7, 2008
169
Remove all diodes from L298 or you will burn it and your motors will never move! Since L298 is a dual bridges the polarity on the two motors will be revesed to obtain the two directions, this means that you cannot clamp the output with diodes without shorting them! Use a RC filter in parallel to the motor. (15 ohms + 100 nF should do)
 
Last edited:
Top