Code Monkey home page Code Monkey logo

stc_diyclock's Introduction

STC DIY Clock Kit firmware

Firmware replacement for STC15F mcu-based DIY Clock Kit (available from banggood [see below for link], aliexpress, et al.) Uses sdcc to build and stcgal to flash firmware on to STC15F204EA (and STC15W408AS) series microcontroller.

Image of Banggood SKU972289

link to Banggood product page for SKU 972289

features

  • time display/set (12/24 hour modes)
  • date display/set (with reversible MM/YY, YY/MM display)
  • day of week
  • year
  • seconds display/reset
  • display auto-dim
  • temperature display in C or F (with user-defined offset adjustment)
  • alarm with snooze
  • hourly chime

Experimental support

  • time sync to GPS receiver outputting serial NMEA data

note this project in development and a work-in-progress Pull requests are welcome.

TODOs

  • time sync to WWVB radio receiver module (for STC15W408AS)

hardware

connection

P1 header UART adapter
P3.1 RXD
P3.0 TXD
GND GND
5V 5V

requirements

  • linux or mac (windows untested, but should work)
  • sdcc installed and in the path (recommend sdcc >= 3.5.0)
  • stcgal (or optionally stc-isp). Note you can either do git clone --recursive ... when you check this repo out, or do git submodule update --init --recursive in order to fetch stcgal.

usage

choose platformio (preferred) or traditional make build

platformio support

  • assumes you have platformio installed
  • choose which mcu you are building for by uncommenting one env_default in platformio.ini
  • adjust upload_port as needed in platformio.ini

traditional make

make clean
make
make flash

make options

  • override default serial port: STCGALPORT=/dev/ttyUSB0 make flash

  • add other options: STCGALOPTS="-l 9600 -b 9600" make flash

  • flashing STC15W408AS: STCGALPROT="stc15" make flash

pre-compiled binaries

If you like, you can try pre-compiled binaries here: https://github.com/zerog2k/stc_diyclock/releases

use STC-ISP flash tool

Instead of stcgal, you could alternatively use the official stc-isp tool, e.g stc-isp-15xx-v6.85I.exe, to flash. A windows app, but also works fine for me under mac and linux with wine.

note due to optimizations that make use of "eeprom" section for holding lookup tables, if you are using 4k flash model mcu AND if using stc-isp tool, you must flash main.hex (as code file) and eeprom.hex (as eeprom file). (Ignore stc-isp warning about exceeding space when loading code file.) (not really needed anymore as current build is within 4k code) To generate eeprom.hex, run:

make eeprom

clock assumptions

For STC15F204EA, some of the code assumes 11.0592 MHz internal RC system clock (set by stc-isp or stcgal). For example, delay routines might need to be adjusted if this is different. (Most timing has been moved to hardware timers.)

disclaimers

This code is provided as-is, with NO guarantees or liabilities. As the original firmware loaded on an STC MCU cannot be downloaded or backed up, it cannot be restored. If you are not comfortable with experimenting, I suggest obtaining another blank STC MCU and using this to test, so that you can move back to original firmware, if desired.

references

http://www.stcmcu.com (mostly in Chinese)

stc15f204ea english datasheet: http://www.stcmcu.com/datasheet/stc/stc-ad-pdf/stc15f204ea-series-english.pdf

stc15w408as english datasheet: http://www.stcmicro.com/datasheet/STC15F2K60S2-en2.pdf

sdcc user guide: http://sdcc.sourceforge.net/doc/sdccman.pdf

some examples with NRF24L01+ board: http://jjmz.free.fr/?tag=stc15l204

Maxim DS1302 datasheet: http://datasheets.maximintegrated.com/en/ds/DS1302.pdf

VE3LNY's adaptation of this hardware to AVR (he has some interesting AVR projects there): http://www.qsl.net/v/ve3lny/travel_clock.html

diagrams

new operation

new firmware operation flow diagram

original operation

original firmware operation flow state diagram

schematics

Kit instructions w/ schematic: scan | PDF

chat

Join the chat at https://gitter.im/zerog2k/stc_diyclock

stc_diyclock's People

Contributors

darinfranklin avatar gitter-badger avatar hoijui avatar jjmz avatar kazukiohno avatar ruthsarian avatar tux75at avatar zerog2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stc_diyclock's Issues

New hardware version from Banggood w/ STC15W408AS?

Hi there,

looks like their might be a new hardware revision from banggod again (or I am doing something wrong).
The clock mostly worked with the original firmware, but was flickery.

Flashing the firmware with "stock parameters" from makefile worked, but the LED segments only show some patterns.
Hardware C build option gave a different LED "pattern" but still not correct.

