Sunday, November 9, 2014

Detect the port to which Arduino is connected

 When interfacing an embedded system with a computer, it often becomes necessary to find the COM port to which the device is connected. This will enable the application running on the computer to home in on the target device.

The methodology is to let the target system to continuously send messages over the COM port to the computer system. The application on the computer, checks each COM port for the particular message and flags when the message is received from a COM port. The application can send back a keyword to the embedded system to stop transmitting the message since it is no longer needed.

I wrote a c++ application just out of curiosity to identify the port to which my Arduino was connected. In the setup I used, the Arduino continuously transmitted  the word "hello". The app checked for this message and identifies the port from which the message was received. I thought it might might be useful to put up the code so that someone else might find it useful. A screenshot of the application is shown below:


 I am adding the source code and the library files required. The Serial library files needed for the purpose was found on the Arduino website. With fair amount of tinkering, I was able to get things running. The app was coded using Visual Studio 2013 Ultimate Edition.

The project can be downloaded from GitHub

Sunday, August 24, 2014

Exciting world of FPGA

I have been in the embedded domain for a while and has a fair share of experience with those tiny 8-bit devices. FPGA (Field Programmable Gate Array) caught my attention recently and is one of the hottest things in the electronics industry at the moment. FPGA is probably the closest you can get near to achieving real time processing.
So what all the hype around FPGA? Anyone who has fiddled with embedded systems will know that processors are never real time. They execute lines of codes one after another. They appear to work in real-time for a wide variety of applications because they execute the code pretty fast. To put things into simple words, suppose that you put up a simple microcontroller circuit to turn an LED ON when a switch is pressed and turn it OFF when the switch has been released. Just a few lines of code will achieve this and the microcontroller will execute the code over and over again so many times in a single second. Think that you are a super fast human being capable of clicking the switch on and off REALLY fast such that you can push the switch ON and turn it OFF before the microcontroller executes the line of code which check if the switch has been pressed or not, you’ll never see the LED turn ON just because you microcontroller never detected the press of the switch. This makes the software or code based embedded systems non-real time.
When it comes to FPGAs things are totally different, there is no line by line execution of code. If you do the same LED operation as mentioned above, what happens is that a direct connection is established between the switch and LED, just like you would do on a breadboard. So you are going to see the LED light up every time you turn the switch ON.
What’s more exciting is that you can implement a number of such units on the same chip and all of those units will run in parallel i.e. you can have a single FPGA to so some serious image processing, blink some LEDs, drive motors all at the same time. Really cool!!!!

A FPGA from XILINX


Altera and Xilinx are the forerunners in FPGA manufacturing. To implement a logic on FPGA, the configuration files are creates in a suitable Hardware Description Language (HDL) like Verilog or VHDL and are downloaded to the FPGA. FPGAs are wiped clean i.e. goes blank when they are powered off. So you always need an external memory to hold the configuration files from which the device can be reconfigured every time it boots up. Most FPGA development boards come with an on-board storage facility to store the config files. The data is not stored exactly as a file. It will be a stream of bits stored in a PROM chip.

Monday, January 20, 2014

A deep introduction to MOSFETs and its working

I have recently fallen for MOSFETs. These incredible power semi-conductor devices simply amazes me. MOSFET is the acronym of Metal Oxide Semi-Conductor Field Effect Transistor.

It is basically a 3-terminal device(even though you might find a 4th one in a few)-the drain, source and gate. It is often an important element in power control applications They are used in numerous devices-inverters, motor drives, SMPS to name a few.

It is basically a switching device in which the conduction between the drain and source can be controlled using the voltage between the source and gate terminals. You have to apply a voltage above the threshold voltage of the FET to turn it on. This value can be found in the datasheet.. At first the conduction increases( drain current) linearly and then it attains saturation values( maximum value).

The name Metal Oxide Semiconductor comes from the fact that the gate is made up of three layers-metal, an oxide layer and a semi conductor. A channel exists between the drain and source terminal whose character differs depending on the type of MOSFET. The channel lies below the insulator at the gate. The conduction between gate and source happens when the channel is filled with sufficient number of free charges.

There are two different types of MOSFETs: enhancement type and depletion type. Enhancement type requires you to enhance its conductivity by applying suitable gate to source voltage or the transistor is OFF by default (application of voltage creates free charges in the channel). On the other hand, depletion ones needs suitable gate to source voltage to stop its conduction or they are ON by default( consists of free charges without the application of voltage). In addition to this a further sub division NMOS and PMOS exists. The former one conducts using free negative charge and the latter one using free positive charge or holes. Enhancement type NMOSFET is the most widely used one due to a number of factors.







If you look at the figure, the topmost layer of the gate terminal is the metal, the white one is the insulating oxide layer usually made of Silicon dioxide. Below that is the semiconductor. When a voltage is applied between gate and source, the insulator does not allow the voltage to go directly to the semiconductor. Instead, a capacitive effect occurs where the plates of the capacitor are the metal and the semiconductor layers and the oxide layer serves the purpose of the dielectric medium. The B terminal is the body terminal and serves to control the threshold voltage. This is not often provided.

Take the case of enhancement type NMOSFET, a positive gate to source voltage induces positive charges on the metal and an equal and opposite charges develop in the semiconductor layer which is actually the channel. Now a path which consists of sufficient number of free charges exist and conduction can happen between drain and source. But for the conduction to occur, the gate voltage has to be above the threshold levels. Removal of the voltage diminishes the conducting channel and the conductivity comes to a halt. 

A typical MOSFET offers an OFF resistance in the order of Mega ohms whereas the ON resistance is within a few ohms. 

This figure shows how the channel is formed and the drain current increases and saturates with increase in gate voltage.  

The various symbols of MOSFET are:





The schematic shows the use of a MOSFET for driving a load, here it is an LED:




Here the transistor is acting as a acting as a a low side driver i.e the MOSFET connects and disconnects the lower voltage, in this case ground, from the load. The resistance between gate and source is to prevent any false triggering and also for discharging the stored charges in the gate during turn off.

A lot of things have to be considered when using MOSFETs and other power control devices. I'll be posting more about MOSFETs. The upcoming posts will be on low side, high side driving and gate driver ICs like IR2111. I simply love them, they amaze me.

Saturday, January 11, 2014

Tri state- The third logic state

All of us are quite familiar with the so called binary system of 0's and 1's which is the essence of digital electronics. In digital electronics, all voltage levels are measured in terms of a logic 0 or logic 1. Taking 5V to be the reference(Vref), logic 0 lies in between 0V and 1/3Vreg whereas logic 1 state is 2/3Vref to Vref. The above said voltage levels is in case of CMOS technology. These levels are 0 to 0.8V in 2 to Vref in case TTL. It has to be noted that the voltage levels in between 0.8V and 2V should be avoided in TTL circuits as it maybe treated as a logic 1 or 0 depending on the circuit characteristics.

Now there exists a lesser known state other than the o and 1 called the tri state or the high impedance state. This third state can be totally isolated state and is similar to an open switch. Usually the output of any digital circuit is a 0 or a 1. But if the output is a tristate, you don't get any voltage readings simply because no voltage exists there. The logic 1 state can be considered to be a direct connection to Vcc( supply voltage) and 0 can be considered as a direct connection to ground. However, tri state is a state when there is no connect to any voltage source.
Suppose you have an LED whose anode is connected to the output of a digital circuit and the cathode connected to Vcc through a resistor and another one whose cathode is connected to the same point in a similar fashion. When the output is 1, the first led glows and when the output is 0, the second one glows. However, when the output is tristated none of the LEDs glow.


The above shown is a figure of a tri state buffer. What it does is that it conveys the input logic level to the output, but the output can be switched to high impedance state using proper signal at enable/inhibit pin.

If you still need clarifications or note any discrepancies, feel free to post them in comments.


Sunday, October 27, 2013

Adublock- can an Atmega get any simpler

Arduino, the ever resounding name in makerspace along with a few others, have taken a lot of bashing as it masks the underlying concepts and hardware. But who cares as long as you can easily bring your ideas to reality with ease. What is the use of all the technical details as long as the purpose is achieved.

Today, when rummaging through the web, I came across ArduBlock, a simple drag and drop programmer for Arduino. It features a neat GUI where you have all the elements needed for programming your arduino. Simple drag ans drop the elements, assign pin numbers, outputs and you are ready to roll. Using the application results in a pictorial representation of your code.
The application works within the Arduino IDE. The equivalent code appears in the arduino IDE!!!!!!

Below is a screenshot of the simple block for blinking an LED:



Give a try

Arduino has simplified things and has helped many without much technical knowledge to make cool projects, but still has kept many at bay from getting their hands on due to their lethargy towards programming. ArduBlock is certain to expand the Arduino maker community