Author Topic: The trouble with Christmas Lights 2023  (Read 3418 times)

0 Members and 1 Guest are viewing this topic.

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
The trouble with Christmas Lights 2023
« on: November 02, 2023, 07:42:01 pm »
OK so I went shopping for some new lights to put around a mirror in our hallway...

And bought...

A set of 880 LEDs with a multi-function controller.  The lighting functions, eight of them, are all pretty psycho except for Continuous ON, which is my preferred setting.

The mode... Combination, In Waves, Sequential, Slo-Glo, Chasing/Flash, Slow Fade, Twinkle/Flash and Steady On are selected using a push button...

So far so good... but I need to select Steady On (seven pushes of the button).



And you guessed it... the lights do not remember their mode so every time the lights are turned on (via a timer) they enter psycho mode.




 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #1 on: November 02, 2023, 07:50:39 pm »
So... I've done the dangerous bit... chopped the end off...

The power supply is like this...



and





So... I guessed that the power supply is on one side and the effects on another... measured between the DS3 and DS4 points with lots of dangerous exposed voltages and measured 11.7V

Now I can put the dangerous stuff behind me since if I apply 11.7V from a bench supply with GND at DS4 and +11.7V at on the far side of the diode at DS3 the lights function.

This is now a safe project so please have no qualms in making suggestions due to concerns for my health and safety.  :)


 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #2 on: November 02, 2023, 07:59:19 pm »
The LEDs are connected by two wires.  I think the scheme is that one set are wired in one direction with the other set in the opposite direction.  The arrangement of the four transistors is an H-bridge to set 12V one way or the other to light up one half or the other.  PWM is used to dim one or other or both of the two segments to create effects.

I probed around the eight pin device and found near enough 5V in the corners.  The two pins connected to the 101 resistors drive the H-Bridge

As anticipated...



150Hz is used to drive the bridge.  Here duty cycle is near 50%... full on in both strings.  Where dimming occurs the duty changes.

So...

How should I approach this?  Add a gadget to press the button seven times on start-up?   Replace the controller with something else that just generates a square (and anti-square wave) at 150Hz?

I seem to have 5V available and could just lift the 101 resistors?

Suggestions welcome.   

Merry Christmas.

PS
I'm not exactly sure where the 5V comes from... must be regulated down from 12V somewhere... perhaps inside the microcontroller?
« Last Edit: November 02, 2023, 08:01:31 pm by NivagSwerdna »
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #3 on: November 02, 2023, 08:08:50 pm »
FYI

The switch is on a sub-assembly... along with two LEDs... 



 

Offline themadhippy

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #4 on: November 02, 2023, 08:16:50 pm »
hows about a 9v ac transformer and forget about the chinesium control board
 
The following users thanked this post: NivagSwerdna

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #5 on: November 02, 2023, 09:14:06 pm »
hows about a 9v ac transformer and forget about the chinesium control board
I like your thinking... how did you arrive at 9V?
 

Offline themadhippy

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #6 on: November 02, 2023, 09:37:10 pm »
Quote
how did you arrive at 9V?
a guesstimation based on the most common tranny sizes,and 9v rms is 12 and a bit volts peak to peak
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 2503
  • Country: au
    • Halestrom
Re: The trouble with Christmas Lights 2023
« Reply #7 on: November 03, 2023, 01:45:05 am »
Some quick thoughts:



There are 3 pins on the 8 pin micro that go to missing parts (CS7, CS8 and CS3 all at the top).  Could they have designed this thing to suit different products?  Perhaps some where you don't want all the flashy modes?

I wonder what happens if you install a capacitor (?) or a small resistor (1K?) in those spots.


