can arduino understand "if" statements?

hi there. sorry in advance for what will no doubt be a very confusing post.

can arduino do the following:

1.)compare 2 voltage inputs.. when the difference between them hits a set limit, e.g. 20%, then it drives either a stepper or servo motor, say 45 degrees, until the difference has hit a set limit, say 5%,
2.)and then return the motors back to where they were? or alternatively, just release all power to the motors until the voltage difference reaches the limit again?
3.)can the difference in voltage be controlled by a potentiometer? i.e. pot value 1= 5%, pot value 2 =10% and pot value 3=20%?
4.)what about damping out the oscillation? (assuming once the motors have been returned to "home" position, the difference in voltages starts to climb again.

the sensors out put a 0-5v signal. the actual signal readings arent important, its the difference between them i want to control.

I can't see any reason why you could not build that using Arduino. Although the specific approach to use would depend on the physical outputs you needed. If you don't need a great deal of torque then using a servo may be simpler than a stepper. What is it you are controlling? How fast and how accurate does the physical movement need to be?

can arduino do the following

Simply yes. It's just a matter of writing the code. :wink:

that is excellent news.
i m building a traction control setup for a car. it will read voltage outputs from wheel speed sensors on the front and back wheels, and if there is a difference between them(wheelspin) it will drive a secondary throttle plate to close off air intake to the turbo. the reason for the potentometer is to be able to select snow, rain, dry, or t/c off. the throttle plate which i will be driving is not the actual main throttle plate on the car, so if the entire system fails it wont send you spearing off into a ditch(see recent toyota fbw throttle debacle)

i built and installed a megasquirt ecu for the car, so circuit building is nothing new to me.

another question: is it possible to use a more powerful stepper motor to control it? i assume that power to the motor controller comes from the main circuit board. what if i were to run a separate power source into a more powerful motor controller, and just use arduino to signal it to run and stop?

thanks for the replies anyway, i have already got the system installed in the car, and was having a hell of a time trying to find a motor controller to run it. i stumbled across this site from a link on a ubuntu forum. (megasquirt, ubuntu, yes i am a bit of a geek)

i assume that power to the motor controller comes from the main circuit board.

No, the power for a motor would be separate. You might want to take it from the 5V line that goes through the on board regulator but that gives you very limited power for the motor. Most systems run off a much higher voltage than 5V and use switching to limit the current. In that way the motors will run faster for a given torque and current.
A typical system for say a RepRap machine (3D printer) or a CNC milling machine uses 12 or 24V motor supply on motors that can draw the full current, normally 1 to 3 Amps, from only 3V.

power to stepper motor ALWAYS comes from seperate powersource
the stepper controller does not usually consume more than a few milliamps at 5V, but the steppers usually require power in the amp range and will therefore fry the arduino with either taking too much current or spiking EMF back to the pins,
the controller has mechanisms to handle those usually, (at least the good designed ones do) so the controller takes two sets of voltage:

  • 5V for the controlling of the stepper,this is from the arduino
  • the voltage that the stepper takes, usually between 2 and 36 volts and much greater amperage.

But never try to power the stepper fromthe arduino direct.

David

i have had to ninja this post after reading the last one.

so if i wanted to run a 12v motor that reuires 1.5 amps at peak i could do that?

Yes you can control any amount you want, it is the motor driver circuit that takes the strain not the arduino, that just provides low level signals.

Something like an l298 H-bridge would do the trick. A google search for:
arduino l298 stepper
should result in plenty of useful hits.

You can find more about what can be used here: Arduino - Home

have a look at this arduino book .pdf

lots of good links from the www.freeduino.org
website :wink:

The pathetic +5 volt I/O from the atmega chip on an arduino can control

A 30 amp 120V motor via solid state relay motor specific contacto
A 40 amp +24volt coil contactor using a larger transistor and +24 volt coil supply for it.
10 LED christmas light strings using a 25 amp general use solid state relay.
A 25 amp SSR driving a monitorso I could turn a coworkers nuts.
etc

Switching audio signals on and off
Switching video signals on and off

10 amp stepper motor driven by a rather expensive H-Bridge / controller whose name I forget.

etc