Show Posts
Pages: 1 ... 36 37 [38] 39 40 ... 88
556  Using Arduino / Project Guidance / Re: comparing an array of inputs on: May 14, 2013, 05:39:45 pm
I think you just have to save the values in two arrays do 8 compares (in a loop).  Or, you can read the 8 pins directly and compare to the 8 values in the array.

And if you are just looking for any-difference or no-difference, you can break-out of the loop as soon as you find a mismatch, since there's no point in checking the remainder of the array once a difference is found.

There might be an easier way if you use a C++ vector, instead of a C-style array...   But, it's been awhile since Ive done any "real C++".
557  Using Arduino / General Electronics / Re: charging caps on: May 14, 2013, 03:41:28 pm
You can't get "free" energy, but there is the possibility of "pulling" more power from the power supply and delivering it to the motor...   Are slotcars AC or DC?  (in this application, capacitors are DC.)

If you have a good well-regulated & filtered DC power supply, a capacitor won't help.   On a commercial/pro track, I assume this is the case.

If you have full-wave rectified, but unfiltered DC, a capacitor will charge-up to the peak of about 1.4 times the RMS value, and if the capacitor is large enough (enough uF) it will boost your power!*    However, if your controller does not have an isolated power supply, that capacitor will boost the power for all of the cars on the shared power supply.  A diode will prevent the capacitor from discharging into the main power supply (powering all of the cars), but you'll get an approximate 0.7V loss across the diode (but still more than the unfiltered DC).

If you have an AC power supply but the motor will run on AC or DC, a full-wave bridge rectifier and a capacitor will again give you a DC voltage that's about 1.4 times the AC voltage.    Minus two diode-drops (about 1.4V).

I would sort-of assume that a good "hot" slotcar motor is optimized, and any tricks with boosting voltage might burn it out or shorten its life.  Of course, you mght damage a regular-average motor too... by running it above it's rated voltage for too long.

Oh...  With a diode preventing discharge back into the controller/power supply, you won't get good breaking if the capacitor is too large and continues to provide power for too long after you try to slow-down.



* Since current increases when voltage increases (through a constant resistance), that means power increases with the square of the voltage, and with 1.4 times the voltage, you'll get about twice the power!
558  Using Arduino / Programming Questions / Re: jumpy analog values on: May 14, 2013, 02:51:37 pm
Quote
Try two readings each time you do an analogRead, and chuck the first one away.
Right... There is really only one analog-to-digital converter in the chip, and the analog inputs are multiplexed (switched).    I haven't studied the timing-diagrams, but it takes some time to process & "settle".
559  Using Arduino / Project Guidance / Re: RGB LED color control wont work on: May 14, 2013, 02:40:57 pm
Every time through the loop you re-initialize i = 1.

Try initializing i=1 during setup.   Then it should increment normally up to 6 and reset when you hit 7.
560  Using Arduino / General Electronics / Re: How to connect C14 and UK AC mains to relay? on: May 14, 2013, 02:26:49 pm
You can use female Quick Connects* which crimp onto the wire, or you can solder wires directly to the contacts.  If you solder I recommend insulating with heat-shrink tubing and if you use quick-connects, I resommend the insulated type. 

You can get quick-connects at from places that sell electrical ro electronic parts, hardware stores, home improvement stores, or auto parts stores.   There are a couple of popular sizes, so make sure you get the right one.

Quote
Also I'm assuming the ground wire skips the relay altogether and goes right across from the C14 ground pin to the 13A ground pin?  What about neutral?
The ground & neutral are connected directly.   The hot wire is switched through the relay.  If you have a double-pole mechanical relay, there's no harm in switching the neutral also, but the ground should be "permanently" connected.

In order for current flow, you need a complete circuit.   You can "break" the circuit and turn-off power with a switch in either the hot or neutral side.    But for safety reasons, the switch/relay normally cuts the hot connection.