Alternatively: find an 8 pin micro with similiar pinout and program it to do nothing but output fast square waves on the H-bridge pins.  You will probably want to add some dead time and double-check you understand how the fets are being driven (possibly the micro's pins are open-collector, so the gates of the fets are driven to the full +VCC and not just the max voltage of the micro?).
« Last Edit: November 03, 2023, 01:47:06 am by Whales »
 
The following users thanked this post: NivagSwerdna

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2867
  • Country: us
Re: The trouble with Christmas Lights 2023
« Reply #8 on: November 03, 2023, 01:59:42 am »
I'm not exactly sure where the 5V comes from... must be regulated down from 12V somewhere... perhaps inside the microcontroller?

DS4 is a zener diode serving as a shunt regulator, RS19 (marked 152) is the resistor that feeds it from the 12V supply.  You could certainly use this to drive other circuitry, just know that the maximum current you can consume from it depends entirely on RS19. 

Note that there is no (explicit) current limiting here, it's relying on the impedance of the secondary and the resistance of the wire to limit current. 

hows about a 9v ac transformer and forget about the chinesium control board

Not a bad idea, but a transformer with sinusoidal output is more likely to produce objectional flicker versus a square wave, because the LEDs will only be on when the transformer output is near its peak.  Plus the fact that the frequency drops from 150Hz to 100Hz.  Visibility of flicker depends on both frequency and duty cycle.  May or may not be a problem, some people are more sensitive to/bothered by it than others.

So... I guessed that the power supply is on one side and the effects on another... measured between the DS3 and DS4 points with lots of dangerous exposed voltages and measured 11.7V

Kinda... One side is the primary side of the switch-mode supply, the other side is the secondary plus the output control.  In this case there's not much "secondary" circuitry, just the rectifier (DS3) and bulk cap (CS4).

Replacing the existing MCU with something else that generates a pair of complementary square waves wouldn't be too hard.  You could do that with a little 6-pin AVR even, or for an easier path use a tiny MCU board.
 
The following users thanked this post: NivagSwerdna

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #9 on: November 03, 2023, 10:33:53 am »
I'm a bit concerned about running at 50Hz especially as there will be a cut-off due to some part of the cycle being too low... so really tempted to add a 150Hz square wave (and anti-squarewave) generator.

There is plenty of space on the top board and I could run bodge wires through the hole.

I must have an old PIC lying around somewhere.
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #10 on: November 03, 2023, 10:38:02 am »
There are 3 pins on the 8 pin micro that go to missing parts (CS7, CS8 and CS3 all at the top).  Could they have designed this thing to suit different products?  Perhaps some where you don't want all the flashy modes?

I wonder what happens if you install a capacitor (?) or a small resistor (1K?) in those spots.
Interesting.  The CS8 and CS7 look worth a fiddle.
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 10773
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #11 on: November 03, 2023, 10:50:35 am »
Agreed, CS7 and CS8 could well be configuration selects. Looking at the rest of the board, CS implies capacitor, so if resistors don't work, try 100nF capacitors.

More of a concern is how you're going to fit 880 LEDs around your hall mirror!  ;D
Best Regards, Chris
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #12 on: November 03, 2023, 03:45:39 pm »
Tried all combinations of 1k resistors in the two positions CS7 and CS8.  Cannot see any noticeable effect.

CS3 is parallel to DS4 so didn't think that was a good idea.
 
The following users thanked this post: Whales

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #13 on: November 03, 2023, 08:06:12 pm »
OK so I looked in the box of things I have bought in the past on EBAY after watching some random video on YouTube... and found...



ATTiny85 in Digispark flavour.

I think this is probably a reasonable start... now just have to figure out how to get it to do two channels of PWM

 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #14 on: November 03, 2023, 08:32:35 pm »
I really need to read some documentation but I think this is what I am after...



i.e. the 8-bit timer to be driven by clk/256 and to count... 0...208

One pin to be on during period 0..100 and the other pin to be on during period 104...204

I'll have to read the datasheet to see if that is doable in registers only, i.e. hardware.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 24201
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: The trouble with Christmas Lights 2023
« Reply #15 on: November 03, 2023, 08:51:00 pm »
What are the waveforms in different modes?

If "chasing" or "waves" and only a small proportion of LEDs are on at a time, it may imply communication with the individual LEDs.

If using a nice simple (i.e. Z80 class not x86 with caches and pipelines) MCU to do nothing other than generate a fixed waveform, I'd be tempted to ignore timers and just use software loops with magic numbers that give the right timing.
« Last Edit: November 03, 2023, 08:55:33 pm by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 2503
  • Country: au
    • Halestrom
Re: The trouble with Christmas Lights 2023
« Reply #16 on: November 03, 2023, 09:19:26 pm »
Be careful with your control signals.  P-channel mosfets might have inverted control and/or require open-collecter output pins on the micro.  Fully reverse engineer the circuit of the 4 mosfets, their resistors and how they are hooked up to the micro before assuming anything.
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #17 on: November 04, 2023, 08:32:13 pm »
Making slow progress...



Using code...

Code: [Select]
#include<avr/io.h>
#include <avr/interrupt.h>

byte counter = 0;

ISR(TIMER0_OVF_vect)
{
  counter++;
  if (counter >= 52) {
    counter = 0;
  }

  switch (counter) {
    case 0:
      PORTB |= (1 << PB0);   // ON
      PORTB &= ~(1 << PB1);   // OFF
      break;

    case 25:
      PORTB &= ~(1 << PB0);   // OFF
      PORTB &= ~(1 << PB1);   // OFF
      break;

    case 26:+
      PORTB &= ~(1 << PB0);   // OFF
      PORTB |= (1 << PB1);   // ON
      break;

    case 51:
      PORTB &= ~(1 << PB0);   // OFF
      PORTB &= ~(1 << PB1);   // OFF
      break;

     default:
     break;
  }


}


void timer_setup()
{
  TCCR0A = 0x00; //Normal mode
  TCCR0B = 0x00;
  TCNT0 = 0;
  TCCR0B |= (1 << CS01); //prescaling with 1:8

  TIMSK |= (1 << TOIE0); //enabling timer0 interrupt
  sei(); //enabling global interrupt
  PORTB |= (1 << PB1);
}


// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  DDRB |= (1 << PB0); // set PB0 as output
  DDRB |= (1 << PB1); // set PB1 as output(LED)

  PORTB &= ~(1 << PB0);   // OFF
  PORTB &= ~(1 << PB1);   // OFF


  timer_setup();
}

