Introduction to LED PCB

Hello everyone. Today is a great day that we are going to put our focus on another type of PCB. So far in the previous articles, we have looked at high speed, metalcore, high density interconnect and the ceramic types of PCBs. In this article, we are going to introduce another type of PCB that might find great use in your day-to-day interaction with the printed circuit boards. it is very important for a designer to take note of how PCBs have evolved and how they have become an important aspect in the design of successful electronic devices. It has become hardly difficult to come across any time of an electronic device that does not involve the use of printed circuit boards.

In PCB boards you come across LEDs fixed in them, and due to the evolving world of technology, things are changing so first leading to the crafting of new technologies that have led to changes in the LED areas. The LED case is an area that has involved the combination of two methods of technologies in order to come up with something else that is more efficient when it comes to solving the intended purpose. This LED PCB comes with advantages of longevity and durability.

Introduction to the LED PCBs

This is a type of PCB that is used for the purpose of lighting in the lighting appliances like modern LED bulbs. The material used in the process of making this board currently is the metal copper clad that has a very good heat-dissipating function. In general, we should note that the single layer LED PCB is made up of three layers namely the circuit layer, the ceramic layer and the insulation layer.

  • The LEDs are laid directly in the circuit layer where they are mounted.
  • The heat that comes out of the LED is quickly linked to the substrate layer for dissipation. This is done through the insulation layer then dissipated through the substrate layer.
  • Copper, aluminum and iron are the most used thermal conductive layer material since they are readily available.
  • The iron core is mostly used in motor high-end PCBs that have a lot of heat dissipation.

How to order LED PCB online?

There are numerous online PCB companies, where we can place the LED PCB order. We are going to take the example of PCBWay Fabrication House, a well renowned PCB Manufacturing House. They have an excellent support team, and it's recommended to first discuss your PCB design with the team, they will guide you at every step. So, follow these steps to place an order of LED PCB on PCBWay:
  • First of all, create an account on the PCBWay official site.
  • After that click on the PCBWay Calculator, which is an excellent tool to get the quote for your PCB order.
  • As you can see in the above figure, I have selected Aluminium PCBs, as LED PCBs are normally aluminum PCBs to avoid heat dissipation.
  • Now click on Calculate and get the quote for your order.

The LED PCB working principle

  • The LED is mounted on the surface of the circuit layer and the heat that is generated when the PCB is under operation is quickly passed to the metal base layer via the insulating layer.
  • This heat is then passed out by the metal base layer to achieve the purpose of heat dissipation of the device.
  • See the attached diagram for a better understanding of the process;

LED PCD structure

Circuit layer

This is made up of the electrolytic copper foil and is etched to form the printed circuit board where the components are attached. When you do the comparison with the traditional boards, the LED board can carry a larger amount of current.

Insulating layer

This layer is the core technology behind this type of boards and plays greater roles in the conduction insulation and bonding of the layers.

Metal substrate layer

Here aluminum is the best choice compared to its availability and the cheap prices it offers. Stainless steel, silicon and the iron can be used if the thermal conductivity required is very high.

Types of the LED PCBs

The single layer LED PCB

This consist of the substrate layer together with a conductive layer. A solder mask together with a silkscreen offer protection functions to these layers.

  • This type of the LED PCB does not have any circuit layer on the back side.
  • Their structure is very thin and they are very weightless.

Double layer PCB

When you don a comparison with the single layer PCBs, you will realize that this has two copper layers which apparently makes them heavier as the number of conductive layers also increase to two.

  • Double layered PCBs are durable since this type of circuit layer can withstand the high currents applied and it has the best heat dissipation mechanism.

Assembly methods of the LED PCB

There are two assembly methods that can be employed in the assembly if the LED PCBs. These methods are used to attach components on the board and we shall discuss it below;

Surface-mount assembly

This method involves mounting the electronic components directly into the board copper layer.

  • the process is highly automated and offers flexible connections and offers spaces for high density connections.
  • They play great roles in circuitry that require high connections and accuracy.

Through-hole assembly

This method involves the drilling of holes into the PCB boards where components are then mounted to the holes using the long leads that are then soldered and the whole filled with flux.

  • The process involves a lot of inspections to make sure that the great accuracy and the effectiveness are achieved.
  • This method off course provides a strong board with long durability.

Considerations while designing the LED PCBs

  • Ideal board design; you must figure out which is the ideal board design that you should incorporate. In engineering everything starts with the design. It is the first step that comes in.
  • Picking the proper orientation; when we talk about orientation, we are after how the flow of the circuit is achieved from one end to the other. The way in which the data and the electricity flow in the circuit is what we are referring to us the orientation.
  • Component placement; in addition to the circuit and the obvious LED, there are many other components that form the printed circuit boards. these components include the resistors, the capacitors, etc. the components should be placed such that they avoid the solder side of the board were solders lie behind the through hole side of the board.
  • Avoid placement of the components on the PCB outline; this will help you manage the board better and also ensure that the design is sturdy and very reliable.
  • Vias should not be placed at the end of the STM Pads; vias allows the placement of circuits in tow or more layers if the PCB boards. these vias can go through the surface of the top layer through to the bottom layer. Avoid passing the via through the pads of the surface mounted devices since this will weaken the components.
  • Definition of the net width design; due to consumption of different current in the circuits, the design paths will vary with the size of the tracks and this will also affect the net width of this design outcome.
  • Cost optimization and the budget issues; this is how the overall budget of the designed PCB will go up to. Therefore, this must also be considered when coming up with the LED PCB.

Industrial applications of the LED PCBs

Consumer lighting

This is one of the common applications the LED PCBs where they find great use on the consumer lighting from flash lights, lamps, spotlights, lanterns to solar powered lighting applications.

Consumer electronics

LED are also becoming a common application in the electronic devices such as the computer keyboards backlights. Other devices that have employed this technology are smartphones, tablets and the televisions.

Telecommunications

Telecommunication displays and indicators use the LED PCBS because of their durability the ability to transfer heat and their longevity since telecommunication gadgets generate a lot of heat.

Transportations

LEDs have a lot of use in the traffic and the transportation industry ranging from the stop lights and the automotive themselves. In the car this PCs are found in the headlights, fog lights, brake lights, reverse lights and the indicators. Highways tunnel lighting also use this technology. The modern streetlighting system is done using the LED PCBs.

Medical

Medical lighting and the medical equipment lighting that are used for medical examination and surgery often use this type LED PCBs.

Benefits of this LED PCBs

  1. Reduced consumption of power
  2. More efficiency compared to the traditional boards.
  3. They are smaller in size
  4. This type of board is mercury free
  5. It is radiofrequency free
  6. It is much environment friendly
  7. Cheap and this implies reduced cost.
  8. It has a longer life compared to others.

PWM with STM32

PWM stands for Pulse-Width Modulation. Once the switching frequency (fsw) has been chosen, the ratio between the switch-on time (TON) and the switch-off time (TOFF) is varied. This is commonly called duty-cycle (D). The duty cycle can be between 0 and 1 and is generally expressed as a percentage (%).

D = TON / (TON + TOFF) = TON x fsw

The variation of the pulse width, made at a high frequency (kHz), is perceived as continuous and can be translated into a variation of the rotation speed of a motor, dimming a LED, driving an encoder, driving power conversion, and etc. The use of PWM is also widely used in the automotive sector in electronic control units (ECU - Electronic Control Unit) to manage the energy to be supplied to some actuators, both fixed and variable frequency. Among the various actuators used in a vehicle and controlled by PWM i.e. diesel pressure regulator, EGR valve actuator, voltage regulator in modern alternators, turbocharger variable geometry regulation actuator, electric fans, etc.

Where To Buy?
No.ComponentsDistributorLink To Buy
1STM32 NucleoAmazonBuy Now

PWM signal generation through Timer in STM32

Let's see now how it is possible to generate a PWM with STM32. In this case, it can be generated using a timer made available by the microcontroller.

STM32 configuration with STCube

In this article, we will see how to configure and write an application to dim an LED connected to an output pin (GPIO) of the STM32F446RE Nucleo board. First of all, let's see how to configure the initialization code with the STCube tool.

Basic Configurations

GPIO selection and configuration

It is necessary to identify a GPIO to associate a timer to generate the PWM. For example, we choose PB3 associated with Channel 2 of Timer 2 (TIM2_CH2). Note that the pin turns orange to remind us of that timer 2 still needs to be configured.

System Reset and Clock Control (RCC) Initialization

  • To initialize the RCC use the following path: “Pinout & Configuration”-> System Core -> RCC. “High-Speed Clock” (HSE) and “Low-Speed Clock” (LSE) select for both “Crystal/Ceramic Resonators”.

Timer 2 Configuration

Now you need to configure timer two which is hooked to pin PB3.

Clock Configuration

We configure the clock tree so that the clock frequency (HCLK) of the microcontroller is 84 MHz, handling frequency divisor and multiplier of PLLCLK. The bus to which the timers are connected (APB1 timer and APB2 timer clocks) is also at 84 MHz.

Timer Configuration

We now know that timer 2 has a clock source of 84 MHz, so every time the clock switches the timer does a count. If we configure it to count to 84 million (it is a 32-bit timer, the Counter must be between 0 and 4294967295) it will take a second. We can set this number to exactly half so that the LED lights up for half a second and turns it off for another half-second. In practice, we will see at the output a square wave that will have a duty cycle of 50% and a switching frequency of 1Hz (too slow not to notice the switching on and off the LED !!). To do what has been said, the timer must be configured as follows:

  1. Enable PWM Generation on Channel 2;
  1. Set Prescaler to 0
  2. Set Counter Mode to “Up”;
  3. Set Counter Period to 83999999;
  4. Set Internal Clock Division to “No Division”;
  5. Set auto-reload preload to “Disable”;
  6. Set Master-Slave Mode to “Disable”;
  7. Set Trigger Event Selection to “Reset (UG bit from TIMx_EGR”;
  8. Set Mode to “PWM mode 1”;
  9. Set Pulse to 0;
  10. Set Output compare preload to “Enable”;
  11. Set Fast Mode to “Disable”
  12. Set CH Polarity to “High”.

Now we are ready to lunch the initialization code and write our application.

The initialization code

In “Private variables” we find TIM_HandleTypeDef htim2, it is an instance to C struct that needs to manipulate the DAC peripheral. In “Private function prototypes” the function prototype used to initialize and configure the peripherals:
/* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_TIM2_Init(void);/* USER CODE BEGIN PFP */
At the end of main() we find the initialization code of System Clock, Timer 2 and GPIO ( as previously selected in STCube):
void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};   /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 2; RCC_OscInitStruct.PLL.PLLR = 2; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } }   /** * @brief TIM2 Initialization Function * @param None * @retval None */ static void MX_TIM2_Init(void) {   /* USER CODE BEGIN TIM2_Init 0 */   /* USER CODE END TIM2_Init 0 */   TIM_MasterConfigTypeDef sMasterConfig = {0}; TIM_OC_InitTypeDef sConfigOC = {0};   /* USER CODE BEGIN TIM2_Init 1 */   /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 0; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 83999999; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) { Error_Handler(); } sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = 0; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM2_Init 2 */   /* USER CODE END TIM2_Init 2 */ HAL_TIM_MspPostInit(&htim2);   }   /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) {   /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOB_CLK_ENABLE();   }   /* USER CODE BEGIN 4 */   /* USER CODE END 4 */   /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ }

On/Off LED with STM32

Now we are ready to write our code in main() to on/off LED.
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); __HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, 41999999); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }

As mentioned earlier we have set the timer two to count up to 84 million, so we know that counting 84 million a second has elapsed. Now let's use the PWM function to make sure that for half a second the LED stays on and the other half a second off. In practice, to generate a square wave with a duty cycle of 50% and a frequency of one second.

We use the function “HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2)” to enable timer 2 to start in PWM mode and the macro “__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, 41999999)” tells the timer which is the value with which to compare the internal count (in this case 41999999) to decide whether the LED should be off or on.

Now we just must connect a led between pin PB3 and ground through a 220OHm resistor to limit the current (if we want to work with a duty cycle of 100%) and compile our application.

Once this is done, we see that the LED will remain on for 500ms second and off for another 500ms as can be seen from the waveform acquired by the PB3.

Since we have chosen a switching frequency of the PWM that is too low (1Hz), we will only see the LED turn on and off and we do not check its luminosity: we will see in the next paragraph how to increase the switching frequency, adjust the duty cycle in order to increase and decrease the brightness.

Dimming LED using PWM in STM32

First, we declare the following define:

#define D_COUNTER 839

Now, we associate it with the field “htim2.Init.Period” of the structure *htim2:

htim2.Init.Period = D_COUNTER;

In this way, we can quickly the number of counts that the timer must do and therefore manage the frequency and duty cycle of our PWM.

This way our timer will count up to 839 in 10us. Consequently, the switching frequency will be 100kHz (clearly exceeding 1Hz !!). Note that as in the previous example we have subtracted 1 from the count value because the timer starts at zero.

Then, we define an unsigned int variable to set the duty cycle:

unsigned int D; //duty cycle In the main() we write; /* USER CODE BEGIN 2 */ D= 10; //it menas duty cycle of 10% HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); __HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, (D_COUNTER/100)*D); /* USER CODE END 2 */

Where (D_COUNTER/100)*D needs to re-proportion the value of the duty cycle to the count that the timer must perform.

Compiling we will see that now the LED will always be on but with low brightness, in fact, the duty cycle is only 10% as can be seen from the generated waveform and the rms value of the voltage given to the LED is about 1.1 Volt (as you can see in the bottom corner of the RMS figure for the green trace). Furthermore, the figure confirms that the duty cycle is 10% both intuitively by looking at the green trace and by reading the measurement at the bottom center (Dty+ = 10,48%).

If we set D=70, the LED will be brighter, in fact the RMS value is about 2.82 Volt (as you can see in the bottom corner of the RMS figure for the green trace). Furthermore, the figure confirms that the duty cycle is 70% both intuitively by looking at the green trace and by reading the measurement at the bottom center (Dty+ = 69,54%).

If we set D=100, the led will be illuminated with the maximum brightness imposed by the limitation of the 220 Ohm resistor. The rms value at the ends of the LED with the resistance in series will be 3.3 Volts (the maximum generated by the GPIO)

Now if you write the following code on while(), we will see that the LED will change brightness every 100ms (in practice it increases, every 100ms the duty by 1% starting from 1% until it reaches 100% and then starts all over again)

/* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ for(D=1; D<=100; D++){ HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); __HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, (D_COUNTER/100)*D); HAL_Delay(100); } /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */

To do this we include the PWM configuration function ( HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); __HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, (D_COUNTER/100)*Duty) in the following loop for(D=1; D<=100; D++) which increases the value of variable D by 1 every 100 ms through the function HAL_Delay(100).

Now we are ready to effectively manage the PWM to control the brightness of a led, but in a similar way, we can control the speed of a DC motor or various actuators.

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir