Show Posts
Pages: 1 ... 36 37 [38] 39 40 ... 90
556  Using Arduino / Programming Questions / Re: Cant find a Zero problem on: May 29, 2013, 03:08:45 pm
I don't know if this is the problem, but you have to be careful with "equal" in floating point.   Floating point numbers are stored in binary (like everything else in the computer).    If there are any mathematical operations, there is rounding and very-high precision...

Just as a made-up example, a number that "shows-up" as 1.001 might actually be stored as 1.0010000000001 internally, and that's NOT equal to 1.001.

Or something that is truly-mathematically zero might be stored as a very-very small non-zero number.

So whenever possible, use less-than or greater-than.    If you are looking for zero, you might be able to look for a value less than 0.0001, etc.    (And if the value can be negative, take that into account.)

There are also numbers that can be accurately represented in decimal, that cannot be accurately represented in floating-point binary (similar to the way 1/3rd cannot be represented perfectly in decimal).  I don't remember what those values are, but you can research it if you wish.
557  Using Arduino / Project Guidance / Re: AC Dimming with PR36MF21NSZF on: May 29, 2013, 02:18:36 pm
Thanks! Is there something I can do, so I can dim properly my LED ceiling lamps?
Look for some example projects.     I've done it a long time ago but with a different processor.

An AC solid state relay will work as long as it's not the zero-crossing type.

