How can I know when the TRIAC turns off?
When the triac is on, the voltage across the triac is clamped to a voltage near zero. (The data sheet for your triac might say something like worst-case V_A1_A2_on is +- 1.5 V).
Many circuits detect when the voltage (positive or negative) across the triac is above roughly +10 V or below roughly -10 V, to indicate that the triac is definitely off. See Figure 4 of AN307.
Have you considered possibly sensing the voltage across the triac, like all zero-crossing solid-state relays do, rather than sensing the line voltage, which no solid-state relay does?
When should I fire the TRIAC's gate to obtain an arbitrary motor speed (let's say half the normal speed)?
For a few loads, the speed is roughly proportional to the triac on-time.
For these loads, turn on the triac 1/2 the time (turn the triac off 1/2 the time) to get a speed close to half the maximum speed.
More often the load increases as the square of the speed
(for example, when pushing a vehicle through the air).
For these loads, turn on the triac 1/4 the time (turn the triac off 3/4 the time) to get a speed close to half the maximum speed.
Nearly always there is some minimum on-time (maximum off-time) just to get things moving; anything less than that and some electric power goes in, but nothing moves.
As Olin Lathrop mentions, it is often adequate to experimentally measure the output speed vs. triac on-time a few times (perhaps for 1/5, 2/5, 3/5, 4/5, of the full on-time or full off-time), figure out which setting gives close to half-speed, and hope it stays approximately the same when you run open-loop.
If precisely maintaining some particular speed is important, you may want to run closed-loop -- in other words, add some sort of tachometer to measure the actual speed at all times, and close the loop by adding something to automatically increase the on-time (decrease the off-time) when the measured speed is too low, etc.
When should I fire the TRIAC's gate when controlling an inductive load?
Please consider doing things in the way recommended by the data sheets and app notes provided by the manufacturer, in this case ST application note AN307: "Use of triacs on inductive loads".
Perhaps the simplest approach is
- watch the voltage across the triac (between pins A1 and A2). When that voltage goes above +10 V or below -10 V, the triac is definitely off.
- After we sense the triac is definitely off, delay some time from 0 (full-speed) to nearly 10 ms (nearly motionless), then pull the gate LOW.
- Keep pulling the gate low for some time, until the triac appears to turn on (until the voltage across the triac is small). Then pull the gate HIGH (set the gate voltage the same as the triac A1 pin voltage).
- Repeat.
The simplest way I can think of is to buy a 5V "wall-wart" power transformer.
Simply connect the output of the 5V power supply to one of the arduino input pins, and the grounds from each device together.
I would recommend placing a resistor in series with the 5V input to the arduino, so if you accidentally set the arduino pin as an output, it wouldn't "fight" the power supply (which could damage the arduino). Something like 1-10KΩ should be fine.
One thing to be aware of is not all wall-wart power transformers are regulated.
Basically, some wall-warts have ICs in them that make sure they always output the same voltage. Other have no ICs for regulation, and as such, the output voltage varies depending on the amount of current you are drawing from the power supply.
Realistically, either type would work fine. However, if you purchase an unregulated 5V wall-wart, it may put out as much as 6-9V when you have no load, or a very small load (e.g. the arduino input) connected.
A simple resistor divider would suffice to make the voltage appropriate for the arduino input pins. However, it is a good idea to measure the wall-wart output voltage before you connect it to anything, to determine what kind you have.
Best Answer
What makes you think that the voltage at pis 1 and 2 is 55VAC? There are back-to-back diodes across pins 1 & 2, and as long as you don't exceed the current rating of the diodes you will never see more than the diode's forward voltage drop between pins 1 & 2.
The max forward diode voltage is specified as 1.5V at 10mA. In your circuit the peak current will be the peak of the AC line, maybe 155V across 30K or around 5mA. So pins 1 & 2 will have less than 1.5V across them.
If you limit the current to a safe value you could use the circuit at 230VAC as well.
There are safety issues with use and PCB layout of this kind of device that you have to understand, but the device itself should be fine for these applications.