Thursday, April 18, 2013

Electrical - Com/NO Relay & LED Resistor Calculation

Recently, I am playing with alarm I/O and requires something that is common but unfamiliar to me - Electrical circuit wiring.

Equipment Required

1. Breadboard - A breadboard (protoboard) is a construction base for prototyping of electronics. See http://tymkrs.tumblr.com/post/6386624174/how-to-use-a-breadboard on how to use a breadboard


2. 3V LED light - Need to display alarm output (see setup picture below)
3. Some electrical wires
4. Open Switch.(see setup picture below)
5. Resistor - We are using 5V input for a 3V LED light. We need a resistor to control the current flow to prevent providing too much current for the LED light (May result in blowing the LED light). 

Setup

The following picture provided a setup for 2 circuits - Alarm input circuit and alarm output circuit.


Alarm Input Circuit

Alarm input are usually used to provide a trigger signal to the attached system. In the above setup, I am connecting a 5V circuit for the alarm input and I used a open switch as a trigger device. If I press the switch button, it will complete the 5V circuit and the alarm system will capture a change in voltage and respond accordingly.

Alarm Output Circuit

Alarm output are usually used to connect external device to provide visual/audio alert. In the above setup, I am using a 3V LED light as the visual output alert with an NO (normally open) circuit.

Normally, there are 3 type alarm output port provided by an alarm system. The port interfaces are C, NO, NC

C - This is a Common port for alarm circuit. Either NO or NC will use Common port to complete the alarm circuit

NO - Normally Open port for alarm circuit. Normally Open means the circuit is opened and will be closed if and only if the alarm system detect an alarm event. For example, if I connect a LED light to NO circuit, the LED light will only light up if there is an alarm event.

NC - Normally Close port for alarm circuit. Normally Close means the circuit is closed and will be opened if and only if the alarm system detects an alarm event. For example, if I connect a LED light to NC circuit, the LED light will be lighted up and it will only be turned off if there is an alarm event.

Now, let's talk a bit about voltage and resistor. If you look at the breadboard, the alarm output circuit is using a 5V input for lighting up a 3V LED light. This implies that the alarm system is providing more voltage (5V) to the LED light (3V) than the LED light required. The extra 2V will eventually blow the LED light. To prevent that, we need a resistor to reduce the voltage flow across the LED light.

Below is a common setup for a circuit. So for us

Supply Voltage: 5V
Current: 20 milliampere (3V LED usually used 20 milliamp current)
Forward voltage: 3V (Voltage needed to light up the LED light)
Resistance: To be calculate


So, to calculate resistance, we need to use Ohm Law



where

I = Expected Current through the conductor in ampere
V = Potential difference measure across the conductor in volt
R = Resistance in conductor in ohm

Therefore, to calculate resistance, use R = V / I

For us, 

V = difference of supply voltage - forward voltage of LED = 5V - 3V = 2V
I = expected current of LED = 20 milliamp = 0.02 amp

Therefore R = 2V / 0.02 amp = 100Ohm

Thus, we need a resistor of 100Ohm to complete the circuit (shown in the picture)

You can use http://www.hebeiltd.com.cn/?p=zz.led.resistor.calculator to calculate your required resistor value

In addition, resistor has color code. You can use http://www.electronics2000.co.uk/calc/resistor-code-calculator.php to compute your resistor color code before going to electrical shop to purchase your resistor. For example, 100 Ohm resistor has a color code of brown black brown gold


The above had described the completed circuit setup for alarm input and output. Please take note that you have to setup your alarm system to relay alarm input to alarm output. Different alarm system has different setting.

Result

For me, after I had linked up the alarm system relay setting and pressed the open switch at alarm input, the LED light will light up as external alarm.


Wednesday, April 10, 2013

Video - Measuring Video Bitrate Over Network

There are 2 ways to measure bitrate for a video streams. You can do it via VLC and Wireshark.

VLC