* "Quick-connect" or "Quick disonnect" mioght be Americqan slang/jargon, and they might have a different proper name..

This is a Spade Terminal and this is a Ring Terminal.
561  Using Arduino / Project Guidance / Re: LED light Project on: May 14, 2013, 01:59:27 pm
Assuming you want them all to come on together, with a higher than 5V supply, you can use a series-parallel combination.   

For example, let's say you have a 12V power supply and your LEDs are rated at 3.5V.   If you put two in series, that's 7V across the LEDs and 5V across the resistors.   With 30 LEDs, you'd wire-up 15 sets of those.   (The more you wire in series, the more efficient your system with less power wasted in the resistors.)

With a resistor current limiter, it's generally best (best for current/brightness control, but not for efficiency) if you drop about half the voltage (or more) across the resistor.  So if you want to go with 3 in series (10 sets), I'd say use at least a 15V power supply.

Quote
1. How to power the LEDs? (the battery must not be too large because it needs to fit on a garden sculpture)
You might want to look-up some Amp-hour ratingsfor various batteries and do some Amp-hour calculations, based on the current required for the LEDs plus the Arduino and other circuitry.   

If you're not up-to-speed on Ohm's Law and Kirckhoff's Laws... Briefly, the same current flows through series components.  So, two LEDs in series share the same current, and use half the current of two LEDs in parallel (at the same brightness).

And, a constant-current switching LED power supply doesn't waste power heating-up current-limiting resistors.  That means your battery would last longer (at the cost of a more-expensive, or more complex, power supply).
562  Using Arduino / Audio / Re: Audio Filtering on: May 14, 2013, 12:56:55 pm
Quote
So if it is a truck, it will be a specific truck in one determined moment. If it is a trumpet, it will be the same trumpet playing the same music notes.

I had thought about make a first reading amplitude attempt (in dB) for three different frequencies, then save them, and after that listen sound compare with them for detect if is positive/false detection.
That might work.  You'll have to experiment, and I'm not sure if 3 frequencies is enough.   You'll also have to allow a range/window of dB levels in each frequency-band, because it's never going to be exactly the same twice. 

You might want to take an average of the 3 (or more) frequency bands to calibrate the overall level before analyzing the frequency content.

563  Using Arduino / Project Guidance / Re: vu-meter on: May 14, 2013, 12:00:06 pm
Quote
the SPL seems like it works and it write out values but  when it quiet it still put out high values. don't know why.
The output might be biased at 2.5V.  That's one way to deal with the fact that negative voltages can damage the Arduino, and that microphone circuit might be taking care of that for you.  (You need to protect the Arduino from the negative-half of an AC audio waveform).

Do you have a multimeter to measure the voltage out of the microphone circuit with silence?  Or, what do you get when you send the ADC reading to serial-out (with silence)?   Or, do you have a schematic for the microphone circuit?

If it's biased to half-voltage (about 512 out of the ADC), you can subtract 512 from the readings and then  either ignore negative results or take the absolute value.
564  Using Arduino / Audio / Re: Audio Filtering on: May 13, 2013, 06:20:45 pm
Quote
•I have characterized my target sounds in three frequencial components (Hz), with their amplitude (dB). And I only want to compare the sound measured with these components but I can't split them from audio samples I have taken.
I'm not sure I understand... If you have a truck and a trumpet at the same time, and you want to filter-out the truck, that's virtually impossible.*   Except, you can filter-out low frequencies such as "rumble" from the truck.

If the sounds are not occuring at the same time, you have a better chance of automatically separating them.    But of course, not all trucks generate the same frequencies at the same volume, and a trumpet can play many different notes and can be played/recorded at various volumes.  There is no simple "fingerprint" for either of these sound-sources.




* "You can't un-fry and egg, you can't un-bake a cake, and you can't un-mix a recording."

