Show Posts
Pages: 1 ... 47 48 [49] 50 51 ... 88
721  Using Arduino / Project Guidance / Re: Random Flashing Strobe Control on: January 29, 2013, 05:49:25 pm
Quote
I will also need to bias my random outputs so that I do not repeat the same strobe twice in a row.
Probably the easiest solution is to put your random-variable selection in a loop (probably a while() loop) and loop 'till the random next lamp is different from the current lamp.

i.e. Pick a random NextLamp number and if NextLamp == CurrentLamp, continue looping and get another random Next Lamp.   If they are not equal (which will be true most of the time), break out of the loop.   As long as this loop is running fast enough (relative to your flash interval), you can randomly pick the same number several times in a row and you'd never see a problem.

Of course when the time is up, CurrentLamp will be assigned the value of NextLamp and you'll have to find a new-random NextLamp.

Another way to do it is to make an array which excludes the CurrentLamp, and then pick a random element from the array.   (Something like this is often done to simulate a deck of cards, where you can't select the same card again after it's removed from the deck.)
722  Using Arduino / Project Guidance / Re: Random Flashing Strobe Control on: January 29, 2013, 05:07:28 pm
Quote
I think I will need to use some sort of psuedo mutitasking or timer variables?
By using the Blink Without Delay technique, you can have multiple delays that don't interfere with each other.

Or, they can relate to each other...  But in any case, you can have more than one timer running at the same time, since your loop runs continuously without any delays in the actual loop.

So you can trigger the 1st strobe

... Then after some delay, send a trigger to the 2nd strobe before the 1st one actually fires.

... Then, after enough time has passed for the 1st on to fire, turn it off before it can fire again.
723  Using Arduino / Project Guidance / Re: Lower the voltage comming into the Arduino Pins? on: January 28, 2013, 06:59:20 pm
First, since 90V can kill your Arduino  I'd recommend a pair of protection diodes* and a series resistor.   (This circuit will knock-down the voltage in a non-linear fasion, so it's just protection against over-voltage...  It is not used to attenuate a 0-90V signal down to 0-5V inearly...   i.e. 90V or 45V would both read "5V".)

Then, you'll need to measure the voltage output under your real-world conditions.    You can experiment with a parallel resistor (probably in the in the megohm range) to knock-down the signal (linearly), if necessary.    You are unlikely to get 90V and you might end-up getting less than 5V depending on your pressure & physical configuration.   (But, I'd still recommend the protection diodes.)   

Or, you can use a regular 'ol voltage divider (again along with the protection diodes).   But, with the high source impedance of piezo will create a 3-way voltage divider, and your signal will be reduced by more than the calculated amount...    A lot more if you use low-value resistors in the voltage divider.

Quote
i need a voltage sensor because i want to detect the voltage comming from the piezo from different pressures. so i want the exact number...
That's only gong to work for quick pressure CHANGES.   A constant pressure (with no physical movement) is NOT going to generate a constant voltage.**   I believe the piezo acts like a small capacitor, so it might sort-of hold the voltage for a several microseconds as it discharges through the load resistance.


* The Arduino has built-in protection diodes, but they are rated for low current and are only there as a "last resort" in case something unexpected happens (such as static discharge).   If you are experimenting with something that puts-out more than 5V in normal operation, you should take steps to reduce the voltage before it hits your Arduino.

** Conservation of energy...   Gravity can generate electricity as water flows down and through a generator.  But, you cannot use the static pressure of water behind a dam to generate electricity.


724  Using Arduino / General Electronics / Re: basic question... on: January 28, 2013, 03:11:49 pm
Are the lamps themselves marked 220V?  Many halogen lamps are 12V and there is a step-down transformer built-into the fixture.

Quote
I am buying 110v lamps but I am not sure if I can buy 50w (easily found around here) lamps or if I should stay with 35w.
Wattage is directly related to heat.   The maximum wattage rating should be marked on the fixture somewhere.  Or, check to see if there is some rating on each of the 5 sockets.   If each socket is rated 50W or more, you can probably get away with it.    But, if there is any plastic, the additional heat may melt it.    If you exceed the rating, and your house burns down, you can't sue the lamp manufacturer...  But, your insurance should still cover the damage... smiley-grin


