This is my observation of grade Crossings in the U.S...
The track circuit detects the resistance of the rails. When no train is near, there is a high resistance. However, as a train approaches, the wheels/axles short across the rails, lowering the resistance seen by the track circuit. The track circuit reacts to the change in resistance. At a certain threshold the gates trigger. This allows for a fast train to trigger the gates at a farther distance then a slow train. If a train is going really slow (i.e. a couple miles an hour, a train can be very close before the gate trigger.
I've seen trains very slowly approach a crossing, then stop a short distance before it, without triggering the gates. Other times a train stopping short of a crossing may trigger the gates before it comes to a complete stop. Then the gates "time out" and go back up because the resistance wasn't changing. When the train starts up again, the resistance starts going down again, triggering the crossing. Then when the train passes the crossing, at any speed, the resistance goes up, causing the gates to go back up.
I remember being stop at a crossing with a very slow southbound train going across the crossing as it approach the south end of the siding. The road was wasn't very wide. When some long cars would go across the road and the axles were on either side of the road, the gates would start back up, then go back down when the next axle went across. The train finally stop at the south signal with no axles on the road. The gates went up and stayed up, even though there was a long car across the road. Then the northbound train approached on the mainline, triggering the gates again. By the time the end of the northbound crossed the road, the southbound was moving again holding the gates down until the end of the train. What an odd sight to see.