Against the Clock (Revisited)

by Gammawave in Circuits > Microcontrollers

3301 Views, 29 Favorites, 0 Comments

Against the Clock (Revisited)

DSCF6874_2.png

A time trial cyclist with servo motor controlled time indicators (wheels), representing the hours and minutes with the cyclist pedalling on the hour. A combination of 3D printing and perspex controlled by a Microbit and RTC.

I revisited a previous project Against the Clock due to a number of changes and modifications.

No direct requirement for Neopixels, using servos instead of steppers, improvements to the gear mechanism for the cyclist. Addition of hand positioning via hall effect switches. Simplification of time setting.

I decided to leave the dials much the same and not add numbers or spoke lines as I felt it detracted from the look of the project.

Supplies

Hall effect IC (A3213EUA-T) or equivalent - Qty 2

Resistor 2k2 - Qty 2

Capacitor 100nF - Qty 2

3 pin screw terminal - Qty 2

RTC DS3231

Battery CR1220

Pinbetween

Servobit (16 way multi servo controller)

Geekservo Building Brick 360 rotation servo - Qty 3

3mm drill bit

5mm drill bit

3mm Spherical magnets - Qty 2

M3 bolts - Qty 4

M2.5 bolts - Qty 6

Brass tubing - 5mm x 5mm

Brass tubing - 6mm x 5mm

Cyclist

DSCF6882.JPG
DSCF6881.JPG

The original cyclist had a bit of a wobble as the pedals went around due to the use of thin aluminium sheet and a plastic axle. In hindsight a thicker piece of metal/perspex or two thin pieces separated by a space.

However, finally settled on a slip bearing made from 2 pieces of brass tubing.

The outer tube is a press fit into the aluminium plus a spot of glue and the inner tube slid onto the axle this is pushed through and aligned with the outer tube. This stops the wobble and eliminates the wear on the axle.

Although, the cyclist is not intended to move continually but for a short period on the hour.

Servos

DSCF5267.JPG

The broad single spokes coupled with the analogue function of time on minimalistic clock faces negates the requirement for precise positioning, repeatability and reproducibility being more important in this regard.

Due to a lack of real time feedback positional drift can occur over time resulting in time shifts.

In order to compensate for this automatic homing is incorporated by fitting a hall effect switch at the 12 o'clock position on both dials.

This positions the hands in the vertical position enabling setting from a known reference.

This occurs at switch on or after a reset.

Additionally, to compensate for positional drift the hour hand will auto home every 12 hours and the minute hand will auto home every hour.

Three servos in total are used one each for Hours, Minutes and the Cyclist.

Hall Sensor

DSCF6821_2.png
DSCF6820_2.png
DSCF6824_2.png
DSCF6827_2.png
DSCF6828_2.png
DSCF6880.JPG

The Hall Effect sensor is used to generate a digital signal in the presence of a magnetic field.

This is enabled by fitting a spherical magnet in the clock hand and the Hall sensor in the dial at the 12 o'clock position.

In the absence of a magnetic field the sensor output is logic 1 and with a field logic 0.

The output of the sensors are connected to P0 (Hours) and P1 (Minutes).

The sensor has an open collector/drain and therefore requires a pull up resistor (2k2) and a decoupling capacitor (100n), across the supply both of which are mounted locally to the sensor using a 3 pin terminal which is mounted to the back of the dial. Each sensor uses 3 wires V+, 0V and Output.

Mounting the sensor entails removing the screw/bolt at the 12 o'clock position and drilling two 3mm holes on the back panel coincident with the pillars at 7.5 minutes past the hours and 37.5 minutes to the hour. Two additional 5mm holes are drilled behind the clock face to enable the sensor wires to be routed behind the main panel.

The original fixings were cheese head allen key type, but when the hand distance was adjusted for detection this resulted in the hand being closer resulting in the hand hitting the bolt head.

In order to resolve this the cheese head bolts were changed to countersunk head.

The sensor has the leads pushed through the hole on the clock face and screwed into the terminal block and a little hot glue applied to hold this and the trailing wire in place to exit the back panel via a 5mm hole.

The sensor is turned up at 90 degrees with its face pointing toward the magnet.

A 3mm hole is drilled in the hand at the same vertical posiition as the sensor to accept a spherical magnet and this is glued in place.

.



Coding

microbit-atc6.png

The application is created with Makecode.

At switch on or a reset the clock auto homes and sets the time based on the RTC.

Button A is used to set the hours, each press of the button increments one hour from 0 up to a maximum of 23.

Settime is called to update the RTC.

Hours is called to increment the hour hand in real time for each press.

This displays the hours setting on the Microbit display, initiates Servo 0 for a 30 degree angle with a time delay of (4*41.5ms) =166mS before setting the servo to 0 degrees which stops the servo.

Button B is used to set the minutes, each press of the button increments one minute from 0 up to a maximum of 59.

Settime is called to update the RTC.

Minutes is called to increment the minute hand in real time for each press.

This displays the minutes setting on the Microbit display, initiates Servo 4 for a 30 degree angle with a time delay of (1*41.5ms) =41.5mS before setting the servo to 2 degrees which stops the servo.

Under ideal conditions the stop value for Servo 4 would be zero, but at zero this servo would not sit still hence the non zero value. Other servos may require a different value.

Pressing both A & B buttons together initiates the set time.

Settime is called and set_enable=1

In the Forever loop the time updates are called.

Hour_update displays the current hour time, but only updates the hour time if it has changed.

If it has changed it initiates Servo 0 for a 30 degree angle with a time delay of (4*42ms) =168mS before setting the servo to 0 degrees which stops the servo. 42ms to compensate for auto time update as opposed to time setting.

Setting lasthr to the updated hour time which is checked with the current hour time to determine if it has changed.

Cyclist is called which initiates Servo 8 for a 60 degree angle for a period of 10 seconds on the hour.

When Hour_update is called if the time is at midnight or midday the hour hand will auto home to the vertical position.

Auto home helping to compensate for time drift.

Min_update displays the current minute time, but only updates the minute time if it has changed.

If it has changed it initiates Servo 4 for a 30 degree angle with a time delay of (1*42ms) = 42mS before setting the servo to 0 degrees which stops the servo. 42ms to compensate for auto time update as opposed to time setting.

Setting lastmin to the updated minute time which is checked with the current miute time to determine if it has changed.

When Min_update is called if the time is at the hour the hand will auto home to the vertical position.

Auto home helping to compensate for time drift.

All timings specified may require adjustment subject to variations in the servos, software and microcontroller used.

Temperature may also have an impact but the effect was not directly evident. If this is an issue the RTC also returns temperature which could be read to apply aditional compensation if required.

Shelf

DSCF6876_2.png
DSCF6877.JPG
DSCF6878.JPG

The electronic elements are mounted on a small shelf made from perspex which is glued behind the main panel directly over the cyclist servo.

The shelf is 85mm wide by 55mm deep by 5mm thick.

Six 3 mm holes are drilled in the shelf, 4 for the Servobit and 2 for the RTC and held in place with 2.5mm plastic screws/bolts.

Circuit Connectivity

clock_cct.png
DSCF6879.JPG

The Microbit is inserted into the socket of the Pinbetween and collectively this is inserted into the Servobit.

The three servos are connected to the Servobit in the following order Servo 0 (Hour), Servo 4 (Minute) and Servo 8 (Cyclist).

The numbering was simply to separate the connectors on the pin headers for ease of insertion and removal without dislodging the other connects during debug.

They could be connected to any 3 of the 16 available channels but the software would have to be updated to reflect this change.

The Hall effect sensors are connected to the Pinbetween on P0 (hours) and P1 (minutes) and the V+ and 0V connected to the relavant pin 3V and GND pins.

The RTC is connected using VIN=3V, GND=GND, SCL=SCL(P19) and SDA=SDA(P20).


Operation

DSCF6883.JPG

Power is provided via a USB connector on the Servobit and this also powers the Microbit.

Ensure the switch on the Servobit is set to on.

When power is applied the hands on the hours and minute dials auto home to the vertical position.

Assuming the RTC has a battery and has been previously set the hands will move to the stored time otherwise the time can be set maually.

Hours - Press the A button to move the hour hand in hour increments to the desired time the Microbit display will also show the increment.

Minutes - Press the B button to move the minute hand in minutes increments to the desired time the Microbit display will also show the increment.

The time is set in 24 hour mode although the analog clock is in 12 hour mode.

Therefore for example 8 o'clock can be set as 8:0 or 20:0

Initiating the set time press the A & B buttons together.

The Microbit display will continually show the current time.

On the hour the cyclist will begin to pedal for 10 seconds.


TThour_auto shows an ~8 minute time period compressed into ~1 minute.

This shows time advancing, power removal and power application which results in a time reset, homing to the vertical position for both hands then automatic movement back to the current time.

TTHour_cyc shows the cyclist pedalling on the hour.

Finally

Well that's it for now until the next time.