Wednesday 16 May 2007

About CAN Bus measurement

When I just joined my present company, I was assigned to work out the measurement methodology for CAN bus system that was deployed in a development project on hand. Basically, the CAN bus is used to communicate voice and control data between handset (with keypad, microphone and LCD display) and mobile radio transceiver. I was excited as I had worked on some other long distance communication systems previously, I knew that CAN bus is very robust against the noise interference and also capable for transmission up to 1KM distance max, though it has quite a marginal tramission rate, i.e. 1.0Mbit/sec max. Anyway, it is more than sufficient for a number of applications which is not data intensive. The opportunity to work more in depth on CAN bus, would allow me the luxury to spend time with this stuff.


Below diagram depicts the overview of the basic CAN bus system deployed. In this system, there consists of two nodes, namely the handset itself and mobile radio transceiver. They are connected via shielded twisted pair wires with Zo of 120 ohm. The differential signalling and shielded twisted pair characteristics would provide a robust resilience toward EMI. EMIcould be notorious in automative environment that the product itself is installed within. We use TI's CAN bus transceiver IC 65HVD230 with 120 ohm differential termination between differential lines. The CAN logic controller resides in a FPGA developed in-house.




For our CAN bus system, we decided to use Vector CANScope as the measurement tool to capture the eye diagram and respective CAN bus data decipher. The reason being the tool could provide a oscilloscope window to display the bus levels and the eye diagram as well. The ability of different trigger condition is also useful. The cost effectiveness of the tool is also an important factor in the purchase decision over other alternative options.


The captured data signal data could look something like below:




In order to design an eye mask for signal integrity evaluation, we would need to finalize the calculation of the bit segments for our product at max length of 40m. Below calculations shown was completed with reference to "CAN Bit Timing Requirements" technical document released by Freescale Semiconductor.

Bit rate = 1M bit per second
Bus length = 40m (or ~130’)
Bus propagation delay = 5.5 ns/ m
Physical Interface (SN65HVD230) transmitter plus receiver propagation delay = 135ns at 85°C

CAN system clock = 16MHz
Physical delay of bus = 40 x 5.5 ns = 220ns
tPROP_SEG=2(220ns + 135ns)= 710ns

A prescaler value of 1 gives a CAN system clock of 16MHz and a Time Quantum of 62.5ns.

This will give 1000 / 62.5 = 16 time quanta per bit.
Prop_seg = round up (710ns/ 62.5 ns) = 12. Therefore, maximum tprop_seg = 750 ns

From 16 time quanta per bit, subtract 12 for PROP_SEG and 1 for SYNC_SEG. This leaves 3 which is the absolute minimum.

The eye mask diagram shown below would be the eye mask used in the CAN signal evaluation based on the calcualations.

Tuesday 8 May 2007

Surge limiter resistor

I was consulted by my colleague junior engineer, Teoh the other day, on what's the actual function of two big resistors prior to the input of linear regulator as circled in schematic below and how do we arrive at the resistance and power rating values.


The resistors indeed serves as surge limiting resistor. When the raw unregulated supply first applied to the circuit, the sudden ramp-up in supply voltage input would be taken as surge for the input capacitors; and the impedance across the input capacitors would be effectively near zero at that spur of moment. As the capacitors are deemed shorted to ground with the voltage surge, there could be large current surge due to short-circuit condition, if without a proper protection mechanism, this could blow up the capacitors; which is catastrophic failure. This method appears to be the most primitive way to limit the surge.

Another popular method would be using NTC thermistor, which might costs slightly higher, but actually induce less heat disspation because of the intrinsic characteristics of NTC thermistor, its resistance would decrease dramatically as the thermistor self-heats with steady-state current flow. The catch is, NTC thermistor needs cool off time prior to another power surge.

A brief reflective thought brought me to realization that in college time, we were not really taught of the electronics design practices to emphasize on safety and reliability. Engineers would only realize how important of all these practice to make the design survive the test of real world when they start to work.

OK, come back to Teoh's question. Let's take a look at the calculations of the resistance and power rating value in the above shown schematic.

Basically, the raw unregulated power supply input we used here is from normal car battery, i.e. 13.8V nominal +/-20%. That means min voltage @11.04V & max voltage @16.56V.

Take a look at the capacitor spec (the one nearest to the raw voltage supply), the max allowable surge current is slightly above 2A @ 1M frequency, which means fastest surge rise time of ~350ns.

So we would take 700mA as our targetted max allowable current.

Calculate the resistance value according to Ohm's law:

@16.56V, R= 16.56V/0.7A = ~24 ohm
@11.04V, R= 11.04V/0.7A = ~16 ohm

So, we would choose the higher resistance value to achieve lower power disspation; max power dissipation would then be V*V/R = 16.56*16.56/ 24 = ~11.4W.

We would choose the final resistance value to be 25 ohm, and thus the max power disspation is ~11W; we would parallel two resistors of 50 ohm each with power rating of 6W. Anyway, a quick thought on this would reveal that the resistors would be too big physically, and the continuous power loss for nothing during steady state doesn't look good. The use of NTC thermistor would be more appropriate as it dissipates negligible power loss at steady-state. In terms of economics of board space, it is more viable as well.

Sunday 6 May 2007

Monte Carlo

When I first heard of Monte Carlo in my job, I was thinking: "What? What does electronics gotta do with casino and gambling?" Mmm... interesting. Well, it turned out that I was not going to learn any gambling skills from my job, but it's all about statistical modeling to estimate the distribution of dependent Y's values e.g. standby drain current, product reliability, performance & etc. You might question: why we bother about using Monte Carlo simulation? Because there is always a certain extent of uncertainties in real world, we tried our best effort to model the risks involved and make proper decision based on the data available. Instead of using single point estimate of "Most likely" value which could lead to disaster, we could use Monte Carlo simulation results to paint the big picture of the probability distribution.

So, how does it work out basically? Firstly, we would need to define the problem that we try to solve and model the system involved. So, what is a model exactly? It basically consists of a number of inputs (independent X's), the intended output (dependent Y to be studied) and the system itself which is characterized by a transfer function. For example, it could be tolerances for various components to determine to reliability of final product output.



Then, we would need to assign some assumptions to the X's factors (well, we gotta make sure the assumptions are valid, else we ain't get anything meaningful from the result); in turn, appropriate statistical distribution would be allocated for each independent X's. Thirdly, the engine would generate random values for each X's based on the assumptions entered, and the value Y would be computed. The third steps would be repeated for tens of thousands times (the more repetition the better, as it could resemble more closely to real world probability distribution with minimizing of noise with a larger samples). Then, histogram, mean and standard deviation for the value Y could be generated accordingly. The result could be something like this:




The Monte Carlo simulation engine that I have is built-in with the CrystalBall software that my company purchased. Anyway, I believe that if one doesn't bother the hassle to build the Monte Carlo engine him/herself, the Excel spreasheet should be suffice for a simple home-brew version. The same engine could be used for forecasting sales figure or risk management in financial market trading purposes.