aFewBits / stc-led-clock

Replacement firmware for STC 8051 based DIY LED clock kits
MIT License
55 stars 20 forks source link

Bad data on display #7

Closed Hegz closed 6 years ago

Hegz commented 6 years ago

I appear to have the BOARD_BLUE_6 unit, as all of the pins match up to that configuration, but I can't get anything to show on the display.

This unit uses a 12 pin 4 digit LED display, and I can't seem to find the magic combination of bits to make it work. Would you be able to recommend a set based on this schematic, or would you be able to explain how I can interpret the '0b00000100' numbers to some up with something that works?

TIA

schematic_clock-schematic_sheet-1_20180412160507

aFewBits commented 6 years ago

BLUE_6 refers to board color and the number transistors on the board. No transistors on your board. Even though the pinout matches your schematic, what you need to use is:

define BOARD_TALKING FALSE

define BOARD_BLUE_6 FALSE

define BOARD_BLUE_5_RELAY FALSE

define BOARD_YELLOW_5 FALSE

define BOARD_YELLOW_SMALL FALSE

define BOARD_WHITE_SMALL TRUE

define BOARD_GREEN_SMALL FALSE

define COMMON_ANODE FALSE

define COMMON_CATHODE TRUE

define PROC_IS_15W408AS FALSE

define PROC_IS_15W404AS TRUE

define PROC_IS_15F204EA FALSE

define HAS_LDR TRUE

define HAS_THERMISTOR TRUE

define HAS_RELAY FALSE

define DIGIT_3_FLIP FALSE

You'll have to determine if you have a common anode or common cathode LED and set the defines accordingly. Blue tends to be common cathode so start there, if it doesn't display switch to anode and recompile. I honestly don't remember if I've seen a blue CA.

One of these days, I need to take some photos and better document the types.

Hegz commented 6 years ago

Ah, I didn't know there were transistors that were taken into account. My bad.

I'm getting some where now, I can see the display, and almost interact with the unit. When I press a button the corresponding pin(15/16) is pulled low and kept there, in a pressed state. I need to touch the pin (15/16) to vcc to release it.

aFewBits commented 6 years ago

The pins should not remain low, the pin should return to logic high when the button is released. Start with the backup battery removed and when it powers up, you should have a 07:59 display. Pressing S1 should result in a "SEt" led display.

If no joy above, remove power (and the coin cell) and while holding down both S1 and S2, re-apply 5V power. This will clear the ram in the DS1302 and reset everything to defaults. You should then have the 07:59 display. If not, post what you see on the display. I'll keep the issue open until you get the unit working.

Hegz commented 6 years ago

I was just able to get things working on my unit by using the WHITE_SMALL definition, and adjusting the SET_PORT_DRIVE parameter to P3M1 = 0x03.

Unfortunately it's quite dark in that configuration, unless I also set P3M0 = 0x3C. I'm still quite new at this, but can both IO port configuration settings be set under the same SET_PORT_DRIVE? or is adding a second directive to main.c the best option?

Messing with the LED brightness is something I can take care of, so I'll close this issue.

Hegz commented 6 years ago

as an addendum to this, I needed to install external pull-up resistors to from VCC -> P3.1/3.0 I wasn't able to adjust P3M1 and P3M0 to the extent that I could enable the internal pull-ups to the extent that they would actually work in this configuration

I'm not sure if this is a bad chip, or poorly designed board.

aFewBits commented 6 years ago

The external pullups are not required as P3.0 and 3.1 default to "quasi-bidirectional" so there is an internal pull-up in the circuit. Given that info, unless you've you're directly messing with P3M0 and P3M1 in your code, which you should not have to do, it sounds like a bad chip. I've never seen a bad one, never problem one with any of the STC devices but anything is possible.

In common anode mode, the code already sets P3M0 to 0x3C with the #define at line 329 in global.h. This enables high current mode output for P3.2->P3.5 which is the anode supply for each digit. P3M1 is left at its default of 0x00 in the code.

Common cathode mode sets all pins of P2 to be high current mode with line 334.

If the display is lit but dim to the point of being unviewable, try recompiling with the opposite polarity display and reflash. I seem to remember that is what happens when it's wrong. Knowing the displays can be either configuration, I measure them with the diode setting on a DMM and label them CA or CC with a sharpie to avoid later confusion as I have a box of every model I could find.

The dim display can also be a result of the LDR circuit. Measure the voltage across the LDR, it should approach zero volts in a bright room, it should go to 2-3 volts in darkness. If you have any doubts, you can force the setting to full brightness by setting the "brt" minimum to 63. The brightness defaults to 63:01 (bright:dark). Change that to 63:63 and it will never dim regardless of the LDR voltage.

aFewBits commented 6 years ago

BTW, yeah, it's poor design too since there are no current limiting resistors in the LED circuit. STC documentation is somewhat conflicted on this issue. The latest document says the output is current limited, the earlier ones say a resistor is needed in high current mode.

As a result of no resistors to limit the current, the display will be brighter when a "1" is displayed due to this being the lowest number of segments and the overall available current is higher. The worst case is at 18 minutes past the hour where you have two segments on (the 1) next to seven segments on (the 8).

I've realized I could adjust for this by counting the number of on segments and reducing the digit on time but I've never gotten back around to spend the time on it. It might be problematic because of the variability in display brightness. The white leds tend to burn your retinas, green is ho-hum bright at best so the range is dramatic, visually. FWIW, there is more discussion about display timing in issue #3.