As I said above:
1 - Detect the zero crossing (with a safe-isolated circuit).  I built my own (linear) power supply and used the same transformer that was powering my microcontroller to give me safe low-voltage AC into the comparator I used for zero-crossing detection.   (I didn't try to find the exact zero crossing.  I looked for a small voltage just-after the zero-crossing.  Then did some expermentation, and compensated in software.)

2 - Delay for some part of the AC half-cycle.

3 -  Send a trigger pulse to the TRIAC or slid state relay.   (If you use a TRIAC, use a non-zero-crossing  opto-isolator designed for TRIACS, such as the MOC3010.)

...I don't remember if I did this, but if you just detect the positive-going zero-crossings you know when the next (negative-going) zero crossing is, so you don't have to detect the negative-going zero-crossings. 
558  Using Arduino / Project Guidance / Re: AC Dimming with PR36MF21NSZF on: May 29, 2013, 01:33:45 pm
First, you can't dim AC with a zero-crossing device! *

Incandescent AC dimmers work by triggering (turning-on) a TRIAC at some point during the AC half-cycle.  Once triggered, the TRIAC continues to conduct until the current goes to (nearly) zero at the next zero-crossing.   

Assuming the trigger signal is no longer present, the TRIAC turns-off at the zero crossing.

If you trigger at (actually just after) the zero crossing, the TRIAC somes on and stays-on for the full half-cycle and is NOT dimmed.

If you trigger just before the zero crossing, the lamp will come on for a short period of time and it will be very dim. 

That means you have to sense the zero crossing or some constant point along AC waveform (with transformer or optical isolation), delay for some part of the half-cycle, and trigger the TRIAC (or TRIAC- based relay).   This is something like PWM, but regular PWM will NOT work because it will trigger the TRIAC at some random non-synchronnized point along the waveform, and the TRIAC will remain on for the remainder of the AC half-cycle.

(PWM signal - 1 = 60VAC, 255 = 240VAC), but when I connect a load (lamp) it's 1 = 240VAC and 255 = 240VAC.
A digital multimeter will not reliably measure the average of a voltage that's switching on & off or jumping around unless it has a "ture RMS" feature.  An old analog "mechanical" meter will work better, and since there is often some leakage, you'll get better readings with a lamp connected.

* You can make a simple high - low - off dimmer that turns lamp on for only the positive (or negative) half cycle.  But, you can't do full-range dimming with a zero-crossing device.
559  Using Arduino / General Electronics / Re: Voltage regulator overheating on: May 28, 2013, 04:58:52 pm
I tried powering the boards with about 11 volts through the Vin pin, I touched the voltage regulator of the Arduino (in the Rev.2 I own the regulator is a NCP1117) and it was very very hot, so I disconnected the power supply.
I tried again, but powering the boards with 7 Volts and the overheat reduces, but after a few minutes the voltage regulator becomes hot again, but fortunately less than before (I didn't measure his temperature, but for my finger was enough).
Right...  The heat is directly related to power, and power is calculated as Voltage x Current.   The power dissipated in the regulator is the from the voltage dropped across the regulator.  With an 11V supply, you have 6V across the regulator.  With a 7V, supply you have only 2V across the regulator for about 1/3rd the power and 1/3rd the heat-rise.

Ther's sort-of a "rule-of-thumb" that if a component is too hot to touch, it's too hot.    I...Not very scientific, but I'd say if you can hold your finger on the part, it's probably not too hot.   If you can't hold your finger on the part, might be too hot.   
560  Using Arduino / Audio / Re: Electret Microphone Sensor on: May 28, 2013, 03:02:27 pm
and I am getting random values (70 to 130) which are independent to the existing noise.
When you say "noise", are you talking about background noise, or are you saying that you get numbers between 70 & 130, no matter how loud the sound?

Do you have a multimeter to measure the voltage out of the microphone board?

Did you connect 5V?   You should have 3 connections - 5 Volts, ground, and signal.

I don't have that board, but looking at the schematic, there are a pair of 10k "bias resistors", that should set the output to half the power supply (2.5V).    With a voltmeter/multimeter, you should measure about 2.5V DC coming out of the board.   

And, since the full range of the ADC is 10-bits (1023 decimal), you should get a reading of around 512 with no sound (assuming the default 5V reference).  There will normally be some jumping-around (i.e. "noise").  If all of your readings are around 100, something is very wrong ...  You knew that already.

The bias is added because the audio is AC (the voltage goes positive and negative), but the Arduino cannot accept negative input voltages.

Since the audio signal is AC, you should get readings (approximately) centered around 512.   With loud sounds, you may get signals that nearly go down to zero, and nearly up to 1023.

Somebody recommended to write a tight loop (e.g. 100ms) to get the min and max values. The difference between the two will give us the volume (sound pressure) during that time.
Since audio is a waveform that's constantly changing from moment-to-moment, if you want to digitize it you have to sample it.    For example, CDs are sampled 44,100 times per second.  Twice per cycle, the (unbiased) audio crosses-through zero. 

Depending on your application, you may want to sample it at a continuous rate (like a CD), and/or take an average, or sample and save the peaks.  I have an application where I calculate a 20-second
moving average by taking a reading once per second and putting 20 values in an array.  (Once per second is very-slow sampling for audio!)

If you decide to take an average, you'll need to take the absolute value, or ignore the "negative" readings below 512, because the average should always be around 512.  The mathematical average of any normal (unbiased) AC waveform is zero.
561  Using Arduino / General Electronics / Re: How Often do Electronic Components Stop Working? on: May 24, 2013, 01:30:38 pm
To be more specific: three N/O switches died, and one tilt switch.

My question is:
Is it normal for components to stop working so often?
No! Mechanical things can wear-out, but how often have you had to change the light switches in your house?   

Have you tested those switches with a multimeter?

or is there maybe something wrong with my workflow which keeps killing them?
Your "workflow" should not harm them, unless perhaps you get solder flux inside the switch, or if you clean them with water and they corrode inside....     If you are running excessive voltages & currents through them, they can be damaged.  But with 5V or 12V and milliamps, any switch should survive.

or maybe the components that come with the starter kit are just low quality?
Possible, but it's unlikely that they are THAT bad!

562  Using Arduino / General Electronics / Re: Compensating for lead resistance. on: May 23, 2013, 07:31:04 pm
V=IR so an increase in resistance means increase in voltage,

So I can get real high voltage if I put a 10 megohm resistor in my normally 5V line?  smiley-razz smiley-roll smiley-eek smiley-evil
Of course not with a "5V line", but if you have a constant current source, yes!   Ohm's Law is actually God's Law (or a law of nature, if you like), discovered/described by Ohm, and it's always true!

If you want to understand or predict what's going to happen under certain conditions, you need to understand the nature of your power source and the nature of your load resistance/impedance.  Most power supplies are designed to be "constant voltage" (approximately, within the limits of their design).  If you connect a very low resistance to a power supply, you don't get unlimited current.    Since Ohm's Law always holds, if you exceed the current available the voltage must drop (and maybe the a fuse blows or the power supply burns-up, etc.).
563  Using Arduino / Project Guidance / Re: shift registers ,LED's ,timer on: May 23, 2013, 05:55:18 pm
When I'm doing bit/pattern shfiting, I create a buffer to hold the pattern.  I'll try to describe the concept in words:

If I want to "shift-in" a pattern (or shift a pattern from left-to-right and then right-to-left) I create a "buffer" variable (with 6 LEDs I'd use a byte) and an output variable.

The basic right-shift sequence would be like this:
Load the pattern into the buffer. 
Copy buffer bit-0* into output bit-5.   Diaplay data/pattern to LEDs.
Shift both bytes right.

Loop-back and copy buffer bit-0 into output bit-5,  Display data/pattern to LEDs ....etc.

Assuming you want to shift the entire sequence through ('till you are back to zeros) you can add a step:
Copy output bit-0 into buffer bit-6 before shifting, so that you don't loose the bit zero value/state.    Note that you are copying into an "extra" bit-6 of the buffer (the 7th bit) so that you don't over-write the pattern before shifting.

This creates a "rotating circle" with half of the data/pattern showing on the LEDs and the the other half of the data saved in the buffer.   Of course you can rotate both directions. It usually helps to draw a picture to keep track of when to copy and shift, so that you don't over-write and mess-up your pattern.

You can also create something called a Johnson Counter, which rotates the pattern in a circle (without hiding it in a buffer) but it inverts the data before feeding it back in the other side.    So if LED 6 is off, that data is inverted before  rotating back-in, turning LED 1 on.   (Again, this does require an extra "buffer bit" to save the bit that's getting rotated out of the pattern and back-in the other side.)

With 4 bits, the Johnson Counter pattern looks like this when rotated left:
0000  ...etc.

If you reverse the pattern at the right time, you can get something like the "KITT effect".

* Bit zero is the least significant (rightmost) bit.   With 6 LEDs, you are using bits 0 - 5.
564  Using Arduino / Project Guidance / Re: Problem with my flash trigger on: May 22, 2013, 07:25:00 pm
I think what you should do is isolate the code that detects the shutter from the code that triggers flash.   

That would also allow you to test isolate any hardware problems.  i.e. Just flash an LED when the piezo is triggered.    Then flash the strobe under program control with no piezo signal.

That's how you troubeshoot...  Test the individual hardware & software sections to zoom-in on the problem.

Do you have a link to the schematic?  Do you have a multimeter so that you can check voltages & connections?
565  Using Arduino / Project Guidance / Re: Alternating Voltage reader on: May 22, 2013, 04:40:45 pm
...but from my understanding a diode creates a drop in voltage around 0.7 Volt.
That is correct.   For detecting and "measuring" line-level audio signals (around 1V), I use a peak detetcor circuit.  (This circuit, "throws-away" the negative half-cycle.)

And can I just interface our linear dynamo through a copperwire to the Arduino?
Not a good idea.  The Arduno can be damaged by feeding-in negative voltages (the negative half on an AC signal).

There are a couple of simpler solutions.   You can use a series resistor and a diode wired "backwards" to ground to "short-out" the negative half cycle.*  Or, use a pair of diodes (like this) to protect against negative voltages and voltages greater than +5V.

Another solution is to bias the Arduino input at 2.5V with a pair of equal-value resistors, and a series capacitor to isolate the DC from your generator.  You can then compensate for the bias in software.

If you use the peak detector or diode protection method, you can use the 1.1V ADC option and get 1mV resolution.

* The protection diodes won't conduct until you hit about +5.7V and -0.7V, but that is still safe.

566  Using Arduino / Project Guidance / Re: MAXIMUM INPUT VOLTAGE AND CURRENT on: May 22, 2013, 01:02:02 pm

Almost zero current flows into (or out of) an Arduino input.   For most engineering purposes, you can assume zero current.  (But, only if you stay within the limits of no more than 5V and no negative voltages.*)

The relationship between voltage resistance (or impedance) and current is described by Ohm's Law.   Current = Voltage/Resistance.  Resistance means "resistance to current flow".   Ohm's Law is the 1st thing you learn when you take an electronics class. 

Since the input impedance on the Arduino is 100 megohms or more, 5/100,000,000 =  0.02 microamps.

A power supply (or a voltage regulator like the LM340) does not "push out" 500mA.  It puts-out a (approximately) constant voltage, and the current depends on the resistance of the load.   If you exeed the limits of the power supply (by trying to get too much current out of it), Ohm's Law is still true (the laws of physics & nature always hold) so the voltage will drop (and the thing might burn-up).

* If you put a negative voltage, or a voltage greater than the 5V power supply, the internal protection diodes begin to conduct.   At that point resistance drops to nearly zero, maximum current flows (whatever the source can supply) and your Arduino might get fried!
567  Using Arduino / Project Guidance / Re: What is the best way to mount a bunch of leds? on: May 21, 2013, 07:44:13 pm
How many LEDs?  Does it matter what it looks like?

When you have lots of LEDs a PC board makes wiring a lot easier, but you'd need to have a board made.  A perfboard doesn't save you much work over point-to-point wiring, but it's mechanically more solid. You can combine a PC board and some sort of front-panel mount if you wish. 

I've used a few hundred of these over the years for front panel mounting.    If you are mounting several in a row or in a rectangular pattern, you have to be careful & precise with your drilling.    And about half the time, I solder the current limiting resistor directly to the LED and insulate with heat shrink tubing.  (I like to use clear heat shrink so I can see the resistor...  Otherwise in the future, I might forget it's there.)

Does what I mount on really affect anything because the heat level is still so low even with the high number of lights?
Regular 'ol ~20mA (~40mW) LEDs don't generate much heat and heatsinking is not important (even with lots of 'em, the heat is spread-around a bit).    "High power" LEDs rated at 1W or more usually need a heatsink.
568  Using Arduino / General Electronics / Re: Value capacitor? on: May 20, 2013, 07:02:27 pm
...but it looks a bit big to be only 100pF.
I was thinking the same thing.   Since it's a new part (not something that needs to be replaced/duplicated in a circuit), if it's for a critical application buy a new one!    Or, try it and if it doesn't work as expected, replace it.
569  Using Arduino / General Electronics / Re: Power Supply for Relay on: May 20, 2013, 05:25:04 pm
If you use something like that and two wall-wart power supplies, you'll have isolation.  So, why not just use a 5V wall-wart?   (If you use the same main power supply for both circuits, you are not isolated.)  You could also use an isolated DC-DC converter module.

Are you sure you need opto-isolation?   A relay is already isolated (there is no electrical connection between the coil and the contacts).

but this is obviously built for a breadboard and there's no obvious way to mount it inside a plastic box?
I see pins on the bottom, like it's designed to be plugged-into something.

570  Using Arduino / General Electronics / Re: Value capacitor? on: May 20, 2013, 05:11:40 pm
It looks like .1K pF = 100pF (=0.0001uF) @ 100V.
Pages: 1 ... 36 37 [38] 39 40 ... 90