VLC provide statistical information for user to understand the input bitrate for video. However, the statistic provided by VLC is current statistic, and thus, it is not the overall average bitrate for the video stream.

To use VLC for seeing current bitrate for a video stream, do the followings

1. Open a network video stream via VLC

2. When the video stream had set up and started playing, go to Tools -> Codec Information


3. Click on the Statistics Tab

4. Look at Input/Read -> Content Bitrate. That will be the current bitrate for your current video stream. At the screenshot, it shows 3kbps. This means that during the time of capture, the bitrate for the video stream is at 3kbps. Thus, this value varies over time.


Wireshark

Wireshark provide statistical analysis on your captured network information and it is a very good tool to understand the average bitrate, maximum bitrate and minimum bitrate for a video stream.

To use Wireshark for seeing bitrate of a video stream, do the followings

1. Open a video stream through your LAN interface. The video stream can be open by any players such as VLC, webpage, etc... 

2.When the video stream had set up and started playing, allow the video stream to play for about 1 minute to stabilize the connection and streaming.

3. After 1 minutes, open Wireshark, click on "List the available capture interfaces" button and start capturing packets from LAN interface.



4. Allow Wireshark to capture at least 1 minutes of video packets.

5. After 1 minutes, stop packet capture by pressing "Stop the running live capture" button


Now, you have all the packets needed to analyze your bitrate for this video stream. There are 2 way Wireshark can do it.

Via Conversation Statistics

Conversation statistics will provide an overview of traffic information for all network conversation captured in Wireshark. Conversation statistics will tells us the average bitrate of the video stream.

To see bitrate of conversation, do the followings

1. Go to Statistics -> Conversations


2. At the open window, look for a column "bps a <- 5.2kbps="" a.="" a="" address="" and="" at="" average="" axis="" b="" below="" bits="" bps="" camera.="" column="" div="" from="" is="" laptop="" means="" my="" per="" referring="" screenshot="" second="" so="" stream="" tells="" the="" this="" to="" transferring="" video="" you="">

Via IO Graph

IO Graph statistics will provide a graph view of the bitrate over time for your network. Applying to our discussion, this will show the bitrate over time for a particular video stream; that include the maximum and minimum bitrate of for the video stream

To see bitrate of IO Graph, do the following

1. Find a video packet in the Wireshark window. Right click -> Follow TCP stream


2. Step 1 will open a Follow TCP Stream window. However, we are not using it. So, just close it.



3. The purpose of performing step 1 is to ask Wireshark to create a logic statement that filter and capture all video packets for the video stream. If you look at the below screenshot, Wireshark create a logic filter "tcp.stream eq 0" to get all video packets for the video stream. Please note that 0 is just a TCP stream index by Wireshark, it can be a different index number for other captures.


4. Now, go to Statistics -> IO Graph


5. It will open an windows that display a graph. Change the y-axis to Bits/Tick to get a graph that show Bits over time. From the below screenshot, it shows that the video steam has a maximum bitrate up to 25kbps and minimum bitrate of 1kbps.

 

Reference: http://www.cardinalpeak.com/blog/?p=1054

Monday, April 1, 2013

Remote Desktop - No Terminal Server License Servers Errors

If you had administrative right with your PC and has the following error with Remote Desktop Connection, this post may help.



You can use mstsc command to workaround this error. MSTSC (MS Terminal Server Connection) creates connections to Remote Desktop Session Host (RD Session Host) servers or other remote computers, edits an existing Remote Desktop Connection (.rdp) configuration file, and migrates legacy connection files that were created with Client Connection Manager to new .rdp connection files.

You can use mstsc.exe /admin to create and connect a administrating session with the sever.

Steps as follows

1. Assuming you are using WinXP. At Start menu -> Run, type mstsc.exe


2. It will launch a Remote Connection Application with administrative setup


3. Enter your remote IP and connect.


References: http://technet.microsoft.com/en-us/library/cc753907(v=ws.10).aspx