Coder Social home page Coder Social logo

Comments (25)

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024 1

hello everyone
i'd like to share some info and schematics for this "new" pcb/kit
i bought a kit and it came without pcb, then they send me another compete kit, so i decide to trace and reproduce pcb board "from scratch" with universal breadboad
i'll attach pic of schematics and archive with kicad files
kicad files were made from original ones from this repo. i fixed schematic for leds too - last two displays rotated 180 degrees, so wires should be fixed too

kit (two kits - two resistor set):

  1. 7 segments led display - 4pcs
  2. PCB
  3. power switch and 2 side button switches
  4. DC Power Jack Socket
  5. DS1302 with socket
  6. STC15W408AS with socket
  7. cr1220 battery with holder
  8. cap: 1x1mkF, 2x30pF
  9. res: 3x10k, 14x1k (or 13x200 + 1x1k)
  10. buzzer
  11. thermistor
  12. photoresistor
  13. programming pin header
  14. 32k crystal oscillator
  15. S8550 tranistor - 5pcs

USB power cord
glass case

diy_clock
stc15w408as.new.tar.gz

i'm not sure if it can be programmed to this firmware because of mixed S1/RM and S2/GM, but i want to try it a bit later

from stc_diyclock.

Kobbe1 avatar Kobbe1 commented on May 29, 2024 1

Thanks!
Re: 3 connections - you said you reconnected 2 buttons and the thermistor. But I understand now you only did that as you burnt P1_0 so I wont need that.

Will try it out on the weekend if my family lets me :)
Thanks again.

from stc_diyclock.

shenghaoyang avatar shenghaoyang commented on May 29, 2024

from stc_diyclock.

Kobbe1 avatar Kobbe1 commented on May 29, 2024

Thanks, looks different indeed. Yet another version - with an DS18B20 and an different RTC IC too.

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

oh, forget pcb photo itself
original ones:
20201109_171943
20201109_171956

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

so because of different wiring, from reference design last display did not work at all: firmware expects display anodes on pins 17-20, while it is on pins 18-21, and 21 pin is for anode of last display, DS4
and DS1302 connected to pins 13, 16, 17 while firmware expects 3, 4, 5 - so clock IC doesn't work too
i suppose it can/should be fixed in hwconfig.h, i've corrected for stc15w404as

wrong hwconfig attached first, this one works for build
hwconfig.h.gz
You should change string in Makefile too
#SDCCREV ?= -Dstc15f204ea
SDCCREV ?= -Dstc15w404as
then compile or you could try this one, but i don't know if it works. can you try?
main.hex.gz
compile log (sdcc 4.0.0):

mkdir -p build/
sdcc --code-size 4089 --xram-size 0 --data-loc 0x30 --disable-warning 126 --disable-warning 59 -Dstc15w404as -o build/adc.rel -c src/adc.c
mkdir -p build/
sdcc --code-size 4089 --xram-size 0 --data-loc 0x30 --disable-warning 126 --disable-warning 59 -Dstc15w404as -o build/ds1302.rel -c src/ds1302.c
src/ds1302.c:123: warning 158: overflow in implicit constant conversion
sdcc -o build/ src/main.c --code-size 4089 --xram-size 0 --data-loc 0x30 --disable-warning 126 --disable-warning 59 -Dstc15w404as -DWITH_ALT_LED9 -DWITHOUT_LEDTABLE_RELOC -DSHOW_TEMP_DATE_WEEKDAY build/adc.rel build/ds1302.rel
   Name             Start    End      Size     Max     
   ---------------- -------- -------- -------- --------
   ROM/EPROM/FLASH  0x0000   0x0f4c    3917     4089   
cp build/main.ihx main.hex

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

@aleksey-ru52
From the schematic you provided, the hardware configuration is significantly different. It's not simply a matter of different pins. In your schematic, the adc lines for light and temperature detection are shared with the buttons. Previously these buttons were shared with uart rxd/txd. Now it looks like the button-press and light/temp detection need to be somewhat coordinated. (e.g. detect if adc is below some threshold, like near zero, which would indicate the button is pressed.)
Looks like the RTC IO and buzzer drive is also sharing lines with uart rxd/txd; not sure if the way these are handled need to be re-designed, or if it's ok.
(Not sure why they had to do all this sharing, when there are plenty of unused io lines on port 1 gpio bus ?)

Anyhow, if anyone wants to produce a working and tested PR, I would be glad to review it.

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

I think they're trying to minimise kit parts. Or "simplify" wiring.
I can try to do some testing with this hw design. If it will be hard to redesign sw or it will be unstable somehow, i prefer to change hw desing to "reference" one from pdf, because i like design with minimal sharing pins too.

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

I think they're trying to minimise kit parts. Or "simplify" wiring.
I can try to do some testing with this hw design. If it will be hard to redesign sw or it will be unstable somehow, i prefer to change hw desing to "reference" one from pdf, because i like design with minimal sharing pins too.

To me this doesn't seem to be the case - wiring these up to separate pins does not (need to) have any additional part count - it's simply some additional tracks on the pcb - and cost would be same there - maybe it was too hard do to the pcb layout? Not sure.
Anyhow, sure if you can come up with a new hardware variant define, and some conditional preprocessor macro logic which is clean enough, it might be achievable to bring this into a single repo codebase.

from stc_diyclock.

Kobbe1 avatar Kobbe1 commented on May 29, 2024

@aleksey-ru52
So the hwconfig.h you shared works? You said it compiles, but I guess you did not test with real hardware?

i suppose it can/should be fixed in hwconfig.h, i've corrected for stc15w404as

wrong hwconfig attached first, this one works for build
hwconfig.h.gz
You should change string in Makefile too
#SDCCREV ?= -Dstc15f204ea
SDCCREV ?= -Dstc15w404as
then compile or you could try this one, but i don't know if it works. can you try?...

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

Not tested yet, you're right.
I suppose buttons will not work, because of shared pins, as @zerog2k mentioned.
I think it's match easer to resolder buttons to two other pins - 5,6,7,8,9,10 - they all available. Then change hwconfig and compile. It WILL work, i'm almost sure, without any other sw modification.

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

@zerog2k need help
i've flashed firmware with my hwconfig
buttons works, indeed...
looks like connection to DS1302 does not work, i checked twice, i see no error

 #define DS_CE    P0_1
 #define DS_IO    P3_1
 #define DS_SCLK  P3_2
 // needed for asm optimizations
 #define _DS_IO   _P3_1
 #define _DS_SCLK _P3_2

manual for 408 says pin 13 is P5.5, i've try P0_1 and P5_5 - no luck

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

also noticed - 3rd element displays rotated 180 deg number
it's a bit strange, 1st, 2nd and 4th element displays correct image
found this trying to set alarm

rotation is ok, i've changed it in led.h

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

issue look like the one was reported to you, but instead of displaying 1F:7F my clock displays 1b:7b
first image in this thread - b:7b - 7 rotated 180 degrees and 1st digit did not shown due to shift of pins

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

@aleksey-ru52
for the pins, you'll need to check your mcu datasheet special function register map addresses and compare to the port/pin definitions listed in SDCC headers, e.g.
https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/device/include/mcs51/8051.h#l56

as you noted for some pins, like ds1302, those have some asm optimizations that need to be coordinated as well.

For rotation and elements, you'll need to verify all the segments and driver pins are adjusted for your hardware.
Different kits may have different kinds and arrangements of led (some using multi-digit, some using individual digit, some with a rotated 3rd digit, etc)

You may need to play around with software pullups (port configuration, per datasheet) depending upon whether certain things, e.g. ds1302, led drivers, etc have external pullups or not.

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

agh... angry
well... i've found that missing P5_5, ok... but this does not work because of absence of pull-up resistors as it was mentioned in issues/30... i will try internal pullups a bit late, but may be you're right saying "you have to change this pin between modes when switching from writing to reading and back"...
so, again, this hw design awful...

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

so... i've compiled @aFewBits fork... add P5_5, unflip 3d display, disconnect buttons from ligth and temp probe - and now it works just fine... temp show wrong value, but all other works... buttons should be disconnected...

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

burn P1_0, so i resolder thermistor to P1_4
reconnect buttons to P1_2(S2) & P1_3(S1)
also, i somehow kill my ds1302... replaced
now... with fw from @aFewBits repo ALL works as it suppose to work!

@zerog2k i don't want to do any modifications for key handling, it's rather easy to reconnect buttons to other pins, but maybe i'll try to fix or understand difference in ds1302 handling

@Kobbe1 i can build firmware for this hw but from @aFewBits repo, it's good, it works... but you will have to reconnect buttons to other pins. maybe we can/should create issuie in @aFewBits repo and continue discussion there.

from stc_diyclock.

Kobbe1 avatar Kobbe1 commented on May 29, 2024

@aleksey-ru52 Great!
What is the deal with the other repo, is this a fork of this one here? But for a different hardware?

I certainly will rewire the 3 connections, is there anything else I need to configure in software? @aFewBits does not seem to have a hwconfig file so I guess it will just work as is?

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

No quite so. It's a bit different clock design. But it's good too.
All configuration is done through global.h, but settings are quite the same.

  1. you need to add 1 string to stc15.h (in this repo too) - it's for connections with ds1302:
    __sbit __at (0xCD) P5_5;
  2. you need to configure global.h, main things is:
    #define DIGIT_3_FLIP FALSE // because it's not flipped in hw design
    and you need to configure on of existed "sets" to work with this hw, i used BOARD_BLUE_6 and deleted all other.
    i attach files - use them as you wish.
    It's my config, you should change S1 and S2 pins to which you resolder buttons, i use P1_2 & P1_3, all other settings should be fine.
    And you should flash with command like, the main thing is 22184:
    ./stcgal.py -p /dev/ttyUSB0 -P auto -t 22184 main.hex

stc15.h.gz
global.h.gz
PS: take ds1302 out, then you flash pic, i think i broke my chip this way; i use sdcc 3.6.0
PPS: why you said about 3 connections? just buttons, my clock has 2 buttons

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

@zerog2k i've try to pull-up ds1302 lines - doesn't work
i don't know is it "bad" rtc ic, or something else
i've try to connect this rtc ic to clone arduino pro mini without any pull-ups: two rtc libs - one lib works, other not
any suggestions/thoughts?

well... i've changed only two procedures: sendbyte & readbyte for ones from @aFewBits repo and now it works...
i'll test a bit longer, but it works!
and it even produces less code... don't know why

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

@Kobbe1 you can try to build from this repo, at last:

  1. make the same changes to stc15.h i explained above
  2. exchange ds1302.c with attached to this post, you can make diff to see difference
  3. make change in led.h, to unflip 3rd element:
-                        tmp=ledtable2[tmpbuf[2]]; if (dot2) tmp&=0x7F; dbuf[2]=tmp; }
+                        tmp=ledtable[tmpbuf[2]]; if (dot2) tmp&=0x7F; dbuf[2]=tmp; }
  1. tune hwconfig.h
  2. Makefile:
    SDCCREV ?= -Dstc15w408as

stc15.h.gz
ds1302.c.gz
led.h.gz
hwconfig.h.gz

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

well, it's a kinda strange, but build from from this repo with modified ds1302.c does not read time/date from rtc after power loss...
read settings - alarm, chime... but not time/date itself... i don't understand why... it's timing or lines problem, dont's sure... the thing is this function works fine, otherwise clock will not work at all, but at start up something goes wrong...

from stc_diyclock.

aleksey-ru52 avatar aleksey-ru52 commented on May 29, 2024

put ds_readburst() just after ds_init() now it reads time from ds after power off, but it's quick workaround, not solution

    // init rtc
    ds_init();
    ds_readburst();
    // init/read ram config
    ds_ram_config_init();

from stc_diyclock.

Kobbe1 avatar Kobbe1 commented on May 29, 2024

@aleksey-ru52 Just tested this from this repo and your above workaround, worked fine.
Temperature is off, will take a look but not important.

from stc_diyclock.

Related Issues (20)

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.