Showing posts with label LED. Show all posts
Showing posts with label LED. Show all posts

Monday, 4 July 2022

NeoPixel Circle PCB

The next step in the DMX patio lamp is to create a PCB with the neopixels on it.

The previous posts for reference are:

https://langster1980.blogspot.com/2022/07/designing-dmx-controlled-patio-light.html

https://langster1980.blogspot.com/2022/07/dmx-to-neopixel-arduino-shield.html

I am going for 32 LEDS but I may change my mind. It depends really on the size and spacing achievable as well as current draw and voltage drop.  Lets see what works first.

I'm confident I could design this PCB straight away but it is always a good idea to read through the datasheet and do some calculations...there may be something critical I have missed or didn't know.  I've used neopixel tape several times but I've never really bothered to read up on their technical aspects.

Here is the datasheet: https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf 

The datasheet isn't the worst I've looked at but it isn't the best either...

After some reading...and some more reading here is what I have found:

The package contains 3x LEDS and a control circuit.  According to the research the control circuit draws
8 mA with all the LEDS not active (Off). 

The Red LED draws 13 mA when fully on. 

The blue LED and green LEDS also draws 13 mA when fully on.

Therefore each pixel (3x LEDS in one package) draws 60 mA.  

If we have 32 pixels our current draw with each LED fully on (White colour) will be:

So if the calculations are correct...then we need to account for this 1.6 Amp current draw on our PCB layout. Our connector and wiring also need to handle 1.6 Amps - I'm going to design for 2 Amps to provide a little margin.

Here is the circuit diagram:
NeoPixel Lamp Schematic

Next we need to design a PCB layout.  I'm going for a circular PCB which will fit behind the 84 mm polycarbonate cover.  Lets set the diameter of the PCB to 80 mm - that way I know it will fit with room to spare. I will need a mounting option too...not worked that out yet!  I suspect some stand offs and attached to the cover will work fine.

Here is the PCB layout:

NeoPixel Lamp Top Layer - PCB Render


NeoPixel Lamp Bottom Layer - PCB Render

I added an extra pixel in the centre of the PCB as there was room.  I also added some mounting holes which weren't on the schematic.  The layout went quite well and only took me a couple of hours...must be getting better at this although it isn't because of practice!  I did have a nights sleep between the hours...maybe that helped...

I have exported the gerber files...next job is to get a quote from JLPCB and then assuming the price is right get some boards made.  I'm going to go with black silkscreen.  

I think that's all for now - take care, Langster!

Friday, 1 July 2022

DMX to Neopixel Arduino Shield

In a previous post (nearly a year ago!) I mentioned I was going to design an Arduino shield to allow DMX control to Neopixels.  I actually did design a board but never wrote a blog post about it.  Here is where I rectify that.


I decided to design my own DMX shield for the Arduino R3 as although there are commercial off the shelf versions available they don't have electrical isolation between the RS485 transceiver and the IO (Input Output) ports. This can be quite critical when connecting up DMX lamps as some of them are not well designed and lets just say ground loops and cheap DMX lamps becoming live when they shouldn't and releasing of magic smoke and electric shocks being a very real and present danger...don't ask me how I know... 

The circuit itself is pretty much the same as those already available.  It has opto-coupling present on the IO, the power supply and has DIP switches on board to set the DMX start address.

Here is the circuit diagram:
DMX to SPI Converter Shield

I suppose I had better explain the circuit - This is as much for me as for the casual reader...I'll be honest I haven't looked at this for a year and some decisions taken were odd to me at first...  

12 V dc input to 5 Vdc out circuit (Switch-mode)


The circuit section shows the 12 V dc input coming from the connector J1 going to C1 (100 nF) - this is a filter capacitor.  Then a DC to DC converter module is present.  Three 100 nF capacitors are then present to filter the output of the DC to DC converter.  These switching converters are known to often cause electromagnetic interference.  The capacitors are present to try to mitigate those issues.