Note that if you keep the power the same (35W) at a reduced voltage, the current will increase.*   You are probably safe, but if you can se the wires, they may be marked with the current rating which should have plenty of safety margin since the whole thing will only pull a couple of amps and most lamp wiring will be rated for more than that.  (Watts/Volts = Amps).   

Quote
Second question.. I tried to turn on a single 220v lamp and it worked weakly as expected, but when I put all the five lamps one of the wires bursted. Why? I thought it work weakly as it did with a single lamp.
  That should not have happened in any case.  Maybe the bulb was defective (shorted-out).    A 220V lamp connected to 110V is something like using a dimmer, plus the fixture should be designed to survive a 110V brown-out when connected to 220V.    Something "funny" could happen if there is a switching step-down power supply, but nothing that bad[/b] should happen.


* The current will increase if you use 110V/35W bulbs.    With the original 220V bulbs, reducing the voltage also reduces the current.
725  Using Arduino / Installation & Troubleshooting / Re: 9V in 5V arduino OUTPUT!!! on: January 24, 2013, 07:29:53 pm
If you have a ladder rated for 500 pounds, it might not collapse with 900 pounds on it...   But, it's always safe at 500 pounds.

Where I work, we make a board that runs off of 5V.   There is about 20 chips on it, all rated for 5V.   A few times I've accidently connected 12V to the power input.   Usually the RAM chip will fry, and sometimes the CPU will fry.   But the other chips usually survive.

Fortunately, I don’t have any experience with over-voltage on the Arduino! ... Yet.
726  Using Arduino / General Electronics / Re: Peltier / Thermo Electric. on: January 24, 2013, 06:31:05 pm
You can extract energy from a system whenever there is a temperature difference (as the heat moves from the hot-side to the cool-side).   So, you could extract energy from the difference between air and water temperature during the day when the air is hotter than the sea, and again at night when the air is cooler than the sea.

I'm sure if this was economically efficient, it would be done.    Energy efficiency is not a factor, since there is plenty of sea & air and an inefficient system just has to be larger.  It's the same issue with photovoltaics...  There is plenty of sunshine and the energy is "free".   But in the real world, the electricity from photovoltaics is more expensive than traditional sources.

But of course, the environmentalists won't like you if you start transferring heat between the sea and the air! smiley-grin
727  Using Arduino / General Electronics / Re: Inverting buck boost converter load connection on: January 24, 2013, 02:51:54 pm
Yes, if you want to reverse a DC moter, you can simlply reverse the connections.

With relays or a bridge circuit, you can make a motor driven from a single-supply that runs either directions.

Sometimes you need a true negative voltage (referenced to ground).   For example, audio signals are AC (the voltage swings both positive and negative) so it's often handy to run an audio op-amp from + & - power supplies (although you can make an audio amp or preamp with a single supply).

Or sometimes if you are working with very-low positive DC voltages, it's easier to build a circuit that goes below zero volts, and that allows you to go down to zero-volts linearly.

If you are building a power supply (that runs off AC house power) you can make it put-out both positive & negative voltages (i.e. use a center-tapped transformer) and you don't need a separate inverter circuit.
728  Using Arduino / General Electronics / Re: Very basic resistor/piezo question on: January 24, 2013, 02:25:50 pm
With the resistor in parallel, you are creating a voltage divider where one of the "resistors" is the internal resistance of the piezo device.   Yes, that will reduce the voltage.   Since the piezo (unlike most voltage sources) has high source-impedance, a high-value resistor in parallel will reduce the voltage.

A resistor in series with the Arduino input will also create a 3-way voltage divider where the voltage is divided between the piezo, the resistor, and the Arduino.  However, since the Arduino has an input impedance of around 100M, almost all of the voltage will be "dropped" across the Arduino input, and the series resistor will have little effect.

Normally, you'd use two resistors to make a regular voltage divider and you could calculate the voltage drop.  With the piezo as one of the "resistors", we don't know the internal impedance of the piezo, so we can't calculate the voltage drop.  (I believe it's capacitive, rather than resistive.)   But, if you want to experiment, a single parallel-resistor is fine.


BTW - You have an unknown and uncontrolled voltage which will go positive and negative.    I'm not sure what voltage you are getting, but the Arduino is limited to 0-5V.   Any negative signal, or any signal above 5V can damage the Arduino.   So, I recommend that you use a pair of protection diodes.
729  Using Arduino / Project Guidance / Re: Lights to music on: January 24, 2013, 01:02:39 pm
Quote
Now its working good. But now i use only 1 cable of 3, so i havent got any ground. Could it be a problem later?
Yes.  The ground from the PC/phone needs to be connected to the Arduino Ground.   If it's working without a ground, there may be a ground between the power supplies or somewhere else.  For example, if the USB is connected to your PC, you already have a common ground.

The 3.5mm audio jack's 3 conductors are left-signal, right-signal, and ground.    You need ground plus either a left or right signal (2 wires) for a mono (1 channel) VU meter.  Do NOT connect the left & right audio signals together.   (If you want to use both left & right signals, use another analog input on the Arduino for the 2nd channel.)
730  Using Arduino / General Electronics / Re: What is 'spectrum' anyway? How can multiple frequencies exist in one signal? on: January 23, 2013, 05:12:52 pm
Another example of superposition is when two people in a room are talking at the same time.    When the 2nd person starts talking, the 1st voice is not affected an any way.  The two sounds are literally summed together acoustically (superimposed).     An analog mixer sums audio signals in a similar way, or signals can be summed digitally in a computer.

Of course, a human voice is not a sinewave or one-single frequency.  Different voices have different harmonics & overtones and that's why no two singers sound alike, even when singing the exact-same notes.

Quote
it's still an electromagnetic wave with a voltage and current at a certain point in time. 
At one point in time, there is no frequency.   Frequency is the rate of change over a period of time.  When you digitally sample a waveform, you take multiple points-in-time (CDs are sampled at 44100 samples-per-second).   Then when you "connect the dots", you can reconstruct the waveform over a period of time.

P.S.
Waves in the water will also superimpose...   If you make two waves moving toward each other in the opposite directions, the wave heights will be added when they "collide".   And after passing-through each other, the waves will continue-on as if nothing happened.

Another thing you can do with digital audio is mix two signals (say a singer and a guitar), and then if you invert the guitar mix it in again, the guitar will be subtracted-out and you'll just have the singer.   (This is easy to do digitally, but in analog it's hard to get the phase-time  aligned precisely).
731  Using Arduino / Audio / Re: audio pickup in analog x on: January 23, 2013, 03:22:55 pm
Guitars like to see a higher impedance.   A pair of 1 Megohm or 2M resistors would be better.   With a 50k load (a pair of 100k resistors) the signal is going to get knocked-down a bit, and your tone will probably be affected. 

With a high impedance load and the guitar volume cranked-up, you should get around 1V, which should be plenty of signal to work with.

