It can be done with interrupts. Attach an interrupt to a timer, so that it fires regularly (say once a milisecond), and use that interrupt to pop the next command off the top of a queue (could just be an array).
Your main loop then just adds commands to this array.
A single Arduino has 14 IO lines, so the number of motors you can control depends solely on the number of wires needed for each motor.
There are dedicated stepper motor driver ICs that are much better and simpler than using a 555 timer. The floppy drive will be using one (maybe embedded inside another chip). They usually accept simple up/down step signals and convert them into the proper sequence of pulses.
Edit
Example code, using the Timer1 library:
#include <TimerOne.h>
void test()
{
digitalWrite(5,HIGH);
delayMicroseconds(100);
digitalWrite(5,LOW);
}
void setup()
{
Timer1.attachInterrupt(&test,100000);
}
void loop()
{
}
This will cause digital pin 5 to go high then low once every 100,000µS - you see there is nothing in the main loop at all. Just replace the two digitalWrite() calls with the code to step your motors once. You do not need to specify any inter-step delay in that part of the code - that delay is set by the value of 100000 in the Timer1.attachInterrupt() function. To change the speed of the steps, change that value.
I have worked on building a homemade quarocopter for my final year project, I remember having trouble with this too :)
I have used Turnigy Plush 30amp Speed Controllers.
Frist of all, FYI:
The normal sequence when staring an ESC (again, the one I worked with) is:
- as soon as your ESC is powered - minimun throttle (close to 1ms pulse) for about 3 seconds (until the beep codes for battery type and ok to start are elapsed)
This is a safety feature - normally, this means that the throttle stick is at minimum.
However, a great majority of Electronic Speed Controllers are programmable in terms that you have to program this minimum (and maximum) throttle I said earlier about.
In other words maybe that programmed minimum throttle is around 0.7ms (if you programmed it from RC transmitter with trim set to minimum) and when you power on your ESC input is around 10ms pulse, it's a safety feature it won't start, since in this case throttle is not minimum.
In order to program the new maximum and minimum input values (calibration):
- Power On
- as soon as you ESC is powered - maximum throttle (close to 2ms pulse) again wait for the beeps (only battery type)
- quickly jump to minimum throttle (close to 1ms pulse) and wait again for the new initialization beeps (this time there will be less, without battery type)
- new values for minimum and maximum throttle are now stored
I strongly recommend you use this kind of initialization every time so that all ESCs will be synchronized regarding minimum and maximum value of throttle. Also I strongly recommend you don't have any propellers mounted when experimenting with this approach :)
Now, regarding your code,
- I don't think you need to slide all the way up to the maximum or to down to the minimum during the initialization phase (in my case ESC expects value ASAP, with no slides), you should write the output value directly(no slide up/down).
- As soon as you reach the maximum value you start sliding down to the minimum. You should stay long enough at maximum value (Around 1 second)
- If initialization is not OK on first try, ESC is locked until supply is cut and turned on back again. There is no point in making attempts to initialize if first attempt is failed.
When calibrating or starting the ESC be sure to hold minimum value and/or maximum value as long as it is required. Something like:
Normal starup(as you described your ESC):
- Turn On ESC
- minimum throttle
- wait 2 seconds
- maximum throttle
- wait 2 seconds
- minimum throttle
- wait 1 second
- OK to Go
Normal starup(the ESC I used):
- Turn On ESC
- minimum
- wait 3 seconds
- OK to Go
Calibration:
- Turn on ESC
- maximum
- wait 2 sec
- minimum
- wait 1 sec
- OK to go
Another thing, good to know, entering programming mode for ESCs allows you to set a lot of parameters such as the cutoff threshold, brake. Before attempting flight, you must be sure that all these parameters are set the same for all ESC you use. Again, for the ESC I used, see the manual, page 2.
I'm pretty sure you've already figured this out, but I wanted to post it maybe it will help others :)
Best Answer
Both are possible, just the RF one is harder than the other. Without knowing the specific remote, it is common for remotes to have simple active low or active high buttons. When the button is pressed, the remote's microcontroller pin, as an input is connected to ground (or vcc), the remote sees the change, and acts appropriately. Your arduino would have it's gpio pins as (High Impedance) Inputs, connected to the microcontoller side of the remote's buttons.
If you need to control the buttons from your arduino, you would need a transistor or relay in parallel with the remote's button. Fairly simple.
RF is harder, as you would need to know the frequency and modulation, possibly the encoding if it uses any, as well as the communication protocol. You might luck out if it uses a standard rf transmitter/receiver IC, but it's not a beginner's project. At a bare minimum, you would need to understand radio frequency and have an oscilloscope or two. Possible yes, practical, no.