The switching converter (PS1) used is a TRACO TEA_1-505 and it's datasheet is here: 

https://uk.farnell.com/traco-power/tea-1-0505/dc-dc-converter-5v-0-2a/dp/3465028

The next section is the opto-coupled RS485 (DMX)section:


The serial and control signals from the Arduino R3 are connected to Jumpers (JP1 to JP4).  This allows the user to isolate the connections from the serial pins of the Arduino R3 to allow for code upload and control of whether the DMX device will be active (in control of the DMX network and sending data packets) or passive (receiving Data packets).

I'm going to discuss each opto-coupler in turn to simplify things:

Resistor R1 (4.7 kΩ) is connected to output of Opto-coupler U1 and is present to current limit the signal presented to the serial input RX of the Arduino R3 (or clone).  Resistor R6 (470 Ω) is present to current limit the signal presented to the input of U1 coming from the RO output of the RS485 transceiver (U4 - MAX 481E).  


Resistor R2 (470Ω) is connected to the input of Opto-coupler U2 and is present to current limit the signal presented to the internal diode of the device.  The output is current limited by resistor R4
(4.7 kΩ) and is connected to the DE and RE (inverted) inputs of the RS485 transceiver (U4 - MAX 481E). 

Resistor R3 (470Ω) is connected to the input of Opto-coupler U2 and is present to current limit the signal presented to the internal diode of the device.  The output is current limited by resistor R5
(4.7 kΩ) and is connected to the DE and RE (inverted) inputs of the RS485 transceiver (U4 - MAX 481E). 

The Opto-Couplers are powered by 5 V dc coming from the regulated Arduino R3 supply and are isolated from the 5 V dc signal coming from the DC to DC converter 

The IO (A and B) signals of the R485 transceiver (U4 - MAX 481E) are connected to three resistors (R7 - 562 Ω, R8 - 133 Ω, and R9 - 562 Ω).  These are present to provide the 120 Ω impedance matching for the RS485 transceiver.  The input and output to the RS485 transceiver are connected to screw terminals with an isolated return (GND2).  These will connect to the signal cable used to connect this circuit to the DMX controller. 


The next section is present to allow the user to pre-set the DMX address:


The 8 way DIP switches (SW1) are connected to the Arduino R3 spare pins and 330 pull up resistors.  It is a standard way of connecting switches to microcontroller input pins.  The current presented to the microcontroller inputs when the switch is closed is 15 mA which is within the specification of the device (ATMEL 328).

The SPI output of the circuit is taken from Pin 12 of the Arduino R3 along with supply voltage and ground to a three terminal screw connector.  This is a nice robust way of connecting to off the shelf Neopixel circuits. 

The final section is the standard layout used for connecting a shield circuit board to an Arduino R3.


It saves time designing PCB layouts as all of the dimensions and connections are present and contain NET labels.

Here is the bill of materials in case it is needed:


I haven't ordered any of these parts yet but I already know that some are not in stock...the fallout from the pandemic is very real.  Some are due in next week so I can get ordering!

Here is the PCB layout: 


The 3D render is probably easier to see and understand:

The DMX to SPI Converter shield - Top Layer 

The DMX to SPI Converter shield - Bottom Layer

There isn't much to say about the PCB layout.  I've tried to make sure that all of the traces carrying high current are nice and thick. The silk screen labels are visible and it is fairly easy to populate by hand if required.  I wish I had labelled in the inputs and outputs so I know where the GND and +12 V input connections are and where the DMX and NeoPixel connections are.  There are always things I would do differently if given a chance to repeat.

I got ten boards made by PCBWay for a reasonable price and they were delivered in very short order!

Here is a picture of the unpopulated board:


My plan is to populate and test this board as soon as possible as I intend to use it in my next project - the DMX controlled patio lamp :)

That is all for now - take care always - Langster!

Designing a DMX controlled Patio Light with Neopixels

