TLE493D-A2B6(TLE) is a smart I2C sensor capable to detect the movement of a magnet.
This Story documents the Powerberry(PWB) app that we have developed to make experiments/test the chip and the real case study applied to a product we are developing.
The APPThe APP is provided in source-executable code, so you can change its behavior as you want.
Connect the TLEThe connection between the raspberry PI and the TLE is through the I2C. An easy connection of 4 cables.
You have to prepare a microSD with Win10 IoT on it, to do that follow the instruction from here.
Install PowerBerry and POWER-KIYou need to install on the board, the PowerBerry SUP (Start Up Package) that contains also the TLE app and at least the POWER-KI GUI on your computer. To do that register and login yourself at PowerBerry site and follow the instructions.
Find your boardTo help to find your board on the network you can use WinIotDetector, that again you can get from your PowerBerry dashBoard.
From your (windows) computer connect to the PowerBerry Manager(PBM) of the board and start the TLE app.
pwb-TLE493D-A2B6.pwk (the App)If all works, moving the TLE you will see the data on the interface. The read Method (see below) has a data filter that you can adjust or disable (0 sample) from the config page.
This app is written in POWER-KI (you need the POWER-KI WorkBench to edit and explore) is an useful example of many technologies (NativeClud, WEB, HIO..) but for our purpose the relevant part is the TLE493D VAR that contains in three methods all the code the you need to operate with the TLE: INIT, READ, PARITY.
===========================================================================
(VAR) TLE493D
Infineon 3D Magnetic sensor 2Go : TLE493D A2B6
--------------------------------------------------
REG_NUM: 23
RG_CFG: 0x10
RG_MOD1: 0x11
RG_MOD2: 0x13
V_MLT: 0.16
T_OFF: 1180
T_MLT: 0.24
T_AMB: 25
--------------------------------------------------
========================================
(MTHD) INIT
--------------------------------------------------
addr:
tle: (TBL)
i2c:
buf:
t:
--------------------------------------------------
..............................
tle=NULL;
addr=if(addr==0 or ~addr==0, 0x6A,addr);
addr=addr >>1;
i2c=HIO_I2Cnew(£I2C,addr);
#if(i2c);
tle=TBL_NEW(NULL,1,NULL,NULL,"i2c;buf;X;Y;Z;T;DGN;AZM;PLR;NRM;SX;SY;SZ;NS;XV;YV;ZV");
buf=BUF_NEW(REG_NUM,£U8);
HIO_I2C(i2c,£READ,buf,NULL,0x0);
TBL_ITM(tle,£i2c,1,i2c);
TBL_ITM(tle,£buf,1,buf);
#end;
..............................
(FALSE) tle
(BREAK) break
--------------------------------------------------
_LEVEL_: (Type of ITEM that break)
--------------------------------------------------
..............................
t=buf_val(buf,RG_MOD1+1);
t=BITF(t,5,1,1,8); !!PR;
buf_val(buf,RG_MOD1+1,t);
t=buf_val(buf,RG_MOD1+1);
t=BITF(t,2,2,0b01,8); !!MODE;
buf_val(buf,RG_MOD1+1,t);
t=buf_val(buf,RG_CFG+1);
t=BITF(t,8,1,0,8); !!TEMP;
buf_val(buf,RG_CFG+1,t);
t=buf_val(buf,RG_CFG+1);
t=BITF(t,6,2,0b10,8); !!TRIG;
buf_val(buf,RG_CFG+1,t);
EXO(£PARITY, tle::tle, wht::£FP);
EXO(£PARITY, tle::tle, wht::£CP);
HIO_I2C(i2c,£WRITE,NULL,RG_CFG,buf_val(buf,RG_CFG+1));
HIO_I2C(i2c,£WRITE,NULL,RG_MOD1,buf_val(buf,RG_MOD1+1));
HIO_I2C(i2c,£READ,buf);
..............................
========================================
(MTHD) READ
--------------------------------------------------
tle:
trg: 0b100
buf:
h:
l:
v:
i:
X:
Y:
Z:
NS: 0
SX:
SY:
SZ:
eps:
NC:
--------------------------------------------------
(FALSE) tle
(BREAK) break
--------------------------------------------------
_LEVEL_: (Type of ITEM that break)
--------------------------------------------------
..............................
buf=TBL_ITM(tle,"buf",1);
NS=TBL_ITM(tle,£NS,1);
SX=TBL_ITM(tle,£SX,1);
SY=TBL_ITM(tle,£SY,1);
SZ=TBL_ITM(tle,£SZ,1);
eps=TBL_ITM(setT@\DATA,£eps,1);
NC=TBL_ITM(setT@\DATA,£NC,1);
HIO_I2C(TBL_ITM(tle,"i2c",1),£Read,buf,7);
TBL_ITM(tle,£DGN,1,bin(buf_val(buf,7)));
l=BUF_VAL(buf,5);
v=buf_val(buf,1)<<4 | (l >>4 & 0xF);
X=int(v,12);
v=buf_val(buf,2)<<4 | (l & 0xF);
Y=int(v,12);
l=BUF_VAL(buf,6);
v=buf_val(buf,3)<<4 | (l & 0xF);
Z=int(v,12);
v=buf_val(buf,4)<<4 | ((l >> 4) & 0b1100);
v=int(v,12);
v=(v-T_OFF)*T_MLT+T_AMB;
TBL_ITM(tle,"T",1,v);
#if(NC>1); !!FILTER;
#if(MAX(abs(X-TBL_ITM(tle,£XV,1)), abs(Y-TBL_ITM(tle,£YV,1)), abs(Z-TBL_ITM(tle,£ZV,1)))>eps);
SX=0;
SY=0;
SZ=0;
NS=0;
#end;
TBL_ITM(tle,£XV,1,X);
TBL_ITM(tle,£YV,1,Y);
TBL_ITM(tle,£ZV,1,Z);
#if(NS<NC);
NS=NS+1;
SX=SX+X;
SY=SY+Y;
SZ=SZ+Z;
#else;
SX=(SX-SX/NS)+X;
SY=(SY-SY/NS)+Y;
SZ=(SZ-SZ/NS)+Z;
X=SX/NS;
Y=SY/NS;
Z=SZ/NS;
#end;
#end;
v=X*V_MLT;
TBL_ITM(tle,"X",1,v);
v=Y*V_MLT;
TBL_ITM(tle,"Y",1,v);
v=Z*V_MLT;
TBL_ITM(tle,"Z",1,v);
v=V_MLT * sqrt(X^2 + Y^2 +Z^2);
TBL_ITM(tle,£NRM,1,v);
v=atan2(Y,X) *180 / pi;
TBL_ITM(tle,£PLR,1,v);
v=atan2(Z,sqrt(X^2 + Y^2))*180 / pi;
TBL_ITM(tle,£AZM,1,v);
TBL_ITM(tle,£NS,1,NS);
TBL_ITM(tle,£SX,1,SX);
TBL_ITM(tle,£SY,1,SY);
TBL_ITM(tle,£SZ,1,SZ);
..............................
========================================
(MTHD) PARITY
--------------------------------------------------
tle:
wht: (£FP,£CP)
v:
reg:
irg:
buf:
rgv:
i:
--------------------------------------------------
..............................
v=0;
buf=tbl_itm(tle,£buf,1);
..............................
(SWITCH) wht
--------------------------------------------------
c_FP: FP
C_CP: CP
--------------------------------------------------
(CASE) _DEFAULT_
(BREAK) break
--------------------------------------------------
_LEVEL_: (Type of ITEM that break)
--------------------------------------------------
(CASE) c_FP
..............................
reg=RG_MOD1+1;
irg=8;
..............................
(CALL) setParity
..............................
v=v % buf_val(buf,18);
v=v % (buf_val(buf,20) & 0x80);
..............................
(CASE) C_CP
..............................
reg=RG_CFG+1;
irg=1;
..............................
(CALL) setParity
..............................
i=7;
#while(i=i+1, i<= 13);
v= v % buf_val(buf,i);
#end;
v= v % (buf_val(buf,14) & 0x7F);
v= v % (buf_val(buf,15) & 0x3F);
v= v % (buf_val(buf,16) & 0x3F);
v= v % buf_val(buf,17);
..............................
..............................
v= v % (v >>1);
v= v % (v >>2);
v= v % (v >>4);
v = v & 0x1;
rgv=BITF(rgv,irg,1,v,8);
buf_val(buf,reg,rgv);
..............................
(BLK) setParity
..............................
rgv=buf_val(buf,reg);
rgv=BITF(rgv,irg,1,1,8);
buf_val(buf,reg,rgv);
..............................
========================================
The Package contains also some docs about TLE.
Real case Study: intelligent remote controllerThe relevant points of TLE technology are: the motion capture without contact with a very good degree of precision and the simplification of mechanics and wiring with the consequent reduction of the overall required dimensions. With this in mind we have rethink one product we are developing.
Is an intelligent remote control to be used outdoors. Actual implementation make use buttons (4) and rotary switch(4), the latter are very cumbersome and require considerable box space.
Even the wiring is very messy, in fact 8x2 cables are required and occupy many controller ports.
Instead using the TLE, and four rotary/push selector, fixed outside the box, we can get the following results:
- reduce the thickness to half;
- ordered wiring with only one cable (in daisy chain);
- use of the only I2C port of the controller;
- a WATERPROOF product !
AND : a dramatic reduction of :
- mechanical machining (no hole);
- assembly time;
- components costs.
Without counting the savings due to the elimination of wiring errors, we have estimated that on this product we can have an overall cost reduction no less then 50%.
----
Let us know.
Comments