Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Friday, 14 April 2017

Current Sensing: High Side vs. Low Side

Occasionally, you will be designing an electronic project, and there will be a need to to measure the current being drawn by a particular section, or  even the whole thing. When designing, prototyping, or even testing the design you can use a calibrated multimeter. In the field though, or inside a real product, how can you monitor current.

A very popular way is to use a very low value power resistor in series with the load you want to measure. As current flows through it it will induce an e.m.f (voltage) across the resistor. This resistor voltage can then be measured by an ADC in a microcontroller. The value will be linearly proportional to the current running through it. Using Ohm's law you can deduce that the voltage across the the resistor is equal to the current x resistance. As the resistor may be slightly off, the device might need calibration.

An issue with this though, you want the minimum voltage drop possible across the resistor. This reduces power loss, and minimises the effect you will have on the load. For this reason a very small resistor needs to be used. There are plenty of resistors out there for this purpose, known as shunt or sense resistors. This tiny voltage could be as small as 0.1v, or maybe even lower, way too small for a standard ADC to pick up reliably. For this reason There is a need for an amplifier, to multiply this voltage by 20 or 50 times. This enables the swing to be measured across the range of the ADC. So if you have a 5v ADC, and the maximum voltage across the resistor will be 0.1v, the amplifier will need to have a gain of 50. There are two main categories of current sensors like this, High side and Low side.

current sensors


The above image shows the basic configuration of these two types of measurement. The difference is based off on the location of the sense resistor. Low side sensing is between load and ground, with high side sensing between power and the load. It shouldn't make much difference, the voltage across the Sense resistor will always be the same.

One reason for not using the the low side method is for the fact it is based off the ground reference. If anything between the power and the high side of the load is shorted, the current sensor wont pick it up. It is just one thing thing that you can't then implement into your design.

Also be careful when choosing the amplifier and the resistors you intend to use. There are many amplifiers on the market designed for this specific purpose. The TSC101 is an amplifier I recently included in a project, for this exact purpose. A high side current sensor, with a precision trimmed preset gain of either 20, 50, or 100. Adding in a laser precision trimmed power resistor to this, and there is an output for a microcontroller, a very simple current sensing application. for less than £2 in your application.

Friday, 24 March 2017

Playing Video on Raspberry Pi

So you have a new raspberry pi, it is all set up, something like Raspbian is running on the SD card, and you have a desktop in front to of you. You might have even played with some of it, maybe one of the built in games. I know the first thing I wanted to do was to play a video. There doesn't seem to be a video player on the dropdown menu, but there is one built in, To get to it, the terminal is needed. I know it seems kinda scary, but its just one line.

Firstly, you need to know where the video is that you want to play. I have mine on a memory stick in the USB port. When the memory stick is plugged in, it will usually open in the file manager. In the bar at the top it will show the file path, mine is shown below as an example.

/media/pi/memstick/
Also, note the name of the file you want to play, and the way it is encoded. So it might be a .mp4 or a .avi or anything similar. If you want to play an uncommonly encoded video, look at the omxplayer documentation to check it supports it.

The next part is easy, open up the terminal, and type in:

omxplayer -o hdmi /media/pi/memstick/hk3.avi
Note the last bit is the file path, and will be different depending on where your file is stored; the above is an example. Just to explain what is going on here, omxplayer is the command we are using, and uses the already installed application associated with it. -o opens the port, and hdmi tells the pi where the stream needs to be output to (remember the pi has a few video outs). This command also allows the audio to play through the hdmi.

All going well, a video will play. Note you cant use the mouse to control the video, it is all done run through the terminal, so pressing keys controls what you want to do. A short list of commands is shown below.

1                    decrease speed
2                    increase speed
<                    rewind
>                    fast forward
z                     show info
j                     previous audio stream
k                    next audio stream
i                     previous chapter
o                    next chapter
n                    previous subtitle stream
m                   next subtitle stream
s                     toggle subtitles
w                    show subtitles
x                     hide subtitles
d                     decrease subtitle delay (- 250 ms)
f                      increase subtitle delay (+ 250 ms)
q                     exit omxplayer
p / space         pause/resume
-                      decrease volume
+ / =                increase volume
left arrow       seek -30 seconds
right arrow    seek +30 seconds
down arrow   seek -600 seconds
up arrow        seek +600 seconds


Saturday, 2 July 2016

Resistors and Ohm's Law

If there is one thing that every single electronic engineer needs to know, its Ohms law, it describes the basis of all electronics. Published in 1827 as the book Die galvanische Kette, mathematisch bearbeitet ("The galvanic circuit investigated mathematically") Ohm's Law states

That the current through a conductor between two points is directly proportional to the voltage across the two points.


To put it slightly simpler, if there is current flowing through a conductor, then that current is proportional to the voltage across that conductor. The proportional bit is the resistance. Basically, if you have a resistor, with a voltage across it, the current will be a certain amount (calculated using ohms law). If that voltage was doubled, the current would also double.
The equation representing this law is:

V = I x R


V = voltage across the conductor
I  = current flowing through the conductor
R = the resistance of the conductor

Example

Lets say that we have a constant 5v supply, and need to draw a constant 10mA from that power supply. We need a resistor, and we can use Ohm's law to figure out the value. Start with the Basic equation:

V = I x R

Then rearrange it so resistance is the subject:

R = V / I

Replace V and I with the values shown above (remember that 10 mA is actually 0.010A).

R = 5 / 0.010

R = 500Ω

Thursday, 12 May 2016

Adding Libraries In Proteus 8

So you are working on a project in Proteus. Whether creating a schematic, or designing a PCB, You often run into the problem of not having the components that you need. You have two choices of what to do, either make your own, or download a library where somebody else has made it for you. During this tutorial we will go over the simple process of adding a library to your copy of Proteus.

Steps:

  1. When you download the library, it will be in the form of two files, an ".IDX" file and an "object file library". You may need to unzip it before you can use the files.
  2. Copy the files by either right clicking and pressing "Copy" or using the "CTRL + C" keys on the keyboard.
  3. Locate the Proteus library folder, usually found at: C:\ProgramData\LabcenterElectronics\Proteus 8 Professional\LIBRARY
    1. Paste the files into this folder by right clicking and pressing "Paste" or using the "CTRL + V" keys on the keyboard. There will be lots of libraries already in this folder that will look similar to the ones you just copied in.
    2. Restart Proteus and check that the libraries have installed. This can be achieved by looking in the "Library Manager" under the "Library" menu bar.
    And now you have a new library to use on your next project.