A friend of mine has approached me to make him some Patio lights. He wants them to be interactive! I'm thinking the best idea would be to make him some sort of DMX controlled light with WS2815 LEDS. I can build on the previous design work I have already done which should save me some time. 

For the enclosure my plan is to take an existing garden rock lamp and re-engineer it for this purpose. This should save me having to design some clever aesthetics. To that end I have bought a cheap (£3.20) garden lamp from B & Q - A popular Home / garden improvement chain in the UK: 


The lamp itself looks like this:
   
Simple Garden Solar charging rock lamp

The lamp housing appears to made of some sort of ABS moulded plastic.  The Reflector and LEDS are protected by a simple circular polycarbonate shield.  There is a battery housing and a button on the base of the housing.

Don't turn it on - Take it apart!!!

The deconstructed lamp

The light actually came apart very easily...it was mainly hot glued together!  The reflector, battery box and solar panel will be discarded as they won't have any purpose in the upcycled lamp.  I will probably leave the solar panel on as getting it off will be difficult and it won't do any harm.

There is ample space inside the lamp for a couple of circuit boards and some ballast (weight) to stop the lamp moving too easily.  My current thinking is to design two circuit boards.  One for the DMX and one for the lighting.  The controller will be a small microcontroller board which accepts DMX and outputs SPI to the lighting board.  The lighting board will be a circular PCB with WS2815 LEDS arranged in a sensible pattern.  If I'm luck it will be possible to fit 32 LED pixels on the display board.

I have not decided which microcontroller to use yet...probably an arduino or teensy variant.  There is no need to go for a wifi enabled micro as the plan is to use wire to carry both power and the DMX signal.

The diameter of the reflector is 84 mm.  I think the lamp PCB will need to be the same dimensions.  Hopefully we can get 32 W2815 LEDS (Pixels) to fit!

So to recap our electronic and mechanical requirements:

Design a lamp PCB with 32 pixels.  I think powering the lights via 12 volts might be a good idea however I will consider this more once I get to the PCB layout.  We will need to ensure the tracks are suitably rated for the current flow.  We will fuse the voltage signal on the control board with a user changeable fuse.

Nice to haves: 32 pixels - allows for simple channel assignment via DMX controllers.  Each lamp on one universe...with 96 channels.  

So the design tasks so far:
  • Design a Lamp PCB
  • Design a DMX to neopixel PCB with optocoupled DMX in and out ports - possibly using the one I've already designed.  
  • The micro is yet to be decided.
  • The circuit will also be powered via 12 V dc but we will probably need to regulate that down to 5 V dc for the micro and other circuitry...sound detection, light detection etc.
I haven't got a budget set however cheaper is always better!

That will do for now!  Take care - Langster!


Sunday, 13 December 2020

How to design a simple LED Circuit

I am out of practice at many things it would seem at the moment...

I recently had to verify a colleague's design and honestly failed miserably.  Things that I consider basic in terms of electronics I didn't see and couldn't quickly do.  
To that end let us start from a simple area and attempt to cover as many aspects as possible...at least that way I will hopefully improve in my skills and prevent others from making similar mistakes.

I'm going to show a simple circuit that I was presented with...I'll be honest I struggle to visualise circuit operation from a schematic...it's probably why I struggle with the task of assessing designs. 

Simple LED Circuit

Lets try to analyze the circuit and explain how it works.  The circuit's function is to indicate which position the switch SW1 is in to the operator.  We have two different light emitting diodes (LEDS) connected via (SW1) a double pole single throw switch to a 5 Vdc supply with two 4k7 Ohm resistors and a 10 k Ohm Resistor.

When the switch (SW1) is in the position shown above LED D2 is supposed to be illuminated and a signal (at 5 Vdc) is also passed back to a microcontroller GPIO configured as an input (not shown here) via the node labelled SW1.  When the switch is in the alternative position the LED D1 is supposed to be illuminated and at the same time a signal or rather lack of signal (0 Vdc) is passed back to the microcontroller GPIO configured as an input. 