If you could do that, there would be no need for multitrack recording...  You could record the whole band with one microphone at once, un-mix, edit, and then re-mix.    That technology does not exist.
565  Using Arduino / General Electronics / Re: Two unrelated questions: capacitors in circuits on: May 13, 2013, 01:42:33 pm
Quote
if I look for ceramic capacitors there are ones that look sort of terracotta-coloured and called "ceramic disc" and there are others which are blue, and these are usually labelled as "ceramic". 
Electrically, it shouldn't matter in this application.  The blue "monolithic" capacitors might be better/stronger physically and/or have better/tighter tolerance.

Quote
1) Are the parts in the circuit for a 5V setup like with the arduino? It's not clear to me...the bit about a "mainframe"(!!!) has me puzzled too   I take it that my arduino is the "mainframe"!
Strange terminology...  Yeah, that could be an Arduino.
 
Quote
2) If I enable the arduino's internal pull-up resistor, does the 1.2k resistor in the circuit then become unnecessary?
Looking at the simplified schematic on the datasheet, you have an open-collector output.  Yes, the Arduino internal pull-up should work.  However, the higher impedance (the 20k pull-up) is more prone to noise pick-up.    So if the signal runs a long distance, lower resistance may help with noise (i.e. false signals).
Quote
3) Am I looking for ceramic disc capacitors again for the capacitors in this circuit?  Also, is the value of those capacitors OK to put in a 5V circuit?
They should be fine.  The voltage rating on a capacitor is it's maximum rating.  Any ceramic or any ceramic-monolithic capacitors, will have a voltage rating higher than 5V and will be fine.

566  Using Arduino / Project Guidance / Re: Arduino controlling 220v ceiling led lamp on: May 09, 2013, 07:31:14 pm
Not all AC LEDs are dimmable!   An AC LED lamp isn't just an LED.   There is a circuit (basically a constant-current power supply).   The power supply is usually designed to supply a constant current.  Not all are designed to supply a voltage/current that's proportional to the average AC input...  Some LED lamps are rated to run on anything between 85VAC and 280VAC.  Obviously, these can't be dimmed. 

With a ceiling fan/lamp the power supply might be built-into the fixture.   If the lamp is replaceable, check the part number & specs.   If it screws-in like a regular light bulb, you can probably replace it with a similar dimmable LED-bulb or with a regular 'ol light bulb.

And, LED some lamps might not run on DC...  I don't know if any household 120V/220V LEDs are designed for DC.  So with a dimmable LED, you should probably build a "normal" AC dimmer with a TRIAC, phase control, and all that (and with isolation on both your zero-crossing detector and your AC output).

Quote
Here's what I used:
AC->DC Convertor (KBL410)
Transistor - BUX8GP
Capacitor - 4.7 uF 400V
Arduino Uno
Resistor - 1k Ohm
You didn't isolate the 220VAC from your Arduino?    That can be OK, but it's usually a bad idea.  It can also be very dangerous if touch the Arduino, and it can be dangerous to your computer if you  connect the Arduino to your USB port and 220 at the same time!
567  Using Arduino / General Electronics / Re: 74LS193 acting wierd... on: May 09, 2013, 07:08:28 pm
Quote
I have the 193 preset to 9

So... You count down from 9, and that's OK?
But, when you keep counting down from zero (without re-initializing to 9) it "rolls over", you get F (1111), and it counts down from there?

...Sounds like normal 16-bit operation to me! smiley-wink

smiley-grin smiley-grin smiley-grin smiley-grin
Quote
Forum rule - when any one says something is acting weird it is always acting perfectly normally.
smiley-grin smiley-grin smiley-grin smiley-grin

568  Using Arduino / General Electronics / Re: My Arduino Nano decided to stop working? on: May 09, 2013, 06:37:44 pm
I can't help you but I had the same problem with an Uno.   It's running a useless-unfinished program and I can't re-program it.  I don't know if the problem is the boot-loader, serial ports, or USB chip.

