Getting Started with Ruby Cucumber on Windows 10

Ruby can be a great language for testing. With libraries like Capybara for driving web apps and JSON, RestClient, SOAP, and others for interacting with service apps, you’ll find testing in Ruby requires much less code than in C# or Java.

Following instructions can be used to setup Ruby Cucumber on windows 10. Following instruction have been tested on windows 10. Should work on Windows 8.1.

Step1

As a first step download and install Ruby from http://rubyinstaller.org/ . Install the latest release of version 2.2.4 64 bit or 32 bit whichever applicable From <http://rubyinstaller.org/downloads/> . I will be using 32 bit version. The 64-bit versions of Ruby are relatively new on the Windows area and not all the packages have been updated to be compatible with it.

Installing Ruby cucumber on Windows 10

Make sure you check the option to “Add Ruby executables to your PATH.”

Step 2

Also install the Ruby Development Kit from the same place, which will allow Ruby to build native extensions for libraries.

Instructions are available here: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.

Note: while installing, check if you are installing the right version of DevKit.

C:\devkit> ruby dk.rb review
C:\devkit> ruby dk.rb init
C:\devkit> ruby dk.rb install

Step3: Install Ruby Cucumber Gems

To install Cucumber, first update current gem setup.

C:\Users\pintu>gem update --system:

Next, install the gems you need for cucumber web testing. Following are recommended

C:\Users\you> gem install --no-ri --no-rdoc rspec
C:\Users\you> gem install --no-ri --no-rdoc win32console
C:\Users\you> gem install --no-ri --no-rdoc watir-webdriver
C:\Users\you> gem install --no-ri --no-rdoc cucumber
Run Cucumber
C:\Users\you\Documents> cucumber

If you try to run Cucumber at this stage you will get an error of missing features. Refer the screenshot.

Ruby Cucumber on Windows 10 -2

C:\Users\you\Documents> cucumber --init
C:\Users\you\Documents> cucumber
You are now done.
Next -> Writing  your first test using ruby & cucumber on windows 10

7 Segment Display

A 7 segment display is typically used to display numbers from 0-9. It consists of 7 bar segments and a dot( 8 Segments).

Segments are numbered A to F and DP for the dot or decimal place. There are 2 types of 7 Segment display

–> Common Anode

–> Common Cathode

A common Anode display has common pin that is connected to Vcc. Each segment is connected through resistor( current limiting) to the ground. To shutoff the segment we need to connect to Vcc.

Driving a 7 Segment Display

A 7-segment display can be thought of as a single display, but it is actually seven individual LEDs within a single package and as such these LEDs need protection from over current. LEDs produce light only when it is forward biased with amount of light emitted being proportional to the forward current.

The forward voltage drop across a red LED segment is very low at about 2 volts, so to illuminate correctly, the LED segments should be connected to a voltage source in excess of this forward voltage value with a series resistance used to limit the forward current to a desirable value.

Typically for a standard red colour 7-segment display, each LED segment can draw about 15 mA to illuminated correctly, so on a 5 volt digital logic circuit, the value of the current limiting resistor would be about 200Ω (5v – 2v)/15mA, or 220Ω to the nearest higher preferred value.

Schematic Diagram

7 Segment Display
7 Segment Schematic

Common cathode is opposite to common anode. Common pins are connected to ground. To light up each segment is set to HIGH.

7 Segment display table.

Band ColourBand #1Band #2Band #3Multiplier value for
Band #3
Band #4
Black
0001
Brown11110
Red222100
Orange3331000
Yellow44410000
Green555100000
Blue6661000000
Violet77710000000
Gray888100000000
White9991000000000
None20%
Silver10%
Gold5%

 

How to use multiple solar panels?

Calculating watts

Power[watt]=Voltage[volt] * Current[Ampere]

if the panel is rated as 5v 200 mA then

Power=1 watt

Wiring multiple solar panels

Parallel wiring

This is required if your application need more power than rated. By connecting the positive terminal of solar panel of one panel to positive terminal of another panel and similarly connecting negative terminals of both the panel as shown in the figure below.

fig – 1 parallel wiring

multiple solar panels parallel

The maximum current that can be delivered will be some of both current. The rated voltage will remain same.

parallel connection_2

Series wiring

This can be used if your application needs a higher voltage than the rated voltage. You can wire the positive terminal of one solar panel to the load and negative terminal to positive terminal of another panel as shown in the figure below.

Figure – 2 series wiring

multiple solar panels series

In this wiring total voltage delivered will be  some of the rated voltage of both panels. Current supply will remain same.

seriesconnection_2

 

 

How radio works?

How does radio works?

Audio signals are transmitted by imposing lower audio frequencies on the high frequency carrier wave. In other words the audio signals are added to the carrier frequency. Its amplitude is modulated.

At the receiving end, a very simple combinations of a capacitor and a coil detect the carrier frequency out of all the other noise in the electromagnetic spectrum. The value of the capacitor is chosen such that the circuit resonate at the same frequency as the carrier wave.

radio works 2

The antenna picks up the electromagnetic radiations from a distant transmitter. The coil is tapped a different interval such that it resonate to match the carrier frequency of the radio signal. All other frequencies are grounded.

radio works

By adding a capacitor, you can tune the circuit more accurately

What happens to the other frequencies caught by the antenna?

The lower frequencies pass through the coil to ground and higher frequencies pass through the capacitor to ground.

Basic Electronics – Resistance and Capacitor codes

Resistance colour codes

Below is the table containing resistance colour codes. Each color band represents a number and the order of the color band will represent a number value. The first 2 color bands indicate a number. The 3rd color band indicates the multiplier or in other words the number of zeros. The fourth band indicates the tolerance of the resistor +/- 20%, 10% or 5%. Continue reading “Basic Electronics – Resistance and Capacitor codes”

Basic Electronics – Resistor Combinations

RESISTOR COMBINATIONS

  • When we do not get specific resistor values we have to either use variable resistors such as potentiometers or presets to obtain such precise values. Pots are too expensive to use forevery case.
  • Another scheme is to combine two or more resistors to obtain the necessary precise values.Such resistor combinations can cost as little as 50p or so only.
  • Then the question arises as to how one should combine these resistors, because, they can be combined in two different ways.
  • These are called “Series” and “Parallel” combinations.

 

Series Combinations

R Total= R1+ R2

  • Calculating values for two or more resistors in series is simple, add all the values up. series resistors
  • The connection ensures that the SAME current flows through all resistors.
  • In this type of connection RT will always be GREATER than any of the included resistors.

Even if we have more than two resistors the total resistance is the sum of all the resistors connected in series:

R Total= R1+ R2+ R3 +•••••

  • Total Applied voltage is divided by two resistors
  • Current in the circuit is  I = V/(R1+R2)
  • Voltage across R1 and R2 are from OHMS law.

 

V1= I*R1

V2=I* R2

Total voltage V=V1+V2

For Example if V=12v and the 2 resistors are 1k each, then the current in the circuit is

12/2k=6mA

The voltage across each resistor is 6v

Thus the series combination is characterized by

  • The same current flows through all the resistors connected in series.
  • The resultant resistor is SUM of all the resistors in series
  • Series resistors divide the total voltage proportional to their magnitude.

 

Resistors in Parallel

In Parallel combination, 2 paths are available for current, hence the current divides but the voltage across the resistors is same.

1/R total =1/R1 + 1/R2   or

R total = (R1*R2) / R1 + R2parallel resistors

  • If the two resistors are equal, the current will divide equally and total resistance will be exactly half.
  • For example if voltage is 12v and there are 2 resistance for 1k each,

 

The current through each resistance will be 12v/1k= 12 mA. Hence the total current is 12 mA.

Effective resistance is 0.5k

Thus the parallel connection is characterized by

  • The same voltage exists across all the resistors connected in parallel, and
  • The reciprocal of resultant resistor is the sum of reciprocals of all resistors in parallel, and
  • Parallel resistors divide the total current in an inverse proportion to their magnitude.

Potential Divider

Since series resistors divide voltage, this idea can be used to get smaller voltage from a power supply output. For example, we have a power supply with 10V fixed output. But we want only 5V from it.

Vout= Vin(R2/(R+R2)) 

  • The Current I=Vin/R1+R2
  • Since the current I flows through R2, voltage developed across it from Ohm’s law is Vo=I*R2=( Vin/R1+R2) * R2            potential-divider                                                                                       Vo = (R2/R1+R2) Vi
  • If R1=R2, then Vo=Vi/2

R1 and R2 cab be 100k or 100 ohm. Which one to be used?

If we need more current through load then R1 must be small. But too small a value will cause energy drain on the power supply. So the value must be chosen very carefully.

Note:

  • When two resistors are in parallel then their overall power rating is increased.
  • If both resistors are the same value and same power rating, then the total power rating is doubled. If parallel resistances are not equal, then the resistors with smaller values will be required to handle more power.
  • Four identical 0.25W resistors can be wired in parallel to give a resistor with one fourth the value in ohms, but four times the power rating. (1.0W). This is most useful when we require higher power handling, but don’t want to go out and buy more expensive (and physically larger) resistors.
  • We have already seen earlier, that the power (in watts) can be calculated by multiplying voltage by current. P=V * I
  • By using ohms law, the parallel or series resistor formulas and the above formula, a minimum power rating for a certain resistor can be calculated. If this is exceeded the resistor is likely to get hot and hopefully quietly breakdown.

LED Basics

Today LED has become an integral part of consumer electronics.

LED TV, LED Display, LED Lights and so on. These are becoming very popular because of there low power consumption.

What is LED?
LED stands for Light emitting diode.

A light emitting diode is essentially a PN junction semiconductor diode that emits a monochromatic(single) colour light when operated in a forward biased direction.

For detail in technical evolution refer the following url

http://en.wikipedia.org/wiki/Light-emitting_diode

Early LEDs were only bright enough to be used as indicators, or in the displays of early calculators and digital watches. More recently they have been starting to appear in higher brightness applications.

LED Basics – Characteristics voltage drop

When a LED is connected around the correct way in a circuit it develops a voltage across

it called the CHARACTERISTIC VOLTAGE DROP. A LED must be supplied with a voltage that is higher than its “CHARACTERISTIC VOLTAGE”  via a resistor – called a VOLTAGE DROPPING RESISTOR or CURRENT LIMITING RESISTOR

How LED works?

LED and resistor are placed in series and connected to a voltage.As the voltage rises from 0v, nothing happens until the voltage reaches about 1.7v. At this voltage a red LED just starts to glow. As the voltage increases, the voltage across the LED remains at 1.7v but the current through the LED increases and it gets brighter. As the current increases to 5mA, 10mA, 15mA, 20mA the brightness will increase and at 25mA, it will be a maximum.

This is just a simple example as each LED has a different CHARACTERISTIC VOLTAGE DROP and a different maximum current.

In the diagram below we see a LED on a 3v supply, 9v supply and 12v supply. The current-limiting resistors are different and the first circuit takes 6mA, the second takes 15mA and the third takes 31mA. But the voltage across the red LED is the same in all cases.

ledfigure1

LED Basics – Head Voltage

As the supply-voltage increases, the voltage across the LED will be constant at 1.7v (for a red LED) and the excess voltage will be dropped across the resistor. The supply can be any voltage from 2v to 12 or more. The resistor will drop 0.3v to 10.3v. This is called HEAD VOLTAGE.

The voltage dropped across this resistor, combined with the current, constitutes wasted energy and should be kept to a minimum.

ledfigure2

Most supplies are derived from batteries and the voltage will drop as the cells are used.

Here is an example of a problem:
Supply voltage: 12v
7 red LEDs in series = 11.9v
Dropper resistor = 0.1v
As soon as the supply drops to 11.8v, no LEDs will be illuminated.

Example 2:
Supply voltage 12v
5 green LEDs in series @ 2.1v = 10.5v
Dropper resistor = 1.5v
The battery voltage can drop to 10.5v
Suppose the current @ 12v = 25mA.
As the voltage drops, the current will drop.
At 11.5v, the current will be 17mA
At 11v, the current will be 9mA
At 10.5v, the current will be zero

Many batteries drop 1v and still have over 80% of their energy remaining. That’s why you should design your circuit to have a large HEAD VOLTAGE.

Some Basic circuits using LED

1. Polarity Tester

ledtools1

2. Continuity Tester

ledtools2

3. USB Reading Lamp

http://digitalab.org/2012/08/usb-reading-lamp/

 

Basic Electronics – 2

Passive Components

RESISTORS

To oppose the flow of electrons ( current). The symbols are shown below.

Resistance is measured in units called “Ohm”. 1000 ohms is shown as 1k ohm (103 ohm) and 1000 k ohm is shown as M.ohms (106ohm).

Resistors can be broadly of two types.

• Fixed Resistors and Variable Resistors.

Fixed Resistors:

Carbon Film (5%, 10% tolerance) and Metal Film Resistors (1%,2% tolerances) and wire wound

resistors. A fixed resistor is one for which the value of its resistance is specified and cannot be varied in general.

Resistance Value

The resistance value is displayed using the color code ( the colored bars/the colored stripes), because the average resistor is too small to have the value printed on it with numbers. The resistance value is a discrete value.

For example, the values [1], [2.2], [4.7] and [10] are used in a typical situation.

Types of Resistance

CARBON FILM RESISTORS

This is the most general purpose, cheap resistor. Usually the tolerance of the resistance value is ±5%. Power ratings of 1/8W, 1/4W and 1/2W are frequently used. The disadvantage of using carbon film resistors is that they tend to be electrically noisy.

METAL FILM RESISTORS

Metal film resistors are used when a higher tolerance (more accurate value) is needed. Nichrome(Ni-Cr) is generally used for the material of resistor. They are much more accurate in value than carbon

film resistors. They have about ±0.05% tolerance.

OTHER RESISTORS

There is another type of resistor called the wire wound resistor. A wire wound resistor is made of metal

resistance wire, and because of this, they can be manufactured to precise values. Also, high-wattage resistors can be made by using a thick wire material. Wire wound resistors cannot be used for high-frequency circuits.

Ceramic Resistor

Another type of resistor is the Ceramic resistor. These are wire wound resistors in a ceramic case, strengthened with a special cement. They have very high power ratings, from 1 or 2 watts to dozens of watts. These resistors can become extremely hot when used for high power applications, and this must be taken into account when designing the circuit.

SINGLE-IN LINE NETWORK RESISTORS

It is made with many resistors of the same value, all in one package. One side of each resistor is connected with one side of all the other resistors inside. One example of its use would be to control the current in a circuit powering many light emitting diodes (LEDs). The face value of the resistance is printed.

4S-RESISTOR NETWORK

The 4S indicates that the package contains 4 independent resistors that are not wired together inside. The housing has eight leads instead of nine.

VARIABLE RESISTORS

There are two general ways in which variable resistors are used. One is the variable resistor whose value is easily changed, like the volume adjustment of Radio. The other is semi-fixed resistor that is not meant to be adjusted by anyone but a technician. It is used to adjust the operating condition of the circuit by the technician.

Semi-fixed resistors are used to compensate for the inaccuracies of the resistors, and to fine-tune a circuit. The rotation angle of the variable resistor is usually about 300 degrees. Some variable resistors must be turned many times( multi-turn Pot) to use the whole range of resistance they offer.

This allows for very precise adjustments of their value. These are called “Potentiometers” or “Trimmer Potentiometers” or “presets”.

LIGHT DEPENDENT RESISTANCE (LDR)

Some components can change resistance value by changes in the amount of light falling on them. One type is the Cadmium Sulfide Photocell. It is a kind of resistor, whose value depends on the amount of light falling on it. When in darkness its resistance if very large and as more and more light falls on it its resistance becomes smaller and smaller.

There are many types of these devices. They vary according to light sensitivity, size,  resistance value etc.

THERMISTOR

They are thermally sensitive resistor. The resistance value of the thermistor changes according to temperature. They are used as a temperature sensor. There are generally two types of thermistors, with Negative Temperature Coefficient(NTC) Positive Temperature Coefficient(PTC). The resistance of NTC thermistors decreases on heating while that of PTC thermistors increases.

ELECTRIC POWER RATING

For example, to power a 3V circuit using a 12V supply, using only a resistor, then we need to calculate the power rating of the resistor as well as the resistance value. The current consumed by the 5V circuit needs to be known.

Assume the current consumed is 250 mA (milliamps) in the above example. That means 9V (=12-3 V) must be dropped with the resistor. The resistance value of the resistor becomes 9V / 0.25A = 36(ohm).

The consumption of electric power for this resistor becomes 0.25A x 0.25A x 36ohm = 2.25W. Thus the selection of resistors depends on two factors namely tolerance and electric power ratings.

OHM’S LAW

Important and useful law.The current(I) flowing through a conductor is proportional to the voltage (V) applied across its ends. This can be written in algebraic form as V ∝ I Or V = IR where R is the proportionality constant. R is called Resistance and is measured in ‘Ohms’ ( Ω ).

Usually resistors are also specified in circuits in kilo Ohms(kΩ) and Mega Ohms(MΩ). The other useful relationships are V = RI, and R=V/I.

Basic Electronics – 1

Introduction

Electronic component can be divided into 2 types: Active and Passive components

Resistors and Capacitors etc. are known as passive components because they can only attenuate the electrical voltage and signals and cannot amplify.

Devices like transistors and operational amplifier(op Amps)can amplify or increase the amplitude and energy associated with the signals and so are termed as Active components.

Apart from components and circuits we must also have familiarity with some of the essential electronic measuring instruments like multimeter, regulated power supplies, function generators and oscilloscopes etc.

Basic electronics - Part 1