This method of connecting LEDS is known as reverse parallel - I'd actually not heard the term before...I had seen it before but not had it described that way...

So why is this circuit not particularly well designed?  There are a couple of reasons...which I'll be honest I did not pick up on during my assessment.  I made assumptions that the designer had performed calculations and checks to ensure the values selected were correct. 

The first reason is with respect to current.  In order to cause an LED to go into illumination normally at least 16 mA of current is required. How much current is flowing in the circuit with respect to D2?

Well the forward volt drop of the LED D2 is not stated so we don't actually know...lets fix that by supplying the datasheet:

C503B-BCS-CV0Z0461 Blue Light emitting diode datasheet

D2 is a 5 mm through hole LED with a wavelength of 470 nm.  It has a typical forward voltage (VF) of 3.2 Vdc when the forward current is at 20 mA.

We can now perform a simple calculation:

(Supply voltage - Diode forward voltage) / Resistor (R2) = Current flowing in LED D2 part of the circuit

(5 Volts - 3.2 Volts) / 4700 Ohms = 0.00038297872 A or 383 µA (micro-Amperes)

In order to get an LED to illuminate at normal brightness there should be milli-Amperes - I normally aim for 16 mA.  So in the circuit shown above with the switch in this position the LED D2 will not be illuminating brightly...I suspect it won't even be visible to the human eye.

The same issue is present with LED D1, here is the datasheet:

L-53SYD Yellow Light Emitting Diode Datasheet

D1 is a 5 mm through hole LED with a wavelength of  590 nm.  It has a typical forward voltage (VF)  of 2 Vdc when the forward current is at 20 mA.

(Supply voltage - Diode forward voltage) / Resistor (R1) = Current flowing in LED D1 part of the circuit

(5 Volts - 2 Volts) / 4700 Ohms = 0.00063829787 A or 638 µA (micro-Amperes) 

If again the aim was to illuminate the LED D1 (16 mA) then when the switch (SW1) is in the alternative positon the LED D1 will not be illuminated brightly at all...

So how do we resolve this issue?  We could try changing the resistor values (R1 and R2) for a lower value...

The standard formula for calculating the current limiting resistor for an LED is:

Current Limiting Resistor (Rlimit) (Ohms) = [Supply Voltage (VS) -  Diode Forward Voltage (VF)] /                                                                                                Diode Forward Current (IF)
Supply Voltage (VS) = 5 Vdc
Diode Forward Voltage (VF) = 3.2 Vdc (Blue LED)
Diode Forward Current (IF) = 16 * 10^-3 Amps or 16 mA

Therefore:

Current Limiting Resistor (Rlimit) (Ohms) in this case R2 = (5 Volts - 3.2 Volts) / 16 *10^-3 Amps

Current Limiting Resistor (Rlimit) (Ohms) = 112.5 Ohms for the Blue LED current limiting resistor.

For the current limiting resistor for D1 we have:

Current Limiting Resistor (Rlimit) (Ohms) in this case R1 = (5 Volts - 2 Volts) / 16 *10^-3 Amps

Current Limiting Resistor (Rlimit) (Ohms) = 187.5 Ohms for the Yellow LED current limiting resistor.

As 112.5 Ohms and 187.5 Ohms are not standard values for resistors one would probably use a 100 Ohm resistor and a 180 Ohm resistor.

The other calculation that should be made when designing circuits with resistors present is to ensure that the resistor power rating is suitable for the amount of power that will be present in the circuit.  Resistor life-time is reduced and unnecessary heat is generated when too much power is conducted through resistors.

The formula for calculating the power in a component is an application of Ohms Law:

Power (Watts) = Voltage (V) * Current (I) or

Power (Watts) = (Current * Current) * Resistance or

