On some level crossings, I guess there's some sort of sensor on the track to detect when the last section of a train has passed, so the barriers can be opened?
Can anyone tell me a little how this works?
If you look at the exit side of some automatic crossings you'll see a small box in the four foot with a leg coming out of it towards the rail. This is a treadle which is used to tell the crossing the train has left and set the opening sequence to allow road traffic across. At the "strike in" point on approach which will vary according to permitted speed a similar treadle will start the crossing sequence before the train arrives. Other crossings will use the occupation of track circuits or passing axle counters.
a car collided with the rear-most wagon of a stationary freight train at Stainforth Road Automatic Half-Barrier level crossing, near Doncaster. The crossing’s warning equipment was not operating and its half- barriers were raised when the car approached and entered the crossing.
...
The crossing’s control circuits dated back to its original installation in 1974. The control circuits had not been modified to incorporate later features which prove that trains are clear of a crossing before it re-opens.
Ooops!

I don't think there are timers involved in starting the crossing opening sequence. The report I linked to above discusses how modern practice would be to put a short track circuit across the crossing, which keeps the barriers down if it is occupied but won't start the crossing sequence if it becomes occupied (as it may be shorted out by something happening on the road). The sequence must be started by one of the track circuits or treadles on the approach. Yes if a train straddles two track circuits both will show occupied.Thanks all
I guess some track circuits have extra time added?
So after the passage of a train, perhaps there's a 4 or 5 second countdown before the barrier opening sequence begins?
I guess also if a train stops with one bogie on one track, and one bogie on a closer piece of track, which is split by a track circuit then it's completing the circuit and the signallers panel (old panel) would show two lights, IE, the train being in both sections?
Only an idiot would drive onto a crossing with the train still in the way, it is a yellow box so you don't enter unless exit is clear and with a train in the way it's not clear is it