I bought an AVR ISP programmer (about the same price as replacing the Arduino) to re-porgram it, but that didn't work either.   I think that's a different problem because the error message seemed to say that programmer wasn't recognized by the Arduion IDE.   (I never tried the programmer with a known-good Arduino.)

So now I just the bricked Uno as a template if I need to drill mounting holes in a box/chassis, or if I want to look at the pinout locations, etc. smiley-grin 
569  Using Arduino / General Electronics / Re: Where do you buy your components? on: May 09, 2013, 04:47:32 pm
Jameco & Digi-Key.    I've been buying from Jameco for more than 30 years!!!!  Digi-Key many years too.

I haven't had any custom boards made (or made any myself) since I was in college.   Usually, I build the project permanently on a plug-in breadboard.  It can be very reliable.  I built a car-alarm on a breadboard about 20 years ago, and it's still working.   I've also use various perfboards, wire-wrap, terminal blocks, etc. to avoid the cos to a custom board

The last perfboard I built was an ugly mess (I didn't have space for the breadboard), so I'm probably going to use a real PCB next time i build that circuit.   There are also a couple of circuits I seem to build over-and-over, and I'm thinking it's time to get some boards made for those.
570  Using Arduino / Project Guidance / Re: Smallest AVR that can handle FFT? on: May 09, 2013, 04:13:35 pm
I've never used FFT.   I've done some lighting effects, but everything I've done works off the volume (no frequency filtering and no true beat detection).

Accurate beat detection isn't that easy...   Detecting the bass isn't exactly the same as detecting the beat.  But IMO, a lighting effect that accurately pulses to the beat 1-2-3-4-1-2-3-4 is kind-of boring anyway! smiley-wink

Some people have done beat detection, so you might want to search the forum.  I think it requires two filters - One low-pass to filter-out everything except the bass, and a bandpass-filter tuned to the beat frequency (around 1/4 of a second or about 4Hz).   That 2nd filter is not to filter the signal (there should be no signal at 4Hz), it's used to filter the detected loudness envelope.   (If it was me, I'd probaly do the bass-filter in hardware and the beat-filter in software.)  Then if you wan to get really good, use some "fuzzy logic" to tune that 2nd filter and know when to expect the next beat...  That's how humans do it...  We don't wait 'till we hear the the beat and then tap our foot...  We know when that next beat is coming and we make tiny adjustments as we listen to keep our foot-tapping in-time with the music.

Something that's super-easy to do with just the volume (once you have the hardware setup so that you can read the loudness on an analog pin) is to compare the input to the average, and turn on the light/LED whenever the signal is louder than average.   That's more of a "flicker effect" than a beat effect, but its something simple to start with.

The Smoothing Example example shows you how to get a moving-average.   If you use a moving average, you won't need a sensitivity control, and your effect will automatically adjust itself to loud songs, quiet songs, and volume changes.  (In my application, I also switch automatically between the 1V and 5V analog references, depending on the signal level.)

I use a 20-second moving-average, updating the average-array once a second.  (Of course, I use the "blink without delay" style timing, so it can uns and flash the lights in-between updating the average.)


For some of my effects, I find the peak value in the average-array, and use that as my trigger threshold.  (For example, a chase effect that changes direction only when it hits a new peak.)  For other effects, I use the halfway point between the peak and average.   If you want to use the peak to detect the beat, you might pick a threshold that's something like 90% of the peak value in your array.   You don't want one big peak to throw everything off...

For my very-crude beat detection, I just delay (or ignore peaks) for about 1/5th of a second, so that I don't get to many beats/flashes close-together.   That's nothing like accurate beat detection, but you do get the feeling the that the lights are being triggered with the beat, and it's easy to do!  ...Actually, there's one more "tweek" I'm using.  I increase the sensitivity while waiting for the next beat.     So... I'm unlikely to get a beat trigger exactly when 1/5th of a second is up, but after 1/2 second the sensitivity is going up and I'm very-likely to detect a beat.   
Pages: 1 ... 36 37 [38] 39 40 ... 88