Power (Watts) = (Voltage * Voltage) / Resistance

We can apply any version of Ohms law to calculate the information required.  I have decided to use

Power (Watts) = (Current * Current) * Resistance

Power (Watts) in R1 =  (16*10^-3 * 16*10^-3) * 180 Ohms

Power (Watts) in R1 = 0.04608 Watts or 46.08 mW

Power (Watts) in R2 =  (16*10^-3 * 16*10^-3) * 100 Ohms

Power (Watts) in R2 = 0.0256 Watts or 25.6 mW

So to ensure that the power rating for the resistors is correct we should use 100 mW or quarter watt (250 mW) rated resistors.

There are still issues with the circuit as shown above however; The circuit is kind of wasteful...When the switch is in the position shown above there will always be current flowing in resistor R1 even though LED D1 is not illuminated.  With the switch in the opposite position the resistor R2 will still have current flowing through it even though LED D2 will not be illuminated.  Why have current flowing in a resistor for no purpose...It would be better to redraw the circuit in a different way but still achieve the same circuit function.

It would also (in my opinion) be better to redraw the circuit and do away with the reverse parallel LED connections...mostly because I find it hard to visualise the circuit...

Here is the circuit which was redesigned by my colleague having had some feedback (not from me):

Improved Circuit Design

The circuit's function is still to indicate which position the switch SW1 is in to the operator.  We have a 5 Vdc supply connected to a blue LED (D2) which in turn is connected to a 120 Ohm resistor (R1) and via (SW1) a double pole single throw switch, to ground completing the circuit.  With the switch SW1 in the alternative position we have the 5 Vdc supply connected to a yellow LED (D1) which is in turn connected to resistor (R2) and via switch SW1, to ground completing the circuit.

A signal is also passed back to a microcontroller GPIO configured as an input (not shown here) via the node labelled Controller SW1.  When the switch is in the first position the LED D2 is illuminated and at the same time a signal  (5 Vdc) through resistors R3 (10 k Ohms) and R58 (1 k Ohms) is passed back to the microcontroller GPIO input. 

When the switch (SW1) is in the second position LED D1 is illuminated and the signal passed back to the microcontroller is 0 Vdc as the  R3 (10 k Ohms) and R58 (1 k Ohms) are now connected to ground as well as the microcontroller GPIO input as the input impedance of a GPIO on a microcontroller is normally 100 k Ohms.  It is a standard method of reading the state of a switch position with a microcontroller.

The current limit on each of the LEDS can be calculated for completeness:

Current limit in LED D1 (Yellow LED) = (Supply voltage - Diode forward voltage) / Resistor (R2)

(5 Volts - 2 Volts) / 560 Ohms = 0.00535714286 A or 5.357 mA (milli-Amperes)

Current limit in LED D2 (Blue LED) = (Supply voltage - Diode forward voltage) / Resistor (R1)

(5 Volts - 3.2 Volts) / 120 Ohms = 0.015 A or 15 mA (milli-Amperes)

It seems a little odd to me that the value of R2 was chosen to be 560 Ohms...that seems a little high and will cause the yellow LED to be less visible when in operation...

The power rating for the resistors can also be recalculated:

Power (Watts) in R2 =  (5.357*10^-3 * 5.357*10^-3) * 560 Ohms

Power (Watts) in R2 = 0.01607057144 Watts or 16 mW (milli-Watts)

Power (Watts) in R1 =  (15*10^-3 * 15*10^-3) * 120 Ohms

Power (Watts) in R1 = 0.027 Watts or 27 mW (milli-Watts)

Therefore a 100 mW rated or 250 mW rated resistor would be ok to use in either position...

As the circuit has been redesigned there are no conditions where unnecessary current is flowing in any of the resistors and we still have the circuit function needed...When the circuit is constructed it should work perfectly.

When designing LED circuits from now on I will always try and do the following:

1. Obtain the datasheets for any and all components to be used.  For LEDS pay particular attention the electrical characteristics: Forward Voltage (VF), Forward Current (IF), maximum voltage (VMAX) and maximum power.

2. Calculate current limiting resistor needed for the appropriate brightness by reading the datasheet and obtaining a figure for the current at the appropriate brightness...it may be shown in a graph.  Use the formula:

Current Limiting Resistor (Rlimit) (Ohms) = [Supply Voltage (VS) -  Diode Forward Voltage (VF)] /                                                                                                Diode Forward Current (IF)

3. Calculate the power flowing through the current limiting resistor and select a suitably rated component.

4. Choose a suitable resistor tolerance...in this case a 5% resistor will probably be fine.

4. Get a friend or colleague to check your circuits <slight smile>.

5. It often helps to simulate circuits but only when the correct information is provided.  It is possibly better to perform the calculations on paper as it will enforce research into the requirements.

6.  Make sure the circuit meets the requirements...If the requirements aren't known then set them before attempting to perform the design...

In writing and researching this blog post I looked at the following website for inspiration:

https://www.ngineering.com/led_circuits.htm

Apologies for the long post - hope this was helpful - Langster! 

Friday, 22 May 2020

Old Idea...new attempt - Chess Clocks!

The first blog post I wrote on electronics was about making a set of Chess clocks!  

Here are those posts in case anyone is interested - Hopefully my engineering skills have improved somewhat since then!







Recently I started playing chess again and I also started watching a very lively bunch on Youtube who play chess and banter often.  They play five minute blitz games and shoot the breeze and it's really entertaining and educational.  

If any of my readers are interested in chess please check them out:


I noticed that they use a set of chess clocks but with liquid crystal displays which when filming doesn't show up well on camera.  I think a seven segment LED display will be much clearer to see and would make the video editing easier.

Every good engineer or inventor should check if there is a product out there already before they rush off and develop something and unsurprisingly there is, chess clocks are incredibly popular products it would seem.  

Here are some examples of chess clocks on the market:

Analogue Chess Clocks - image credit Farrar - Tanner


Digital Chess Clock - image credit - Wish

To be honest...the main reason I never finished the original chess clocks is because I was able to download an application for my mobile phone which worked well and cost me nothing...I also struggled to engineer the PCBS down to a sensible size...at the time - I wasn't particularly keen on surface mount technology and I was making PCBS from scratch.  I can now use surface mount happily and I can have printed circuit boards made easily for a small cost.

There is even a chess clock which uses seven segment displays which looks very well designed and realised but it is quite expensive:

ZMF-II Digital Chess Clock - image credit: Chesshouse.com

The ZMF-II is actually pretty close to what I would like to achieve however I have a few tricks to make it more useful than an average set of chess clocks.  We can add wifi connectivity, sound and possibly video overlay of the clocks.  I'm hoping the guys at coffee chess will like it....hopefully they will get in contact ;)

Lets list the functions we will need:
  • Two displays
  • A method of indicating who's turn it is
  • A method of setting the time / starting / stopping time
  • A simple sound output device.
  • A method of powering the device
Lets list the functions we would like to have:
  • Wifi or bluetooth connectivity
  • Video overlay of player clocks output to facilitate editing
Lets list the Components I think we will need (this may change):
  • 1x off / on slide switch
  • 1x programming / settings button
  • 2x move buttons
  • 2x LEDS to display which player has to move
  • 2x four digit seven segment displays
  • 1x small speaker to provide limited audio
  • 1x 18650 battery to provide power 
  • 1x 18650 charging circuit with USB C connector
  • An ESP32 or possibly an FPGA with a softcore...
I possibly have all of the bits required in my electronics junk pile which is nice.  Once we have the circuit working as required I'll design a PCB and get a permanent version of the circuit working. I may well design a laser cut or 3D printed case...

I also should probably read up on the rules for chess clocks!


Well that is all for now - take care, Langster