[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previaÚltima revisiónAmbos lados, revisión siguiente | ||
es:howtos:hardware:arm:interfacing_i2c_devices [2019/07/18 17:59 (UTC)] – [Communicating With An I2C Device] rramp | es:howtos:hardware:arm:interfacing_i2c_devices [2019/07/31 01:37 (UTC)] – [Desplazamiento del nivel de tensión] rramp | ||
---|---|---|---|
Línea 55: | Línea 55: | ||
===== Comunicación con un dispositivo I2C ===== | ===== Comunicación con un dispositivo I2C ===== | ||
- | Communication with I2C devices id done by reading and writing to it's registers. Each device has it's own register list and is something you need to look for in the device' | + | La comunicación con dispositivos |
- | Registers can be set by using i2cset | + | Cada dispositivo tiene su propia lista de registros y es algo que debe buscar en la hoja de datos del dispositivo. |
+ | Algunos dispositivos incluso necesitan que se realice una calibración preliminar antes de que pueda leer cualquier dato sensible | ||
+ | Los registros se pueden establecer utilizando | ||
- | Even once you know if your device needs calibration and the registers involved, the content of the registers may not be in a convenient format for ready use. There are generally various | + | Incluso una vez que sepa si su dispositivo necesita calibración y los registros involucrados, el contenido de los registros puede no estar en un formato conveniente para su uso inmediato. Generalmente hay varios |
+ | |||
+ | En este punto es imposible mostrar más información sobre la comunicación I1C sin entrar en detalles sobre un dispositivo específico, | ||
+ | Generalmente cada dispositivo I2C tiene un rango de direcciones que pueden ser configuradas. Nos concentraremos en el dispositivo con dirección 0x69. Haciendo una búsqueda de referencias cruzadas en la hoja de datos de la pcb IMU y en las hojas de datos individuales de cada dispositivo presente en mi IMU, se revela que 0x69 debe ser la dirección de la ITG3200 (giroscopio + sensor de temperatura) y, de hecho, la hoja de datos de la ITG3200 afirma que puede tener una dirección de 0x68 o 0x69 seleccionable por nivel lógico en el pin 9. | ||
+ | No que nosotros necesitamos es la tabla del ITG3200: | ||
- | At this point it's impossible to show any further info about I1C communication without going into some detail about a specific device so I'll pick one ot the devices on my IMU pcb. While detecting previously on my PI I found 4 devices with the flowing hex addresses: 1e,40,69 and 77. | ||
- | Generally each I2C device has a range of addresses than can set. We shall concentrate on the device with 0x69 address. By doing some cross reference search on the IMU pcb datasheet and on the single datasheets of each device present on my IMU it's revealed that 0x69 should be the address of the ITG3200 (gyro + temp sensor) and indeed the ITG3200 datasheet asserts that it can have either 0x68 or 0x69 address selectable by logic level on pin 9. No what we need is the ITG3200 register chart: | ||
Addr Addr | Addr Addr | ||
Línea 80: | Línea 84: | ||
| | ||
- | I chose the ITG3200 | + | Elegí el ITG3200 |
root@pi:~# i2cdump | root@pi:~# i2cdump | ||
Línea 87: | Línea 91: | ||
root@pi:~# | root@pi:~# | ||
- | The above example dumps registers | + | El ejemplo de arriba muestra los registros de volcado |
root@pi:~# i2cget -y 1 0x69 0x1b b | root@pi:~# i2cget -y 1 0x69 0x1b b | ||
Línea 94: | Línea 98: | ||
0x90 | 0x90 | ||
root@pi:~# | root@pi:~# | ||
- | + | | |
- | So we got c090 as our temperature reading. According to the datasheet this value is a 2's compliment of the temperature. So let's try and figure out what that would be: c090 written in binary is 1100000010010000, | + | así que tenemos el registro |
16528 - 32768 = -16240 | 16528 - 32768 = -16240 | ||
- | I was unable to find in the datasheet what units this reading is in but they did mention that there was an average offset of 13200. | + | |
+ | No pude encontrar en la hoja de datos en qué unidades se encuentra esta lectura, pero sí mencionaron que había una compensación promedio de 13200. | ||
35 + ((raw value + 13200) / 280)) | 35 + ((raw value + 13200) / 280)) | ||
35 + ((13200 - 16240)/280) = 24.14 | 35 + ((13200 - 16240)/280) = 24.14 | ||
- | Considering that my current ambient temperature is about 20 Celcius | + | Considerando que mi temperatura ambiente actual es cerca de 20 grados |
- | If you want a script | + | Si quieres un script |
#!/bin/bash | #!/bin/bash | ||
Línea 147: | Línea 152: | ||
echo " | echo " | ||
- | The above script | + | El script |
- | A bash script | + | Un script |
+ | La documentación del núcleo de Linux para i2c me pareció una referencia útil (<kernel source tree>/ | ||
- | I hate showing my poor C programming capabilities but here's some code that uses i2c-dev | + | Odio mostrar mis pobres capacidades de programación en C, pero aquí hay un código que usa i2c-dev |
#include < | #include < | ||
Línea 269: | Línea 275: | ||
- | ====== | + | ====== |
- | You may end up with heterogeneous voltage level devices and if you have many devices the correct way to work around this problem is by using bidirectional | + | |
- | This is how I connected my 5v IMU pcb to a 3.3v I2C bus on my RaspberryPI: | + | Usted puede terminar con dispositivos de nivel de voltaje heterogéneo y si tiene muchos dispositivos, |
+ | Así es como conecté mi PCB IMU de 5V a un bus I2C de 3.3V en mi Raspberry | ||
+ | Tomé como supuesto que 4.4 V (5V con un diodo en serie 1N4148) seguiría siendo una tensión de alimentación tolerable para toda la pcb IMU, lo que probablemente permitiría a todos los dispositivos I2C de la pcb IMU reconocer un mínimo de 3.08 V. (4.4 * 0.7) como la tensión de nivel lógico 1 más baja y fiable, lo que le permitiría interoperar con los niveles lógicos de 3.3V de la Raspberry PI. | ||
+ | No pude encontrar si la Raspberry Pi tiene Resistencias de pullups internas en el bus I2C o si tienen que ser colocados externamente, | ||
====== Fuentes ====== | ====== Fuentes ====== | ||
<!-- If you are copying information from another source, then specify that source --> | <!-- If you are copying information from another source, then specify that source --> |