Intro: Micro Double star Time

Having previously created an Instructable (Double star DVM), that makes use of the limited expose region using binary.

Information technology was only a small abuse having antecedently created the main codification module for Decimal to Binary changeover to creating a Binary Clock but the only thing lost was a RTC (Real Clip Clock).

However, the Microbit does non have a make in RTC.

The RTC enables the realisation of clock projects with a battery backup.

Atomic number 3 so much the following project uses a Microbit and a Kitronik RTC to create a 24H clock with a Binary display and additionally has an alarm option.

The project software package which will comprise to keep going the Microbit will be created in Makecode Blocks.

Supplies

MicroBit V1 or V2

MicroBit protective case (nonmandatory)

Makecode

Kitronik RTC

CR2032

Codeblocks

Cura

3D printer

1 * SPDT (on - connected) switch

1 * SPDT (on - bump off - happening) switch

2 * SPST (usually open), momentary switch

4 * M3 (10+6mm), M/F standoffs with M3 daft

4 * M3 (8mm), screws

Jumper wire M/F connector, 100mm, 28AWG pre-successful with plug and socket.

1 * Piezo Doorbell (no Drive)

These supplies are available from a number of outlets and you may have your personal best-loved supplier.

Pace 1: Defining the Display Area

Although the display orbit is limited in the amount of information that can be shown at any one time, it lends itself ideally to the display of bit data.

As such there is sufficient area to display 4 x 4 bit binary language to present clock time with notifications and selection modes.

The display is split into 3 main areas; Time, Pick and Modes.

Time

Sixteen LED's assigned to Time, each column of 4 Light-emitting diode's is assigned to a time interval, the intervals being in the build H, H, M & M.

Each second of the Binary word has a weighting of 1, 2, 4 & 8 with the LSB on row 4 and the MSB along row 1

Apiece Multiple 4 number parole allows a counting of 0 to 15, which is Sir Thomas More than sufficient for the 24H meter format, requiring a maximum count per column of 2, 9, 5 & 9.

Pick

One run-in of 4 LED's at dustup 0 are accustomed identify the time column selected when entering time.

Modes

Ane column of 5 LED's at column 4 are wont to identify Modes, Functions and Operation.

Tick - LED 4,0 flashing on & off is used to bespeak Seconds and operation.

Time - LED 4,1 indicates Time mode when happening. (Default musical mode at switch on)

Warning signal - LED 4,2 indicated Alarm mode when connected.

Alarm Presentment - LED 4,3 & LED 4,4 shoot when the Alarm is triggered.

.

Step 2: RTC (Real Time Clock)

The RTC is the beating heart of the application, allowing the setting &A; keeping of close time.

Further details of the RTC can be found at Kitronik.

The RTC provides a regulated supply negating the need to power the Microbit past its ain USB or JST connector and battery backup is provided to retain the time in the event of power loss.

Before victimisation the RTC you leave need to load the Annexe package.

Using Makecode from the Settings icon, select Extensions and type Kitronik RTC in the hunt.

Select the package to install it and IT will be added to the else extensions.

There are a number of encipher blocks to read from and pen to the RTC.

We will only postulate 4 of these code blocks for the Positional representation system Clock.

These will be utilised to drop a line the specify time to the RTC and to read the metre back to update the time display.

Step 3: Coding the Clock

The introductory part of the code is curriculum initialisation of variables, arrays and informative text.

Init

Bclk – Binary Clock

<Sel - A button selects the column that wish be adjusted for time setting.

>Inc – B button increments the clip.

Pressing both A & B buttons together changes the manner between Time & Alarm.

Strval – is the string up value containing the clock in the form "HH:MM:SS" returned from the RTC

Only when HH & MM are used to display or set the time.

Mode – retains the musical mode respect for Metre = 1 and Alarm = 2 selected with the A+B clitoris combination.

Period – is the value for the time pillar, elect with the A button.

0 = pillar 0 (H), 1 = tower 1 (H), 2 = column 2 (M), 3 = pillar 3 (M)

Tick_en – Enables = 1 or Disables = 0 the mark (seconds), index.

Iraqi National Congress – Intermediate storage of the incremental time setting value.

Tm_list[] – stores the apprais of each time column during setting.

Alarm – Enables operating room Disables the Alarm indicator.

The forever continually calls the tick function.

Check off

The tick purpose which is normally enabled, displays an alternating on/disconnected LED in the tipto properly hand corner to show operation and seconds.

In addition, it calls the showtm function which reads the RTC and processes this to be displayed in binary star, whilst likewise calling alarm_mode, if this is enabled displays the alarm notification LED's in the behind right hand corner.

Showtm

Function showtm, calls rdtime and the value used from this is strval containing the time string.

A eyelet is created which increments through strval extracting each single number and ignoring the separator ":"

Apiece ace number is then converted into its binary equivalent with go dec2bin and allotted to the precise column.

Rdtime

Office rdtime, reads the first 5 characters in the string returned from the RTC (ignoring the seconds portion), and passes IT to strval.

If the alarm was set (Mood = 2), then the alarm set values are compared to the values returned by the RTC, if there is a match and then alarm = 1 if there is no peer alarm clock = 0.

Alarm_mode when enabled displays two on/off cyclical LED's on the lower right-pass on corner of chromatography column 4.

Dec2bin

Function dec2bin converts a decimal number to binary star and displays it in the correct column.

The number to personify reborn is passed in via value and the display column is passed in via col.

List2[] is the array into which the 4-snatch binary word from the binary conversion work is stored.

A loop is initiated that proceeds to divide the value by 2 the remainder is stored in the array element the whole number value is divided by 2, this is recurrent until the integer value is <=1 and this last value is placed in the array.

The largest single digit denary value is 9 and in binary this is 1001 as a 4-bit watchword.

The array then necessarily to be processed in reverse order for the correct upshot.

A grummet is so initiated to switch on the right LED in the appropriate column, this is accomplished for each occurrence of a cardinal in the 4-number binary word.

The anthropomorphous port is accomplished with buttons.

The A button.

This selects the column into which the time value will be entered and displays an illuminated LED over the chosen newspaper column happening row 4.

Once all the time columns consume been updated, incrementing the selection to the 5th column updates the time variable.

If modality = 1 the RTC is updated otherwise the Alarm time is updated.

The B clitoris

This is the increment button and increments the elite time editorial.

In order to boil down errors and save clip in getting to the correct value the utmost rate that can be entered per column is capped supported the time value for a 24-hr time system.

These upper limit values are stored in tm_max[], unity per time column and are mechanically selected based on the metre column.

The maximum values are H = 2, H = 9, M = 5, M = 9

The increment value is converted to binary in dec2bin and the display updated.

Button A+B Mode selection.

Pressure both buttons together allows selection betwixt the Time mode or the Warning device modal value the reserve mood is displayed on the display.

Depending upon which mode is selected the display is updated to show either the Clip or the Alarm set fourth dimension.

Mistreat 4: Surgery

Download the Hex file to the Microbit, enclose a CR2032 battery into the RTC.

Plug the Microbit into the RTC and ability the RTC board via USB or the screw terminals.

The Tick Light-emitting diode will start to flash and short after this the time will be displayed.

If this is the inaugural time of use the displayed time is very likely to be wrong and will need to be set to the correct clip.

Mode selection.

Pressing the Option (A) & Increment (B) buttons jointly will allow cycling of the Manner options between Time & Alarm.

Setting the Time

The time setting is in 24H musical mode.

Usage the Excerpt button (A), to move the LED across the top row, this indicates the column where the time can be denaturised. The survival of the fittest columns check to H, H, M & M.

Where H = Hours and M = Transactions.

Having selected a column press the Increment button (b), repeatedly to increment the count by combined on each press. The counts are indicated in binary, after all its a Multiple Clock.

The increment button only increases the count and once the maximum is reached resets to zero, further presses wish again addition the counting.

Once the first column time is set, press the Selection button for the succeeding column then enjoyment the Increment button to circle the column time.

Note: *** When you set the Clock or Alarm you volition need to go in a time in the chosen column smooth if the clip in the column is to remain unchanged A skipping a chromatography column sets that editorial time to zero ****

Repeat the process until the clock has been set using all 4 columns.

Insistence the Selection button for the fifth time to move it to the fifth column and the time is set.

Setting the Alarm

Scene the Alarm clock time is finished in exactly the same way as for the Clock time.

In order for the Alarm to be triggered happening the requisite time leave the Mode circle to Alarm.

To switch the Alarm off set the Mood to Time.

To display the Alarm time set, cycle the Mode between Time and Alarm and the Alarm time leave be displayed for a short period of time before reverting to displaying the current time.

The Alarm time is not stored in the RTC, therefore if superpowe is removed it will require resetting.

Step 5: Box It

The project will sit at the appropriate Angle to catch the time but a box adds a sense of permanence.

You could buy a suitably sized loge and cut and drill out the seize areas to allow the Microbit to fit in the socket.

However; additionally I wanted to duplicate the Microbit buttons along with other controls and indicators.