With audio inputs, I normally use a peak detector (You'll need to change the 100k input resistor to 1M or more.)    A peak detector will work with lower signal levels, and since it's not biased at 2.5V (like the 2-resistor method) you can use the 1.1V ADC reference with weaker signals.
732  Using Arduino / General Electronics / Re: Simple switch - delay in pin going to low state on: January 22, 2013, 07:20:39 pm
Quote
I have no idea of the spec of the switch but I've tested it with my Ohmmeter and worked out I need to use 3 of the pins on one side: Power to the center pole, "off" state (left pin) to 10k resistor and then back to ground and "on" state (right pin) to pin 2.
OK.  Just make sure the "center" terminal is the electrical center.  (It usually is.)   

Then +5V can be connected to one of the other terminals, and ground to the remaining terminal.   That way, the center is either connected to +5V or ground, depending on the switch position.  In that configuration, you shouldn't need the 10K resistor at all. 

But, the 10k resistor (between 5V and the switch) is slightly "safer" because there are some very-rare switches (called "make before break") where the two "other" terminals are connected together for a moment in-between positions.    If that happens, you'll momentarily short-out the 5V.   Everything will probably survive a momentary short, but the Arduino would reset/restart and that would be a problem.

You can test the switch (with or without the resistor) with your multi-meter before connecting it to the Arduino.   Just check for 5V (at the center) in one position and zero volts in the other position.   And, it would be a good idea to turn-off the power and use the ohmmeter function to confirm that the "zero volts" connection is a good-ground, and not simply an open.   

The REAL solution is to use a pull-up resistor:   The Arduino has optional internal pull-up resistors which can be enabled (see this page).   The pull-up resistor pulls the input high (+5V) when there is no connection.   Then, you only need two connections to your switch to force the input low (to ground) when the switch is on.

Brandeaux suggests using a pull-down resistor.   That will work fine too.  But, pull-ups are the more standard way of doing it, and the built-in resistors are pull-ups.

With a pull-up resistor, you are "shorting-out" the input and shorting one side of the resistor to ground.  That's fine, since only a teeny-tiny current flows through the resistor.   If you were to make a "hard connection" to 5V (without the resistor), turning-on the switch would short-out the 5V supply, shutting everything down.

Quote
I've tried adding a delay to the loop (from 10ms to 100ms)...
That's only going to make things worse! smiley-wink  As the program is "stepping" through the loop, depending on where the program execution is in the loop, the input-read might get delayed or your "action" might get delayed 'till the delay is done.

FYI - As a general programming rule, it's best to avoid using delay().   Because while delay() is running, your program can't do anything else.   (Of course, you can use it when appropriate.)   So, if you you want to delay something without holding-up your entire program, you can read the "time" and compare like the Blink Without delay()Example..    With this techinque, you can have multiple delays/timers running at the same time, and they won't interfere with each other or with your main loop.
733  Using Arduino / Project Guidance / Re: Actuating a full size airplane on: January 22, 2013, 03:30:02 pm
It sounds like the only thing missing is a "flaps down" indicator.  Right?   I agree, you don't need to program an Arduino for that.

Quote
So, I'd use those same switches as my cut-offs for the motor as well?
Maybe...  It depends on how it's wired.    You should be able to "tap into" that switch's logic and possibly use a transistor as an inverter to turn the light on when the motor goes off.  You may need some additional logic to hold the indicator on, and then to keep it off when the motor is reversed. 

There are various logic circuits such as "and gates", "or gates", "inverters", and "flip-flops".   These don't need to be programmed with software.   Their function (and combined function) depends on how they are wired.    If the logic is fairly simple, and there's no "counting" or math, logic chips are usually easier.
When the circuit starts getting complicated, it becomes easier to do it in software (with a microcontroller).   

Note that most logic circuitry (as well as the Arduino) runs off 5 Volts.    "Converting" a 12V signal from  a switch down to 5V only takes a couple of resistors.   But, converting up to run a 12V lamp (if you don't want to use an LED) requires something like a MOSFET or transistor or relay.

Or, maybe there's an unused terminal on the switch (if it has normally-open and normaly-closed terminals).

Or, you may need to use an additional similar switch.
734  Using Arduino / General Electronics / Re: first pcb try on: January 21, 2013, 08:03:28 pm
I guess some people are having success, but my plan is...  smiley-grin I'm NEVER going to attempt it again! smiley-grin

I made some boards many years ago.  It was messy, the boards looked homemade, the drilling was not very accurate, and I don't remember what other problems I had, but it wasnt' much "fun".  It probably took a couple of attemps to get a working board.   

When I went to college, there was a lab where I could get boards made from my supplied artwork.   Since graduating from college, I've built several projects permanently on plug-in "breadboards", and sometimes I use perfboard and hand wire.   In the past I also used some wire-wrap.

If I ever decide to make a custom board again, I'll use a service like ExpressPCB to get the boards professionally made.   
735  Using Arduino / Audio / Re: Arduino DAC on: January 21, 2013, 06:50:15 pm
The Arduino does not have a DAC.   It has a 10-bit ADC with multiple inputs. And, it has 8-bit PWM outputs which can substitue for analog output for some applications.  But, it won't work for good-quality voice or music. 
Pages: 1 ... 47 48 [49] 50 51 ... 88