Show Posts
Pages: 1 ... 10 11 [12] 13 14
166  Forum 2005-2010 (read only) / Interfacing / Re: Driving solenoids. Please help on: March 15, 2007, 10:45:05 pm
You won't be able to drive the solenoids directly. The Arduino only wants to drive about 40mA at 5v and that is not enough current or voltage. What you are going to need to do is add a device that acts as a switch to turn the 24v power on and off and a path to absorb the big reverse voltage spike that the solenoid coil will create when you turn it off.

Following, I'm guessing from your question that you don't have much exerience with electronics at the component level. You are going to need to get some components and solder them together to build this.  I'll describe the bits in enough detail that you can get them, but you will want to look at some sort of circuit building tutorial or better yet get someone who has done this sort of thing to help out.

I think in the interest of simplicity, you might be best using a single component for this. I won't sweat cost and will suggest a part that is many times too good. Get an IRF640, which is a kind of MOSFET transistor that costs under $1 US in single quantities. Get a couple spares too so you can make mistakes. It has three pins, there are 6 permutations for hooking it up, several of which may explode the transistor. Wear glasses.  (For those following along, I avoided the darlington so it should be very difficult to explode.)

The three pins of the MOSFET are named "gate", "source", and "drain". Electrons live in the "minus" side of the circuit, the ground for you. That is your source. You let them out the "drain" (the plus side) by turning on the "gate". This may seem backwards to you, but it makes more sense if you remember electrons have a negative charge.

I will now describe your circuit in a thousand words for the lack of a picture. I assume you have a 24v power supply. Attach its ground (minus side) to the ground of your Arduino. You really need to share a ground. Attach a digital output pin of the arduino to the gate. Attach the source to the ground (of your power supply, don't make 2 amps run through the arduino board). Attach the drain to one end of your solenoid and the +24v to the other. Viola! You are done. Use wire at least the size of a pencil lead for the path through the solenoid and out the source. Any sort works for the rest.

Ok, I lied. There is one more part you want to have.  Just in case your arduino is off and your +24v power supply is on you need to make sure that the MOSFET is either all the way on or all the way off or it could heat up and explode. A 10kohm resistor attached between the gate and the source should take care of this.  The Arduino will easily overpower this when it is on and when the Arduino is off this will hold the MOSFET off.

One more caveat... Many people will be expecting a bypass diode around the solenoid, but I don't think you need one. The IRF640 should be able to handle the beating from the solenoid according to its spec sheet. That said... I'd put a diode in parallel with the solenoid so that it didn't conduct normally but would gently pass the surge when the solenoid is turned off. No sense tempting fate. I hesitate to explain the diode because if you put it in backwards then you are going to blow the fuse in your power supply at the very least. The diode has two wires, one end of the diode has a stripe. You want to connect the stripe side of the diode to the +24 end of the solenoid and the non-stripe end of the diode to the other end of the solenoid. Something like a 1N5401 would be a fine diode for this. On further though... since I don't know how much energy your solenoid stores, you'd better put this in. It is 10 cents well spent.
167  Forum 2005-2010 (read only) / Interfacing / Re: serial with both usb and tx/rx? on: March 17, 2007, 12:04:33 am
If you only need to receive bytes with the Arduinos you could tie together their ground and RXD (digital0) pins. Only the first Arduino will be able to send data back to the host computer, but they will both receive it.

If the 2nd Arduino needs to send data back then it gets trickier. You can't tie together the TXD pins since they are both outputs and would fight. You could take another pin on the 1st Arduino, tie it over to the TXD of the 2nd arduino and use the software serial implementation to listen on that pin on the first arduino, then forward the bytes out the hardware serial port.
168  Forum 2005-2010 (read only) / Interfacing / Re: Potentiometer - which ohm value? on: March 15, 2007, 12:09:18 pm
The board should easily supply another 11mA. The power supply makes about 500mA and the base Arduino consumes something under 100mA.

About "higher is better", there is a rub... higher resistance will lower the power consumption which is nice, but it also increases the effect of the current consumed by the analog input pin. In a situation where you are turning a knob by hand that effect won't matter. The second effect is that at very high resistances (>>10Mohm? just guessing, it's been a while since I needed that neuron) you will start to see "shot noise" where the discrete nature of electrons raises its ugly head.
169  Forum 2005-2010 (read only) / Interfacing / Re: arduino rc car on: March 15, 2007, 11:46:52 pm
There are bluetooth modules (Bluesmirf) made for the arduino that will do 115k bits/second. That won't get you streaming video since you don't have the horsepower to do compression, but it is plenty for sending command data and telemetry back. If your lapop doesn't have bluetooth already you can use a generic bluetooth USB dongle.

The next piece you will want to look at is something called an H-bridge motor controller. There is an entry in the Arduino tutorial section that talks about that.
170  Forum 2005-2010 (read only) / Interfacing / Re: Creating an analog second hand on: February 02, 2007, 12:47:37 pm
I don't think you will get those little motors to turn slowly, you would end up needing a gear box. You could use a small stepper motor, but you probably won't find one that goes in 6 degree increments so your hand would jump at non-second intervals.