No circuit diagram was supplied, the one from the website is similar but has a few differences, resistor placement and values etc.

I found no diagram on the Chinese website, it might be there but with google translate hard to find.

Pressing one of the buttons changes the display to 0:00 while it is pressed.

I can try to trace connections on the PCB if you give me a hand where to start, these matrixed segments are somewhat complex.

https://www.banggood.com/DIY-4-Digit-LED-Electronic-Clock-Kit-Temperature-Light-Control-Version-p-972289.html
http://img.banggood.com/file/products/20170116024635SKU203096.pdf
http://www.52dz-diy.com/index.php
IMG_6888
IMG_6889
IMG_6890

Weird bevaviour with STC15W408AS

Hi there,

I have what I believe is one of the banggood kits. I did successfully flash this firmware a while ago, I can't quite remember what settings though.
Recently I fried the µ-controller while trying to flash - I think by connecting it incorrectly.

I therefore replaced the micro - however not with the STC15F204EA as originally but with an STC15W408AS I thought to be pin compatible.

I played with the compile options - but I only get the result as attached.
The right most digit goes on/off with light level.

I swapped the segment port and digit and interestingly the pattern changes completely, telling me that the micro is indeed driving the segments somehow.

Any ideas? Maybe pullups one of the µ-controllers has and the other does not?

Thanks a lot,

-Kobbe
IMG_6444
IMG_6443

Trickle-charging DS1302

Hi, I would like to know, have you disabled in your firmware trickle-charging function of DS1302 RTC chip? In the kit, received from the aliexpress, this feature is enabled, and as a result, it is impossible to use a normal CR1220 battery as it is charging. MCU is STC15W404AS.

Windows Software

please can you or any other people suggest some windows software to compile and flash ??

a little how to for windows users would be nice too 👍

many thanks for your work!

STC15W408AS based clock

I purchased http://www.ebay.com/itm/152077409965 and on a whim decided to load this firmware onto it, which has turned out badly for the device.

I can't find a datasheet for this processor, so this might be a lost cause, would you mind helping me decide?

The clock starts up and for about 100ms shows all digits fully lit, then the display shifts to "1F:7F." with the 'colon' blinking at a rate about 2x faster than it should be. No button presses or combinations can trigger a result as far as I can tell. The light sensor works and I can see it visibly dim the display in darkness.

I have injected different display tests using led.h bit masks to test and the display seems to properly be using the lookup table for the 3 normal and 1 upside down digit, so that part of the code is also working fine. No incrementing of digits has been observed over hours of runtime.

Pin for pin the CPU is nearly the same. P1.4 has no relay driver on it, and some pullup resistors on the IO to the DS1302 chip are not there.

I could replace the CPU with a known good model, but I can't seem to find the DIP style of STC 15 series available on ebay or anywhere reasonable.

I'm happy to try and debug and share the instructions included with the model to get this working if there is a reason to. Do you have any input on the subject?

Thanks

Flashing 404as?

I see some bits in the code that mention the 404 but how do I specify it to write the eeprom? I flashed your precompiled main.hex and I'm flashing 1f:7f

Need help with make on windows

Hi there,
unfortunately i am too stupid to compile the code on windows. Tried it on a ubuntu VM too, but no luck.
Under windows i can't just get a .hex file out of the makefile. it only prints out many others amongst the main.ihx.
Would you be so nice and upload a compiled version?
The complied version from zerog2k uploaded just fine.

Thanks

Swapped pins on external serial connector

While studying the diagram DIY_LED_Clock_STC15W408AS.pdf I noticed the RxD/TxD on the external pins of P1 are swapped. All diagrams of the clocks that I have seen so far connect the 3rd pin of P1 (next to ground) to pin 15 of the controller and the P1/4 to pin 16 of the controller.

Dot-Matrix version?

Hi! Apparently there’s a new dotmatrix version of these little clocks, which would also make it really easy to display day of the week as well as have a true menu for the settings.

Here’s a link to the product on Amazon:
Amzn.com/B07T369S58

No idea where to track down the original code, but I’m wondering if yours can be modified to work with this. I would be more than happy to contribute to the cause and ship you one of these clocks if you wanted to take a stab at it. Heck… even if you can just get a simple hello world on the screen, I could probably take it from there. I’ve already soldered on the header on the circuitboard so I should be good to go with programming. I just have no idea where to start.

Random slow downs. STC15W408AS

I have built three of these clocks and they are all having the same issue with this latest firmware. My clocks have the STCW408AS chip.

Everything starts off fine then...

At random times, usually under a day the display will slow down (as in instead of 60 seconds to change to the next minute it takes a lot longer) but the flashing two dots still stay the same, flashing every second. If I bring the seconds display up, the dots will flash maybe ten times, and then the second digit will turn to the next number. Then some time later that will change to maybe 6 flashes before the seconds digit changes, then maybe 8 flashes. Then out of the blue it will go back to normal.

I have swapped chips between devices and it makes no difference.

Can't flash. Stuck on "Waiting for MCU, please cycle power"

Hoping you have some pointers for me here. I'm using the DIY kit that uses the STC 15F204EA chip and I'm using Adafruit's FTDI Friend cable in its default configuration which simply emulates a USB-to-Serial cable.

However, no matter what I try, I can't get it to download the firmware. I've tried running on a Mac, Windows 10 and Linux, I've tried 11k and 22k clock speeds, I've tried specifying 9600baud for the connection. I've tried yanking the power pin only, the TX pin only, the ground pin only, yanking them all at the same time, but no matter what, I can't get past the 'Waiting' message. What the heck am I doing wrong?

Note, I also tried the Windows app, but that just visually hung when I clicked 'Download'. I could stop it (the button to cancel was still enabled) but nothing happened.

Brightness level

Hi. Could you please release an update that would significantly lower the bottom brightness value? Would be awesome if it was closer to the original Chinese firmware where the clock is barely visible at night.
Currently it's too bright for the bedroom and really disrupts sleeping, decreasing melatonin levels and so on and so forth :)

Thanks a lot in advance and really appreciate your amazing work 👍🏻

buttons don't work

I have a model with the stc15w404as. according to the schematic for my clock here: http://www.diyleyuan.com/jc/1/01-1.html

the buttons should be on the the 3.0 and 3.1.

Also, I can't find any usage instructions for the clock, like how to set it and set the different modes. maybe it's obvious once the buttons work?

Custom pin support.

I want to use this firmware because of critical bugs on stock clock kit.
Since this kit is different from banggood varients, I want to modify pin numbers.
However I cannot change A1~A4 pin numbers of this source code because I don't know the way this code works.
Could you tell me the way to change these pins?
(In this schematic, A1-A4 is P3.4-P3.7)
photo6251231338216662969

Привет!

Again I am to you, but with a specific request. You can change the firmware so STC15W404AS the functionality is:

55 seconds displays the current time in 24 hours format
5 seconds displays temperature in degrees Celsius only
At night, when the lighting drops, the clock brightness automatically decreases (as in standard firmware with the lighting sensor coming in)
Simple alarm clock (according to standard firmware, but without hourly signal)
GPS (GY-NEO6MV2 module):
Standard NMEA data
Speed 9600 bps
Displays GNRMC and GNGGA
Everything else, according to standard firmware, is unnecessary.

barebone firmware

Can one compile this firmware so that the clock displays only time and nothing else? Time + autodimming only; no date, temperature etc.

My version has STC15W404AS

My kit reset time to 00:00 01-01-2000 each power cycle

I checked battery voltage on DS1302 directy - fine 2.98V
I checked XTAL - running nicely at 32 kHz even in no-power state.
Any ideas what could be wrong ?
Is there any FUSE bits, what need to be set during MCU flashing to avoid this ?

Chip is 15W404AS. I have the same issue on "original" chinise firmware too...

Time stops ticking when power is lost

I recently bought one of these kits and flashed it with this custom firmware. One thing I noticed is that even with a battery installed, when I stop supplying power, the clock will resume at the exact time it was unplugged. The battery is brand new showing 3.3v, and I know it's working since the ram is keeping when unplugged for a long amount of time. Is this just a normal issue with my version?

Here's the schematics if that helps.

schematics

hourly chime

i like to have a hourly chime in my clock but not so annoying as in original firmware, just a short beep. also i like functionality and logic of your firmware. so here is the patch for hourly chime support. chime display are right after alarm, both displays are with timeout when not adjusting. 12h/24h supported, dot1/dot3 are pm indicators for start/stop hours, dot2 - chime on/off, shown only at chime display.

works fine with my STC15W404AS.

of course, chime can be disabled with WITHOUT_CHIME at compile time.

diyclock_chime_1224.diff.txt

4 digit display models?

Hi, I purchased this unit:

https://www.ebay.ca/itm/New-LED-DIY-Digital-Electronic-Micro-Controller-Kit-Clock-Time-Thermometer-CA-/292048065603?var=&hash=item899c6ccd6d

The major difference that I can see would be that this unit uses a single 4 digit seven segment display. I'm not sure if this firmware would have support for that.

Schematic:
clock.pdf

Will this work with the open source firmware? It would be fantastic to stop this thing changing the display, any maybe turn down the LED intensity...

Support for relay

The PCBs have non populated space for a diode, terminal block and 5v relay (not sure which type fits but it's a six pin model). I wonder if this is supported by the original firmware and what it does. We can consider this a feature request.

Unrelated to this: some notes would be nice to have about unused pins and such. I was thinking about building a RF synchronized set of clocks using a NRL module.

"Waiting for MCU, please cycle power"

Apologies if this is the wrong place for this question, I'm new to Git and this is my first attempt to flash an MCU of any kind.

I am working with the Geekcreit clock from banggood: https://www.banggood.com/DIY-4-Digit-LED-Electronic-Clock-Kit-Temperature-Light-Control-Version-p-972289.html

My kit came with an STC15W404AS

I'm using this USB-UART adapter: https://www.ebay.com/itm/CP2102-USB-2-0-to-UART-TTL-6PIN-Module-Serial-Converter-Adapter-Red-Silver-TS/222617611551?epid=1286993754&hash=item33d50b2d1f:g:FqYAAOSwxbpZl5x6

I'm trying to flash my clock from Raspbian Jessie on a Raspberry Pi 3, using STCGAL. I'm able to build properly, but I'm trying to flash the precompiled <4kb release file, just to be safe.

When I run "STCGALPROT="stc15" make flash," the process is able to detect my adapter, but it hangs on a step saying "Waiting for MCU, please cycle power." I can't seem to find any way to get past this. The clock is clearly getting power from the adapter, as it powers on and works as normal when I connect the GND and 5V pins. I have tried disconnecting and reconnecting the power while at this point, but that doesn't do anything.

Is this expected behavior, and if so, what am I supposed to do to proceed? If not, what could be wrong?

Worked for 10 minutes with new chips and then stopped...

So I tried anything I possibly could with stock chips - no luck. Ordered a set of new both STC15W404AS and DS1302 - actually like 2 of STC and 10 of DS1302. Put a new set in, flashed STC - worked for like 10 minutes perfectly well and then stopped. I disassembled the clock again and found that DS1302 gets nasty hot - I actually slightly burned my finger.

Any ideas on why is that possible? Anything I could do to fix that?

Thanks in advance and great job!

Website for original maker of these kits

I was looking around at photos of a different kit (the OLED watch one, completely separate from the ones in this project) trying to figure out what MCU they're using, and came across the website of what I assume is the original maker of these kits. It probably doesn't offer much more than what's already known here, but it might be an interesting resource.

http://www.diyleyuan.com/JC/
STC15F204EA (non-voice): http://www.diyleyuan.com/JC/01.html
STC15W408AS (with voice): http://www.diyleyuan.com/JC/HJ1.html

Alternate 7 segment display

I have built the clock kit. I am attempting to load the code onto a stc15w408as processor. The code does not operate as expected. I suspect this is due to the use of a 4 digit display block with two rows of 6 pins. The display appears to be of this general type: http://www.robotshop.com/media/files/pdf/datasheet-com-09483.pdf

Pinout may not be a match.

I guess that I need to adjust to code to match the display block. I have an unbuilt PCB and will look to buzz out the connections to the processor. I will welcome any suggestions.

Maybe new model? Schematic Provided..

SKU593344 光控工控YD010(英文).docx

I've one of this could you please tell me if it's supported?
Bought here:

https://it.aliexpress.com/item/DIY-Digital-Clock-Kit-Light-Control-Industrial-Control-1-Inch-LED-Electronic-Kit-5-Colors-in/32804714439.html?spm=a2g0y.search0104.3.8.ef30158cQz0JnA&ws_ab_test=searchweb0_0,searchweb201602_4_10152_10151_10065_10344_10068_10342_10343_10340_10341_10696_10084_10690_10083_10691_10618_10304_10307_10302_10689_10313_10059_10184_10534_100031_10688_10103_10624_10623_10622_10621_10620-10152,searchweb201603_25,ppcSwitch_5&algo_expid=adec31bf-5b61-43c2-8298-4f984780b608-1&algo_pvid=adec31bf-5b61-43c2-8298-4f984780b608&priceBeautifyAB=0

(Led Digits have Amber colors stock firmware has too dark light when ambient is full dark I must always set to disable automatic dim)

P.S.
I'm only windows user could you please provide a guide to compile and flash?
Command lines etc.. thanks in advance.

Best regards
Tony
Here it is also a scan but docx is perfectly my model.

schematic

Other kit models

Hi

Firstly, this repository is really cool. Fantastic work.

I have a similar ebay clock

They have the same micro controller, thermistor and photo resistor.
Would this firmware also work with it?
Can I use this stc programmer to write the firmware, or is it not required?
Sorry for all the questions - I'm new to STC

Best regards, Warren

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.