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 :)
Most of the ABS speed sensors that I have seen are CURRENT-MODE devices. That is: they modulate the current passing though them rather than the voltage.
This has several significant benefits for the automotive manufacturer. The main benefit is the elimination of ground-induced noise in the sensor.
The easy way to verify this is to install a 100 Ohm resistor in series with one of the sensor leads. Then measure the voltage across that resistor.
I've made simple adapter boards for local auto enthusiasts. I had them identify the most positive lead going to each wheel sensor and interrupt that. I then used some Zetex ZXCT1008 hi-side current sensors to give me a proportional current output that was then converted to a voltage at the add-on board that they were using. The Zetex part is connected across an 18.2 Ohm resistor in series with the +12V lead feeding the sensor.
Again, keeping the sampled signal as a current eliminates ground-related problems for the add-on system.
Best Answer
If the machine has a brushed or universal motor, you can use a triac dimmer to control its speed.
However, triac dimmers are annoying to control. They fire on each mains cycle, ie every 10ms on 50Hz mains which inserts a large phase lag in the control loop. Also the input-output curve is very nonlinear.
If you want to control needle position you will need fast and accurate control, so you don't want to insert a large phase lag in your control loop. You'd need a smart control algorithm to compensate for this lag.
A much better scheme is to rectify mains and smooth it with a capacitor, then use high-ish frequency PWM like 10-20 kHz through a MOSFET. This has much lower phase lag, and would be easier to control. You can also control current through the motor, if you want to control torque.
For example, I have several electric drills. Most drills use triac dimmers. When using such a drill to drive a screw it is impossible to control torque and speed accurately, and the screw always ends up either deep into the workpiece, or sticking out. Triac dimmers just aren't accurate. I have another mains powered drill which uses a rectifier and PWM dimmer, and this one is very easy to control, the screw ends up perfectly flush with the workpiece every time.
Note your project uses high voltage thus it will be dangerous. Be careful.