Friday, April 28, 2017

The Length of a Rectangular PCB Inductor

When it comes the time to design a planar PCB inductor for RFID antennas, it is needed to characterize its parameters. One of them is the series DC resistance, which depends on the conductor length and resistivity as well as its thickness and width. The latter ones can be easily defined in any CAD software for PCB layout. What about the conductor length? Well, not every software allows you to define the length neither can give you the length of a certain trace. In such case we have to calculate that manually.

The paper in [1] presents an equation to calculate the conductor length of a square planar antenna. It appeared to me that one of elements of the equation was not correctly defined. The original proposal is the following:


 From my revision the corrected equation should be:

 

With n being the number of turns, d0 the external length of the conductor, w the conductor width and s being the gap as shown in the picture above.

Since most RFID antennas are rectangular rather than having a square shape, the expression could be further developed as the one presented below, with c0 and d0 being the external length of each side:


As a side note, the total series resistance also depends on the operating frequency, since the AC current will be distributed mostly close to the conductor surface.

[1] Islam, A. B., Et al., "Design and Optimization of Printed Circuit Board Inductors for Wireless Power Transfer System"

Friday, May 29, 2015

PID Control for Embedded Systems

An Analog PID control is described by the equation below:


Moving to discrete domain the equation can be expressed as following (note that the integral part was converted using trapezoidal rule):

Where:

A better way to implement a digital PID on an embedded system platform can be achieved by getting rid of the integral sum. This can be done by adding the previous output. Obviously, it will be also needed to remove the proportional and derivative actions on the previous error input. So the final equation is expressed like this:
Translating to a C code, it can be computed as the following:
      
typedef struct pid_tag{
 float kp;  //proportional gain
 float ki;  //integral gain
 float kd;  //derivative gain
 float in;  //input value
 float err[3]; //error history
 float out[2]; //output history
 float in_ref; //input reference
 float out_max; //maximum acceptable value for the output
 float out_min; //minimum acceptable value for the output
}pid_t;

float perform_pid(pid_t *p){
 /*compute actual error*/
 p->err[0] = p->in_ref - p->in;

 /*start with the previous output*/
 p->out[0] = p->out[1];

 /*add proportional part*/
 p->out[0] += p->kp * (p->err[0] - p->err[1]);

 /*add integral part*/
 p->out[0] += p->ki * ((p->err[0] + p->err[1]) / 2);

 /*add derivative part*/
 p->out[0] += p->kd * (p->err[0] - 2*p->err[1] + p->err[2]);

 /*set up the output limits to avoid abnormal behavior*/
 if(p->out[0] > p->out_max) p->out[0] = p->out_max;
 else if(p->out[0] < p->out_min) p->out[0] = p->out_min;

 /*update error history*/
 p->err[2] = p->err[1];
 p->err[1] = p->err[0];
 p->err[0] = 0;

 return p->out[0];
}


Obviously using the structure variables as floats might not meet the time requirements for you application. You can optimize the code using some other variable types.

References:
[1] Bräunl, Thomas, "Embedded Robotics: Mobile Robot Design and Applications with Embedded Systems", pp.56-61

Hello World!

This blog is related to embedded systems and electronics.