Have you thought about going to stand-alone chips?
A 328P-PU costs less than $3. Last I bought from Mouser, I paid less than $2.40 ea. Buy 10 and get a price break.
Here are all the steps and software to make different versions of Arduino on a breadboard.
That includes with external clock source and without.
It also covers making a breadboard 1284P Arduino which for the price is a lot of AVR.
@GoForSmoke : If u refer to my original post, you will note that my objective is in fact to use a standalone chip. However, since I am prototyping with Arduino, I decided to take a step back and to first refine the design based on Arduino. The next step will be to replace the Arduino with a chip on a custom PCB.
Alas, but first I still need (and waiting for) a technical expert's guidance...
Given my application as described in this thread, which standalone chip would you recommend? A priority would be to conserve battery life.
An 8 pin ATtiny45 might do. They cost about $1. The 85 has more RAM and flash if you need that.
You could probably get away without a PCB too. It's amazing what you can stick in a socket besides chips and there's no law that says the socket has to be the same length as a chip put in it.
Hey, this guy is fantastic for simple how-to. Check his channel for others.
Sometimes I get the feeling that in Australia there is or was a really big electronics hobby movement or some very good schools.
@GoForSmoke: Thanks for the response and I especially appreciate u addressing my question with a very specific answer.
Crazy Pommie in the video - getting his fingers so close to that rotating blade.
Interesting idea to use a socket as a mounting base.
Would you recommend to program a standalone chip (for my project) with the Arduino bootloader and software libraries or the manufacturer's i.e. Atmel's VB programming platform?
You might want to see what Nick offers in his breadboard Arduino blog.
I did bootload using what the Arduino site made available when IDE 0023 was out and it was harder. It didn't make it easier that I had bought 328P-PU chips that then I had to hack a chip file to get the ID number recognized. With Nick's program that was not a problem, it recognizes the cheaper -PU's.
For the tiny45 and 85, this link and a Youtube might help. It's not new but probably works with 1.06.
Here's Matt Richardson of MAKE Magazine. It's an old video and I gave the link to the newer MIT Hi-Low Tech page. Look for the one on taking pictures of balloons popping some time.
Chip sockets make nice led holders. You can even change bulbs without soldering.
They also make nice DIY DIP switches with short jumpers. I should find staples that fit.
That circuit is bad and will not work.
You have a relay then there is no need to connect the contacts back into the arduino's circuit. Even if you want to there is no common connection between grounds between the 12V supply and the Arduino supply so the relay transistor can never get turned on.
@GoForSmoke : Thanks for the info and links. I will check them out.
@Grumpy_Mike : Please see new image, I have grounded both sides (oops).
Not sure what u mean by "You have a relay then there is no need to connect the contacts back into the arduino's circuit".
The relay circuit is not feeding back (or is not supposed to be feeding back) to the Arduino's circuit.
The 2 circuits are "isolated" via the PNP transistor switch.
The Arduino circuit is acting as sensor+switch for the relay circuit.
Could you please elaborate a bit more as to what u see as a problem with the circuit?
FWIW my design was based on info from the Bristolwatch web site and in particular the Plate 9 on this page.
According to "Bristolwatch" 2 transistors are used with the NPN protecting the Arduino and the PNP being the switch.
Are u omitting one transistor because since I am only switching the relay and not the motor itself, the base current will not be high enough to damage the Arduino pin/port?
FWIW I still cannot get used to the idea of switching the ground, electrically speaking it is like switching the neutral and not the active/live - something I was taught not to do.
Yes, simple 12V motor I would do it like this.
You can put the relay contacts between 12V and the motor, or between the motor and Gnd.
Arduino output is only good for 20mA, enough to drive a transistor, or a relay with high coil resistance, most 5V coils are not; you can find some, but you have to look at distributors such as digikey or mouser.
Example for a 16mA coil, 2A contact rating
Motor is not really simple motor. Original incarnation was a Wexco wiper motor. It raises and "drops" a metal paddle, which rotates on a fulcrum through 90 degrees.
In wiper action terms starting from paddle raised position: on sensor input the motor wipes left-to-right (paddle drops to 270 deg) and then right-to-left (paddle is raised to 180 deg), then waits for next input.
Relay voltage will be 12 VDC. Motor draws 6 amps under load. The relay won't be a PCB relay as it will be housed with the motor. I am researching automotive relays and saw some with coil ratings between 0.80 to 1.20 watts, but looking for one with built in diode.
Also motor+relay and sensor controller are physically 2 separate items in separate enclosures with different voltage supplies, so each will probably be grounded separately.
Type of motor being used is presently under review.
Is there anything in particular (any don'ts) I should be aware of when selecting the transistor for the switch?
According to "Bristolwatch" 2 transistors are used with the NPN protecting the Arduino and the PNP being the switch.
I think you misunderstood that. It is not correct.
Are u omitting one transistor because since I am only switching the relay and not the motor itself, the base current will not be high enough to damage the Arduino pin/port?
No. The single transistor provides enough current. Typically with a gain of 100 to 300 times the current from the arduino, more than enough to trigger a relay.
electrically speaking it is like switching the neutral and not the active/live
No it is nothing like this. What you call incorrectly "switching the ground" is called "current sinking" and is the way real electronics engineers generally do things. This is because normally the sinking capability is greater than the sourcing capability, unusually this is not the case with the Arduino Uno's processor.
GoForSmoke:
1 sink should handle 10 sources? (vague memories of the TTL Cookbook)
Well not quite right.
In TTL outputs had a fan out of 20 not 10. This meant that one output could drive 20 inputs. Then less demanding inputs were put on chips so you had to have a fractional fan in figure.
Also inputs were driven by sinking current as they tended to float high. This meant pull down resistors had to be quite low, arround 300R and so were not used much.
Seems I need to throw away my electrical hat and acquire an electronic one.
Basing the design on CrossRoad's sketch and using an NPN transistor with min hfe of 20, I calculate as follows for a 12V DC relay with coil rated at 0.8 watts :
Ic = 66.67 mA
Ib = 3.33 mA
Ie = 70 mA
R1 = 1320 Ohms
Are my calcs correct?
1320 Ohms for R1 is the max, would 1 k Ohm be low enough or do I need to go lower?
Any recommendations for the transistor?
@CrossRoads : You offered circuits for 3 switches viz. for an opto-coupler, a transistor and a Mosfet.
What criteria would you suggest to use, to decide which of the three designs to use?
Ok since I am not getting any comments, let me turn the transistor question on it's head.
I have some NPN 2N2222 transistors on order.
From datasheets I note the min hfe is 35, which basically means my max R1 value goes to above 2k and the base current goes down. I should thus still be fine with 1k for R1. Voltage and current specs all seem ok for my use.
Any reason why I cannot use an NPN 2N2222?
FWIW, this is my very first project so please excuse the mundane questions.
I am still waiting for the parts I ordered, so I have not been able to do any concept testing so far.
However, as I have a self-imposed timeline to finish this project, I thought I would jump ahead.
I have thus converted my previous Nano based circuit to an ATTiny85 based circuit, which is effectively the prototype circuit.
As there is a 12V lead acid cell external supply available, I have added a voltage regulation circuit as an optional supply source.
Questions I have:
Do I need to connect anything to the ATTiny85 Reset pin?
Is the LM7805 ok for 12v to 5v?
For C1 & C2 I will be using electrolytic 10uF capacitors - are these the correct ones to use?
Should I be adding 0.1uF ceramic capacitors to the voltage regulation circuit as well? - I have seen them on some example circuits.
I would have liked to have used 3.3V internal batteries, but the HC-SR04 requires 5V - so I am hoping to get away with 4.5V. Has anyone tried running the SR04 on 3.3V with success?
I would appreciate some answers to the above questions and also input on the attached circuit.
FWIW I find the best way to view attachments is to right click and view in a new tab or window - the image will then self adjust to the screen size.