# smbus_mlx90615

SM bus library for Melexis IR sensor MLX90615

Author | Vasile Surducan, Copyright © 2010...2012, all rights reserved.
Adapted-by |
Compiler | >=2.4m

Description

    software implementation for single SMbus master, use 4 hw stack

Dependencies

- delay

## Summary

### Global variables/contants

- `const id_number1 = 0x0F ; read only`
- `var word temp = 0`
- `var byte mem_low = 0`
- `var volatile bit pwm_frequency at config: 1 ; 1=low, 0=high`
- `var word config`
- `const raw_ir_data = 0x05`
- `var word temperature_k = 0`
- `const tambiant = 0x06`
- `const emissivity = 0x03`
- `var volatile bit*3 iir_setting at config: 12 ; see table below`
- `var word w_t_high = 0`
- `var sword temperature_c = 0`
- `var byte mem_high = 0`
- `var byte t_high = 0`
- `var volatile bit zero at config: 15 ; keep 0`
- `const config_reg = 0x02`
- `const bit ACK = low`
- `const pwm_t_range = 0x01`
- `const bit NACK = high`
- `const tobject = 0x07`
- `var sword temperature = 0`
- `const id_number0 = 0x0E ; read only`
- `const eeprom_access = 0b0001_0000`
- `var volatile bit*9 factory_cal at config: 3 ; do not alter`
- `const sleep_mode = 0b1100_0110`
- `const smbus_sa = 0 ; SMbus Slave Address 7 bit, 0 to 6; 0x5b factory default`
- `var sword s_t_high = 0`
- `var bit mlx90615_ack = high`
- `const ram_access = 0b0010_0000`
- `var byte pec = 0`
- `var volatile bit mode_select at config: 0 ; 1=SMbus, 0=PWM`
- `var volatile bit pwm_output_temp at config: 2 ; 1=Tambiant, 0=Tobject`
- `const sword c27315 = 27315`
- `var byte nack_counter = 0`

### Procedures

- `mlx90615_sleep( byte in senzor_address )`
- `calculate_temp_k()`
- `mlx90615_wake()`
- `calculate_temp_c()`
- `sm_start_bit()`
- `sm_stop_bit()`
- `sm_bus_initialize() is ; not necesary if SMbus`

Private

- `_scl_high()`
- `_sda_high()`
- `_scl_low()`
- `_sm_send_bit(bit in x)`
- `_sda_low()`
- `_sm_receive_bit(bit out x)`

### Functions

- `sm_transmit_byte(byte in tx_buffer) return bit`
- `sm_receive_byte(bit in ack_noack) return byte`

## API details

### Global variables/contants

- `const id_number1 = 0x0F ; read only`

  No documentation found

- `var word temp = 0`

  No documentation found

- `var byte mem_low = 0`

  No documentation found

- `var volatile bit pwm_frequency at config: 1 ; 1=low, 0=high`

  No documentation found

- `var word config`

  No documentation found

- `const raw_ir_data = 0x05`

      0x04 to 0x4h Melexis reserved

- `var word temperature_k = 0`

  No documentation found

- `const tambiant = 0x06`

  No documentation found

- `const emissivity = 0x03`

  No documentation found

- `var volatile bit*3 iir_setting at config: 12 ; see table below`

  No documentation found

- `var word w_t_high = 0`

  No documentation found

- `var sword temperature_c = 0`

  No documentation found

- `var byte mem_high = 0`

  No documentation found

- `var byte t_high = 0`

      var byte t_low = 0

- `var volatile bit zero at config: 15 ; keep 0`

  No documentation found

- `const config_reg = 0x02`

  No documentation found

- `const bit ACK = low`

  No documentation found

- `const pwm_t_range = 0x01`

  No documentation found

- `const bit NACK = high`

  No documentation found

- `const tobject = 0x07`

  No documentation found

- `var sword temperature = 0`

  No documentation found

- `const id_number0 = 0x0E ; read only`

  No documentation found

- `const eeprom_access = 0b0001_0000`

  No documentation found

- `var volatile bit*9 factory_cal at config: 3 ; do not alter`

  No documentation found

- `const sleep_mode = 0b1100_0110`

  No documentation found

- `const smbus_sa = 0 ; SMbus Slave Address 7 bit, 0 to 6; 0x5b factory default`

  No documentation found

- `var sword s_t_high = 0`

  No documentation found

- `var bit mlx90615_ack = high`

  No documentation found

- `const ram_access = 0b0010_0000`

  No documentation found

- `var byte pec = 0`

  No documentation found

- `var volatile bit mode_select at config: 0 ; 1=SMbus, 0=PWM`

  No documentation found

- `var volatile bit pwm_output_temp at config: 2 ; 1=Tambiant, 0=Tobject`

  No documentation found

- `const sword c27315 = 27315`

  No documentation found

- `var byte nack_counter = 0`

  No documentation found

### Procedures

- `mlx90615_sleep( byte in senzor_address )`

  No documentation found

- `calculate_temp_k()`

      conversion to kelvin

- `mlx90615_wake()`

  No documentation found

- `calculate_temp_c()`

  No documentation found

- `sm_start_bit()`

      SMbus start bit

- `sm_stop_bit()`

      SMbus stop bit

- `sm_bus_initialize() is ; not necesary if SMbus`

  No documentation found

Private

- `_scl_high()`

  No documentation found

- `_sda_high()`

  No documentation found

- `_scl_low()`

  No documentation found

- `_sm_send_bit(bit in x)`

      Transmit one bit on SM bus (for internal use only )

- `_sda_low()`

  No documentation found

- `_sm_receive_bit(bit out x)`

      Receive one bit on SM bus (for internal use only)

### Functions

- `sm_transmit_byte(byte in tx_buffer) return bit`

      Transmit one byte on SM bus

- `sm_receive_byte(bit in ack_noack) return byte`

      Receive one byte on SM bus

## Related samples

Here are the list of samples which use this library:

18f25j10 | 18f25j10_test_mlx90615.jal