// the loop routine runs over and over again forever:
void loop() {
  // Hard Loop
}

Just got to figure out how I can program that into a bare ATTiny85 (without the Digispark bootloader)
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #18 on: November 13, 2023, 03:05:14 pm »
OK... so it's done...

Lifted the two pins that drive the H-bridge and added bodge wires... Bodged in the Digispark Attiny85 board...

Reassembled...   Job Done



 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #19 on: November 13, 2023, 03:07:25 pm »
Final notes:  Upgraded the bootloader to make the delay at start to a small value.

https://github.com/ArminJo/micronucleus-firmware/tree/master/firmware/upgrades

micronucleus.exe /run upgrade-t85_entry_on_powerOn_activePullup_fastExit.hex

Now it starts almost immediately
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #20 on: November 13, 2023, 04:26:36 pm »
 
The following users thanked this post: Whales

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 10773
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #21 on: November 13, 2023, 06:29:07 pm »
Yay, with a month to spare (I hope!). :-+
Best Regards, Chris
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 24201
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: The trouble with Christmas Lights 2023
« Reply #22 on: November 13, 2023, 06:51:28 pm »
No, a month too early.

Put the damn things back in the box, then relax and enjoy November before the stress of Yule.

Bah, humbug.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: bd139

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2531
  • Country: gb
Re: The trouble with Christmas Lights 2023
« Reply #23 on: November 13, 2023, 10:32:19 pm »
I try and keep December free for adventofcode.

https://en.wikipedia.org/wiki/Advent_of_Code
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf