kennt jemand den Sensor TLV493D-a1b6

jomixl
Benutzer
Avatar
Gender:
Posts: 225
Registered: 02 / 2008
Subject:

kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 09.04.2021 - 15:24  ·  #1
Hallo zusammen,
seit tagen versuche ich ein Board mi 8 solchen Sensoren zum laufen zu bringen ......,
leider nur mit beschränktem Erfolg. Das Problem liegt in der Initialisierung bzw bei der Vergabe der I2C-Adressen. Bei 3 von 8 funktioniert das auch bereits aber das war es dann ....

Nun meine Frage, hat jemand schon mit diesen Sensoren gearbeitet, bzw hat jemand ein paar Zeilen code für mich mit einer funktionierenden Initialisierung?. Im Netz und von Infineon gibt es zwar Code Beispiele, die sind aber alle für Arduino und zu kryptisch für mich.

schönes Wochenende und bleibt gesund
Joachim
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 09.04.2021 - 21:05  ·  #2
Can you show us your initialisation code?
jomixl
Benutzer
Avatar
Gender:
Posts: 225
Registered: 02 / 2008
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 11.04.2021 - 10:04  ·  #3
Code

procedure InitMode(DevAdr : byte); 
var
  i      : byte; 
  oddpar, ok : boolean; 
begin
  Writeln(Serout, 'TLV_init'); 
  if I2Cinp(DevAdr, TLV_rdBuf) then 
    
    TLV_wrBuf[0]:= TLV_rdBuf[7] and %01111000; 
    TLV_wrBuf[0]:= TLV_wrBuf[0] or TLV_BITS_FST; 
    TLV_wrBuf[1]:= TLV_rdBuf[8]; 
    TLV_wrBuf[2]:= TLV_rdBuf[9] and %00011111; 
    TLV_wrBuf[2]:= TLV_wrBuf[2] or TLV_BITS_LPP or TLV_BITS_PTE; 
    
    // Parity 
    //    oddpar:= parity(TLV_rdBuf[6]); 
    oddpar:= parity(TLV_wrBuf[0]); 
    oddpar:= oddpar xor parity(TLV_wrBuf[1]); 
    oddpar:= oddpar xor parity(TLV_wrBuf[2]); 
    
    if not (oddpar) then 
      TLV_wrBuf[0]:= TLV_wrBuf[0] or %10000000; 
    endif; 
    
    for i:= 0 to 1 do 
      Write(Serout, bytetobin(TLV_wrBuf[i])); 
      Write(Serout, ','); 
    endfor; 
    Writeln(Serout, bytetobin(TLV_wrBuf[i])); 
    
    if not (I2Cout(DevAdr, 0, TLV_wrBuf)) then 
      Writeln(Serout, 'Write Error'); 
    endif; 
  else 
    Writeln(Serout, 'Read Error'); 
  endif; 
end; 


function InitAdr(DevAdr, iicadr : byte) : boolean; 
var
  MOD1 : byte; 
begin
  I2Cout(DevAdr, 0); 
  mdelay(5); 
  MOD1:= %010; 
  MOD1:= MOD1 or (iicadr shl 5); 
  if not (parity(MOD1)) then 
    MOD1:= MOD1 or %10000000; 
  endif; 
  Writeln(Serout, bytetobin(MOD1)); 
  if not (I2Cout(DevAdr, 0, MOD1)) then 
    Writeln(Serout, 'Init Error ' + bytetobin(MOD1)); 
    //    I2Cout(DevAdr, 0); 
    return(false); 
  endif; 
  return(true); 
end; 


// setze Adressbits und PowerMode = master controlled 
procedure TLV_PowerUp; 
begin
  sda:= true; 
  scl:= true; 
  mdelay(10); 
  InitAdr($5E, %11); 
  InitMode($4A); 
  
  sda:= true; 
  mdelay(10); 
  TLVVCC1:= true; 
  InitAdr($5E, %10); 
  InitMode($4E); 
  
  sda:= true; 
  mdelay(10); 
  TLVVCC2:= true; 
  InitAdr($5E, %01); 
  InitMode($5A); 
  
  sda:= true; 
  mdelay(10); 
  TLVVCC3:= true; 
  InitAdr($5E, %00); 
  InitMode($5E); 
  
  
  
  sda:= false; 
  mdelay(10); 
  TLVVCC4:= true; 
  InitAdr($1F, %11); 
  InitMode($0B); 
  
  sda:= false; 
  mdelay(10); 
  TLVVCC5:= true; 
  InitAdr($1F, %10); 
  InitMode($0F); 
  
  sda:= false; 
  mdelay(10); 
  TLVVCC6:= true; 
  InitAdr($1F, %01); 
  InitMode($1B); 
  
  sda:= false; 
  mdelay(10); 
  TLVVCC7:= true; 
  InitAdr($1F, %00); 
  InitMode($1F); 
  
// I2Cscan; 
  
end; 



hello merlin,
this is the code i'm using at the moment. It is working somehow but it is not really stable.
One time all sensors are initialized, next time one or two not and they are not all times the same.
I guess this is a problem of timing during initialisation but i did not find the hotspot til now.
This is the reason why i'm using softi2c. When a sensor is completely initialized it is working correct. Beside this sensors there are two other devices on the board (NCP5623,PCA9554) and they are also working.
At the moment i have no idea what to do to get it stable.

Thanks for your interest
regards joachim
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 11.04.2021 - 12:44  ·  #4
Yes, initialising these devices is difficult and time critical, looking at the specs. Each device must be powered and initialised separately. You will probably find the optimiser makes things worse too. You could try increasing your delays to make things more stable I guess, perhaps between InitAdr and InitMode.

Since sometimes it works then the basic functions must be correct. It hopefully is just a case of the timing.

Good luck
jomixl
Benutzer
Avatar
Gender:
Posts: 225
Registered: 02 / 2008
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 11.04.2021 - 13:13  ·  #5
Yes, you are probably right with this. I have two boards with different behaviour .
The influence of the optimizer is only that it changes the not working sensors, similar to change the board ......

I need some luck to find it out ...
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 11.04.2021 - 21:19  ·  #6
I definitely think a small delay between

Code
  InitAdr($1F, %10); 

and
Code
  InitMode($0F);


will help. You need to allow 0.2ms between these for reliable initialisation.

Regards
jomixl
Benutzer
Avatar
Gender:
Posts: 225
Registered: 02 / 2008
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 12.04.2021 - 15:01  ·  #7
hello merlin,
i have tried up to 10ms delay between both calls without result,
but in the meantime i found a solution:
I have used for the pullup resistors a value of 2k7.
After i have changed the value to 1k2 all sensors are running.
I have tried it on 3 diffrent boards with the same result.

regards
joachim
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: kennt jemand den Sensor TLV493D-a1b6

 · 
Posted: 12.04.2021 - 15:56  ·  #8
Excellent news. Of course I always look for a software solution :-)
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   137   151 · Page-Gen-Time: 0.034195s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI