Friday, July 31, 2015

I2C Bus extender

     
    
     Sometimes I feel to communicate my data for long distance via an I2C bus communication. But unfortunately the I2C protocol supports very few meters only. As a normal application interfacing such as RTC, external memory or I/O extender doesn’t need a long distance for communication. Here the slave and master can be placed closely on those applications.
        But when we are going to use special functions ( interfacing with AFE, Motor driver IC and etc.), we have to carry our I2C signals for the long distance. Because of our master communicate with slave remotely, not a board itself.
        Here I have attached one of my sample schematic diagram .I have tested this circuit one of my application. I have used P82B715 (TI manufacture).This IC can communicate up to 50 meters without any data losses.
      For a very long distance communication, you can use following formula (figure (a)) to find out pull resistor values otherwise go through their manufacture datasheet. But anyway 4k7 and 470R suitable for most of the applications (figure(b))

figure(a)




                                                  figure(b)

Have your PCB design isolated between AGND and DGND?


    
    Generally AGND, DGND stands for Analog and Digital Ground respectively. Recently most of the microcontrollers and AFE (Analog Frond End) chips are having separate ground pins (consists of AGND and DGND separately).

     
    Because of an Analog signal can be easily affected by a noise signal, which has been produced by a digital signal related components (ie... relay switching, solid state devices, motor driver and etc.).So we have to beware about PCB layout designing side.


    The figure (b)  is showing, how the ADC signal affected by the noise signal. Actually when we are consider about the digital signal, the MCU is having min and max threshold limit value by their manufacture for input signal processing. So we don’t care about digital signal consideration. But the ADC signal continuously has been taken when the ADC sampling processing time (figure(b)).So your noise signal also may be sampled at that time. It leads to take you observe wrong ADC values.


For Digital signals consideration (figure (a)),

0 to 1.5 -0 voltage that means ‘1.5 Volts’ –min threshold voltage level.
3.5 to 5 -5 voltage that means ‘3.5 Volts’ -max threshold voltage levels.

Note: min and max threshold voltage level may be varied from one MCU to another MCU. Here I have taken that values are approximately.

Here we can get only 0V or 5V .So the noise signal has never affect the digital signal.

For Analog signals consideration (figure (b)),
0 to 5 –it have collective of range (steps resolution).So we have to think about noise signal. It may affect our original ADC signal.

                                                                figure(a)



                                          figure(b)


We can reduce our noise level by the following ways,
  1. Separate your AGND and DGND plane area in CPU and all add-on boards(ie.. even ADC or motor driver board also) as a figure (c).                                                                                             
  2. Moreover trying to use individual power supply for all add-on boards (should be isolated ground) and finally connected together with all the ground pins (if needed) using star ground technique.                                                                                          
  3. Always kept away your filter circuit and analog related components from your Motor driver or any solid state related components.                                                                                              
  4. Place your sensor, Amplifier and AFE (Analog Front End)ADC chips very closely .If the length of wire or track on the PCB may increase ,you may lose few micro volts .(For 18 bits resolution ,each and every bit can be changed by 15.625uV at 2.5V Ref. So you have to create the best PCB trace for ADC higher bits resolutions).                                                                                                
  5. The isolator IC which can prevent your components as well as reduce the noise level.

Here I gave few isolator ICs details with suitable application,

GPIO –ISO7340
SPI    –ISO7341
I2C    – ISO1540
PWM – ISO7821

The isolator IC can be used by the following three ways,

a) Level swifter (5 to 3.3V or vice versa)
b) Protect the pins from reverse current or any other fault condition
c) Isolate the ground signal from the noise signal

Note: Here I have just consider about TI chips only. But most of the companies, they are designing the same type of isolator chip with different type of the parameters. So let’s consider about it.


 If your design satisfies the above conditions, you can able to get the best accuracy results and protect your ICs from unwanted signals.

figure(C)

  
                                                         figure(d)

Is your design having Anti-aliasing filter at that time of ADC sampling?


          Anti-aliasing filter which is going to be used for remove a higher frequency noise signal before to be taken a sampling processing at that time. Generally the sampling frequency should meet with Nyquist theorem .But in this case, the Aliasing signal doesn’t satisfy with Nyquist theorem. So that, your ADC digital values may be fluctuated that means aliasing happened.  

Nyquist Theorem:
(ADC) fs >= 2 x fc
     The maximum frequency of the input signal is less than half or equal to sampling rate (fs).

For example, if you are application having the frequency of the sensor signal is 1KHz, you can choose your cut off frequency of anti-aliasing filter is greater than 1KHz and it should be less than sampling rate of your ADC. Here my sampling rate for my ADC is 10KHz so that I have designed my cut off frequency of my filter is 5KHz.

Here I have chosen cut-off frequency (fc) (input signal frequency) is half of my ADC sampling rate (fs).




                                                                                               


The following online design tool may helpful for you.
Recently I have used ST electronics android application. It’s really very fun.
You can go through the following link to work for OpAmp circuit and filter design,

Digital filter:
     This is one of the algorithm technique .Generally we are displaying ADC digital value for every sampling processing. But here we can display the average of 20 or 30 (whatever..) digital values. So we can avoid fluctuated data.
The algorithm looks like this,
 Total=ADCValue=FinalVlaue=0;
for(int i =0;i<=20;i++)
{
ADCValue=ADCRead(channel); 
Total=ADCValue+Total;
}
FinalValue=Total/20;
SAC Vs Delta Sigma:
Here I don’t discuss about SAC and Delta Sigma architecture. So we will see again in my future tutorial. But right now I will try to explain about differences and few valid points for our application. Last one year I was using Delta Sigma Architecture ADC. Because it suitable for my following application.
1. It is very accuracy .We don’t feel about Anti-aliasing filter at all. But depends on your application you may need filter circuit.  
2. Compare with SAC architecture, it have slow speed. But it does almost reach enough speed.
Both AFD type ADC chips have I2C and SPI protocol communications.
1. ADS1231:
2. MX7705:
3. MCP3421:





Star Ground System


                  It is one of the essential concept for the system designer .By which, we can limit the noise level for our system. When the people, who are going to interfacing with lot of the boards in the single system, they got ground noise signal. Generally this noise signal induced by the solid state relay, switching application or any other motor driver. But a digital signal is never affected by the any ground noise. But an analog signal is getting affected easily. When you are going to take ADC signal about the sampling voltage level mV or uV, you may get noise values.

You can reduce ground noise following ways,
      
     

      
            
             1. In case your system is having 3 more boards, the power supply for the three boards should be connected with SMPS terminal directly.


         2. In case the first rule not possible, just create a small intermediate stage from SMPS to hub(just kind of small board to distribute power supply). After that all the boards connected with hub's ground directly.