Show Posts
Pages: 1 ... 39 40 [41] 42 43 ... 87
601  Using Arduino / Project Guidance / Re: RS-485 Circuit, isolated & stable, well as much as possible! on: April 24, 2013, 07:02:27 pm
If you are sure you need isolation, a quick search turned up the LTC1535.  Since RS-485 is differential, it has fairly good noise immunity and you may not need isolation.

...but I'm not sure what isolation (diodes, or whatever)
There are 3 isolation methods -   Optical, electromagnetic (transformers), and mechanical (relays).  Optical is usually the best & cheapest.   Transformers have a limited bandwidth (i.e. They don't work at all with DC).  Relays only work with DC.
602  Using Arduino / Audio / Re: [start] arduino to rec only certain sound (activation trigger on spectrum) on: April 24, 2013, 05:58:28 pm
...Sounds like DSP to me! smiley-wink

I know there's an FFT library, but I've never done any DSP.

What you are trying to do is not that easy.   For example, every time the dog barks you get a slightly different sound at a different volume.   

It can probably be done...  There is voice recognition and speech recognition.  But, I don't know if it can be done on an Arduino.   And there will be "false alarms" (false positives) and "misses" (false negatives).   So, it becomes a matter of trying to minimize the errors,  and balancing  (or biasing) the remaining errors to build a useful system.
603  Using Arduino / Audio / Re: audio to relay on: April 24, 2013, 03:48:32 pm
Simply use digitalWrite() instead of analogWrite().  And, take-out any code that sets the "analog" PWM values.
604  Using Arduino / Audio / Re: start circuit with condenser mic on: April 24, 2013, 03:44:50 pm
if is exactly right.   if is the most common way for a program to "make a decision".     But somehow you've made a mistake in your code.  Can we see it?

Don't put a semicolon at the end of your if-statement.
And if the true-condition is supposed to execute more than one line of code, use curly-brackets.

Something like:
if(analogRead(1) > 200)
   digitalWrite(13, HIGH);   // Turns-on LED

(I haven't checked that code snippet, so I hope I didn't make a stupid mistake myself.   But that's the general idea.)

You can troubleshoot your code by simplifying...  For example, turn on an LED instead of the motor.  Or, take-out the if-statement, or force the if-statement to always return true by changing it to if(1), etc.

You'll also have to decide what to do after turning-on the relay...    For example, delay and hold the relay on for awhile.  If you run your if-statement in a tight loop, the Arduino's output will switch on & off when the level goes over/under 200 and the relay will either "chatter" or never come on, since mechanical relays don't come-on instantly.

605  Using Arduino / Project Guidance / Re: Use 9v battery on Uno +4 9g servos--would it be a problem? on: April 24, 2013, 02:46:14 pm
You need to check the current rating (mA) on the servos.  Your total current draw is the sum of the servo currents plus the Arduino current.    That will tell you about how long your battery will last, and if you can use the on-board regulator.

I read another thread saying he used 9v battery and it ruined the board? I am scared.
If you want to be safe, do what CrossRoads says and don't power the servos from the Arduino...[/b]  Just sent the control pluse from the Arduino to the servo.    It's best not to power anything other than a few LEDs from the Arduino's voltage regulator and if you need to power more stuff (like motors), you'll need to make some calculations to see if it's possible.    I would guess that when you make the calculations, you'll find that the 4 servos are over-stressing the Arduino's regulator.

The more current you draw through the Arduino's voltage regulator, the hotter it gets.   And the more voltage you "drop" across the regulator, the hotter it gets.   (Power is calculated as Voltage x Current, and the power is dissipated as heat.)

Of course, any power wasted/dissipated in the regulator has to come from the power supply or battery.  This shortens battery life.    With 9V into a linear regulator and 5V used in your circuit, you are wasting almost as much power as you are using in the Arduino & servo.

Switching regulators are more complicated, but they can be almost 100% efficient.   Under normal conditions, you'll get more current-out of a switching regulator than goes-in.  (It's not more than 100% efficient and the voltage-out is less than the voltage going-in, which is the whole point of a voltage regulator.)   

The energy in a battery is related to it's milliamp-hour rating.   A 9V Energizer battery is rated at about 500mAh.   So at 100mA, it can go for about 5 hours.*    At 500mA, the milliamp-hour rating is reduced, and you can go less than one hour.

* IIRC A battery is considered "good" down to about 80% of it's full-charge voltage.   So, you'd be at about 7V and the battery could power the Arduino for awhile longer.
606  Using Arduino / General Electronics / Re: Opamp mystery on: April 24, 2013, 12:30:15 pm
What's the voltage gain of your circuit?  My "gut feeling" is that gains of 1000 or more are "difficult".   And DC is more difficult than AC, since with AC it's easy to filter-out offset & drift.

when I substitute a very low Vio opamp (OP07A, Vio = 10uV) for the original LM358 I used, the output errors are more like 1 volt!
In a high gain circuit, that might be "normal".   How would you characterize that error?   If it's a constant DC offset (bias), you should be able to calibrate it out (in hardware or software).

There are 4 or 5 different types of error in a measurement like this:
1. Offset -    This is a constant-voltage or constant-count error.    For example when you are measuring volts, you might always read 1 Volt high.   It is normally calibrated-out by "zeroing" (adjusting your system so that zero reads zero).

2. Gain -   This is percentage-of-reading error.  For example, your reading may be a constant 10% high.   This is normally calibrated-out by adjusting the gain so that the maximum-range reads correctly (after zeroing).

(Offest and gain adjustments are standard in just about every measurement calibration.)

3. Nonlinearity - Once the zero & maximum are reading correctly, intermediate readings may be high or low.  With software, you can make one or more different gain adjustments to different sections along the range.  But, this kind of calibration-adjustment is not that common.  It's usually not needed and it's only used when high-precision is required.  And, it's only useful when noise & drift are lower than the non-linearity.  Where I work, we have a digital-to-analog converter that's calibrated at 100 or more points along the slope.     (This can get tricky, because there can be discontinuities where the gain suddenly changes.)

4. Noise - Random variations.    Sometimes you can reduce the noise pickup/input, sometimes you have to build a lower-noise circuit (if possible).

5. Drift - Slower variations or lower-frequency noise.   The system may read high for awhile, and then start reading low.    Again, you have to build a better circuit (if possible).
607  Using Arduino / Project Guidance / Re: Battery operated servo! UNO on: April 23, 2013, 07:22:41 pm
You could use three big diodes in series to drop the voltage to the servo from ~6v to ~3.9v.
It's a cheap-and-dirty solution, but I'll admit I've done something like that.*   But I don't feel  good about it! smiley-grin     

The problem is, that you are regulating the voltage drop (and not regulating it very well) instead of regulating the voltage supply to the servo.    So as the battery voltage drops over time, the servo voltage will also drop.   And as a percentage drop, the servo drop is worse!!!    When the battery voltage drops by 1V (from 6V to 5V),  that's a 17% voltage reduction.  But with an approximately-constant 3V drop across the diodes and the batteries down to 5V, you'll only have 2V remaining for the servo.  That's a 33% voltage reduction to the servo.     

So, you end-up with something that's the opposite of a voltage regulator!   The output-voltage has more variation than the input-voltage (as a percentage).

* I used a string of "big" diodes in front of a some linear regulators to reduce the voltage, so that the regulators would run cooler.      But switching regulators would have been a much better solution.   And if I ever build one of those gizmos again, or if I rebuild that one, I'll do it right!
608  Using Arduino / General Electronics / Re: Zero crossing detector on: April 23, 2013, 02:10:13 pm
I assume the input to your comparator is isolated from the AC?  i.e. From the secondary of a transformer?

But so far the i have tried using basic zero crossing circuits like comparator comparing the sine wave with a ground but to no avail.

That's how I did it... Is the comparator "firing"? (Is the output changing state?)   If the comparator is running from a single supply, it might not work near ground.    If the comparator is running from positive & negative supplies, it should work fine and put-out a square wave.     

If you have a single supply, you can set the reference voltage higher, and calculate when the actual zero--crossing occurs.

Actually, it's probably better if you set the comparator reference to around 45 degrees (half the peak AC voltage).      The actual-exact zero-crossing is difficult to detect.  If your detection circuit is detecting small voltages, a little noise on the AC line near the true zero-crossing can give you a false-trigger.   The peak is even more difficult, since the AC voltage vaires a bit.   Somewhere in-between is more ideal.
609  Using Arduino / General Electronics / Re: RGB LED's and the color white on: April 23, 2013, 01:48:09 pm
Yes.   That should work.    However, sometimes the different colors have differnet brightness with the same current (or slightly different "maximum brightness").    So, you might need to experiment a bit to get a "white" that you like.
610  Using Arduino / General Electronics / Re: Linear Motion on: April 22, 2013, 05:23:11 pm
I've got a 6-inch digital caliper (about 150 mm).  It reads down to 1/1000th of an inch, which should be 0.025mm if I've done the math correctly.  It probably doesn't have 1/1000 accuracy over the entire distance (espeically since I've never had it calibrated), but it does have 1/1000th  resolution.

It works mechanically with a gear (or wheel), so something inside is counting rotations.   If you can get the mechanical accuracy, that same concept could be extended to 1M.  In fact, you can buy a 1M caliper if you have the budget...

It shouldn't be too hard to build a wheel/gear system with 0.01mm resolution, especially if you can move in one direction after zeroing to eliminate play & backlash.   But getting 0.01mm accruacy over a 1M range might be beyond anything the average machine shop can build...    Which means you probably don't really need that kind of accuracy over that distance...
611  Using Arduino / General Electronics / Re: SSR VS Standard Relay. on: April 22, 2013, 01:53:18 pm
A SSR should be easier to use, since most can be controlled directly from the Arduino's 5V output.    Most higher-power mechanical relays are going to require 12 or 24V for the coil (and possibly more than the 40mA supplied by the Arduino). 
612  Using Arduino / Audio / Re: audio crossfade on: April 22, 2013, 01:48:05 pm
I've never used an audio shield, but crossfading should be easy in software, as long as your software has access to the uncompressed (or decompressed) audio data.

Mixing is done by addition.   Sample one from file one is added to sample one from file two, sample two from file one is added to sample two from file two,  etc., etc..

Volume control is done by multiplication (or division).  For example, multiply every sample by two, and you've increased the volume by 6dB.   Divide by two (or multiply by 0.5) and you 've reduced the voolume by 6dB.

By reducing one set of samples while increasing the other, and adding them together, you are crossfading!

When mixing or boosting volume, you have to be careful not to exceed the maximum sample-value for the given bit-depth.   If you try to go higher than you can "count" with the given number of bits, you will get clipping (distortion).   This is not an issue with a normal crossfade, since one value goes down while the other goes up.
613  Using Arduino / General Electronics / Re: Analog read on: April 19, 2013, 01:28:17 am
It looks like your voltage may be high (or your reference too low).    How much AC voltage are you feeding-in?

Remember that (with a sine wave) the peak voltage is about 1.4 times the RMS and peak-to-peak voltage is about 2.8 times RMS.   The maximum peak-to-peak voltage has to be less than 5V if you want to accurately read the waveform (without clipping).   That means your AC voltage should be less than about 1.75V RMS (with a 5V reference)

Quote get ac signal from transformer 50hz.
You won't be able to read the negative AC half-cycle (unless you add some bias) and you can damage the Arduino if you feed-in negative voltages, or voltages greater than +5V.
614  Using Arduino / General Electronics / Re: I will like to know how many watts are consumed in a led on: April 18, 2013, 06:55:50 pm
...Your are confusing Power (Watts) and energy (Watt-hours).    For example, small batteries are rated in milliamp-hours (mA-hr), and from that you can calculate mW-hours.   You can "pull" a lot of milliwatts (maybe a few Watts) from a battery for a short time, or the battery will run longer if you pull less power out of it.

Power is calculated as Voltage X Current.   If you have 2 Volts across an LED and 20milliamps flowing through it, that's 40mW.   Over 3 Hours, that's 120mW-hours.

If you don't know how much current is flowing through the LED you can calculate (or estimate) it if you know the series resistance and the applied voltage.

Let's say you have an LED rated for 2V @ 20mA.    Unlike resistors, LEDs have (approximately) constant voltage drop (when they are on and operating normally).  In a series circuit, the same current flows through all components, but the applied voltage is divided among the components. (That's Kirckhoff's Laws.)

Let's say we have a 200 Ohm resistor.   With 5V from the Arduino and 2V across the LED, that leaves 3V across the resistor.  Using Ohm's Law, we can calculate the current.   3V/200 Ohms = 0.015 Amps (15mA).  The same 15mA is flowing through the LED with 2V across it, so we have 30mW of power dissipated in the LED (2V x 15mA).    Plus 45mW wasted in the resistor (3V x 15mA).  Or if you want the total power coming out of the Arduino, 5V x 15mW = 75mW, which is the same as 30mW + 45mW.

If you have a multimeter, you can measure the voltage across the resistor and LED to make a better calculation.  (The LED voltage rating is not always exact.)    In order to measure current you have to break the connection and insert the multimeter in series.  So, it's usually best to measure the voltage across the known resistance and calculate the current through it.
615  Using Arduino / Project Guidance / Re: Can you run 2 different loops in 1 sketch?? on: April 18, 2013, 05:38:34 pm
1 for the LEDs and uploaded on 1 Duemilanove, then uploaded the link for the MIDI stuff to another Duemilanove
I did something like that once.  I built two projects that would always be used together.   It made the hardware & software design easier for me, but in hindsight an all-in-one unit would have been better.

For future thought...   

 - The main thing is to avoid delay() because your program is "locked up" and can't do anything during the delay.
 - You can put loops inside loops (nested loops).  Most of my programs have loops inside the main loop.  (Be aware that the outside loop can't do anything while your program is "stuck" in the inside loop.)
 - You can run one loop after another.  (Again, you may not want to be stuck in one loop too long.)
 - You can put everything in one big loop.
 - You can put everything into functions in one loop, and then call the functions in sequence.  And, you can conditionally call (or skip) some functions (with if-statements, etc.) if the all of the functions don't need to be called every time through the loop.
Pages: 1 ... 39 40 [41] 42 43 ... 87