Tuesday, August 23, 2022

Linux Commands For Raspberry Pi Users - Part#1

If you are venturing into Raspberry Pi (RPi), without a good hold on Linux, this series of articles might be of interest to you. Let me present a list of useful Linux commands those will be handy for you to operate from the RPi Command Line Interface (CLI). Especially if you have loaded the Raspberry Pi OS Lite version of the OS image, which is the leaner version of the OS, you will be left with the only option of operating from the CLI.

First thought of mentioning a few basics about the directory structure for the new users. As the Raspberry Pi OS is based on Linux, everything is organized under the "root" directory, which is denoted as "/".  The working directory for an user is usually at a location "/home/<username>". If the username is "pi", then the working directory for that user would be "/home/pi". Note that, this working directory is under the root directory "/". 

The working directory for a particular user, which is know as the home directory for that user is denoted as "~". Once you login to the Raspberry Pi, you will be in your working directory "~". To see which directory you are in currently, type:

$ pwd 

The above command reveals the "present working directory" to you.

You could change directory to the root directory by typing: 

$ cd /

But it is worth cautioning here, avoid messing up with the root directory unless you know what you are doing. We could move back to the home directory by using the command:

$ cd ~

Or, simply, type:

$ cd

This might be useful to know that your previous working directory is stored in a variable $OLDPWD. In case, you want to change to the previous working directory, type the command:

$ cd $OLDPWD

Next, you might want to know the content of a particular directory. The following command is a quick one to know the other directories and files stored in a directory.

$ ls [flags] [directory path]

The flags, which are optional, control the format and the level of details that will be displayed about the content. The path for the directory for which this command is to be executed is also option. If the path is omitted, the list command will be executed for the present working directory.

To learn more about the options available for the flags, type the following command:  

$ man ls

The above command brings out the manual of the command "ls".

Let us now see a handful of frequently used flags and how powerful those could be. Executing the "ls" command without any flags, would just show the names of the directories and files stored under the present working directory. Note that, the hidden items are not shown. In order to show all directories and files including the hidden ones, you need to use the option "-a": 

$ ls -a

Any file that begins with a "." is considered a hidden file in the Linux environment.

To know more details about the file or the directory, type the following command:

$ ls -l

The flag "-l" reveals the detailed information such as the owners of the file/directory, permission, date of last modification, size in bytes etc. along with the name of the file or directory.

If you need to see the subdirectories under each of the directories in the present path, type:

$ ls -R

The "-R" (capital R) flag in the "ls" command will list all directories with their corresponding subdirectories down to the last file. Obviously, this command will also show the files in the current directory.

Now let us see how we could list the content of the present directory by sorting them by their size and time. Use the flag "-S" (capital S) to sort the content with respect to their sizes, in descending order (biggest to smallest):

$ ls -S

Similarly, use the flag "-t" (small t) to sort the content according to the time last modified, in descending order (most recent first).

$ ls -t

If you want to reverse the order, simply add "r" to the above two commands:

$ ls -Sr

$ ls -tr

The above two commands will reverse the order of sorting respectively. Now it is interesting to note here, you could combine multiple flags as shown above. However, the above commands will not show the size or time information. In order to show those information too, you could combine "-l" flag with the respecting commands, for example:

$ ls -S -l

OR:

$ ls -Sl

OR:

$ ls -lS

etc.

Is not it so flexible and powerful feature of Linux? I am sure you will love it eventually.

Now, could you please try the command yourself:

$ ls -lSr

What does the above command yield?

In the following part of this series we will see the commands to create, copy and move files/directories.

Saturday, July 16, 2022

Let's not trash a microSD card before we try this!