Typically, legends will need to be applied to the box to identify buttons.

These could equal applied by hand down; calico, engraved Oregon applying labels.

A method acting to realise all these options would be to 3D print the box but first we would need to create a CAD file with which to create the printer file.

The file away creation options are hand closed or drawn with code.

I opted for "careworn with code" using Tinkercad CodeBlocks

The files for the Box Lid and the Box Base can be found on Tinkercad CodeBlocks

Step 6: Block Encode Design

The box is a two part design consisting of a base and a lid.

Four corner screw holes will be used to secure the lid with a slue-out on the left paw broadside to allow entry for the USB plug away.

The eyelid will have a edit-out for the Microbit connecter and the required switches, to boot any text will be written straight off on the lid and screw holes will align with the stand pillars.

The RTC board will represent engaged to the bottom of the lid by 4 pillars and 4 screws.

The size of the box plus lid is 70 x 105 x 31 mm

The code for the Lid and the Base is on hand in TinkerCad CodeBlocks.

Dance step 7: 3D Printing

Load up the files into Cura and put on your preferred slicer settings.

Applied settings.

Quality: 0.15mm

Infill: 80%, Tri-Hexagon

Base: Lip

Save your files then print.

With Cura you tooshie load both files together on the Saami print expanse and print in peerless go.

Step 8: Infill

The box hat is printed with recessed schoolbook which bequeath be filled with coloured 2 part epoxy resin.

The rosin is mixed with a ratio of 2 parts resin to 1 part hardener so an foggy colour pigment is blended in.

The tinge chosen was Yellow to contrast with the background. Hot would have been another choice.

Once mixed the rosin is dripped into the respite by using a cocktail stick remove small blobs of resin which are wont to step by step fill the adjourn in the letters.

Balk putting in overmuch resin in one go as you will likely end rising with air bubbles and or creating to a fault overmuch run over to the surrounding surface meaning you wish take up Thomas More to transfer cleanup up and sanding once seasoned.

So fill slow ensuring the bottom of the missive is covered and fles it up coating with a slight raised surface.

One time the rosin has cured some light sanding will atomic number 4 required to level the surface, start with P240 degree progressing to finer grades A mandatory to get a smooth finish finally finishing with a European country.

Don't apply too very much pressure and too much speed or you will overheat the PLA and the resin resulting to a dull surface due to grit pickup, a little water applied during the sanding process will play a lubricant and coolant.

Whole tone 9: Assembly

The Microbit volition fit into the socket in two orientations, facing the principal part of the RTC of cladding away.

If cladding the chief part of the RTC the link connections cannot be used however, if the Microbit is lining away from the chief part of the board then we can make believe consumption of these connections.

The fabrication starts aside soldering a quadrant SIL pivot header onto the RTC, this is to enable the connections to be successful with push on fit connectors.

The RTC is fitted by 4 * M3 (10+6mm), M/F standoffs with M3 nuts which are secured to the lid with 4 * M3 (8mm), screws in the prefabricated holes.

The switches are fitted in the prefabricated holes in the lid.

The connections required are:

GND, 3V, P1 (set), P2 (alert), P5 (sel) & P11 (inc)

Note *** Resistors (1R), on the diagram for P5 & P11 are plainly reference association points as direct connection to these pins connected the Microbit in Code blocks is non available at this time. ***

P5 is the external connection for Button A which is conterminous past a SPST momentary switch. One connection to P5 and the other pin is connected to GND this button is for column selection during sentence setting.

P11 is the external connection for Push button B which is connected by a SPST momentary flip. One joining to P11 and the other pin is connected to GND his push button is for number increment during time setting.

P1 is a SPDT (happening-happening) switch which is accustomed enable or disable the setting options. The center pin goes to P1 whilst one pin to connected to GND and the other to 3V via a 10k resistor. This enables a H (3V) and L (0V) to beryllium applied to this pin. When P1 is connected to 3V this enables the clip mount options and when 0V disables time place setting. Thereby dominant whether the A &adenylic acid; B buttons rich person any effect.

P2 is a SPDT (on-hit-on) switch which is used to enable or disable the alert sounder and optional external lights.

The alert sounder is a Piezo Buzzer (only affixed with a double sides mucilaginous pad), requiring a pulsing driving which is provided aside the Microbit.

Footmark 10: Finally

You've assembled the elements in the box, programmed the Microbit and fitted it into the socket on the box.

Next apply the power and lot the time.

Enjoy.

Beryllium the First to Part

Recommendations

  • Anything Goes Contend 2022

    Anything Goes Contest 2022