Show Posts
Pages: 1 ... 385 386 [387] 388 389 ... 813
5791  Using Arduino / General Electronics / Re: Reading rotary encoder on: April 29, 2013, 11:19:07 am
Then in your loop() function you can implement de-bouncing on the value of phase using your moving
average if you wish.

Rotary encoders use grey-code to make debouncing unnecessary. It's what those codes are for. Only one switch can be in transition at any time.

If both went high then both went low again, that's a click. All you need to know is which one went high first - that gives you the direction.

Debouncing is sometimes desired, since the cheap rotary switches often transition very close to the centre of
a detent, causing the value to oscillate as the spring settles into a detent - the user interface behaves most
intuitively if such rapid variations are hidden from the business-logic of a sketch.  Rotary switches usually have
4 transitions per detent, so the chance of such false pulses is high as the distance from an arbitrary stopping
point and the nearest detent is 0 to 2 transistions, average of 1...

[ and its Gray code, not grey code. ]
5792  Using Arduino / Motors, Mechanics, and Power / Re: Servo Problem... on: April 29, 2013, 11:12:16 am
Not to be rude but when responding to an OP, it's best that you actually read what they wrote, "listen", and not make assumptions.

Yes, I read that you tried a 9V battery, and saw that you had connected a servo supply to the 5V pin in the first photo - both of
these are common issues that crop up all the time here - which suggested a lack of research, causing me to re-iterate
the posting guidelines on these forums.

I didn't say anything about the LM317 case since you didn't show that part of the circuit, nor did I say anything about
common grounds.
5793  Using Arduino / Motors, Mechanics, and Power / Re: Need advice to control intensity in electromagnet for ferrofluid sculpture on: April 29, 2013, 10:53:49 am
Yes, the IRF520 is not logic-level, not suitable for driving from 5V.  You're alternative is logic-level (and much lower on
resistance - the 520 is a truly ancient device I believe).
5794  Using Arduino / General Electronics / Re: arduino and MOSFET IRL540 on: April 29, 2013, 10:50:14 am
You should include a 150 -- 1k ohm resistor inbetween the Arduino pin and the MOSFET gate to limit the
maximum current taken from the Arduino pin during switching - otherwise the momentary gate currents
will exceed the 40mA maximum for the Arduino.  If you connect directly you may cause issues even if
it appears to work happily now.

If you want the valve to definitely be off when the Arduino is starting up, add a 10k resistor directly between
MOSFET gate and source - this will discharge the gate whenever the Arduino is not driving the gate pin.  MOSFET
gates behave like capacitors and can retain charge / state for long periods otherwise.
5795  Using Arduino / Sensors / Re: BMP085 the apocalypse has come on: April 29, 2013, 07:51:57 am
You are using the 5V version of the breakout board??
5796  Using Arduino / Sensors / Re: Can't get a MMA7660FC work ? (Accelerometer) on: April 29, 2013, 07:48:00 am
This thread sounds useful about I2C on Due:,132981.0.html
5797  Using Arduino / Sensors / Re: Conversion units from mg/L to ppm on: April 29, 2013, 07:43:48 am
mg/l is not a dimensionless ratio.  However if we are talking water as the solvent then it is basically the same
as mg/kg which is ppm.  If we are talking air as the solvent, then air is 1.2g/l, so the conversion factor is
833ppm (by mass) and 525ppm (by molarity).

The google value matches the parts-per-million by molarity in air closely enough.

[ btw:  molar mass of ethanol = 46g, of air ~= 29g ]
5798  Using Arduino / Programming Questions / Re: Can the Arduino Uno rev 3 handle 2 sensors? on: April 29, 2013, 07:38:45 am
The first two appear to use a serial wire pair, and they suggest using SoftwareSerial library which can use any two
pins - so each sensor kit can run on your choice of pins.

The last combo board seems to use USB connectors for analog inputs and for I2C bus, for obscure reasons, but
basically packages several options in one shield - it will have fixed pin assignments since its a shield, but might well
do all you need (although it might use more pins than you have spare, always check out the pin usage before
5799  Using Arduino / Motors, Mechanics, and Power / Re: Stepper Motor Basics on: April 29, 2013, 07:31:54 am
You need AccelStepper to get to the full speed (steppers are both velocity and acceleration limited).

Vibration can also be a symptom of one phase being unconnected.
5800  Using Arduino / Motors, Mechanics, and Power / Re: Servo Problem... on: April 29, 2013, 07:28:49 am
This is a very common problem - its best to search first, ask questions later.

Small 9V batteries have no chance of powering a servo, which can take an amp or so peak.  PP3-sized
9V batteries barely handle 100mA.

You probably will have problems running the servo and Arduino from the same 5V rail - worst case
you could damage the Arduino, but random resets are highly likely.
5801  Using Arduino / Motors, Mechanics, and Power / Re: Monitoring current with ACS712 on: April 29, 2013, 07:24:57 am
What maximum currents are you expecting?  The ACS hall sensors only go down to +/-5A (and even that really means +/-10A with
the best linearity in the +/-5A range).  They are more noisy than other current sensors (but have total isolation from the circuit
being measured).

If you are only need a couple of amps then choosing the right shunt + rail-ro-rail opamp will give more accurate results (and will be cheaper).
5802  Using Arduino / Motors, Mechanics, and Power / Re: Motor Choice Question on: April 29, 2013, 07:21:06 am
Please define "quite accurate" -  5 degrees? 1 degree?  10 minutes of arc?

How heavy is the camera?
5803  Using Arduino / General Electronics / Re: Best way to control the direction of motors on: April 29, 2013, 07:16:32 am
Shouldn't do.

Depends on the set-up - full-on braking with a large motor spinning fast and lots of (moment-of-)inertia could rip the motor
off its stand!  With a small hobby motor I don't think there will be any issues...

With electric vehicles the electromagnetic braking is under PWM control so the braking force can be controlled
to the desired level, avoiding wheel-lock or damage.  Full-on braking is equivalent to stall-conditions so that the
current (and thus torque) is limited ultimately by the motor's internal resistance.

DC motors produce torque pretty much directly proportional to current, and back EMF is directly related to rotation
speed.  When under normal load the applied average voltage is roughly the same as back EMF, only the difference
between applied voltage and back EMF is available to drive current through the windings.  Braking is simply applying
0V to the windings (thus full back-EMF is available to drive current through windings)
5804  Using Arduino / General Electronics / Re: Help with low voltage supply on: April 29, 2013, 07:04:11 am
The capacitors are not optional, why did you think they were?

Without the capacitors you have built an oscillator circuit - without an oscilloscope it is hard to
diagnose such things, but if you follow the correct circuit it won't oscillate (correct caps on
both input and output, right next to the regulator).
5805  Using Arduino / General Electronics / Re: Reading rotary encoder on: April 29, 2013, 07:00:47 am
In my frustration with not getting any of the example code to reliably read my rotary encoder, I wrote my own. It works very well for me on my 20 detent 10 ppr encoder. I am using this encoder for a small user interface, so I don't need perfect accuracy at high speeds.

The problem with that code is that you run moving averages on the wrong variables.

You treat the A and B phases independently, which will lead to occasional errors since the
mark/space ratio of each phase is not the same thing as the phase or position state.

A more reliable approach is to read both pins simultaneously using PIND register, maintain the correct
phase/position information from that, then use moving averages (or any other de-bouncing technique) on the
phase/position variable.

One way to maintain the postion variable is this:
void setup ()
  attachInterrupt (0, handle_enc, CHANGE) ;
  attachInterrupt (1, handle_enc, CHANGE) ;

volatile long phase = 0 ;
volatile byte portd = (PIND & 0x0C) >> 2 ;   // initial state of pins 2 and 3

void handle_enc ()
  byte pd = (PIND & 0x0C) >> 2 ;  // read pins 2 and 3 simultaneously (we know one has probably just changed)
  pd ^= (pd >> 1) ;               // 00 01 11 10 sequence converted to 00 01 10 11 sequence
  byte sig = (pd - portd) & 3 ;   // difference from last observation (crop to 2 bits)
  if (sig == 1)  // sig should be either 0, 1 or 3 (2 is an illegal state for a working encoder)
    phase -- ;
  else if (sig == 3)
    phase ++ ;
  portd = pd ;   // remember this pins' state for next time

Then in your loop() function you can implement de-bouncing on the value of phase using your moving
average if you wish.
Pages: 1 ... 385 386 [387] 388 389 ... 813