I'd go with a cheap clockwork, but you aren't done there.  You will probably want to sense when the hand is straight up so it is synchronized with your digital section. An infrared LED/photodiode pair would be a good choice, put them both on the back side and watch for the reflection. Then you can stop the clockwork any time it gets off and wait for the next minute. Hopefully that isn't too often.

You could wind 60 little coils, use 4 of the serial in, 16 out LED drivers, put a bit of magnet on the end of the hand and make your own synchronous clock motor... I mean you are already using nixie tubes, simplicity has left the room a long time ago.
171  Forum 2005-2010 (read only) / Interfacing / Easy remote control on: January 31, 2007, 02:22:58 am
I needed a couple indicator lights in a remote location. In the process of building them I stumbled on some easy to use parts that work well with the arduino to make simple remote operated devices.

The first piece is the radio module. I used the Laipac RLP434. This is a 315MHz unit that does about 2400bps over 150 meters. I got mine from sparkfun electronics.  $12 for the transmitter and receiver. (Other frequencies are available.)

Next is the decoder. The Holtek HT12D is designed for things like garage door openers. You get an 8 bit address and 4 data bits.  Note that we don't use the corresponding encoder. We will do that in software since that takes only one data pin instead of 12 on the arduino and we can save parts and soldering. I don't recall where I bought this, maybe futurelec? It was someplace for about $3 and no minimum order.

Yes.. see where we are going? You can put a couple hundred of these around your house and have little lights all over the place that are all individually addressable!

There is very little to be done in the build.  You need to select the clock rate of the decoder to be compatible with the bit rate capability of the radio.  50kohm for the decoder and 1Mohm for the encoder chip (if you used one) fits nicely. (parallel two 100kohm resistors for an easy 50k)

The HT12D doesn't make much current at all, you won't drive an LED directly. I used some little transistors and resistors to drive my uncomfortably bright LEDs.

On the transmitter end it is power, ground, data pin, and a 30cm antenna wire. Nothing to go wrong there.

A note about the radios: The receiver automatically sets its gain, so if you aren't transmitting it turns up the gain until it hallucinates data. You have to use some form of encoding and decoding on the link, fortunately the HT12D takes care of that. Also, you have to send some data to get the radio synced, so you will end up sending your codes several times to make sure they get through.

Now the encoder code:
int bitTime = 380;// microseconds per cycle of fOsc, 3 of these make up a bit time.
                  // You want this to be 1/50 of the fOsc on the decoder. 380 is the right answer
                  // if you use a 50k resistor for the decoder (2 100k in parallel). This fits nicely
                  // in the 3kHz rate of my radio units and matches with a 1M resistor on the encoder
                  // chip if you use a physical encoder chip instead of software.

void encodeBit( byte pin, byte val)
  val = (val ? 1 : 0);
  digitalWrite( pin, 0);
  delayMicroseconds( val ? bitTime * 2 : bitTime );
  digitalWrite( pin, 1);
  delayMicroseconds( val ? bitTime : bitTime * 2 );