I came across a corrupted microSD the first time and therefore thought of documenting the story for me to remember later and sharing the problem along with the fix, in case it serves you in some way. If you have found a microSD card, that behaves like a healthy one but does not show all the disk space it was supposed to have, this article might help you. The good thing was that the 16 GB microSD card (shown in picture# 1) was detected but was only showing 256 MB as the full capacity. 


Picture# 1: The 16 GB microSD card, I had trouble with

First I tried formatting the card, which did not help. I have also tried to enable any hidden files so that I could delete them. I could not see any hidden files or folders which could have explained why the card was showing only a tiny piece of its entire capacity.

As I was getting frustrated and increasingly tempted to buy a new one for my RPi Zero W, found the recommendation in the webpages mentioned under references. All of those talk about using the DISKPART utility that comes with Windows. Details about the DISKPART utility and the commands could be found in the link below:



Picture# 2: The commands to use the DISKPART utility to restore a microSD to its full capacity

To launch the DISKPART command interpreter, I launched the "Command Prompt", typed: diskpart and hit Enter button. A message popped up asking if I wanted to allow the app to make changes to my device. Clicked on yes to launch the DISKPART interpreter window. Next, I followed the five steps in the sequence that are shown in picture# 2, and, voila!! it worked! My microSD was restored to its full capacity of 16 GB! It saved money for me! 

References:

Saturday, April 30, 2022

Conquering the very first challenge for the Sparkfun Edge board

A couple of months back, I became interested to learn TinyML to build machine learning "edge" applications on microcontrollers. I got hold of the book "TinyML" by Peter Warden [ISBN: 9352139607] and started scanning through it. Among the three boards mentioned by Peter, I was attracted to "Sparkfun Edge" as the author stated the collaboration he had with Ambiq, the manufacturer of the Apollo 3 microcontroller and Sparkfun, the manufacturer of the board while writing this book. Also, I found the cost of this board to be reasonable - $16.5. Therefore I decided to buy it!    

Figure 1: Sparkfun Edge with USB to 3.3V TTL (CH340G) breakout

In case you are also using this board for the first time, here is a gist about the features of Sparkfun Edge: The board is based on the Apollo 3 MCU, which is built around an ARM Cortex-M4 core, that can run at 48 MHz and up to even 96 MHz in TurboSPOT mode. This tiny 5 x 5 mm package comes with a load of features including an FPU, integrated BLE5. The functional block diagram of Ambiq's Apollo 3 MCU shows its features:

Figure: Block diagram of Apollo 3 MCU from Ambiq - Source: Datasheet 

Apart from the fairly powerful MCU, the board has 2 MEMs microphones, one 3-axis accelerometer, one camera connector for the HIMAX HM01B0 camera, four LEDs, GPIOs, and a coin cell (CR2032) connector. The BLE5 antenna is assembled on the board and it does not require an external antenna.

Well, all looked great, till I received the board I ordered. All the other boards I used so far came with either a USB connector or a pin-jack type of connector for applying power to the board. I realised that Sparkfun Edge was missing such an easy feature, which provides convenience to the users. Do not know why it was not done, but guessing, to keep the size of the board smaller? From the Sparkfun website, I found out that, I need to have a USB to TTL (3.3V) breakout board in order to program the MCU on the Edge board. Sparkfun recommends the USB-C to TTL (3.3V) breakout board ($9.95), based on the CH340C chip.

Figure 3: Sparkfun Serial Breakout Board - USB-C to TTL (CH340C)

[Picture Source: www.sparkfun.com]

I could find a $2 option for the USB to TTL breakout (branded as "WEMOS"), which has 5V as the default logic/power option for the TTL but can be configured by a jumper connection. The TTL connector has the exact pinout as the Sparkfun serial breakout board. There is one more jumper, which is needed to be configured to configure "CTS" as the data flow control signal. Ensure that you check the continuity with a multimeter after desoldering the default jumper pads and soldering the correct connections. I had to cut the default connection track (for 5V & RTS), before soldering the pads to select 3.3V and CTS.

Before connecting the serial breakout board to the Sparkfun Edge, you might want to double-check if you are getting 3.3V between the VCC and GND pin on the TTL connector while powering the serial breakout board alone. Once you are confirmed that the serial breakout board is correctly configured, connect it to the Sparkfun Edge board. As the Sparkfun Edge board comes preprogrammed with the speech recognition program, you might see the blue LED (GPIO# 37) blinking fast. That means, your Sparkfun Edge is powered up successfully.

Now here comes the challenge. The instructions for using Arduino IDE to program the SparkFun Edge board can be found on Sparkfun's webpage:

Programming the SparkFun Edge with Arduino - learn.sparkfun.com

But the instruction provided in the "The Upload Sequence" section is not entirely accurate. A small error in one step has cost me a week's effort. The instructions as written:

  • Press and hold the Reset button
  • While still holding down the Reset button, press and hold the 14 button
  • Release the Reset Button
  • Release the 14 button (Wrong!!!)
  • Hit Upload in the Arduino IDE (or use your keyboard shortcut)

The 4th step is not correct. If button# 14 is released before the upload is completed, the programming fails! It will only work if button# 14 is kept pressed and not released unless the upload is completed. In case you are struggling with the same matter, pay attention that button# 14 is kept pressed after 2nd step till the programming is completed. I got this clue after I posted this question in the forum:

Failing to upload to Sparkfun Edge board using Arduino IDE 1.8.19 · Issue #461 · sparkfun/Arduino_Apollo3 (github.com)

 

Thursday, April 7, 2022

Test your knowledge in Arduino and ATmega328P: QUIZ# 2

 


[Picture Source: https://content.arduino.cc/assets/Pinout-UNOrev3_latest.png]

Arduino Quiz# 2

1. As the pins A0 to A5 are configured as Analog Input pins on Arduino UNO, it is not necessary to declare the pins as input pins using the function pinMode(). State true or false.

A. True
B. False

2. Which one of the following statements is not correct about the microcontroller ATmega328P?

A. The IO port registers PORTx and DDRx are read/write types, whereas the PINx register is a read-only type
B. The six of the PORTC pins are configured as Analog Input on Arduino UNO
C. All ports B, C and D could be configured as digital input/output along with other functions
D. The ADC inside ATmega328P is six channel 10-bit ADC
E. None of the above

3. The IO ports of ATmega328P are controlled and accessed by three registers:

A. DDRx, PORTx and LOADx
B. DDRx, PINx and LOADx
C. PORTx, PINx and DDRx
D. PINx, PUSHx and POPx
E. None of the above

4. The IO port registers are basically built out of:

A. Diodes
B. D-FFs
C. RS FFs
D. Wire junctions
E. None of the above

5. Stack Pointer register increments by 1 during the execution of a POP instruction execution and decrements by 1 during PUSH instruction execution.

A. True
B. False

6. If the ADC of ATmega328P on Arduino UNO is configured to use the internal voltage reference, the analog values 0 and 1023 read on pin A0 using the analogRead() function would correspond to:

A. 0V and 5V respectively
B. 0V and 1.1V respectively
C. 0.1V and 4V respectively
D. 0V and 4V respectively
E. None of the above

7. STACK has majorly two uses. Those are:

A. as temporary storage for variables, the values which are needed to be restored later and to store the Stack Pointer
B. to store the return address during function calls and as temporary storage for variables, the values which are needed to be restored later
C. to manipulate data during program execution and to store the return address during function calls
D. to store instructions and to store the addressed of the functions

8. Assume that the ADC of ATmega328P on Arduino UNO has the default configuration for reference voltage (AREF). What is the LSB in terms of voltage?

A. 4.25 mV
B. 0.12 V
C. 4.88 mV
D. 3.26 mV
E. None of the above

9. Data memory read access is faster than the same for program memory.

A. True
B. False

10. PINx register can be read or be written as well by the program. State whether true or false:

A. True
B. False

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Answers for Quiz# 1 (in the previous post):

1. B     2. A     3. C     4. A.    5. A    6. A    7. A    8. A    9. C    10. D

 


Tuesday, April 5, 2022

Test your knowledge in Arduino and ATmega328P

 


Arduino QUIZ# 1

1. As the AVR CPU has a 16-bit wide address bus, the ATmega328P microcontroller is known to be a 16-bit microcontroller.

A. True

B. False

2. The Program Counter register of the microcontroller ATmega328P [select the correct answer from the choices below]

A. is a 14-bit register which contains the address of the instruction stored in the program memory

B. is a 8-bit register which contains the address of the instruction stored in the data memory

C. is a 16-bit register which is part of the 32 general-purpose registers

D. is a 14-bit register, which contains the result of the ALU operation

3. The second phase in an AVR CPU cycle is called "Execution" and this phase is subdivided into [select the correct answer from the choices below]

A. ROF, ALU

B. ROF, IF, ALU

C. ALU, ROF and RWB

D. IF, ROF and RWB

4. Pipelining helps in implementing a certain amount of parallelism in the CPU execution and IF phases so that the RISC CPU could finish most of its instructions in a single clock cycle. [True/False]

A. True

B. False

5. The execution phase might involve ALU operation and read/write operation from/into general-purpose registers and/or data memory. [True/False] 

A. True

B. False

6. Boot Loader is a program that helps the application program image to get uploaded in the desired sections of the program memory. [True/False]

A. True

B. False 

7. As the Program Counter (PC) of ATmega328P is a 14-bit register, it allows access of 32KB of program memory organized in 16K x 16 bits. [True/False]

A. True

B. False 

8. An occurrence of an interrupt for the ATmega328P microcontroller is independent of ALU operation. [True/False]

A. True

B. False  

9. How many Pin Change Interrupt inputs are available on Arduino UNO?

A. 3

B. 10

C. 23

D. 16 

10. Which of the following statements is NOT correct about the polling method?

A. In polling method, the microcontroller keeps on checking an input repeatedly in a loop to determine its state of change

B. Polling method is not efficient to determine the state of change of an external digital input

C. On Arduino UNO, the analog inputs can be checked by polling method

D. In polling method of reading any change of a digital input, there is no chance of missing a transition 

Can you guess the answers correct? Answers to follow in the next post. 😉

Saturday, June 5, 2021

BEGIN WITH ARDUINO - My first book for the Electronics Enthusiasts

The year 2020 started with a gruesome spell, the remnant of which is still continuing around the globe. As the vaccination drive caught up speed around the world, it seems like we have just crossed the most difficult time for the last several decades. During such depressing times, a book seems to be a great companion, apart from the near and dear ones of course. Especially for my fellow electronics enthusiasts studying in high schools and colleges, who might be missing their social groups at schools, I thought of writing something which would be a productive and entertaining engagement. 

I have named the book: BEGIN WITH ARDUINO as the book provides a quick start guide to learn about the Arduino UNO hardware and Arduino IDE software. The book also introduces the basics of a microcontroller, sensors (input devices) and output devices such as displays, motor drivers, I2C/SPI based input/output devices. One chapter is dedicated to circuit building using a breadboard. The last several chapters describe the programming concepts and demonstrate quick programming using the built-in libraries. I am hoping this book would definitely encourage the freshers into this subject to venture out fearlessly and learn.


Chapter 1: Tools & Equipment - A list of essential components and tools you would need to start experimenting with Arduino board.

Chapter 2: Arduino Family - This chapter lists down all major boards in the Arduino boards and draws a quick comparison.

Chapter 3: Arduino and friends - Other popular open-source microcontroller or microprocessor based hardware boards and a quick comparison with Arduino.

Chapter 4: Important digital electronics terminologies for the beginners

Chapter 5: Arduino anatomy - This chapter describes the major components of the Arduino UNO board and lists down the IO pin functionalities or Arduino UNO board.

Chapter 6: Brain of Arduino UNO - Describes the features and major functionalities of the ATmega328P microcontroller in brief. 

Chapter 7: Input Devices - Sensors - Talks about the popular Arduino compatible sensors which could be used for the projects.

Chapter 8: Output Devices - Outlines the concept of driving the output devices using the microcontroller pins. Lists down the basic output devices such as various displays, relays, motor drivers.

Chapter 9: Building Circuit on Breadboard

Chapter 10: Getting started with programming - Describes the features of the Arduino IDE software tools and provides a quick start guide to develop, upload and run your first code using the Blink code.

Chapter 11: Analog Input - Explains how the analog voltages could be read

Chapter 12: Analog Output using PWM - This chapter describes how the pulse width modulation technique could be used to convert analog voltage from a digital value.

Chapter 13: Writing Code for LCD Display - Explain how to use the library for the LCD display and how to develop code for displaying messages on an LCD display with a parallel interface and having an I2C interface.

Chapter 14: Completing the Input-Output Loop - This last chapter provides a complete example of a project using the Arduino UNO board. 

The Book is now available on Amazon KDP International:

 

US: https://www.amazon.com/dp/9390507014

 

UK: https://www.amazon.co.uk/dp/9390507014

 

Germany: https://www.amazon.de/dp/9390507014

 

France: https://www.amazon.fr/dp/9390507014

 

Spain: https://www.amazon.es/dp/9390507014

 

Italy: https://www.amazon.it/dp/9390507014

 

Japan: https://www.amazon.co.jp/dp/9390507014

 

Canada: https://www.amazon.ca/dp/9390507014


Paperback version is available for Indian Distribution:

 

Amazon : https://www.amazon.in/dp/9390507014

 

Flipkart : https://www.flipkart.com/begin-with-arduino/p/itmcd632de58952a



Wednesday, May 14, 2014

My Experience with Raspberry Pi: Getting Started!

As off-the-shelf small sized single board computers are gaining popularity among the professional developers, electronics enthusiasts, hobbyist and also students, three names have become known to almost all of these people: Arduino, Raspberry Pi and Beagle Bone Black. Among these three, I some how got attracted to Raspbery Pi, don't know why. Once reason could be that I was looking for a cheaper but somewhat powerful single board computer. Recently I got one from Element 14 and it is Raspberry Pi "B" version. I expected that it would atleast come with the SD card loaded with the OS, but it doesn't. So, I had to buy one 16 GB Class 10 microSD card with a SD card adopter as the Raspberry Pi has the slot for SD card. Somebody on the web suggested to keep the SD card adopter installed on Raspberry Pi and just take the microSD card in and out when required. In that way, the wear & tear on the Raspberry Pi SD card connections would be minimum. I followed the instructions mentioned in Raspberry Pi official website to format the microSD card and load NSBOOT in it using my computer. An microSD/SD card reader would be required for loading the necessary files in the microSD card.
I did not have a HDMI cable and hence I bought one. I had a wireless keyboard-mouse set and already had power supply with mini USB connector. So I just connected all of these to Raspberry Pi. By the way, I bought a little cute transparent case too.


Picture 1: Raspberry Pi in a case, micro-SD card and SD card adopter & HDMI cable

Picture 2: Bottom-side view of Raspberry Pi with SD card adopter with micro SD card installed, HDMI cable, USB power cable & wireless USB dongle for keyboard & mouse connected and all set to go.
Picture 3: Top-side view of Raspberry Pi with all connected and ready to go.
I used my 32" LED TV as the display and I connected the other end of the HDMI cable to one HDMI port of the TV. Next I powered the TV on, changed its input to the corresponding HDMI input and then switched Raspberry Pi on. It came alive!! The first screen appeared as shown in Picture 4 below:

Picture 4: The first screen appeared after power-up, prompting which OS to install
I had a low confidence on how my wireless keyboard and mouse would work. I moved my mouse and awfully enough I saw the mouse pointer moving on the screen. My respect for the Raspberry Pi engineers got mightier than I originally had. I clicked on the little box next ti "Raspbian [Recommended]" and the "install" button on top left corner appeared, on which I clicked. The installation began and as the installation progressed, several important information appeared and re-appeared time to time.


Picture 5: Raspbian installation in progress.
 After the installation was completed, the following screen appeared as shown in Picture 6 below:


Picture 6: OS Installation Successfully Completed

Sunday, September 29, 2013

My Experience With "Noise": Part Vb

CONDUCTED RF: Effects of RF Interference on electronic components (Work in progress)
It would be good to understand how RFI (Radio Frequency Interference) affects the functionality of the different electronic components. I saw a nice article "Integrated Circuit Susceptibility to Conducted RF Interference", published in the Compliance Engineering magazine, which describes the effect of RFI on the functionality of different active electronic components such as diode, BJT, MOS transistor, Op-amp, Digital IC individually. The link is given below:
This could serve as a good starting point for understanding and predicting what kinds of components are there at the board entry (generally IO circuit, power circuit, communication ports) which could see the RF noise. Once it could be predicted the behavior of the components in the circuit with RF Interference, necessary precautions could be taken to prevent the failures.  
  

Friday, June 28, 2013

My Experience With "Noise": Part Va

CONDUCTED RF:

Conducted RF immunity test is performed to check whether the EUT functionality is compromised or not, when a RF noise gets coupled to the EUT through its one or more ports. Some how I have not seen major issues with this test and that might be because I have worked more on digital circuits. There might be exceptions, but in general, digital circuits are less susceptible to continuous RF while analog circuits are more so.

The purpose of the test is to simulate the proximity of the EUT and its connected cables to radio transmitters and RF manufacturing equipment operating at low frequencies. These frequencies are not easy to test as it is hard to generate uniform fields in typical test facilities at frequencies much below 80MHz, but for typical sizes of apparatus the immunity problems at frequencies below 80MHz are normally associated with cable coupling, so conducted testing of the cables is seen as a reasonable alternative to radiated methods at such frequencies. Conducted RF immunity testing is also a lot less costly to do properly than radiated RF immunity. Please refer the link below and the IEC 61000-4-6 standard to learn about the conducted RF test procedures

http://www.compliance-club.com/archive/old_archive/011021.htm


The standard cable-coupled RF immunity test of IEC 61000-4-6 specifies an injected level, typically of 3V or 10V open circuit voltage from a source impedance of 150 ohm, in common mode into each interface to be tested. The test frequency range is 150kHz – 80MHz (expandable up to 230MHz). So, there are two principal parameters defined in conducted RF tests, the frequency range and the test level.

The exact frequency range used for a test is defined in the corresponding product standards. Frequency range is chosen defending on the size of cable and EUT. In general, if the cable and EUT length is λ/4, the upper frequency may be increased. This rule also holds true for the start frequency which may be higher than the specified 150 kHz. Start frequencies would be increased when the cable and EUT length is λ/4.



Monday, June 17, 2013

My Experience With "Noise": Part IVd

We were discussing about surge voltage transient and how to make our designs more and more immune to this kind of disturbances...we are not done yet.

The picture below shows a circuit how a TVS doide is connected one one input port, which shows the parasitic inductors L1, L2, L5 & L6 seen by the physical copper traces on the board when a high frequency transient V1 is applied to the input. Please note that the equivalent load at the input port is represented by a capacitor and resistor in parallel: C1 & R1. Also note that the signal ground and frame ground are usually separate and usually connected together by a capacitor (usually having high voltage rating such as 2KV) and high value resistance (~10M ohm); that is what is represented by C2 and R2 in the Figure 1 below. Please note that V1 represents a surge transient source and that is why it is referenced to "FRAME GND" not the signal ground. Also it is to be noted that the TVS device (represented by D1 in Figure 1) or any other suitable transient suppressor device shall always be connected between the line it intends to protect and always the "FRAME GND" not the signal ground (assuming these two ground connections are not the same). 

Figure 1: Surge suppressor & parasitic inductance
Each piece of copper trace on the PCB imposes some inductance to a "high frequency" transient current, caused by ESD, EFT or Surge. Since the objective of the transient suppressing device D1 here is to divert the transient energy back to the source from right at the port entry, the protection device shall ideally placed right between the port connector pins: signal under protection and frame ground. But it is not always practically possible to do the same. So care must be taken to make the traces to TVS as short and wide as possible. The intention here is to reduce the values of the parasitic inductors L1, L5 and L6 to "practical" zeros. The trace represented by L2 could have a longer length and theoretically it should be better to have a bit of inductance on that trace (L2) to offer impedance to any transient noise tries to propagate on its path to the device under protection (but if it is permitted for its correct functioning).

We will discuss this further when we will take a look at the some layout design techniques. Next topic I would like to pick would be "conducted RF".    

Tuesday, June 11, 2013

EMC: Theories, Equations, Foundation

I am going to add the following link to the blog page, which contains many useful information for engineers like me who has lost a touch with the academics; I found the tutorials very helpful in refreshing our knowledge on the foundation, based on which we take some of our engineering design decisions:
http://www.learnemc.com/EMC-Tutorials.html    

Sunday, June 9, 2013

My Experience With "Noise": Part IVc

I beg your pardon to all who were following this blog, for an extremely long silence on this page. Actually I got caught in an EMC mess starting from the beginning of this year and got occupied for last few months. The problem was radiated emission related and it helped me gathering some more knowledge around that topic and we will discuss something similar when we discuss on "radiated emission". 
But I can't help sharing a lesson I learned from my experience: "I would always run Radiated Emission (RE) Test FIRST after I could power a prototype successfully, before running all other EMC immunity tests, if I feel there is a risk with RE. So that I could fix any issues related to RE first". We will discuss on this later, but let us just continue on what we were discussing.
In the previous part we have seen how the surge testing gets conducted as per IEC 61000-4-5 on the un-shielded IO lines. There are again different test procedures specified in that standard for the EUT having balanced unshielded IO/communication lines, shielded IO, communication line etc. I am not going through all of those test procedures and would recommend you to get hands on the standards and be thorough with the test procedures to be well equipped with the knowledge rather than learning in the hard way while going through the testing.     
So far, do we understand the difference between the EFT and Surge? I found the the article in the link below, which is very useful to understand that difference between EFT & Surge:
http://7ms.com/enr/online/2007/01_02/notebook.html

Just to highlight a few important takeaways from the article, please note that the rise time of the surge voltage is approximately 1.2us, where as the rise time of the EFT waveform is ~5ns.
Now, given the rise time of a pulse = tr, the knee frequency Fknee is given by the following equation:
Fknee = 1/(pi*tr);
For surge voltage having rise time of 1.2us, Fknee = 265KHz, approximately 300KHz;
Where as on the other hand, EFT voltage having rise time of 5ns, Fknee = 63.7MHz, approximately 65MHz; Hence, surge is a high energy, low frequency transient and EFT is a low energy high frequency transient.
The following picture shows comparison of energy level produced by different types of electrical transients such as EFT, ESD, surge, ring wave (we will discuss next) etc, having same peak voltage level. Note that the energy contained in surge voltage transient is the highest among all:



The measures for making the design tolerant to the required level of surge voltage is quite the same as the techniques used to make the design immune to ESD transients and EFT:
(1) Use transient suppressors or "SHIELD" to "divert" the voltage transient to the "Frame ground" or "Chassis ground" with MINIMUM RESISTANCE AND INDUCTANCE (ideally zero) on the return path. The following table shows a comparison of different types of transient suppression devices to be used to divert the energy to the frame/chassis ground. Please note that the transient suppression devices used for diverting the "surge transients" shall be required to handle maximum amount of energy compared to other transients. But it need not to be as fast as that required for EFT or ESD.


Table 1: Comparison of different transient protection devices

(2) Implement appropriate filtering for the transient noise due to voltage surge to get filtered out so that the disturbance does not affect the functionality of the design or damage the devices while operating. For filtering power lines, bandwidth is not an issue. In principal, we could use enough filtering to control both surge and EFT. Audio frequency signal lines can usually be filtered adequately as well. Surge, having a bandwidth of 300kHz, requires a filter cut-off of 30kHz or less in order to provide sufficient protection. Where as EFT, having a bandwidth of 60MHz, would need a cutoff of 6MHz or less, might be acceptable for many RS 232 lines, but too low for many digital data streams.

In the next part I am going to discuss some more on the design tips for surge protection. 




Monday, January 28, 2013

My Experience With "Noise": Part IVb

HIGH VOLTAGE SURGE: TESTING 

In the previous chapter IVa, the nature of the surge voltage waveform as described in the  standard IEC/EN 61000-4-5 was illustrated. 
The coupling of surge waveforms into a system under test has many variations and a full description might not be possible here as I plan to keep it simple at this stage. I plan to describe specific cases some point of time later where I will include a much more detailed description. 

There are general concepts that will be discussed here. In practice all testing is done based on a specific test standard and the standards give detailed descriptions as I am referring to IEC/EN 61000-4-5 standard.

Surges can be applied to both power and data lines. The considerations are similar. The test setup must be able to deliver the stress to the system under test without interfering with system operation before and after the application of the stress. The test setup must also prevent damage or upset to electronics needed to exercise the system under test. This is done with a combination of a coupling network to apply the stress to the system under test and decoupling network to prevent damage or upset to auxiliary equipment. This "Coupling & Decoupling Network" is a commonly known by the short form "CDN". An example is shown in Figure 1 for stressing a set of data lines. The network in Figure 1 allows the stressing of any of the data lines with respect to any of the other data lines or ground. The parallel combination of the capacitor and the surge arrestor feeds the stress into the system. In most cases the arrestor is not included and the surge is coupled into the system capacitively. High speed data lines may not be able to tolerate the micro Farad sized capacitors needed for coupling. An arrestor, such as a gas tube, provides a low capacitive alternative.
Figure 1: Typical Surge Voltage Set-up on IO ports

Test setups for stress to power supply lines are similar. The values of the coupling capacitor may be larger and it is unlikely that the capacitance will be too large so that the use of arrestors for coupling is not needed. Resistors would not usually be used in the decoupling network and capacitive filters may be added between lines on the opposite side of the decoupling network from the unit under test. 

The test set-up described above is necessary to understand how surge voltage disturbances are applied to system/equipment under test and might make it easier to understand how to protect the equipment against such disturbances. In the next post we will see some examples of design practices for surge protection. 


Wednesday, December 12, 2012

Quick Fundas: Op-amp# 6 Contd...

In the Op-amp circuit application example "Quick Fundas: Op-amp# 6" we have seen that the output of the Op-amp circuit oscillates between positive and negative saturation voltages when VIN is set to 0V. How the output voltage behave when the input voltage VIN is set (-2V) and when VIN is set (+2V)?

Ans:
Setting VIN (-2V) helps in the capacitor C2 to be charged to the negative threshold voltage faster. At the same time it takes more time for the capacitor C2 to be charged to the positive threshold. Hence the Op-amp output VOUT remains in positive saturation for more time than the time it remains in negative saturation. 
The opposite happens when VIN is set at (+2V). In that case, the Op-amp output VOUT remains in negative saturation for more time than the time it remains in positive saturation. 

Basically this is kind of a PWM (Pulse Width Modulation) circuit using an Op-amp. Pulse width modulation is achieved by varying VIN. In the picture below, the simulated waveform of the output VOUT is shown when VIN is varied from (-2V) to (+2V).

Figure 1: Pulse Width Modulation waveform (for circuit shown in Op-amp# 6)

Saturday, December 8, 2012

Quick Fundas: Op-amp# 6

Let us see a little bit complex Op-amp circuit. Can you figure out how the Op-amp circuit shown below behaves when VIN (V2: DC voltage source) could be set anywhere between -2V to +2V? 

Figure1: Op-amp circuit# 6
Ans:
It might look tough, but it is not! :) Actually the circuit looks a bit clumsy. If you assume VIN is set to be zero, then you will find that the output of the Op-amp oscillating between +ve saturation voltage (around +10V) and -ve saturation voltage (around -10V). When the output of the Op-amp is at +ve saturation, the zener diode D1 (clamps @ 6.2V) and D2 (forward biased) sets +ve reference voltage (~7mV) at the non-inverting terminal of the Op-amp. As the capacitor C2 gets charged through R1, the voltage at the inverting terminal of the Op-amp increases and after time t1, just crosses the voltage present at the non-inverting input of the Op-amp. This turns the output to the -ve saturation voltage. The reference voltage at the non-inverting terminal gets changed to ~ (-7V). As the output turns -ve, the capacitor C2 gets charged through R1 to the -ve voltage. After time t2, the voltage at the inverting terminal of the Op-amp decreases just below the voltage set at the non-inverting terminal and the output of the Op-amp switches back to the +ve saturation voltage. The same continues. The output of the Op-amp remains at +ve saturation for the time t1 and remains at -ve saturation for the time t2. The time period of oscillation is (t1 + t2).
Simulated waveforms are shown below:
Figure 2: Simulated waveform of VOUT (VIN = 0V)
Figure 3: Simulated waveform of voltage at the input terminals of Op-amp (VIN = 0V)
Next: What happens when VIN is set at some voltage other than 0V?    

Thursday, November 29, 2012

Quick Fundas: BJT# 1

What happens to VOUT when the source V1 is varied from +12V to +20V? Also, what will be the nature of variation of the current through R1 during this time? How could this circuit be useful? The Zener diode D2 has a breakdown voltage of 10V.

Figure 1: PNP Transistor Circuit

Hints: The circuit drives nearly constant current through R1 even though voltage V1 varies from +12V to +20V. Due to constant current through R1, voltage VOUT remains almost constant with respect to the positive rail (VOUT gets clamped with respect to positive rail of V1 irrespective of the variation of V1).

Using NPN transistors, the circuit below would provide nearly constant voltage ~9.6V at VOUT with respect to ground even if the input voltage varies between 12V and 30V.

Figure#2: NPN Transistor Clamp Circuit

One application of this circuit is to use this circuit to clamp the voltage of the gate drive of the MOSFET when the voltage used for the gate drive could vary over a wide range.   

Sunday, November 25, 2012

Quick Fundas: Op-amp# 5

A slight improvement to the circuit described previously in "Quick Fundas: Op-amp# 4" is to add a capacitor C1 in parallel with R3. The capacitor C1 and R3 should be chosen appropriately to filter out over-voltage glitches that mostly occurs during power-up.

Figure 1: Improved Over-voltage detection circuit with latch