Thursday, 19 February 2009

High-side sensing

Ok, I've finally finished those tests for power consumption for the board that has the RF antenna on it. Only difference is, the low-side sensing wouldn't work for me. I forgot I had a serial port connection, which obviously has a ground shield on it, so not all the current was returning through the negative terminal. Leaving me with crappy results in the region of 50mV when it should have been a good solid 2V.

Anyways, for high-side current sensing, the shunt resistor needs to be added on the positive wire. However, adding this resistor on the wire will cause a voltage drop and will decrease the voltage into my device. By how much, you say? Ask Mr. Ohm and his law, (V=IR), it just keeps coming back up. So there's about 2V drop across the shunt. I needed to increase the bench supply by about 1.7 volts, thus compensating the drop and ensuring 12V input to my device. With my negative terminal grounded and all my other connections setup, I needed to sort out the oscilloscope traces. Again, I need to find the drop across the resistor to find the current consumption. I add one probe on one side of the shunt and another probe to the other side. Both probes can be grounded on the ground terminal. Now all you have to do is get the trace on the scope, subtract the differences under different operations and divide by the shunt resistance to get your current. Now I'm finally done and back to my C++ project.

Current Sensing

I've been working another project in parallel with my C++ programming stuff and it's been interesting to say the least. I think I may have mentioned a DVT on a small little board a few weeks back. Anyway, I've been given the task of doing tests on the power consumption of this board. Simple enough you may think. It was, but now it's slightly more complicated.

First off, I just attached a digital multimeter in series with the negative terminal to the DC power supply. I made all my measurements through this, and it worked grand. Unfortunately, we have an RF board attached and when this is powered, I need to measure for current spikes. The multimeter won't catch these as they'll be quick. So I found I need to attach a shunt and an oscilloscope to the works.

Now this is where it all became a little more complicated. I've probably got the worst setup ever, but it'll do for the moment. I started reading up on current sensing and found that if I had a current probe with a torsal ring, I could simply attach it onto the wire (unobtrusively), without worrying about change in voltage. Do I have one? No. So I have to figure out the other way to do this. So I need to setup a low-side current sensing circuit in order to take my measurements. What's low-side? This is where I attach a small series resistor with high power rating, breaking the negative terminal. I also have to connect the negative terminal to a grounding point for accurate results. Then I need two traces, one tracking the voltage across the 12V bench power supply and another across the resistor measuring the voltage drop across it.

Now I've used a 10ohm resistor, 5% tolerance and rated at 1/4W, this is not an ideal resistor to use at all. The value should be as low as possible, with a tolerance of 1% or even 0.1% for accurate results as well as a proper power rating. My circuit is operating at 12V, my current load is roughly 0.2 to 0.3A, which means, my power rating should be 4Watts. I'm way off the mark with a 1/4W resistor. As a result I'm going to lose accuracy due to temperature rise.

Now with a proper setup, I should be able to accurately measure any current spikes by recording voltage spikes and doing the necessary maths using good old Ohm's law (Voltage = Current x Resistance). Currently I'm not finding any specific spikes other than plain noise, so I guess my circuit is ok for now.

Trying to learn C++ fast!

For the last week, I've been trying to learn C++ using Microsoft Visual Studio 2008. It's a great tool and a very useful language to know, as well as a great addition to my CV.

However, I've been currently trying to decode someone else's program in order to re-write one section of the code and it's driving me mad. I wish I could just get some program that reads the code, tries to make sense of the code and then explains in comments on each line exactly what is going on. What I want to add is a very simple little adjustment, but the problem lies with using current variables and placing it in the right part of the code, which means I must have a proper understanding of the part that I want to edit.

So I think I'll cheat for the moment instead, I'm just going to add in code as follows
puts ( "In this section, I'm doing....!\n");

This is a simple piece of code which outputs to the stream the text.

That way when I run the code, I can try and figure out where it does what. It's kind of cheating and nor really learning, but I'm under time constraints and this will do for the moment. Next problem, writing the code I want to use.