// Note: depending on your radio you have to do more than one of these. It might take your radio
// a while to settle down.  I have to do 2 with mine.  Maybe a brief period of 1-0-1-0 would be
// faster for getting the radio's attention if you are speed constrained.
void encodeTransmit( byte pin, byte addr, byte data)
  byte i,j;
  for ( int j = 0; j < 4; j++) {   // send 4 times
    // do the pilot phase
    digitalWrite( pin, 0);
    delayMicroseconds( bitTime * 12);  // make sure we have met minimum low time
    digitalWrite( pin, 1);
    delayMicroseconds( bitTime);       // 1/3 of a bit of high

    for( i = 1; i; i <<= 1) encodeBit( pin, addr&i); // send the address bits
    for( i = 1; i != 0x10; i <<= 1) encodeBit( pin, data&i); // send the data bits
  digitalWrite( pin, 0);  

... then you can do things like...
  encodeTransmit( encoderPin, addressByte, valueByte);
  encodeTransmit( encoderPin, addressByte, valueByte);
  encodeTransmit( encoderPin, addressByte, valueByte);
  delay(1000);  // this is a shared radio frequency, don't monopolize it

Notice that bit about not transmitting too often. As I understand this frequency, it is intended for intermittent use. You don't want to get on it and keep it.  Send your code a few times and get off.  Hope it got through. I update my lights every few seconds, so if one doesn't get through it will on the next update.

Also, it is possible for noise or a neighbor's garage door to trigger your decoder and latch in new bits. Don't use this for controlling anything that will upset you if it fires accidentally.

In my application my router collects data and passes bytes down the serial port to the ardino to set the state of the lights. The arduino just acts as the radio controller. In the next incarnation I will put an arduino on the receiving end as well with a 16 channel, 4096 level LED controller chip and have 16 channels of analog current controlled lines for variable intensity lights and driving analog meters... but that is a project for March.

172  Forum 2005-2010 (read only) / Interfacing / Re: Getting Arduino to DMX512 on: January 17, 2007, 01:33:52 pm
digitalPinToPort() is in lib/targets/arduino/wiring.c but it doesn't appear to have a declaration in a .h file so is probably meant to be private. You will notice that it is a one line function.  In the OneWire library the code needs to be accurate at the microsecond level and I found the normal digitalWrite() type calls to be a bit too inexact in timing so I went to the port and bit level like this...
extern "C" {
#include <avr/io.h>
... blah blah blah...

    port = digital_pin_to_port[pin].port;
    bit =  digital_pin_to_port[pin].bit;
    outputReg = port_to_output[port];
    inputReg = port_to_input[port];
    modeReg = port_to_mode[port];

... blah blah blah...
    sbi( _SFR_IO8(modeReg), bit);    // make pin an output
    cbi( _SFR_IO8(outputReg), bit);  // zero
... blah blah ...
    cbi( _SFR_IO8(modeReg), bit);   // set pin to be an input
    r = (( _SFR_IO8(inputReg)>>bit) & 1);

You can see the whole gory mess at if you need.

You should be aware of the downside of this.  Some pins get special handling in the digitalWrite() calls and such, specifically the TIMER* pins. If you hit one of these pins bad things will happen.
173  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pompie on: February 04, 2007, 08:15:39 pm
An alternative for liquid sensing is to use two vertical, parallel, insulated strips of metals separated by a small air gap. Clearly this is a capacitor. As the liquid rises the air gap is replaced with water gap which has a different dielectric constant and changes the capacitance. Either charge and discharge the capacitor through a resistor (probably very high, this is a small capacitor) and measure the voltage on either end of the cycle, or maybe better, make an oscilator's frequency controlled by the capacitance and count pulses.
174  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: microsecond on: July 06, 2007, 09:45:23 am
If your signal arrives in the right way, you can use pulseIn.

If you need something more complicated then maybe you can get by looking at the hardware counters directly. For instance, TCNT0 looks like a variable, but is an 8 bit counter that increments every 64 clock cycles so you get 4 microsecond resolution with it. You need to watch closely to handle overflows.

Your ultrasonics are probably something like 40kHz, so you get a sampling rate of about 6 samples per cycle which should be plenty for recognizing the wave front and sound in air will only move about 1mm in that 4 microsecond interval so you get good resolution. The motion of the air will probably disturb your signal more than that.
175  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Digital-Out 13 / "14 to 19" on: July 02, 2007, 05:16:32 pm
Be careful with digital 13. It gets strobed by the bootloader. The resistor will keep you from driving large loads, but you can use it as an input or a logic level output. You just won't get more than a few milliamps through it.
176  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Project safety:  Fire?  Too paranoid? on: June 29, 2007, 12:27:26 am
CAT-5 is what... 24 gauge? Check a table like this one,  Now, which number to use... If it is a short wire, not in a bundle you can use the chasis wiring column. If the wire is in a bundle you will want to use the transmission number. If it is in a big bundle, even less.

As a sanity check, Power Over Ethernet moves 400mA, but that is over two wires and is spec'd to survive in bundles of 100 wires. 200mA/wire is well within the power transmission column.

In general, you will want to compute the resistance of your wire (remember to count the length of the wire coming and going) and decide if the power loss is tolerable.

Stranded wire holds up better. Flexing won't cause it to fracture like a solid wire. But that might not be problem in your application.
177  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Project safety:  Fire?  Too paranoid? on: June 28, 2007, 11:01:05 am
Assuming your adapter complies with UL guidelines (many things carry fraudulent UL and CE markings) then when you draw an amp or so the AC/DC adapter should safely fail. Probably by melting a filament somewhere in the transformer, those things are too cheaply made to have fuses. The plastic case should stay intact and no high voltage should be exposed.

You will want to check the output voltage of the power supply to ensure that "regulated" means "close to the set voltage". AC/DC adapters are notorious for running well over their labeled voltage at low current.

If you have plenty of cooling capacity at 12v, you could switch your adapter down to 10 or 9 volts. The fans will turn a bit slower and be quieter.

You could put a 500mA fuse in the +12v line for the day when you move a piece of metal gear, mash the power lines to the fan with an edge, and short the wires. Maybe the fuse would blow before the transformer fails. Which goes first in a short circuit has many variables.
178  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: pwm pitches on: June 24, 2007, 08:24:33 pm
You can take the given octave and extrapolate from there. Each octave up is twice the frequency, half the period of the one below. If you sound a bit out of tune at higher pitches, you might consider that each digitalWrite() call takes about 5 microseconds.
179  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Frequently-Used OpAmps? on: May 27, 2007, 11:13:41 am
What part of the AD7792 to you consider too complicated? Is 4 pins too many, or is the SPI and all the messing with registers?

I've got a parts order going in Tuesday, I could tack on a couple AD7705s and write up a new tutorial and library if it is just software complexity that is the problem. (I won't move to surface mount until autumn so the AD7792 is out for me, but they look similar in spirit. The registers are different, but the same ideas.)
180  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Frequently-Used OpAmps? on: May 25, 2007, 11:55:06 pm
5v single supply, first guess is an LM324.
Pages: 1 ... 10 11 [12] 13 14