Movement detection railway gate

I want to measure the lowering and rising time of railway crossing barriers without connecting the measuring device the installation. The device should be "sticked" to the gate itself. After initializing the device should detect movement of the gate, start a timer (i.e. remember the time) and stop the timer the moment the gate stops lowering or even gets up again due to bouncing. Question is: what kind of sensor is best suited for this task? A gyroscope?

Peter

Two micro switches. One to sense start of lift and one to sense end of lift.

Weedpharma

Or one microswitch, which signals either "gate open" or "gate closed".

I want to measure the lowering and rising time of railway crossing

This would infer timing from down to up and up to down so two micro switches required.

Weedpharma

Consider using an accelerometer to measure the tilt of the railway barrier: best placed near the pivot unless you want to try to detect its acceleration and deceleration.

Microswitches will not work. The device should be fixed to the barrier, it has to be portable. It's not for permanent use, only for a single measurement per barrier. The use of cables is not allowed, that's why I'm thinking about a sensor like a gyroscope or an accelerometer.

Archibald: why does the accelerometer be near the pivot? Doesn't it have the smallest (and thus worst measurable) acceleration at this point? That's why I suggested the gyroscope, which measures the angle.

Peter

At constant speed, there will be no acceleration...so that is out.

Any reason for not using a laser pen and a suitable diode?

peter-bos: Archibald: why does the accelerometer be near the pivot? Doesn't it have the smallest (and thus worst measurable) acceleration at this point? That's why I suggested the gyroscope, which measures the angle.

You can think of one axis of an accelerometer as being like a weight sliding on a track with springs attached between the weight and each end of the track. If the track starts off level, you will get a certain reading from the accelerometer but if you then tilt the track the weight will slide and the reading will change. So an accelerometer will measure tilt. If you place your weight, track and springs in a vehicle oriented parallel to the direction of motion, when you accelerate along a level road, the weight will move and the reading from your accelerometer will change. So an accelerometer measures both tilt and acceleration. In other words an accelerometer measures gravitation acceleration at the same time as measuring motion acceleration.

To measure a railway barrier it would be best to use two of the three axes. One axis will work well to determine when the barrier is horizontal, another axis will work well to determine when the barrier is vertical.

Let's consider sticking the accelerometer on the barrier arm furthest away from the pivot and lets consider the barrier to be initially in the closed position to allow a train to pass. You could get your Arduino to monitor the vertical axis of the accelerometer so when the barrier lifts, the reading will gradually get close to the reading you get when the accelerometer axis becomes horizontal, indicating the barrier has become vertical.

The snag is that the end of the barrier will decelerate when it reaches vertical and is quite likely to bounce a little. This deceleration will affect the reading so you won't know when the barrier is exactly vertical. You would eliminate that trouble if you mount your accelerometer over the axis of the pivot (ideally). Alternatively it may be possible to use the readings from your accelerometer to detect the deceleration, perhaps by detecting a relatively sudden change in the readings from your accelerometer. If your barrier moves at constant angular velocity, the reading due to the tilt will change in a cosine relationship, so in theory you could detect the deceleration when the barrier reaches vertical by detecting when the reading deviates from a cosine curve. The coding for that would not be simple. Anyway it's quite likely the barrier motor drive will be designed to decelerate just before it reaches vertical so detecting deceleration is probably not a good way to detect when the barrier has reached vertical. So I recommend sticking your accelerometer as close as possible to the pivot so you only measure the tilt. You will need to consider what happens to your measurement if the barrier does not quite reach vertical; so it may be better to detect when the change in tilt ceases rather than detecting when your accelerometer axis becomes precisely level.

I am not so familiar with gyros but my understanding is that they respond to angular velocity, in practice mostly to changes in angular velocity, not to the angle with respect to gravity. So a gyro could, at least in theory, be used to detect the initial angular acceleration of your barrier and the angular deceleration when it becomes vertical.

Johnny010: At constant speed, there will be no acceleration...so that is out.

An accelerometer will measure tilt.

Archibald: thanks for your reply. I ordered a 6DOF gyro/accelerometersensor today, so I can try what's best: the accelerometer, the gyro or maybe the combination. I'll keep you posted.

Peter

peter-bos: Archibald: thanks for your reply. I ordered a 6DOF gyro/accelerometer sensor today, so I can try what's best: the accelerometer, the gyro or maybe the combination. I'll keep you posted.

I recently purchased a 6DOF to experiment with the gyro part but have not played with it yet. I have a 3DOF accelerometer currently in use by a client where they are unable to mount it near the pivot. I was wondering whether using a gyro would be better because the acceleration/deceleration would be interfering currently with the measurement of tilt. I will be interested to learn whether you can get reliable signals from your gyro considering the angular velocity of a railway barrier is fairly small.