Smart Coffee Vending Machine using Arduino
Hello geeks, Welcome to our new project. As most readers have already seen the coffee vending machine or maybe you are drinking coffee while reading this article and if you are a tinker or a geek, it must have come to your mind how to make a coffee vending machine on your own. In today's tutorial, we are going to learn how to make a Smart Coffee Vending Machine using Arduino with Proteus Simulation for the same.
We can use this project for an engineering project’s showcase for electronics, electrical engineering students, and can be used in offices as well.
Coffee is the second most popular drink in the world and it is one of the oldest beverages of the world. According to Wikipedia, more than 2 billion cups of coffee are consumed every day in the whole world. As engineers or working professionals, we all know how coffee is very important for us. Having a good coffee makes our day better and refreshes the mood. Research shows coffee drinkers tend to live longer but when keeping it in moderate consumption. And making a good coffee is one of the most skillful jobs and time-consuming processes as we want our coffee in minutes. Now here our project comes to the picture, this smart coffee vending machine can make a good coffee in a couple of minutes. There are various flavors of coffee and our smart coffee vending machine can provide us with 4 different flavors which are the most commonly loved such as Latte, Cappuccino, Espresso, and Cafe Mocha. Here's the video demonstration of this project:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | DC Motor | Amazon | Buy Now |
2 | LCD 20x4 | Amazon | Buy Now |
3 | Arduino Uno | Amazon | Buy Now |
Software to Install:
As we are going to design this project using Proteus Simulation, instead of using real components. As in the simulation, we can figure out the issue which may occur while working on real components and that can damage our components.
Proteus is the software for simulation and designing electronics circuits. As Proteus software has a big database of electronics components but still it does not have few modules in it like Arduino boards or LCD modules etc.
So we have to install the libraries, which we are going to use in this project:
- Arduino Library for Proteus: We have to add the Arduino boards to the Proteus components list.
- LCD Library for Proteus: We have to add the LCD module to Proteus Suite.
You can download this whole project for example Proteus Simulation and Arduino Code, by tapping the below button
Smart Coffee Vending Machine using Arduino
These are required components for Smart Coffee Vending Machine, as follows:
- 20X4 LCD display: It is used to display user-related messages like the state of the vending machine.
- Arduino UNO: It is used as the brain of our project. All operations and decision-making will be done using this microcontroller.
- DC motor: It is used for dispensing the ingredients of coffee and the mixer.
- Buttons: It is used as a user interaction option.
As a suggestion, whenever we make a project, it should be like a product, as it should be user friendly and interactive, so considering that we have used an LCD module to display the messages related to available coffee flavors and their individual prices so that users can easily select them using buttons and DC motors to pour the ingredients related to coffee like water, sugar, coffee powder, and milk, and a mixer for blending the coffee.
We have connected the LCD using an I2C GPIO expander as we have limited GPIO pins to connect other peripherals with Arduino UNO. I2C Gpio expander requires only two pins as we know that I2C uses SCL(Serial Clock) and SDA(Serial Data) pins for communication.
Components Needed:
- Arduino UNO
- LCD display
- 4 Buttons
- 8 Motors
- PCF8574
Components Details
Arduino UNO:
We can use any Arduino development board but here in this project, we have used an Arduino UNO board.
- Arduino UNO is one of the programmable, open-source microcontroller boards of the Arduino family.
- It contains an Atmel’s Microchip ATMega328 or ATMega328P microcontroller which has Harvard architecture 8-bit RISC processor core and 32 KB flash memory.
- Arduino UNO comprises 14 digital I/O pins out of which 6 are PWM pins as well and 6 Analog I/O pins with 10 bits resolution(0-1024).
- Arduino UNO has only 1 hardware UART pin(but we can use other pins also for UART communication using SoftwareSerial library in Arduino), 1 I2C, and 1 SPI.
PCF8574:
We have used this IC as a GPIO expander for our project as we have restrictions on the availability of GPIO pins in Arduino UNO.
- It is an 8-bit I/O, silicon-based CMOS GPIO expander.
- It can be used to write data on the pins and also can read data on those pins.
- It uses the I2C protocol for communication with the master device.
- As we know that I2C protocol uses the slave address to send or receive data from slaves, so for that it has 3 pins A0, A1, A2 for setting the slave address.
- Slave address for PCF8574 starts from 0x20 to 0x27. That means we can add only 8 PCF8574 IC directly to a master controller.
- The following image explains the logic of the slave address of PCF8574.
- It is used for connection for the LCD module with Arduino UNO in our project.
- If you want to learn more about IC PCF8574, you can refer to the datasheet using the following URL: PCF8574 Datasheet
LCD display
The LCD display is used to show the user-related messages in this project.
- LCD is a short form of Liquid Crystal Display which is basically built using Liquid Crystal technology.
- There are different sizes of LCDs available, in this project we have used 20X4 size.
- Here 20X4 signifies that it can display 80 ASCII characters at a time.
- There are 16 pins in the LCD. We will not use every pin of LCD in this project.
- It has 8 data pins, 1 Read/ Write select pin, 1 Register mode pin, 1 Enable pin, 2 pins for backlight, and 2 pins for power supply, 1 contrast control pin.
- There are mainly two types of register in the LCD: Command Register and Data Register.
- When we set the RS(Register Select) pin to logic High then it will select the data register mode and in logic Low, it will select the command register.
- To display the data on LCD we will set the RS pin to logic High.
Proteus Simulation of Smart Coffee Vending Machine :
Now, it's time to start designing the Proteus Simulation of our Smart Coffee Vending Machine.
- Most importantly, ensure that Proteus is installed on your PC and download all the required libraries for Proteus ahead.
- For this project, we are going to need libraries of Arduino and LCD modules.
- Make sure that you have read about how to use libraries in Proteus software.
Let’s create a new project, open the new project in Proteus and import all the required components which we are going to use, and place them within the working area.
- We need the following components, so select all of them from the Proteus component library.
Circuit Diagram and Working:
- Now let’s design our circuit, first place all the selected components in the Proteus Workplace, as shown in the image below:
- We will start connecting the LCD module and PCF8574, as we are using only 4-data pin-mode of LCD.
- After that, we will start the GPIO expander PCF8574 I2C connections, connect the SDA, SCL pins of PCF8574 to Arduino UNO’s SDA, SCL pins which are A4, A5 pins of the development board.
- As we know, we have to set the slave address of PCF8574 using A0, A1, A2 pins. And in this project we are going to use the slave address 0x20, therefore for that, we have to connect all pins to the ground. (As we have already seen in the above PCF8574 addressing image)
- In the next step, we are going to connect the buttons to Arduino digital pins D2, D3, D4, D5 as "Latte", "Cappuccino", "Espresso", "Cafe Mocha" flavors respectively and another terminal of the buttons is connected to ground. As we are going to use the buttons inactive low condition which means, when we press the button it will give us a logical LOW state.
- There may be a doubt in your mind why we have not used any PULL-UP resistors with buttons because we will handle that in our code. Arduino UNO comes with an internal PULL-UP resistor of 20-50 KOhms.
- Now connect the dc motors for each container, Water, Coffee, and Sugar container’s motors are connected with Arduino’s digital pins D10, D12, D11 respectively. Connect the coffee outlet motors for each type of Latte, Cappuccino, Espresso, Cafe Mocha with digital pins D6, D7, D8, D9 respectively. And at last, connect the mixer with the D13 pin.
- As we have mostly completed the wiring part, the first thing which we must make sure of before going to start our simulation is that all components should have adequate power supply and ground. And ground must be common in the whole circuit.
Now we hope you have understood the connections and you have already done it, so it is time to move to the coding part of our project.
Arduino Code for Smart Coffee Vending Machine
If you already know about the syntax and structure of Arduino sketch, it's a good thing, but if you have not been familiarized yet, no need to worry, we will explain it to you step-by-step.
Arduino coding language mostly follow the syntax and structure of C++ programming language, so if you are familiar with C++, then it would be like a cup of cake for you to understand the code but still if you don’t have any background knowledge, you don’t have to worry again, we have your back.
Arduino Coding follows a strict structure, it has mainly two sections. we have to write our code in those two functions.
As we are going to explain the Arduino code, it would be easy to understand if you have opened the code in the Arduino IDE already.
Declaration code:
- When we start our code, we will first include all the required libraries which we are going to use in this project.
- So our first step would be to download the required libraries if they are already not pre-installed in the Arduino IDE.
- Mainly we will use only two libraries, one for LCD display and the other for I2C communication.
- And I2C related functions come in the Wire library which will be pre-installed in Arduino ID, we don't have to install it explicitly.
- For the LCD module, we will use the Liquid Crystal_I2C library that we have to install.
- We can install libraries related to Arduino from the Arduino IDE by going to ‘Sketch > Include Library > Manage Library’. Now in the library manager, we can search for our required libraries. We can install the libraries using zip files also.
- >> Now, as we have installed all the required libraries. Let’s include them in our sketch.
- After that, we will define the pins which we are going to use in our project.
- We have to define them globally so that we can use them in all functions.
- You must be having a doubt why we have not defined pins for I2C.
- Because those pins are pre-defined in the Wire library, we can not assign any other pins for I2C communication.
- Now we will define and declare all the variables which are required in our project.
- There is an array for the price of a coffee with the size of 4, as we will only provide only 4 types of coffees and a string type variable for storing the name of flavors of coffee.
Arduino Setup() Function:
In this Arduino Setup() function, we will write a section of code that will only run once.
- So mostly we will write the declarations, define the type of pins and initialize the peripherals such as the LCD module.
- We want to take user input from the buttons therefore we will declare them as INPUT type.
- We have not connected PULL UP resistors in buttons as you have read above, we will handle that in the code therefore we have declared it as INPUT_PULLUP mode.
- We have declared motor pins as OUTPUT mode because we want to control the motors.
- After that we will initialize the LCD module then we will turn on the backlight of LCD, set the cursor to 0,0 index and using ‘lcd.print()’, we will print the welcome message on the LCD module.
- In the setCursor function, the first argument is used for X-Axis and the second argument is for Y-Axis.
- It will display the welcome message for 1 sec as we have given a delay for 1000 milliseconds after we clear the display.
Arduino Loop() Function:
Arduino Loop function runs after the the
‘void setup()’ function.
- In this section, we will write the code which is required to run in a continuous loop. So we will write our main application code here.
- So when the code reaches the void loop section, first we will display the flavor and the price of the coffee on LCD display as we want to show the user what type of coffee our vending machine makes and the price of those individually.
>> Now we will write the section for reading the user input from the buttons. As we have set that the condition will be true when the button will be logic LOW state.
>> Now when the user will press the button, the state of the button’s pin state will be changed to logic LOW state and then our ‘if condition’ will be true and code and our operation will enter in the ‘if condition’ section.
>> Here we will display to the user the current process stage of the coffee making. So we will clear the LCD display and then set the cursor to 0,0 index. After that we will display the message for collecting the ingredients.
- As we have not cleared the display, it will display the same message.
- After 1 second delay, we will start the water container motor for pouring the water for 2 seconds.
- Thereafter we will set the water’s container pin to LOW and Sugar’s container motor pin to HIGH for 2 seconds, similarly for the coffee’s container pin.
- Now we will start the motor for the selected flavor of coffee for 2 seconds and then stop it.
- As now our selected coffee is getting ready so we will display the message for the same.
- To display any new message, we have to clear our display with pre-occupied text.
- Now we will start the mixer motor for 10 seconds to mix all the poured ingredients.
>> Now our selected coffee is ready. So we will clear the LCD display and set the cursor, and will print the message regarding the prepared coffee with the price of it.
Results/Working:
- Below is the Flow diagram of coffee vending machine:
- Let’s understand the code with an example, we will go with the starting step.
- Power ON the device, the machine will display the welcome message that you can change from that code as per your choice.
- That message will be shown for 1 second thereafter it will clear the display.
- Now it will display the type of coffee as "Latte", "Cappuccino", "Espresso", "Cafe Mocha" and their respective prices.
- Let’s suppose, the user wants to have a Latte today, so he/she will press the button for the same, thereafter our coffee-making process will start.
- The first LCD display will show the message “Wait a Moment Collecting Ingredients” and it waits for 1 second.
- Thereafter it will start pouring the water for 2 seconds, then it will stop that motor.
- After that, it will start to pour sugar for 2 seconds, then stop that motor.
- At last, it will start to pour the coffee for 2 seconds, then stop that motor.
- It will start the motor of the selected type of coffee to dispense the coffee to the container and then it will wait for 1 second.
- Now LCD will display the message for coffee getting ready as "Wait a Moment Your’s Rich Latte is getting ready…” as the user has selected Latte that’s why it shows “Latte is getting ready… “.
- Now we will start the mixer to mix all the ingredients for 10 seconds.
- Again we will clear the LCD display to show the message for prepared coffee as “ Your's Rich Latte is ready. Please Collect it Your's Amount - 5/-”.
- Then it waits for 5 seconds and clears the display and again shows the price and the available types of coffee.
- As Proteus requires the hex file of the code to run the simulation.
- So for that, open the Arduino IDE and please verify your code before making a hex file by clicking on the ‘Verify’ button to remedy any errors.
- To get the hex file from the Arduino IDE click on “Sketch > Export Compiled Binary”.
- Your hex file will be generated successfully now put that hex file to the Arduino UNO board in the Proteus software.
- Everything is now in place, it's time to run the simulation and get a nice virtual coffee.
I hope you have understood the whole working of our smart vending machine project and enjoyed it as well. I think we have explained pretty much everything but still if you have any doubts or improvements please let us know in the comment section.
Thanks for giving your valuable time for reading it.
Introduction to Single Layer PCB
Hello friends, I hope everything's going well. Today, I am going to share the 13th chapter in the PCB learning series, where we will discuss the single-layer PCB in detail i.e. definition, construction, advantages, manufacturing, applications etc. So let’s try to absorb everything about the single-layer PCB:
Single-layer PCB overview:
- Just a quick recall, PCB stands for a printed circuit board having different electrical components connected with the help of pads and tracks of copper foil, incorporated on an insulating material(substrate).
- Single-layer PCBs have only one conductive layer of copper.
- The PCB board itself has a total of 3 layers in single-layer PCB other than the copper layer which are substrate, solder mask, and silkscreen.
- In the past, phenolic aldehyde was used as a substrate but nowadays glass fiber epoxy resin is used because of its flexibility with temperature variations.
Single-layer Definition
- Single-layer PCB refers to a printed circuit board that has only 1 layer of conductive pattern.
- Single-layer PCBs are simple, low-cost and can be designed at home.
- Different materials like glass fiber reinforced epoxy resin with copper foil and a paper mask having phenolic resin with copper foil are used in the manufacturing of single-layer PCB.
Pricing of Single Layer PCB
Now let's have a look at the pricing of Single Layer PCB. As Single Layer PCB is the simplest form of PCB, so it's quite low cost as compared to other PCB types. Let's take the example of JLCPCB Fabrication House, a well-renowned PCB manufacturing company, that offers competitive rates for PCB designing.
- We need to open JLCPCB official site and click on its Order Now page, as shown in the below figure:
- As you can see in the above figure, I have selected 1 for Layers, so I am ordering for Single Layer PCB.
- The size of the Single Layer PCB is 100x100mm and I have placed the order for 5 pcs of PCB.
- For this order, JLCPCB has given me a price of $2.00, so you can see it's quite cheap to design Single Layer PCB.
Construction of single layer
- In 1950, the first single-layer PCB was designed.
- The base material or substrate is made up of fiberglass and is compact in its sense.
- There is a copper layer that has conducting path for various competent on the boards above subtract. Needless to mention, different boards have different copper thicknesses consistent with your needs and demands, defined in ounces per sq. ft.
- On one hand, there is a solder mask layer on the top of the copper foil. The layer mainly protects the copper foil from insulating which avoids conduction in case direct contact happens with some conducting material.
- On the opposite hand, there's a silkscreen layer on the highest of all layers, which is especially in adding characters and symbols on the board, so it’s easy to have a far better understanding of the board.
Types of singles layer PCB
There are some types of single-layer PCB. We are going to explain them below concerning its manufacturing material.
- Single-layer rigid PCB
- Single-layer flexible PCB
- Single-layer rigid-flex PCB
- Single-layer high-frequency PCB
- Single-layer aluminum-backed PCB
1 Single-layer rigid PCB
- Single-layer rigid PCB is a type that is made up of a rigid material such as fiberglass.
- These PCBs are hard and prevent the circuit from bending and breaking.
- It's used in applications i.e. calculators, power supplies etc.
A single-layer rigid is shown in the figure below.
2. Single-layer flexible PCBs
- A single-layer flexible PCB has a flexible substrate like polyimide in its manufacturing.
- Single-layer flexible has so many advantages over single-layer rigid PCBs. But the cost is too high for its fabrication. A single-layer flexible PCB is shown below.
A single-layer flexible PCB
3. Single-layer high-frequency PCBs
- Circuits emitting a frequency in Gigahertz, single-layer high-frequency PCB is used.
- Polyphenylene oxide (PPO) or Teflon Material is used in single-layer high-frequency PCBs.
- If you are selecting High-frequency single-layer PCB, you should consider many aspects such as dielectric loss, thermal expansion, water absorption, etc.
- A single-layer high-frequency PCB is shown in the below figure
A single layer of high-frequency PCBs
4. Single-layer rigid-flex PCBs
- Single-layer rigid-flex PCB is a combination of both Rigid PCB and Flexible PCB.
- Single-layer rigid-flex PCBs have so many advantages over single-layer rigid and flexible PCBs such as it reduces the size and weight of the overall PCB.
- Single-layer rigid-flex is shown below figure.
A single layer rigid flexes PCBs
5. Single-layer aluminum-backed PCBs
- Single-layer Aluminium-backed PCB has an aluminum substrate.
- Aluminum-backed PCB is used with the thermal insulating material for the heat to dissipate by Aluminium.
- Single-layer aluminum-backed PCBs are shown below in Figure.
A single layer aluminum backed PCBs
Steps for the manufacturing process of PCB
- There are a lot of processes involved in the construction of a PCB.
- Almost 12-20 machines are used in the manufacturing of a simple single-layer PCB depending upon the demand of the customer and the requirement of the product.
- For ease of understanding, single layer PCB manufacturing process can be defined as
1. Cutting & Cleaning of PCB sheet:
- The circuit pattern is drawn on PCB using the photolithography technique in which warm iron is used to draw a pattern from photo paper to PCB.
- Photo paper is removed by washing PCB having photo paper on it.
- After drawing the pattern, check connecting nodes, jumpers, and docking points for additional components.
2. Etching with ferric chloride:
- prepare a solution of ferric chloride with water in a 1:3 ratio and dip board into it.
- The processing speed in this step is affected by the temperature of the solution and the thickness of the foil. You have to moderately heat the solution to speed up the process.
- Again clean the board with alcohol.
3. Drilling holes on the single layer PCB:
- now holes are drilled according to the requirement of the product. Clean the board again.
4. Soldering holes and lubricate sides of the board:
- at this stage, first of all, holes are soldered to make them able to make connections between components and layers.
- After soldering holes lubricating the sides of the board with a cover layer is done.
5. Testing of the final board:
- at this stage, the final prepared board is tested for whether it is ready or not.
6. Packaging:
- in the end, the final packaging is done and now the single layer PCB is ready to be delivered.
Common mistakes in single layer PCB manufacturing:
Following mistakes are made by designers during the manufacturing 9f the single-layer PCB.
1. incorrect conducting paths width:
- The maximum allowable width of the conducting path should be drawn to avoid voltage loss, overheating of the conductor, and low mechanical strength.
2. improper power circuit designs:
- When the width of the track is not made maximum then problems like output ripples, output voltage loss, and interference have to be faced. To avoid these problems track width should be maximum.
3. grounding problems:
- To avoid grounding problems, a separate insulating layer is used for wiring.
4. small gaps between copper:
- Gaps between copper conductors deposited on the board should not be so small, this can lead to the violation of the integrity of the board.
5. large no of holes on one plate:
- By increasing no of holes, no of conductive paths increases, and this, in turn, increases resistance.
Application for single-layer PCB
It is no doubt that single-layer PCBs are very simple. But single layer PCBs are used still in such a lot of complex devices. Some devices are listed below.
- Single-layer PCBs are used in digital cameras circuits.
- Single-layer PCBs used in coffee-making machine circuits.
- Single-layer PCBs are used in soiled state drives which are mostly used in the power industry.
- Single-layer PCBs are utilized in switching relays which are mostly utilized in the automotive and power industry.
- Single-layer PCB used in vending machine circuits.
- Single-layer PCBs used in digital calculators which are consist of only a single PCB.
- Single-layer PCB used in photocopy and printer machine circuits.
- Single-layer PCB is used in radio and stereo equipment circuits.
- Single-layer PCB is utilized in digital microwave timer circuits to modify on or off the oven timely.
- Single-layer PCB is used in led lighting circuits for making power light circuits.
- Single-layer PCB used in digital and analog power supplies circuits.
- Single-layer PCB used in surveillance machine circuits.
- Single-layer PCBs are used in sensors products circuits.
- Single-layer PCBs are used in packing machines to achieve the high targets of fast-packing and are mostly used in packing industries.
- Single-layer PCBs are used in timing circuits to switch on or off the machine timely.
Advantages of single-layer PCB
There are some advantages given below of single-layer PCB.
- The single-layer PCs is very easy to design and has a lower probability to make incorrect design because the single-layer PCBs is very simple.
- Its price is very less especially when it is ordered in bulk quantity as compared to the other types of PCBs.
- It is easy to understand for anyone because it is a very simple circuit
- Because its components are installed on only one side there for its a required lower jumper o compensate for the circuit.
- Its drilling, soldering, de-soldering, and components inserting process is very easy because single layer PCBs only consist of a single layer.
- Its design circuit required a very short time to make a simple design.
- There is less probability of short-circuiting and producing noise because its components are installed at some distance from each other.
- For fault tracing and repairing of this single layer PCB need less time.
- When we compare the single-layer PCBs to the other types of PCBs. It is more reliable and efficient.
- The installation of single-layer PCBs is very easy.
Disadvantages of single layer PCB:
- Single-layer PCBs have many advantages regarding cost, efficiency, and ease of installation but they still can not be used for any circuit because of their limitations. The limitations or disadvantages of using single layer PCB are discussed below:
The simplistic design and small space:
- Single-layer PCB has a very simple design and this simplistic design presents as the hurdle in complex devices that require a lot of components and connections.
- To mount a large no of components, large space is required but single layer PCBs don’t have enough space to mitigate this problem.
Slow speed and low operating capacity:
- As they have a limited no of components so their speed is slow, their power is also slow.
- Due to their low speed, they have low operating capacity.
Large size and high weight:
- To add components to the single-sided PCB you need to enhance PCB into its dimensions. As it is single-sided so that’s why we can not add layers. By enhancing PCB into its dimensions, the size of PCB.
- The enhanced size and large no of components ultimately enhance the weight of single-layer PCB.
Conclusion:
- At the end of it all, we can conclude that single-layer PCBs have unique advantages, benefits, and applications but as an end-user, you always have to choose which type of PCB you need.
- In modern technology advancements, single-layer PCBs are now in an underestimated situation but are still used.
- With a low budget and volumes of specific design single-layer PCB is the right choice when compared to the other types of PCB.
That’s all for today’s article. I hope you have enjoyed the article and made grip on the understanding points. However, if you still face any skepticism regarding single-layer PCB then please feel free to leave your questions in the comment section. I will provide an answer to these questions to the best of my knowledge and research skills. Also, provide us with your innovative feedbacks and suggestions you improve the quality of our work and provide you content according to your needs and expectations. Stay tuned! Thank you for reading this article.
How to use ADC with STM32?
An Analog to Digital Converter (ADC) converts a continuous signal (usually a voltage) into a series of discrete values ??(sequences of bits). The main features are:
- Resolution (in analog terms): It is the minimum variation of the analog input voltage that can determine the variation of the LSB, that is of the least significant bit of the output code. Since the quantization step Q corresponds to the LSB, it can be said that the resolution coincides with the quantization step Q (and therefore is measured in Volts). We can say that the quantization step Q corresponds to the LSB because two contiguous quantization bands, each of amplitude Q, are identified by codes that differ only for the least significant bit.
- Resolution (in digital terms): It is the number n of bits present at the converter output, that is the number of bits with which the converter encodes a sample of the analog input signal. As the number of bits of the converter increases, the number of quantization bands increases and (with the same full-scale value VFS) their amplitude decreases, an amplitude which is nothing more than the step Quantization Q. If the quantization step narrows, the smaller the voltage variation necessary to determine the variation of the LSB, i.e., of the least significant bit of the code, becomes the exit. So, saying that a converter has many bits is equivalent to saying that the voltage variation necessary to make the LSB vary is small. The image below shows the 3 bits ADC input-output characteristics.
- Full-scale voltage: It is the range, that is the maximum excursion, of the input voltage. Typical dynamic values are between 10 Vpp ( pp peak to peak) and 20 Vpp, unipolar or bipolar.
- Types of response: in general, ADCs have a response of a linear theoretical type of response, but there are also types with a logarithmic response.
- Accuracy: indicates the goodness of the conversion depends on it. The error made by the ADC is usually measured. This error consists of two components: a quantization error and a non-linearity error.
- Sampling frequency: A sampling is an operation with which the input signal is discretized over time, transforming it into a succession of values, samples in fact, which will subsequently be digitized. The simplest way to extract values is to use a switch, in series with the signal, which closes and opens at defined and equidistant intervals. The smaller this interval, called the sampling step (Ts), the more faithful the reconstruction of the signal will be starting from its samples. Likewise, too small a sampling step leads to a waste of resources (measurement time, memory for data storage). A sampling of the signal generally indicates not only its discretization over time but also its maintenance until the next closing of the circuit-breaker. These two phases are realized by special circuits called Sample & Hold (S / H).
There are different types of ADCs, the most common are listed below (illustrating their operation is not the purpose of this article):
- A direct conversion ADC (Flash ADC)
- A Successive Approximation Register (SAR) ADC
- One dual ramp ADC (Dual Slope or integration)
- A pipeline ADC
- A tracking ADC (delta-coded)
Generally, STM32 microcontrollers have at least one ADC (a SAR ADC) with the following characteristics:
- Resolution: ADCs have a resolution of up to 12 bits with a maximum conversion frequency of 2.5 MHz, with 18 multiplexed channels among which 16 can be available for measurements of external signals, the other two are for internal measurements (temperature and voltage).
- Conversion Time and Conversion Groups: The conversion time can be individually programmed for each channel. There are 8 discrete times conversions for each ADCCLK clock frequency (Fc), these times range from 1.5 to 239.5 cycles.
Fc = ADCCLK / (12.5 + Number of cycles)
Each ADC has two conversion modes: “regular” and “injected”.
- The "regular" mode allows you to specify a channel or a group of channels to be converted in turn one after the other. The conversion core can consist of more than 16 channels, and the order in which the channels must be converted can also be programmed. The conversion can be initiated by software or by a hardware event consisting of a series of timer signals or by line 1 of the EXTI. Once the conversion has started, you can carry out continuous conversions, or you can operate discontinuously by converting a selected number of channels and then stopping the conversion pending the triggering of the next core. At the end of a conversion the result is stored in a single register (result register) and an interrupt can be generated. The ADC1 has a dedicated DMA channel that can be used for transferring the converted value from the result register to a memory buffer. Through this method, an entire conversion cycle can be copied into memory, eventually obtaining a single interrupt generated by the DMA. To further speed up the conversion, a double-sized buffer can be used to generate two interrupts: one when the first half has been filled (first conversion cycle) and the other when the second half is filled (second conversion cycle). This mode can be combined with the "DMA circular buffer mode" to handle multiple conversions with hardware.
- The second conversion mode is called the “injected group”. It is able to carry out the conversion sequence up to a maximum of four channels, which can be triggered by a software or hardware event. Once triggered, it will stop the conversion of the regular group, carry out its sequence of conversion and then will allow the regular group to continue the conversion. A conversion sequence can be configured in this mode. Unlike the regular group, in this mode, each result has its own register (result register) and its own offset register. This last register can be programmed with a 16-bit value automatically deducted from the ADC result.
Furthermore, the "Dual Conversion Modes" can be active:
In the STM32 with almost two ADCs and it is, therefore, possible to perform different conversion modes: in these types of conversion the ADC2 acts as a slave while the ADC1 acts as a master allowing 8 different types of conversion.
- Injected Simultaneous Mode and Regular Simultaneous Modes: These two modes synchronize the regular and injected group conversion operations on two converters. This is very useful when two quantities (current and voltage) have to be converted simultaneously.
- Combined Regular / Injected Simultaneous Mode: This mode is a combination of both the regular and injected modes and allows us to have a synchronized conversion sequence.
We are now ready to write a first simple example using the ADC peripheral. The goal is to measure the voltage in a voltage divider composed of a fixed value resistor and a potentiometer (so that by moving the potentiometer cursor, the voltage to be read varies) we begin by configuring our peripheral with STCube Tool. For this project, we will use the NUCLEO STM32L053R8. This board has only one ADC with 16 channels and a resolution of up to 12bit.
Now we’ll see the configuration step by step:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | STM32 Nucleo | Amazon | Buy Now |
ADC channel selection
We have to flag IN0 to activate Channel 0, then we can configure the peripheral. Channel 0 is on GPIO PA0 as we can see in the picture below:
ADC setting
We select the ADC_prescaler equal to 4, resolution to 12bit (maximum of a resolution, we can choice between 6, 8, 10 and 12 bits), “right data alignment” (we can choose between right and left alignment), and “forward” as scan direction (we can choose between forward and backward).
For this first example we’ll hold disabled Continuous, Discontinuous conversion and DMA mode. Furthermore, the ADC sets, at the end of single conversion, the EoC (End of Conversion) flag.
ADC Regular conversion mode
We select 12.5 Cycles as sampling time (in this way the sampling frequency is 320 kHz obtained from the formula described above), the start of conversion is triggered by software. Furthermore, for this application the watchdog is disabled.
After the generation of the initialization code with STCube, we can find in our project the ADC configuration. As for every peripheral, the HAL library defines the dedicated C structure, for the ADC defines “ADC_HandleTypeDef”.
In our case the “ADC1” is the instance that points to our ADC. The structure “ADC_InitTypeDef” is used to handle the configuration parameters. In our example is generated as follow:
static void MX_ADC_Init(void)
{
/* USER CODE BEGIN ADC_Init 0 */
/* USER CODE END ADC_Init 0 */
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC_Init 1 */
/* USER CODE END ADC_Init 1 */
/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/
hadc.Instance = ADC1;
hadc.Init.OversamplingMode = DISABLE;
hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc.Init.Resolution = ADC_RESOLUTION_12B;
hadc.Init.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc.Init.ContinuousConvMode = DISABLE;
hadc.Init.DiscontinuousConvMode = DISABLE;
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc.Init.DMAContinuousRequests = DISABLE;
hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc.Init.LowPowerAutoWait = DISABLE;
hadc.Init.LowPowerFrequencyMode = ENABLE;
hadc.Init.LowPowerAutoPowerOff = DISABLE;
if (HAL_ADC_Init(&hadc) != HAL_OK)
{
Error_Handler();
}
/** Configure for the selected ADC regular channel to be converted.
*/
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC_Init 2 */
/* USER CODE END ADC_Init 2 */
}
The function
HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) needs to initialize the peripheral and define the clock and the GPIO ( in our case PA0).
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hadc->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC GPIO Configuration
PA0 ------> ADC_IN0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
}
}
/**
* @brief ADC MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hadc: ADC handle pointer
* @retval None
*/
The function
HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) needs to de-initialize the peripheral.
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
{
if(hadc->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspDeInit 0 */
/* USER CODE END ADC1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_ADC1_CLK_DISABLE();
/**ADC GPIO Configuration
PA0 ------> ADC_IN0
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
/* USER CODE END ADC1_MspDeInit 1 */
}
}
Before describing the code let's see how to make the connections on the development board.
We need a 10kOhm potentiometer and a 2kOhm resistor. The potentiometer is connected between 3.3V and 2kOhm resistor, the common point is connected to PA0, and finally, the other end of the 2k Ohm resistor is connected to the ground pin.
Acting on the potentiometer we will see the read voltage vary from 3.3 Volt to about 0 Volt.
Now let's dive into the code:
In the Includes section we add the header file of main.
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
In “Private variables” section we find “ADC_HandleTypeDef hadc” as previous said is an instance to C structure to handle the ADC peripheral. Then, we add three variables:
- Resolution defines the number of steps used by ADC (12bit = 2^12 -1= 4095) is a constant integer;
- vs defines the maximum voltage to read, is a constant float;
- volt is the variable where the voltage value read by the ADC is store ( is a float variable)
/* Private variables -----------------------*/
ADC_HandleTypeDef hadc;
/* USER CODE BEGIN PV */
const int Resolution = 4095;
const float Vs =3.300;
float volt;
/* USER CODE END PV */
Then, we can find the protype of function to handle the peripherals and resources initialized (system timer, GPIO, and ADC).
/* Private function prototypes -----------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
Finally, the main starts.
In the first part we call functions to initialize the peripherals and resources used:
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_ADC_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
In the second part, that is, inside an infinite loop (while (1)) there is the function to start the conversion of the ADC, read the data and save it in the variable volt and finally stop the conversion wait for a second and start with the conversion and so on.
while (1)
{
/* USER CODE END WHILE */
HAL_ADC_Start(&hadc);
if(HAL_ADC_PollForConversion(&hadc,10)==HAL_OK)
{
volt=HAL_ADC_GetValue(&hadc)*Vs/Resolution;
}
HAL_Delay(1000);
HAL_ADC_Stop(&hadc);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Now, once our code has been compiled, we can debug it in real-time, just press the "spider" icon (see figure below) and see how the volt variable varies by acting on the potentiometer.
Once we have clicked on the debug button, at the top right, we can select the "live expression" window and add (by writing the name in the table) the variable to be monitored.
Now we can start the debug by clicking on the “Resume” button (on the top right) or by pressing the F8 key (on our keyboard).
We are now ready to read our voltage value. We will see that by acting on the potentiometer we will read the voltages in the whole range considered.
Some measures are shown below:
- First reading volt=1.3188 Volt
- First reading volt=3.29919 Volt
- First reading volt=1.02158 Volt
So, that was all about How to handle ADC in STM32 Microcontrollers. In the next tutorial, we are going to work on STM32 DAC operations. Till then take care !!!
STM32 SPI Communication
The SPI (Serial Peripheral Interface) protocol, or rather the SPI interface, was originally devised by Motorola (now Freescale) to support their microprocessors and microcontrollers. Unlike the I2C standard designed by Philips, the SPI interface has never been standardized; nevertheless, it has become a de-facto standard. National Semiconductor has developed a variant of the SPI under the name Microwire bus. The lack of official rules has led to the addition of many features and options that must be appropriately selected and set in order to allow proper communication between the various interconnected devices. The SPI interface describes a single Master single Slave communication and is of the synchronous and full-duplex type. The clock is transmitted with a dedicated line (not necessarily synchronous transmission that has a dedicated line for the clock) and it is possible to both transmit and receive data simultaneously. The figure below shows a basic connection diagram between two peripherals that make use of the SPI interface.
From the figure, it is immediately possible to notice what has just been said, namely that the communication generally takes place between a Master and a Slave. The interface presents 4 connection lines (excluding the ground however necessary), for which the standard SPI is also known as 4 Wire Interface. The Master starts the communication and provides the clock to the Slave. The nomenclature of the various lines in the SPI interface is normally as follows:
- MOSI: Master Output Slave In. Through this line the master sends the data to the selected slave;
- MISO: Master Input Slave Output. Through this line the slave sends the data to the master;
- SCLK: Serial Clock is generated by the master device, so it is the master starts the communication and the clock synchronizes the data transfer over the bus. The SPI clock speed is usually several MHz (today up to 100 MHz);
- SS: Slave Select or CS (Chip Select) generated by the master to choose which slave device it wants to communicate with (it must be set to a low logic level). SS (or CS) is not indispensable in all applications.
In addition to this standard nomenclature, there are other acronyms.
For example:
- The MOSI line is also called: SDO (Serial Data Out), DO (Data Out), DOUT and SO (Serial Out)
- The MISO line is also called: SDI (Serial Data In), DI (Data In), DIN and SI (Serial In)
- The Clock line is also called: CLK, SCK (Serial Clock).
- The Enable line is also called: CS (Chip Select), CE (Chip Enable)
The first advantage in SPI communication is faster communication, instead, the first disadvantage is the presence of the SS pin necessary to select the slave. It limits the number of slave devices to be connected and considerably increases the number of lines of the master dedicated to SPI communication as the connected slaves increase.
To overcome these problems, the devices in the daisy chain can be connected (output of a device connected to the input of the next device in the chain) as shown in the figure below where a single slave selection line is used.
The disadvantages, however, are the lower updating speed of the individual slaves and signal interruption due to the failure of an element.
We can use this communication to put in communication our micro-controller with different peripherals as Analog-Digital Converters (ADCs), Digital-Analog Converters (DACs), EEPROM memories, sensors, LCD screen, RF module, Real Time Clock, etc.
The STM32 micro-controllers provide up to 6 SPI interfaces based on the type of package that can be quickly configured with STCube Tool.
STCube Tool initializes the peripherals with HAL (Hardware Abstraction Layer) library. The HAL library creates for SPI (as all peripherals) an C structure:
It is so defined:
Where the main parameters are:
- • Instance: is the pointer variable it describes the SPI that we want to use. If we use SPI1, the name of the instance is SPI1.
- • Init: is an instance that points to the structure ( SPI_InitTypeDef) used to initialize the device. We will discuss the structure SPI_InitTypeDef shortly.
- • pTxBuffPtr, pRxBuffPtr: are pointer variables that point to an internal buffer. They are used to store the data during the communication when the programmer handles the SPI in interrupt mode (we will see forward)
- • hdmatx, hdmarx: are the pointer variable to instances of the DMA_HandleTypeDef struct. They are used when the programmer handles the SPI in DMA mode (will see forward).
As just said to initialize the SPI peripheral to be used, it is necessary to use the struct SPI_InitTypeDef. It is defined as follow:
When we use the STcubeMX to initialize the SPI peripheral we are modifying this structure
In details:
- Mode specifies the SPI operating mode, and Direction specifies the SPI bidirectional mode state. It is very easy to configure in STCubeMx. If we want to configure the SPI1. We can find SPI windows in Pinout&Configuration -> Connectivity. Here we can select between the SPI available. Now is possible to select the communication mode (Master, Slave, half-duplex, full-duplex, etc.) as follow:
If the slave supports, the full-duplex communication can be enabled.
- DataSize indicates the SPI data size. The user can select 8bit or 16bit.
- CLKPolarity defines if the serial clock steady state is LOW or HIGH.
- CLKPhase defines if the bit capture (trigger) takes place when the clock is on the falling edge or rising edge.
- NSS: if selected "Output Hardware" the slave select signal is managed by hardware otherwise is managed by software using the SSI bit.
- BaudRatePrescaler can be select the Baud Rate prescaler value.
- FirstBit indicates if data transfers start from Most Significant Bit (MSB) or Last Significant Bit (LSB).
- TIMode specifies if the TI mode is enabled or not.
- CRCCalculation: to enable to activate the CRC calculation.
- CRCLength: to define the length of CRC data.
- CRCPolynomial specifies the polynomial (X0+X1+X2) used for the CRC calculation. This parameter is an odd number 1 and 65535.
By enabling the SPI and the chip select pin, the pins available on the microcontroller are automatically chosen to manage this interface (but they can be changed by looking for the alternative functions of the different pins of the microcontroller). For example, in our case the following pins are selected:
- PA4 SP1_NSS
- PA5 SP1_SCK
- PA6 SP1_MISO
- PA7 SP1_MOSI
Now you can generate the initialization code. Before being able to write the first code to manage this communication interface, it is necessary to understand the functions that the libraries provide and the different communication modes.
As for other communication interfaces, the HAL library provides three modes to communicate: polling mode, interrupt mode, and DMA mode.
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | STM32 Nucleo | Amazon | Buy Now |
STM32 SPI Communication in Polling Mode
Using the SPI in Polling Mode is the easiest way, but it is the least efficient way as the CPU will remain in a waiting state for a long time. HAL library provides the following functions to transmit and receive in polling mode:
- HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Master receives data packets in blocking mode (polling mode).
The parameters are:
- hspi is a pointer to a “SPI_HandleTypeDef” structure. “SPI_HandleTypeDef” structure includes the configuration information for SPI module.
- pData is a pointer to data buffer
- Size is the amount of data to be sent
- Timeout is the timeout duration
- HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Master transmits data packets in blocking mode (polling mode).
If the slave device supports, the full-duplex mode:
- HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout)
Master transmits and receives data packets in blocking mode (polling mode).
The parameters are:
- hspi is a pointer to a “SPI_HandleTypeDef” structure. “SPI_HandleTypeDef” structure includes the configuration information for SPI module
- pTxData is a pointer to transmission data buffer
- PRxData is a pointer to reception data buffer
- Size is the amount of data to be sent
- Timeout is the timeout duration
STM32 SPI Protocol in Interrupt Mode
Using the SPI in Interrupt Mode, also called non-blocking mode. In this way, the communication can be made more effective by enabling the interrupts of the SPI in order to receive, for example, signals when the data has been sent or received. This improves CPU time management. In applications where all the management must be deterministic and it is not known when an interrupt can arrive, these can potentially manage the time management of the CPU, especially when working with very fast buses such as SPI. We can enable the SPI interrupts directly during the initialization with STCube Mx.
HAL library provides the following functions to transmit and receive in interrupt mode:
- HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Master receives data packets in non-blocking mode (interrupt mode).
The parameters are:
- hspi is a pointer to a “SPI_HandleTypeDef” structure. “SPI_HandleTypeDef” structure includes the configuration information for SPI module
- pData is a pointer to data buffer
- Size is the amount of data to be sent
To handle the interrupt needs to write our code in the callback:
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef * hspi)
{
// Message received .. Do Something ...
}
- HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Master transmits data packets in blocking mode (interrupt mode).
To handle the interrupt needs to write our code in the callback:
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef * hspi)
{
// Message transmitted.... Do Something ...
}
If the slave device supports, the full-duplex mode:
- HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
Master transmits and receives data packets in non-blocking mode (interrupt mode).
To handle the interrupt needs to write our code in the callback:
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef * hspi)
{
// Message transmitted or received.. .. Do Something ...
}
STM32 SPI Communication in DMA Mode
Using the SPI in DMA Mode the SPI bus can be used at its maximum speed, in fact, since the SPI must store the received and transmitted data in the buffer to avoid overloading it is necessary to implement the DMA. In addition, use by DMA mode frees the CPU from performing "device-to-memory" data transfers. We can easily configure the DMA during the initialization using STCubeMx :
In this case, the DMA is enabled in normal (we can use it in circular mode) mode both in transmission and reception
HAL library provides the following functions to transmit and receive in DMA mode:
- HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Master receives data packets in non-blocking mode (DMA mode).
The SPI device receives all bytes of data in the buffer one by one until the end in DMA mode. At this point, the callback function will be called and executed where something can be done.
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef * hspi)
{
// Message received .. Do Something ...
}
- HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Master transmits data packets in non-blocking mode (DMA mode).
The SPI device sends all bytes of data in the buffer one by one until the end in DMA mode. At this point, the callback function will be called and executed where something can be done.
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef * hspi)
{
// Message transmitted….. Do Something ...
}
If the slave device supports, the full-duplex mode:
- HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size,)
Master transmits and receives data packets in non-blocking mode (DMA mode).
The SPI device sends or receives all bytes of data in the buffer one by one until the end in DMA mode. At this point, the callback function will be called and executed where something can be done.
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef * hspi)
{
// Message transmitted or received.... Do Something ...
}
We are now ready to handle an SPI communication with STM32.
Write and Read an I2C EEPROM with STM32
EEPROMs (Electrically Erasable Programmable Read-Only Memories) allow the non-volatile storage of application data or the storage of small amounts of data in the event of a power failure. Using external memories that allow you to add storage capacity for all those applications that require data recording. We can choose many types of memories depending on the type of interface and their capacity.
EEPROMs are generally classified and identified based on the type of serial bus they use. The first two digits of the code identify the serial bus used:
- Parallel: 28 (for example 28C512) much used in the past but now too large due to having many dedicated pins for parallel transmission
- Serial I2C: 24 (for example 24LC256)
- Serial SPI: 25 (for example 25AA080A)
- Serial - Microwire: 93 (for example 93C56C-E/SN)
- Serial – UN I/O: 11 (for example 11LC040-I/SN)
Now we will see how to write or read data on an I2C EEPROM like 24C256C. This serial EEPROM is organized as 32,768 words of 8 bits each. The device’s cascading feature allows up to eight devices to share a common 2-wire bus. It is available in various 8-pin packages
The device can be used in applications consuming low power. The device is available in all standard 8-pin packages. The operating voltage is comprised of between 1.7V and 5.5V.
- Serial Clock (SCL) is an input pin used to control data flow. On the positive-edge clock, the data is inserted into the EEPROM device, while on the negative edge clock, the data is processed out of the EEPROM module.
- Serial Data (SDA) is a bidirectional input-output for serial data transfer. It is an open-drain pin.
- Device Addresses (A2, A1, A0) are input pins to set the device address. These pins allow you to customize the address of the device within the I2C bus. They must connect directly to GND or to VCC (hard wired). If these pins are left floating, the A2, A1, and A0 pins will be internally pulled down to GND. When using a pull-up resistor, it recommends using 10kOhm or less.
- Write Protect (WP) is an input pin. We can perform normal writing operations, by connecting it to GND; When connected directly to VCC, all write operations to the memory are restricted. If this pin is left open/floating, it will be pulled down to the GND(internally). When using a pull-up resistor, it recommends using 10kOhm or less.
- Device Power Supply (VCC)
- Ground (GND)
In our example, we connect A0, A1, A2 directly to VCC in this way the device address is 1010111 (in general A0, A1, A2 identify the last three significant bits of the device address 1 0 1 0 A2 A1 A0) is 0x57 in Hexadecimal. The 4 most significant bits are preset (Control Code), the A0, A1, A2 are Chip Select Bits.
Now we start with our project using STNucleoL053R8 and STCube to generate the initialization code. Below is shown the connection
- A0, A1, A2 are connected directly to VCC in this way the device address is 1010111 (in general A0, A1, A2 identify the last three significant bits of the device address 1 0 1 0 A2 A1 A0) is 0x57 in Hexadecimal.
- WP is connected to the ground to allow the normal write operation
- SCL and SDA are connected to PA8 and PA9 respectively of STM32L053R8
So, we configure the I2C1 using STCube and leave all configuration as it is and we will operate in polling mode.
In GPIO setting select PA9 (SDA) and PA8 (SCL).
Now we create a new STM32CubeMX project with the following steps:
- Select File > New project from the main menu bar. This opens the New Project window.
- Go to the Board selector tab and filter on STM32L0 Series.
- Select NUCLEO-L053R8 and click OK to load the board within the STM32CubeMX user interface
Then the tool will open the pinout view.
- Select Debug Serial Wire under SYS, for do it click on System Core (on the topo right) and then select SYS and finally flag on “Debug Serial Wire”.
- Select Internal Clock as clock source under TIM2 peripheral. To do this click on Timers and then select TIM2. Now go to clock source and select through the drop-down menu “internal clock”.
- Select and enable in “Connectivity” the I2C1 and left all configuration as it is and we will operate in polling mode.
- Configure in GPIO setting PA9 (SDA) and PA8 (SCL) to manage the I2C communication.
- Check that the signals are properly assigned on pins:
- SYS_SWDIO on PA13
- TCK on PA14
- SDA I2C1on PA9
- SCL I2C1on PA8
- Go to the Clock Configuration tab and no change the configuration in order to use the MSI as input clock and an HCLK of 2.097 MHz.
- Select Timers -> TIM2 and change the Prescaler to 16000 and the Counter Period to 1000.
- In the Project Manager tab, configure the code to be generated and click OK to generate the code.
Our project has been initialized by STCubeMX. In the /Core/Src/main.c we will find our main where we will write the main body of our program.
Now let’s see what the code generator did:
First of all, we find the “Include” section we can add the library needed.
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
In our case we can add also “stm32l0xx_hal.h” library to be able to use HAL library (I2C HAL library included)
#include "stm32l0xx_hal.h "
#include "Var.h "
#include "Funct.h "
In “Private variables” has been defined two privates variable htim2 and hi2c1;
- - htim2 as first parameter an instance of the C struct TIM_HandleTypeDef;
- - hi2c1 as first parameter an instance of the C struct UART_HandleTypeDef.
/* Private variables ---------------------------------------------------------*/
TIM_HandleTypeDef htim2;
UART_HandleTypeDef hi2c1;
unsigned short int address; // eeprom address
unsigned char EEP_pag = 0x00 // EEPROM page
unsigned char EEP_pos = 0x00 // EEPROM position
unsigned char rdata = 0x00 // to store the data read from EEPROM
In “Private function prototypes” we find the protype of function to initialize the System Clock, GPIO, timer and peripheral:
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_TIM2_Init(void);
static void MX_I2C1_Init(void);
This function has been generated automatically by STCubeMx with the parameter selected.
The main contains the initialization of the peripherals and variables, before the while loop the code call the function Write_EEPROM() and Read_EEPROM() to write and read a data in a specific address of the EEPROM. these functions were written in EEPROM.c, a C file added to our project in the src folder.
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();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
address = 0x00 << 8 | 0x00 // eeprom page 0 , position 0
// Now we want to store 10 in page 0x00 and position 0x00 of EEPROM
Write_EEPROM(address, 10, 0)
// Now we want store in rdata variable the content of cell memory 0x0000
rdata = Read_EEPROM(address, 0)
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
}
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Furthermore, we have added two header files and one c file:
- Var.h contains the declaration of global variables:
/** Var.h
* Created on: 27 ott 2021
* Author: utente */
#ifndef INC_VAR_H_
#define INC_VAR_H_
extern unsigned char buf[20];
extern int i;
#endif /* INC_VAR_H_ */
- Funct.h contains the prototype of the user function
/** Funct.h
* Created on: 28 ott 2021
* Author: utente */
#ifndef INC_FUNCT_H_
#define INC_FUNCT_H_
extern unsigned char Read_EEPROM(unsigned int, unsigned char);
extern void Write_EEPROM(unsigned int, unsigned char, unsigned char);
#endif /* INC_FUNCT_H_ */
- EEPROM.c contains the function written by the user to handle the writing and reading operation with EEPROM:
- unsigned char Read_EEPROM(addr, device) reads from cell memory address (addr)and store the content in dato.
- void Write_EEPROM(addr, dato, device) writes data (dato) to memory address (addr).
/** Serial.c
* Created on: Oct 29, 2021
* Author: utente */
#include "stm32l0xx.h" // Device header
#include "stm32l0xx_hal_conf.h"
#include "stm32l0xx_hal.h "
#include "Var.h "
#include "Funct.h "
extern I2C_HandleTypeDef hi2c1;
unsigned char Read_EEPROM(unsigned int addr, unsigned char device)
{
unsigned char page;
uint8_t dato;
page=0xAF; // due to chip select bits setting
HAL_I2C_Mem_Read(&hi2c1,page, addr, I2C_MEMADD_SIZE_16BIT, &dato,1,5);
return dato;
}
void Write_EEPROM(unsigned int addr, unsigned char dato, unsigned char device)
{
unsigned char page;
page=0xAF; //due to chip select bits setting
HAL_I2C_Mem_Write(&hi2c1,page, addr, I2C_MEMADD_SIZE_16BIT, &dato,1,5 );
while(HAL_I2C_IsDeviceReady(&hi2c1, 0xA0, 1, HAL_MAX_DELAY) != HAL_OK);
HAL_Delay(10);
}
Now we are ready to compile and run the project:
- Compile the project within IDE.
- Download it to the board.
- Run the program.
So, that was all for today. I hope you have enjoyed today's lecture. In the next tutorial, we will have a look at How to perform SPI Communication with STM32. Till then take care and have fun !!! :)
Creating the First Ladder Logic Program in PLC Simulator
Hello friends, I hope you all are doing great. In today's tutorial, I am going to create the first Ladder Logic Program in PLC Simulator. It's 3rd tutorial in our Ladder Logic Programming Series. In our previous tutorial, we have installed PLC Simulator and now we can say our lab is ready to learn and practice. So let us get to work and get familiar with the ladder logic components.
After this article, you will have a complete understanding of PLC contact and coil including their types and possible causes. Because they are the building block of any rung of a ladder logic program. So let us start with ladder logic rung components.
Ladder Logic Contact/Input
- In ladder logic programming, a contact represents the input of the system and it could be a button press by the operator or a signal from the sensor.
- Examples of contacts are toggle switches, pushbuttons, limit switches, sensors like level, pressure, proximity switches et cetera.
- There are two types of contacts normally used, which are:
- Normally Open Contact.
- Normally Closed Contact.
1. Normally Open Contact
- A normally open contact is Open/LOW by default and it gets Closed/HIGH by pressing or getting signal from any external source i.e. sensors.
- As shown in the first row of figure 1, the contact is open or disconnected by default and then the operator turns it to closed or connected status, shown in the second row.
Figure 1: Normally Open (NO) contact [1]
- Let's understand it with its equivalent electrical circuit, imagine you wire a switch in series to a lamp as in figure 2.
- After you complete wiring and connect L1 to the hotline and L2 to the neutral.
- See that at the start the lamp is off until you come and press the pushbutton then it is turned on.
- So, here the switch is acting as a normally open switch.
Figure 2: Normally open contact or switch in a circuit [2]
2. Normally Closed Contact
- A normally closed contact is at HIGH/Closed state by default and gets Low/Open if pressed by the operator.
- Figure 3 shows the symbol of normally close contact.
- So it flows current at the very beginning and disconnects the current flow by being pressed by the operator to become like an open circuit or contact.
Figure 3: Normally Closed (NC) contact
- For elaborating the behavior, let us wire a circuit that is depicted in figure 4.
- The contact is connected in series with a lamp to convey the current and let it turn on.
- So initially, the lamp started in ON status when the contact is not activated by the user.
- And, when the operator activates the contact it turns off.
- So, the switch is acting as a normally closed switch.
Figure 4: Normally close contact or switch in a circuit [2]
Ladder Logic Coil/Output
- The coil in ladder logic represents the actuator or the equipment we aim to turn on or off.
- A good example of a coil is a lamp and motor.
- Typically it is located at the most right side of the ladder logic rung.
- Same as contact has two types based on the initial state and the next state after user activation, also the coil comes in two forms which are:
- Normally Active Coil
- Normally Inactive Coil as shown in figure 5.
- An inactive coil is normally not energized until it gets connected by connecting the left side to the hot wire thanks to a contact.
- In contrast, active or negated coil type comes initially On status or energized and turned off when the left side is connected to the hot wire.
Figure 6: active and inactive coil
Create First Ladder Logic program
To our fortune we no longer need wires and devices to practice what we have been learning together, thanks to the simulator, which we have installed in the previous lecture. Let's create a new project on TIA portal software and test it with the PLCSIM simulator.
Creating a new project on TIA Portal
As this is the first time to use our software to write and simulate a ladder logic code, let us go step by step creating our very first project on the TIA portal software.
- You now get in the Lab by opening the TIA portal and hitting create a new project as shown in Figure 7.
- On the right, you just need to name your project like “new project” and you may leave the default location of projects or alter the data to the project file location as you prefer.
Figure 7: Creating a new project on TIA portal software
- You will have to select a PLC controller whom we are going to use. So you simply select one PLC controller as shown in figure 8 and click okay.
Figure 8: adding PLC controller
- The wizard now goes on asking you to add a program block.
- You can see in Figure 9, the default program block is the Main block which has the main program and other blocks are additional blocks.
- So for now let us go with the essential requirements for our program which is the main block and you just double click on the Main block to go to the next step.
Figure 9: adding program block
I just want to say well done! And congratulate you that you are now all set to start writing your first ladder logic rung as shown in Figure 10. It shows on the left the project components including hardware i.e. devices and controllers, networking devices, configurations, program blocks etc. The most important thing you need to know for now is the program blocks which contain the only main block and other blocks as the project needs. Now! please stare your eye toward the right to see the icon bar that contains every ladder symbol. You can see the contact of normally open and normally closed. Furthermore, you should see the coil and more which we are going to go into detail later in our upcoming articles of PLC tutorial.
Figure 10: starting writing ladder code
Writing First program on the TIA Portal
- WOW! You are a superb learner as I can see you can follow figure 11 and by dragging a contact and dropping it on the blue line, you added a start button of normally open (NO) contact type.
- For identifying contacts and coils, the compiler assigns a unique name & address to each component and can recognize it anywhere in the program.
- Therefore, you just set the address and name for every component you add to your rung.
- The address of components has a specific format that is very logical and easy to understand.
- For example, the contact address “I0.0”, the first character is “I” which denotes input and it is followed by the number of the input module in the rack that holds all inputs and outputs modules.
- Then a number of the input channel as each input module has many channels.
- For instance, an eight channels input module can have numbers from 0 to 7 while 16 channels input module can have numbers from 0 to 15.
- A period is used to separate between the number of input modules and the channel number.
- So by set address I0.0, this refers to the very first channel in the first input module in a PLC rack.
- In addition, a name is used as a tag to easily identify the input i.e. “start” to refer to a start switch.
- Similarly, you add a stop button of the type normally closed (NC) with address I0.1 which means the second input channel in the first input module.
- Furthermore, you double-clicked the coil for the motor and set address Q0.0 which means the first output channel in the first module.
- I know you wonder what is “Q”? Yes! “Q for denoting output like “I” is denoting an input. Well done!. Now let us enjoy simulating the very first code you just have done yourself.
Figure 11: writing the first ladder logic program
Compiling Ladder Logic Program
- Like any programming language, the first thing to do after writing a program is to compile, to make sure it is free of error and ready to be downloaded into the PLC controller to run.
- Figure 12 shows the very simple steps to compile your program by clicking the compile icon in the toolbar which is highlighted in yellow.
- And you can notice in the lowest window below the results of compilation in blue showing that the code is free of error and warnings.
Figure 12: compiling ladder logic program
- To let you imagine how the compiler can help you to find the error location and type, we have done one mistake in the code and compiled as shown in figure 13.
- You can notice that compiler is telling the rung that has the issue which is network 1.
- In addition, the message clarifies the error by telling, you missed the required data for operand which is the address of input is missing.
Figure 13: Example of an error in compilation
Simulating First ladder logic program
- After compiling our program successfully, now the next step is to download it to the PLC controller.
- Yes for sure our simulator will act as the plc controller.
- So, by clicking the simulator button on the toolbar, the simulator window comes out and also another window to download the program to the controller as shown in figure 14.
Figure 14: calling simulator and downloading program
- You simply hit the “start search” button to search for the connected PLC controller.
- In our case, the simulator will appear in the search results.
- So, you just select it and click load to proceed with the wizard of downloading your program as shown in figure 15.
Figure 15: the wizard of downloading the ladder program to plc controller
- By reaching the last screen and clicking finished you have downloaded your first program to the simulator.
- Well done! And let's move forward with simulating our first program to validate our code and enjoy tracing the logic behavior same as a real-time plc controller.
But wait! Will you continue pressing the push button for our motor to keep running? For sure No, there should be a way to let it keep running by just hitting the button thanks to the latching technique.
Simulating our first PLC Program
- After downloading the program and pressing the run button on the very small window of the PLCSIM simulator, we can notice the run/stop indicator turned on in green showing the running status of the PLC as shown in figure 16.
- Now, click on the monitor icon on the toolbar highlighted in yellow on the most right of figure 16, you can notice the rung shows every status of each contact and coil in our program.
- I am very happy to reach this point at which you can see the normally closed contact is showing a green connection as we described above and the normally open contact showing disconnect status and can not wait until the operator press it down to connect and energize the output.
- But how do we press the buttons or switches when we are simulating? There is no physical switches or button to press!!! No friends that are not the case. Let us see how that can happen thanks to the great simulator that we have between our hands.
Figure 16: Simulating the first PLC code
Simulating the operator behavior
- This section is more than exciting, it shows you how the simulator not only does imitate the PLC controller but also it has the facility to imitate devices, switches, push buttons besides showing outputs’ status and values.
- In addition, we will go further in plc programming to show the series and parallel connections of contacts in branches and utilize simple logic AND, OR, NOT to form simple and complicated logics.
- The first way to set inputs on and off is by right-clicking on any contact and modifying the status to 0 or 1 as shown in figure 17.
Figure 17: forcing the inputs on and off
- The other way is to go to the expert mode of the full functional simulator, by hitting the which icon on the very small simulator window.
- A full version of the simulator control window will open up, where you can add inputs and outputs on the right as you can see in figure 18(left side).
- You can notice the inputs have an option in form of a check button to set it on or off.
- As a result, the contact will be turned into the selected status and the program perform according to the new status and the designed logic of your program as shown in figure 18 on the right side.
- It shows the output coil is turned to true status and highlighted in green.
- At this point, I would like to thank you my friends to follow up on our PLC tutorial series and let us move forward to learn further and do more practice with our simulating lab.
Figure 18: operating using simulator full control window
What’s next
Now, how do you see your progress so far? I can see you have just completed the most basics of ladder logic programming. You are now very familiar with the ladder basic components, using the editor to write a ladder logic program, simulate your work for verifying your logic correctness. So you are doing progressively and that’s great to hear that. However, we still have a lot to learn to master ladder logic programming. For example, using blocks like timers, counters, mathematical blocks, data comparison etc. So we hope you have enjoyed what we have reached so far in our PLC tutorial and please get yourself ready for the next part. In the next part, you will learn about types of Timers and how you set their configuration and how you utilize them to achieve the timing-based tasks accurately.
Installing PLC Simulator for Ladder Logic Programming
Hello friends, I hope you are doing very well! In today's tutorial, we will set up a simulation environment for Ladder Logic Programming. It's our second tutorial in Ladder Logic Programming Series. In our previous tutorial, we have seen a detailed Introduction to Ladder Logic Programming and we have seen that this programming language is used for PLC controllers.
As PLC is an Industrial Controller, it comes with built-in relays/transistors(with protection circuitry) and thus is quite expensive as compared to microcontrollers/microprocessors i.e. Arduino, Raspberry Pi etc. Moreover, if you are working on a real PLC, you need to do some wiring in order to operate it. So, in order to avoid these PLC issues at the beginning, instead of buying a PLC one should work on a PLC Simulator. Using PLC Simulator, we can program our PLC controller and imitate its real behavior without having the hardware, saving both time and money as now we don't need to buy a new PLC and can start right away.
To sum up, by completing this article you will have a complete lab that includes the software you are going to use, the simulator that plays as the hardware, and certainly, you will be familiar with installing a PLC programming environment by which you can program, configure, moving the program to the PLC hardware, retrieving the program from the PLC to the software environment, and testing your program on the simulator. In addition, we are going to test our environment setup with a very basic program and take the chance to show you how to program, configure, upload, and test your program on the simulator.
Setup PLC Simulator
As I mentioned in the last tutorial, we are going to work on Siemens PLC throughout this tutorial, as it's one of the most common PLC controllers. So, we are going to install PLC Environment designed by Siemens and is called Total integrated automation (TIA). Along with this software, we will also need to install a PLC Simulator called S7 PLCSIM, again designed by Siemens. At the time of this writing, their most stable versions are 15.1, so download these two applications from below links:
Installing TIA Software
After downloading the TIA and the simulator, we extract the package by double click on the file we downloaded, and then it will be self-extracted and initiate the setup wizard as shown in the below figure. The image shows many steps. Moving our eyes from left to right, on the first part, the downloaded package has been extracted. In the next part of the picture in the middle, the setup wizard gets started by general settings in which you can set the preferred language and select the preferred installation location. The third part shows the setup goes on progressively and takes you to the end of the installation of the software IDE. Congratulation! You know have the programming software IDE installed on your computer and the good news is, all packages of Siemens go with the same scenario, you download the software package files. Click them to be extracted. And then, the installation wizard is launched by the end of file extraction which is a very systematic and easy way.
Figure 2: TIA portal version 15.1 setup wizard
Installing the PLC simulator
Well done so far! After having the programming software IDE completed, the next step is to install the simulator package which is PLCSIM version 15.1. Download PLCSim from the above link and then double-click the downloaded file of the simulator package as shown in Figure 3 to start extracting the packed file. You will be asked for the language and the location you prefer to have the installation folder. So you can leave it as the default or go with your preferences.
Figure 3: PLC simulator PLCSIM version 15.1 package extraction
After file extraction has been completed, the setup wizard will start automatically as shown in Figure 4 with the general setting screen by which you can set the preferred language and the location to install the simulator software. So you can use the default setting or update with your preferred choices.
Figure 4: the simulator setup general settings
Figure 5 shows the simulator setup configurations screen which helps you to configure and customize your installation. In this configuration screen, you can go with the typical options of installation in which all software components are selected to be installed or you can customize your installation to select or deselect components of the package. And by hitting the next button of this window, the installation will go on as shown in figure 6 until the end of the installation. During the installation progress, Siemens show off the features you may find in the software and the facilities you will enjoy by using this software. At the end of the installation, the wizard will request you to restart your computer now or later for completing the setup wizard by saving settings and registry values related to the installed software as shown in figure 7. That’s great! As for now, you have everything is ready and you are all set to get started and enjoy practice and learning the ladder logic programming and simulating your work.
Figure 5: the simulator setup configurations
Figure 6: the simulator installation screen
Figure 7: Simulator setup completion screen
Checking the setup environment
Before going any further let us check the successfulness of the installation process of the software and PLC simulator. Simply go to start and open TIA portal 15 and S7-PLCSIM you will see the software opening with no problem as shown in Figures 8 and 9. In figure 8, you can see options to create a new project or open an existing project. Also, there is an option to migrate projects from one version to another version by upgrading or downgrading the version of the projects. In addition, you can enjoy the welcome tour to know about the software programming tools and be familiar with its components. In addition, there is an option to check the installed software to validate the packages you select to include within your installation. for any further information you can click help to search and inquiry about any doubts.
Figure 8: Opening the TIA 15 software for testing installation successfulness
Moving to the S7 PLCSIM simulator software, as you can see in Figure 9, it is a very smart and simple interface. It shows a power button by clicking it you can shutdown the PLC controller or turn it on. Also, all indicators like the real PLC controller are included. You can see the RUN/STOP indicator. In addition, the ERROR indicator blinks red for any faults with the CPU of the PLC. In addition, you can see the run and stop buttons to start and stop the controller. Also, the MRES button to reset the PLC to the default values at any time. In addition, there is a detailed interface of the S7 PLCSIM simulator as shown in Figure 10. You can launch the detailed or maximized interface of the simulator by hitting the top-right icon on the shortcut window version of the simulator.
Figure 9: Opening the PLC simulator PLCSIM 15 for testing installation successfulness
The shortcut or the small version of the simulator shows the basic functions of the simulator like starting and stopping the controller or resetting the PLC and showing the status of the controller i.e. Run, stop, in fault status. But, the maximized or the detailed window simulator interface shows more options and facilities of the simulator. For example, you can create a simulation project to link it with a PLC project. Showing status of all input and output channels on the Input and output modules. In addition, it enables you to set and reset any of the inputs as we will elaborate in detail later in the next articles.
Figure 10: Opening the PLC simulator PLCSIM 15 in detail mode
Validating the PLC Simulator
After completing the installation successfully of the programming tools software TIA version 15.1 and the simulator PLCSIM version 15.1, it should be validated to make sure all components are installed and working properly. Let us validate by going through the functions and wizard. You now get in the Lab by opening the TIA portal and hitting create a new project as shown in Figure 11. On the right, you just need to name your project like for example let it be “first_ladder_prog” and you may leave the default location of projects or alter the data to the project file location as you prefer.
Figure 11: Creating a new project on the TIA portal
By hitting create, the creating project wizard comes out as shown in figure 12. As you can see you have many options to do on this screen like configuring the hardware, designing visualizations by designing and programming a human-machine interface (HMI) screen, motion control, or writing a ladder logic program. As for now do not worry about all these options as they are all not our scope in this series except those are relating to ladder logic programming like writing program option and configuring PLC device and network which we will come to them later in the next articles. For testing the installed software, you can simply select write a plc program for now.
Figure 12: creating project wizard
By choosing to write a PLC program, the wizard takes us to add the controller on which we are going to run the designed program as shown in Figure 13. If you are not familiar with the type of PLC controller models and hardware for now. That is not an issue because we are here to learn Ladder logic programming which is general for most PLC controllers of all brands i.e. Siemens, Schneider, Rockwell Automation, Allen Bradley, Beckhoff, WAGO, et cetera. So, for now, let us for testing purposes select S7-1200 which is one of Siemens PLC controllers to use in our project. By hitting the yellow small cross icon to add a device. You will see the list of the Siemens controllers that have appeared. For each controller, you can see many versions. Each version represents firmware for example, by selecting S7-1200 CPU 1211C AC/DC/RLY, you will see three versions. Each version represents a specific controller CPU in the market i.e. the selected one if of firmware ver 4.2 as shown in figure 14. By seeing this long list of CPUs and models, that means the software has been installed successfully and is ready to be used in our projects. So congratulation for successfully setting up the working environment for our Lab of ladder logic programming and being ready for utilizing this environment including programming software TIA 15.1 and simulator S7 PLCSIM version 15.1 in our learning and practice.
Figure 13: adding PLC controller wizard
Figure 14: selecting S7-1200 CPU v4.2
What’s next?
We are now all set to write our first ladder program on the TIA software and enjoy simulating our work on the S7 PLCSIM. In our next tutorial, we will write our first ladder logic program on the PLC simulator. Thanks for reading.
Everything You Need To Know About Anodizing Aluminum Colors
Manufactured parts need a quality surface finish and visual appeal before releasing them to the client or market. Although there are different methods of applying the surface finish, anodizing aluminum colors produce the best results.
There is a wide range of aluminum anodizing colors to choose from; therefore, product developers need to know how to color match before releasing the end product. Let’s examine more on anodizing aluminum parts, how to color anodized aluminum and the common anodized aluminum colors.
What is Aluminum Anodizing?
Anodizing is an electrolytic process that produces excellent mechanical properties to enhance aluminum parts' durability and visual appeal. Manufacturers use the anodizing process for corrosion resistance to prevent surface scratches and improve surface hardness, making it an ideal foundation for painting or coating.
The aluminum parts are coated using a wear-resistant oxide layer which meets the aesthetic requirement of most users.
What are The Types of Anodizing Processes?
Manufacturers use three common types of anodizing processes, Type 1, Type 2, and Type 3. Each method differs due to the coating intensity.
This anodizing process is a “lighter” alternative. It uses chromic acid as the electrolyte. During the electrochemical process, the positive particles from the aluminum part form microscopic grooves, which are oxidized to form an oxide layer. Aluminum parts made via this process have better corrosion and heat resistance.
This is the most common method of anodizing aluminum parts. Instead of chromic acid, this process uses sulfuric acid, which is more potent and produces better positive aluminum particles than Type 1. The oxide layer becomes thicker; therefore, the parts have better paint retention properties.
The common color options for this process include blue, red, brown, purple, green, gold, black, and grey.
Type 3 is the ideal one for hard coating and making heavy aluminum products. It uses a higher voltage and sulfuric acid.
How to Color Aluminum Parts Using Anodizing
The anodizing aluminum colors are very different from the ones used in powder coating or painting. The colors will depend on the grade, size, and finish tapes. Here's the process.
The anodizing process begins with cleaning the aluminum part with detergent and rinsing tanks. The part is then etched to give a matte, polished and shiny surface finish. The etching and brightening are done to remove any trace amounts of metal. The material removed depends on the size, shape, temperature, and solution pH.
After cleaning, you need to build the oxide layer on the aluminum part. Depending on the coating intensity you want to achieve, you can use Type 1, 2, or 3 anodizing processes. Once the piece is suspended in the electrolyte, you need to keep in mind that the shape and size of pores depend on the metal alloy.
In addition, the depth of the pores will depend on the electric voltage, tank temperature, time in the tank, and solution concentration.
Manufacturers add anodized aluminum colors in four ways, dip coloring, electrolytic coloring, interference, and integral coloring.
With dip coloring, the part is placed in a tank containing a dye. Once the dye is absorbed into the pores, the surface is boiled in de-ionized water to stop further reactions. Although there are many coloring variants, they are not UV resistant.
On the other hand, with electrolytic, the part is immersed in a solution containing metallic salts. These salts fill the pores to form a UV-resistant layer. However, the colors are limited to brown and black.
Interference coloring works by enlarging the pore structure. The metals are then deposited, which results in blue, green, and yellow to red colors. These colors form because of optical interference effects. Integral coloring combines coloring and anodizing by adding bronze and black shades.
Once the aluminum part is completely dyed, the last step is sealing it off to preserve the color. This sealing process protects the part from absorbing undesired molecules.
How Do You Color Match With the Aluminum Parts
There are several possible colors for anodizing aluminum. For effective results, the product developer needs to understand the concept of color matching. Let’s take a look at some of the critical factors you should look out for when matching colors.
To achieve the best aluminum reflective properties, the part of the film is essential. Use a sample with the same finish when color matching.
When anodizing aluminum parts, looks out for the grade. Each aluminum grade has a different color variant and shade, which could affect the color matching.
-
The Part’s Crystalline Structure
The crystalline structure affects the reflective properties of the aluminum part. Therefore, before you color match, check that the reflective angle is the correct one.
The dyes affect the color variation. When product developers use more dyes, there’s an increase in color variation. During layering, this variation also differs.
Benefits of Anodizing Aluminum Parts
If you anodize your parts, here are some advantages.
Anodized aluminum parts have a visually appealing look. This makes them popular with users because they are market-ready.
The oxide layer from the anodizing process protects the aluminum parts from corrosion. This makes them durable than other parts which have had powder coating or painting.
Summary
After manufacturing is done, it’s essential to have a quality surface finish. There are different anodizing processes that product developers can use. It’s also vital to choose the best anodizing aluminum colors according to the aluminum part. This makes it easier to color match and get the best end product.
Anodizing has benefits such as boosting the product's aesthetic value, enhancing the surface finish, and increasing durability. Therefore, it's an essential step in manufacturing aluminum parts for any industry.
A detailed Guide on PCB Fabrication Process
Hello friends, I hope you all are doing great. Today, I am going to share the 10th chapter in the PCB learning series. So far, we have studied the basics of PCB i.e. What is PCB? Main Types of PCB, techniques to mount components on PCB etc. Now, we are ready to have a look at the complete PCB Fabrication Process.
So, in today's tutorial, I am going to share a detailed guide on PCB Fabrication Process. We will discuss everything related to it i.e. How PCB boards are manufactured? Which material is used to fabricate printed circuit boards? etc. But before starting the Fabrication PRocess, we first have to understand a few terms/features. So, let's get started:
RoHS-compliant PCB
- RoHS stands for Restriction of Hazardous Substances.
- EU ban the use of lead under the legislation RoHS. So, in PCBs, lead can't be used.
- RoHS-compliant PCB means that PCB is free from lead, Mercury and other heavy toxic metals.
PCB Lamination
- Laminates are prepared, first controlling pressure and temperature for cloth or paper with a thermoset resin and then a final integral piece of uniform thickness is formed.
- Its size can be up to 4×8 feet.
- Desired thickness can be achieved by controlling cloth weaves, thickness and resin percentage.
- Some important characteristics of the laminate are:
- strength of fire retardant
- dielectric constant(e) of the laminate
- the loss factor of laminate
- tensile and shear strength of the laminate
- the glass transmission temperature and
- the z-axis expansion coefficient.
Different dielectrics are used to obtain different insulating values depending on the requirement, which are:
- Polytetrafluoroethylene(Teflon)
- FR-1, FR-2, FR-3, FR-4, FR-5,and FR-6
- CEM-1, CEM-2, CEM-3, CEM-4, andCEM-5.
Here are a few of the factors affecting the laminate quality:
- Size of the board.
- Increasing frequencies.
- Uneven distribution of fiberglass glass or other filler.
- Bubbles and thickness variation in resin.
- Variations in the dielectric constant.
Key Substrate parameters
- The circuit board substrates are made up of dielectric composite materials.
- The composites contain
- matrix(epoxy resin)
- reinforcement(glass fibers, paper etc.)
- filler (ceramics)
Reinforcement has two major classes of materials
- woven: these are cheaper but have a high dielectric constant that is not suitable for many applications.
- non-woven: these are expensive but suitable for RF and analog applications.
Key parameters of substrates are:
- thermomechanical(tensile and shear strength, glass transition temperature and thermal expansion)
- electrical(tracking resistance, dielectric constant, dielectric strength, breakdown voltage etc.)
- others(moisture absorption)
- At a transition temperature, thermal expansion increases because the resin in the composite becomes soft. Below transition temperature, thermal expansion decreases and matches with copper and glass. Above transition temperature, a very high thermal expansion exerts mechanical overload on the board components.
- Expositions to high temperatures and repeated soldering can be the reason for the failure of the plating, especially with thick boards.
- Dielectric substrate constant depends upon the material used and the frequency(decreases with the increase in frequency). Signal propagation speed depends upon dielectric and phase distortion depends upon frequency. So flat dielectric constant vs characteristics frequency is important. The transmission line impedance is inversely proportional to the frequency therefore faster edges of signals reflect more than the lower edges of the signal.
- At maximum voltage gradient, material suffers from breakdown is determined through dielectric breakdown voltage.
- Tracking resistance means how the material resists high-voltage electrical discharges creeping over the surface of the board.
- The amount of electromagnetic energy from the signals in the conductor, that is absorbed in the board material is called loss tangent. It is important for high frequencies. The cost of the board increases by choosing low-loss material(expensive) in high-frequency digital design.
- When the material is exposed to high humidity or water, moisture absorption occurs. Both resin and reinforcement absorb water. Absorbed water can cause degradation of key parameters. It affects tracking resistance, dielectric parameters and dielectric constant. Absorbed water can cause cracks during heating and soldering.
Common Substrates
- FR-2, FR-4, aluminum or insulated metal substrate( IMS) and flexible substrates(Kapton and parallax) are the commonly used materials as the substrate.
- FR-1, FR-3, FR-5, FR-6, G-10, G-11, CEM-1, CEM-2, CEM-3, CEM-4, CEM-5, PTFE(Teflon), RF-35, alumina and polyimide are rarely used as a substrate.
Copper thickness
- Copper thickness is the weight of copper per area. Its unit is ounce/square foot. (1 ounce/ square foot = 34 micrometers thickness).
- A heavy copper layer means 3 ounces of copper per foot. It is used for high currents and to dissipate heat.
- In FR-4 substrate 1oz copper/feet is the common thickness. Other options are also available.
- Metal core boards use thicker copper(35 micrometers) for high-power devices.
PCB Circuit properties
- Trace is made up of a flat but narrow
copper foil and its resistance should be low. Its resistance is
determined by its length, width, and thickness.
- In multilayer PCB, one layer is made up of solid copper that is used for power and shielding return.
- In microwave circuits, to attain consistent impedance stripping or microstrips of transmission lines are used.
- HDI PCBs have vias or tracks with a diameter of under 152 × 10^6 m.
Safety measurements
Some safety measurements should be considered, i.e.
- flammability
- electrical tracking
- maximum operating temperature
- heat deflection
Old Technique for PCB Manufacturing
In the beginning, PCBs are designed on a clear mylar sheet having a photomask.
- First, component pins/pads are laid out on the mylar and then traces are routed to connect with the pads.
- Self-adhesive tape is used to make traces.
- In mylar layout, pre-printed non-reproducing grids are used.
- The final photomask is produced onto blank copper-clad boards having photoresist coating using a photolithographic technique.
Modern PCBs are produced by adopting the following steps.
PCB Fabrication Process
PCB manufacturing consists of many complex steps.
1. PCB Computer-aided Design(CAD):
- CAD software are used to create the software image of the PCB design.
- Commonly used PCB design software are Eagle, Altium Designer, OrCAD, KiCAD, Proteus etc.
- Online CAD software are also available i.e. EasyEDA.
-
Once the design is finalized, the CAD software generates the Gerber files, which include detailed information about drill drawings, copper tracking layers, component notations apertures, components labeling etc.
2 Panelization:
- Panelization is the process of adding a PCB design multiple times in a single PCB board.
- If you want mass production, the best practice is to create a panel of your PCB design.
- It reduces the cost and manufacturing time. (We will cover PCB panelization in our next chapter)
3 Copper Pattern Printing
- On the copper foil layer, the PCB design generated from CAD software is printed using black ink, it acts as a
protective mask for the copper under design traces/pads.
-
The remaining unwanted copper has no black ink and a process called etching removes it, as it's unprotected by the design mask.
- Some other techniques used to create copper patterns:
- Silkscreen printing
- Photoengraving
- PCB milling
- Laser resist ablation
- Laser etching
4 Chemical etching:
- The process of submerging the board into the ferric chloride solution is called chemical etching.
- The function of etching is to remove copper from all the surfaces not protected by the resist.
5 Lamination:
- Note the via, visible as a bright copper-colored band running between the top and bottom layers of the board.
[TEPImg9]
- A stack of material is laminated in a press by applying heat and pressure for a certain time. Multi-layer PCBs have trace layers inside the board.
6 Drilling:
- Drill bits are used to drill holes through PCB. It is made up of solid-coated tungsten carbide.
- Holes can be made conductive by electroplating. These conductive holes are used to electrically connect the layers of PCBs.
7 plating and coating:
- PCBs are plated with solder, tin or gold over nickel.
8 Solder Resist
- Areas that do not need to be soldered are covered with solder resistance.
9 legend printing:
- After the solder resists is done, a legend is printed on both sides of the PCB.
- Silkscreen printing, liquid photo imaging, and inkjet printing are the three methods to print legends on PCB.
10 Bare board test:
- Boards without components are tested for shorts and open. It is called the bare board test.
11 Assembly:
- Assembly is the process of stuffing bare boards with electrical components.
- After assembling, many tests are performed on the PCB. If it fails any test, means it needs rework.
12 Protection and Package
- For protection, a conformal coating is done to avoid leakage of current and corrosion.
- After all the protection checks, the final product is placed in a package.
Precautions
- Based on the required circuit, the PCB board dimensions are decided.
- Components and heat sinks are also positioned carefully.
- Decide the no of layers, ground and power planes as a power plane acts to encounter a ground plane, so shouldn't be together.
- Signal planes should be on external layers, especially if both AC and DC involve in the circuitry.
- High-frequency signals are routed in the internal layers between ground & power planes for attaining optimal EMI performance.
- Routes copper thickness, dielectric layer thickness and trace
width are used to determine the line impedance. To route signals, normally three striplines are used named:
microstrip, stripline and dual stripline.
- During components and vias placing on the PCB board, heat effects and geometry should be taken into account.
- If you are placing an order on a PCB manufacturing company, make sure you provide the final Gerber files.
How to order for PCB Manufacturing?
There are many online PCB Fabrication Houses available, offering PCB
& PCBA manufacturing services. We are going to take the example of JLCPCB Fabrication House. Let's see How to place an online PCB Fabrication order on JLCPCB company.
- First of all, open the official website of JLCPCB
Fabrication House.
- They have placed an online Quote Calculator, where you need to
enter all your PCB requirements and it will give you the cost and time
required to design it.
- As you can see in the above figure, I have placed an order of 5
PCBs and the size of each PCB is 100x100mm, and I am getting a price of
$2.
- As you increase the quantity of PCB boards, the price per board reduces.
- JLCPCB
is a well-renowned PCB Manufacturing House and always provides quality work at a nominal price.
APPLICATIONS OF PCB:
- In electronics: used in computers, home appliances, communication systems etc.
- In industry: used in power, measuring and industrial equipment.
- In medical: used in scanning, monitoring and surgery equipment.
- In the automotive industry: used in navigation, media devices, control systems and proximity monitors.
ADVANTAGES OF PCBs:
- Inexpensive/ cheaper.
- High volume production.
- Hold the components easily.
- Highly reliable.
- Automated soldering is possible.
So, that was all for today. In the next lecture, we will have a look at the PCB Panelization Process. I hope you have enjoyed today's lecture. Thanks for reading.
Why Flexible PCBs are expensive than other PCB types?
Hello friends, I hope you all are in good health. Today we will discuss a detailed overview of flexible PCB, its definition, types, advantages and manufacturing. We will also discuss why we need flexible PCB? We will discuss its uses and the reason for its high price, as it's expensive than other PCB types. I will try to deliver you my best knowledge about flexible PCB so you will clear understanding of flexible PCB. So let’s try to absorb everything about flexible PCB.
Flexible PCB overview
- For irregular-shaped locations, it was difficult to place hard substrate PCBs. So, as necessity is the mother of invention similarly difficult locations and irregular surfaces are the mother of flexible PCB invention.
- Before the 1950s flexible PCBs are not in common use but now they are used everywhere like in ATM keypads and smartwatches. Now let us have a look at the proper definition of FPCB.
Flexible PCB definition
- The board that is made up of flexible plastic substrate usually polyester, polyimide or thin sheets of glass are called flexible printed circuit boards or FPCBs.
- FPCBs have the ability to change their shape because they can twist and bend easily. In some devices, both rigid and flexible PCBs are incorporated to produce the desired functionality.
- FPCB should not be so flexible that the board breaks down during folding or twisting.
Flexible PCB Pricing
Let's discuss the pricing of Flexible PCB and here I am going to take the example of an online PCB Fabrication House named PCBWay. It's a well-renowned PCB house and provides competitive rates with a quality product.
- If you open the PCB Calculator of PCBWay and select Rigid-Flex PCB at the top, you will get a similar result:
- Now, here I am going to select Flexible PCB and I am going to place an order of 10 PCBs, each of size 10x10mm.
- In order to get the quote, we need to click on the Calculate Button and here's the price:
- Now you can see the price for 10 pcs is $125 and it's quite expensive as compared to normal rigid PCB.
- PCBWay provides the best rates for PCB manufacturing and if you check on any other site, you will get even higher rates.
Types of FPCB
- FPCB has a few common types listed below:
- Single-sided FPCB
- Double-sided FPCB
- Multi-layer FFPCB
- Rigid-flex PCB( RFPCB)
- High Density interconnects FPCB.
Single-sided FPCB
- It contains a conductive layer of copper on only one side of the PCB.
- They are used in applications that need highly flexible circuits.
Double-sided FPCB:
- It contains a copper layer on both sides of the PCB. The layers are made connected by vias or by plate through holes( PTH).
- Double-sided FPCB is popular for its ease of manufacturing.
Multilayer FPCB:
- In the multi-layer FPCBs, multi-layer PCBs are connected by vias or PTH.
- It may contain more than 10 conductive layers of copper.
- They are used in designs that require PCBs with high-density connectors.
- Using more layers in flexible PCB design adds to the cost of FPCB.
Rigid-flex printed circuit board:
- In RFPCB, flexible layers are integrated with the rigid layers and PTH technology is used to assemble circuit boards.
- Small Interconnect areas are created by using both rigid and flexible layers so the chances of failure of PCB are reduced in an application.
High-Density flexible FPCB:
- HDI are flexible circuit boards having microvias and precise features.
- They are used to provide more technical solutions interesting of layout, design and construction.
- HDI are known for their improved usage of ICs, greater reliability and high electrical performance.
Materials used in FPCB
- We use flexible materials for both substrate and adhesive.
- The substrate is basically made up of polyimide(PI) film. The PI film does not soften on heating but remains flexible.
- Normally used PI film does not show the best resistance against humidity and tears but upgraded PI can overcome this problem.
- To attach layers adhesives are used. This adhesive should also be flexible but it is difficult to attain so now PI without adhesives are used that attach copper layers without any adhesive.
- Now coverlay film created with PI is used instead of solder mask. To make areas hard staffers are used instead of solder masks.
Manufacturing Process of FPCB
The manufacturing process for FPCB is procedural and structural. that's the main reason for its high cost. The manufacturing process of Flexible PCB is too lengthy, complex and needs a special environment, which makes it too expensive to design. Let us try to understand three major steps involved in the manufacturing of FPCB.
Step 1: Build up flexible PCB
The material used as a substrate is polyimide and in this step, the main focus is to save the base material because it is expensive than FR- 4. So to avoid wastage of polyimide circuits are placed close to each other. It includes the following steps:
- CAD designing: first of all design is prepared using CAD software.
- Drilling: holes are drilled and the size of holes is tried to make small.
- Looping: adding a slight amount of extra material for servicing circuit assembly.
- Sizing conductor: use the thinnest amount of copper.
- Etching: To compensate losses especially line width losses etching is done.
- Routing: the conductor is held perpendicular to the bend and fold. Folding and bending are improved by reducing stress and by helping the conductor perpendicular stress is reduced.
- Ground planes: creating ground areas will improve the flexibility of the circuit by reducing the weight of the circuit board.
Step 2: FPCB fabrication process:
Depending on the design and application the diameter of the hole in FPCB may vary.
- Size of the hole: small holes are best for flexible PCBs. Small size holes are difficult to drill. So the no of holes and size of holes determines as the cost control factors.
- Filleting: filleting is necessary for joining pads and land termination points. By filleting area is multiplied and stress is reduced so flexibility improves.
- PTH: Nowadays, copper is used for preparing vias and plated through holes.
Step 3: focus on physical constraints/ testing:
- Layers and coating problems are dealt with in this step. So the testing of these cover layers is necessary.
- Adhesive-backed films: these films are used for overcoating or at the areas where the adhesive is missing.
- Screen printable liquid overcoats: these are used with polymer films that are thick.
- Photo imaginable liquid and film polymer: It is the modern method used for overcoating because it avoids circuiting traces by acting as a solder mask. It avoids external and internal damages to the board.
- Overlay: After testing, FPCBs are laminated which is called an overlay. For best quality overlay, the budget of flexible PCB increases.
- Packing: FPCBs are packed and delivery is made.
Advantages or benefits of flexible PCB
- It can be twisted, bent, folded, and shaped in various dimensions, unlike rigid PCB.
- It overcomes other technologies like wire harnesses, rigid PCBs, and connectors.
- It can be arranged in various stacked configurations.
- Very easy to install.
- For high flexible applications, single-sided FPCBs are used. As the spaces are generated to make them flexible so they are light in weight and small in size.
- FPCBs are more durable than PCBs and rigid PCBs.
- Using FPCBs the capability of the product is enhanced.
Disadvantages or drawbacks of FPCBs
- Their cost is high than other PCBs because of the poor utilization of panels.
- They can be damaged easily because of their flexibility and poor handling.
- A complex assembly process is used in their manufacturing.
- In case of any fault or problem, they can not be repaired easily. High-quality machinery is required to repair them and the repairing price is also very high.
- For the manufacturing of FPCB highly professional designers with a lot of time are required.
FPCB Market Costs
- The market for the flexible printed circuit board is raising day by day.
- It was $ 200 million in the past and crossed $800 million till 2020.
- High demand is expected in the future.
Applications of flexible printed circuit boards
- FPCBs have diverse applications almost in every industry. They are designed in such a way to meet all the requirements of any kind of flexibility.
- Flexible printed circuit boards are used in both static and dynamic applications based on the requirement.
- Material use varies in static and dynamic applications. So before the manufacturing, their type and requirement should be confirmed.
Static application:
- These applications are also known as flex-to-fit or flex-to-install applications.
- Only a small amount of flexibility is produced in boards for these applications.
- Inexpensive electrodeposited (ED) copper is used to make minimal flexible boards for static applications.
Dynamic applications:
- For dynamic applications, the flexibility of built-in boards is set as high as possible.
- Rolled Annealed (RA) copper is used for making highly flexible printed circuit boards for dynamic industrial applications.
Diverse FPCB industrial applications:
- The applications of flexible printed circuit boards in different industries are listed below
- Electronics: flexible PCBs are used in laptops, cameras, calculators, printer heads, flip cell phones, computers keyboards...etc. Moving the print head of printers and plotters uses flexible PCBs to draw prints. Now flexible solar cells are made which can bend easily. Flexible wristwatches are also becoming popular in young generations.
- Manufacturing: flexible PCBs are also used in robotic arms, sensors equipment, processing machines, bar code equipment, and human-machine interface equipment In the manufacturing industry.
- Automotive: in the automotive industry, flexible printed circuit boards are used in airbag systems, anti-lock brakes, Global positioning systems( GPS), in engine controls.
- Medical: in the medical industry, flexible printed circuit boards are used 8n pacemakers, hearing aid devices, heart monitoring devices, and exercise monitors.
- Miscellaneous: flexible PCBs are also used in resistors, satellites, capacitors, Tower lights, LCD fabrication, light and motion systems.
Development prospects of flexible PCBs
Flexible printed circuit boards should have to be improved in the following aspects:
In the future flexible printed circuit board should be thinner and more flexible. They should have the flexibility of complete 360°.
Improved and developed substrates should be used to overcome the folding resistance.
At this time flexible printed circuit boards are too much costly. In the future, their price should be reduced to increase their market growth rate.
It is very difficult to make flexible PCBs because they required highly qualified personals, high machinery, and a lot of time. In the future, their process level should be upgraded and minimum line width and minimum aperture must meet higher requirements.
Parameters on which the cost of FPCB depends
Many factors affect the cost of the flexible printed circuit board. But I am here to categorize these parameters into these cost drivers.
The size of the flexible PCB is measured in a square inch and the price is calculated as price/ square inch.
So for large flexible printed circuit boards having the vast size, the price will be high than the smaller one.
When the no of layers increases the price of flexible PCB increases. So double-layer FPCB has high price than the single-layer FPCB and multi-layer FPCB must be high in price than single and double layer FPCB. Price also depends upon the material used in the construction. Price also depends upon the no of pads, for more pads used in flexible PCB price will be high.
Price also depends upon the volume of flexible PCB. For greater volume price will be high.
Finishing determines the shelf life of the flexible printed circuit board. With good quality, the finishing price is affected.
- No. Of the holes and size of the holes
It is difficult to make small holes, and for small holes, which are normally drilled in the flexible printed circuit boards, the price will be high than the big holes.
For more holes price will also be high.
- Custom or unique specification
When the custom specification is required that will add to the price of the flexible printed circuit board. Examples of custom specifications are contoured edges, side plating, and solder mask clearance.
Conclusion
In the future, flexible printed circuit boards will play a major role in security and entertainment dynamics.
The demand for flexible printed circuit boards is not high till 2016 but now their demand is increasing day by day. In future preference will be given to the flexible products in the market.
In short, the future belongs to flexible products.