Show Posts
Pages: 1 ... 382 383 [384] 385 386 ... 813
5746  Using Arduino / Programming Questions / Re: Stepper Motor Speed Increase Response to Sensor on: May 03, 2013, 04:57:20 am
i is just a counter to keep track of the number of steps taken.
Yep, I forgot to declare it smiley-eek-blue
You should declare it as an int before loop().
Introducing unnecessary global variables is poor style, this sort of loop variable should
be declared locally like this:
Code:
  for (int i = 0; i<stepsPerRevolution; i++){
and if you do want it global give it a descriptive name.

I would always recommend writing such code in an event driven manner, so rather than
update speed every time round the loop (and call setSpeed() every time round the loop),
detect only those times when it needs to change, so instead of:

Code:
   if(digitalRead(pirPin)){       //if pirPin is high
      speed = 40;  //double the speed, or set it to whatever faster speed you want
      }
   else {
      speed = 20;   //else set speed back to 20
      }
use something like
Code:
  byte buttonState = digitalRead (pirPin) ;
  if (buttonState != prevButtonState)
  {
    myStepper.setSpeed (speed = buttonState ? 40 : 20) ;
    prevButtonState = buttonState ;
  }
(this also illustrates conditional expression and assignment operator in an expression to set variable and use
its value in the call to setSpeed()) - perhaps a little too terse, but I think its always preferable to use
the conditional expression:
Code:
  speed = buttonState ? 40 : 20 ;
to the long-winded
Code:
  if (buttonState)
  {
    speed = 40 ;
  }
  else
  {
    speed = 20 ;
  }
5747  Using Arduino / Motors, Mechanics, and Power / Re: Anyone familiar with the "AccelStepper" library? on: May 02, 2013, 12:14:44 pm
I look at your code again and can't see why you are not calling motor.run() in loop - you must call this
very regularly - in loop() before each call to a subroutine might be a good place.  Remember run()
returns a boolean to tell you if you have arrived at the target.

You also call moveTo() repeatedly while a button is being held down - doesn't sound a
great idea - call it once when the button is first depressed (in other words detect button state
transitions).
5748  Using Arduino / General Electronics / Re: Driving HighVolt modules (5KV) with Arduino's PWM output on: May 02, 2013, 12:03:59 pm
You need a DC-DC converter with variable output voltage capable of providing upto 150mA.  That's normally
done with a specialist chip using an inductor and capacitors - for 150mA no need for external MOSFET for
most of these chips.

It would be possible to use the LPF solution with poor efficiency though, something like a MIC4422 MOSFET
driver run at 15V, PWM into that and take the output through a 15ohm resistor to say 220uF, and PWM at
say 10 to 20kHz.  Again no external MOSFET needed, but the resistor should be at least 5W and the capacitor
a low-ESR version - and you waste loads of power.

The reason a special chip is needed for the efficient inductor circuit is that inductors saturate above a
particular current level, and then behave like a short circuit, blowing the switching devices very rapidly.
Most of the chip's function is preventing failure modes!
5749  Using Arduino / General Electronics / Re: How to connect this rotary encoder on: May 02, 2013, 11:47:19 am
That diagram must be wrong, the 200 ohm resistor should be the series resistor for both IR emitters,
suggesting green as +5, but the 10k resistors are then not right for green as +ve supply.

if you wire the power correctly there should be about 10+mA flowing (indicating the emitters are functioning).

If no current flows its definitely wrong.
5750  Using Arduino / General Electronics / Re: Led light replacement of a 300wat halogen on: May 02, 2013, 11:42:56 am
I've seen a 5W mains LED array, but nothing higher power.   There are 25W, 50W and 100W led arrays available,
all require a particular DC voltage/current (for instance the 100W arrays are 10 strings of 10, so about 32V at 3.15A...)

Yes a constant-current driver is needed for such DC LED arrays.  And plenty of heatsinking / fan.

Checkout dx.com for examples of these LED arrays - search "100W LED" or whatever.
5751  Using Arduino / Motors, Mechanics, and Power / Re: Brushless motor: Why do I need an ESC? Alternatives on: May 02, 2013, 11:33:51 am
Thank you Erdin, appreciated!

Could you recommend any websites or reading that'd take me into the various types of motors and motor controllers, their advantages disadvantages etc? I'm just after some cheap and cheerful fans with speed control to drive air round some apparatus. The speed control is to control the noise as much as their output... a bit bewildered by the permutations that seem to be cropping up between h bridge, motor shields, integrated electronics, ESCs etc.

Many thanks again!

In that case you want PC fan with speed control input.
5752  Using Arduino / Motors, Mechanics, and Power / Re: Brushless Motor Direction control on: May 02, 2013, 11:28:29 am
That's a sensorless motor by the look of it, most ESCs are unidirectional (there is no way to cleanly reverse a sensorless motor
without stopping and re-starting it).  The bulk of such motors power airscrews which only ever need to go one way.

However its worth looking for RC model car/truck ESCs to see if there's a reversing one for that application.

[ edit: Oh, that's a high-resistance motor - does it have hall-sensors then? ]
5753  Using Arduino / Motors, Mechanics, and Power / Re: Flywheel as quadcopter power source on: May 02, 2013, 11:25:55 am
Probably 3 orders of magnitude out?
5754  Using Arduino / Sensors / Re: Small signal and high voltage on: May 02, 2013, 07:02:11 am
Thanks for all the replies!

The dual diodes trick certainly got me started! I tried that spice circuit and as dc42 mentions, I used the 102 capacitor, replaced the 100k resistor with a much smaller one and got better results, also used a 1mH inductor to dissipate the DC build up, the end result so far is a really short blanking area of <100us (way better than I expected).
Reducing the 100k resistor is fraught with issues - if the incoming signal during TX is hundreds of volts a low value resistor will absorb all
the power and burn out...  You need to switch the signal, which means using 1000V rated transistors or similar.  Basically an RX-TX switch is
a requirement.
Quote

As dc42 also mentions, the bandwidth limitations of the LM324 would not allow me to even make a unity gain filter.
I now realize I need much better bandwidth op-amps. What would you guys suggest?

This is RF circuitry really - the normal approach is to use several stages of transistor or FET amplification with
tuned transformers to couple between stages.  This filters out all but the 200kHz and the LC circuits tune out
all the stray capacitance.  Failing that find a decent high frequency opamp - there are many, but don't expect them
to also be 5V and rail-to-rail...
5755  Using Arduino / Sensors / Re: Gyro data gets disrupted by Servo.attach (UNO) on: May 02, 2013, 06:50:53 am
Its also vital to avoid sharing ground wires between high-current devices (like a motor/servo) and a sensitive analog input,
otherwise the IR voltages in the high current wire appear across the sensor inputs.  Use different GND headers on the Arduino
for these separate purposes.  Remember a wire is just a low value resistor, any large currents will cause a voltage drop across
the wire.
5756  Using Arduino / Programming Questions / Re: invalid conversion from 'int' to 'void' on: May 02, 2013, 06:46:55 am
Your curly braces are also mis-nested - you need to indent your code properly to make it readable.
5757  Using Arduino / Motors, Mechanics, and Power / Re: Servo moving without instructions. Power loss or code error? on: May 02, 2013, 06:44:10 am
Quote
I didn't include the decoupling capacitor as per the first link's article and am wondering if this could be the cause? It's not like the board loses power or resets itself, it's just that the servo moves without being instructed to?

Decoupling capacitors are not optional components.

The symptoms of inadequate decoupling can be many and various and hard to diagnose, so always
include decoupling of every chip before even attempting to run the circuit.
5758  Using Arduino / Motors, Mechanics, and Power / Re: Anyone familiar with the "AccelStepper" library? on: May 02, 2013, 06:41:03 am
You have to wait for the motor to reach its target position before changing speed or acceleration settings, I believe,
otherwise you get the erroneous behaviour described.
5759  Using Arduino / Motors, Mechanics, and Power / Re: Using solar panel to power small DC Motor 6/9v on: May 02, 2013, 06:39:08 am
How much capacity do you want in the battery?
What battery chemistry?
You realise for most batteries you have to protect against over-charge and over-discharge? (otherwise you
ruin the battery)

If you say what you want to achieve, we can probably advise better.
5760  Using Arduino / Motors, Mechanics, and Power / Re: MG995 servo current draw? on: May 02, 2013, 06:35:29 am
My multimeter is telling me that the servo is pulling 1A without any load! That seems like a lot to me.

Is this normal? I don't have another power supply to test them any further.

Not normal, idle current should be more like 0.1A or less - either its trying to move and is jammed somehow, or its
duff.  You said they were cheap.
Pages: 1 ... 382 383 [384] 385 386 ... 813