Revision: 1858
Author: sebastien.lelong
Date: Tue Mar 30 04:48:26 2010
Log: remove invalid lib/sample, moved to group's file section
http://code.google.com/p/jallib/source/detail?r=1858
Deleted:
/trunk/include/external/temperature/mcp9800.jal
/trunk/sample/18f2585_mcp9800.jal
=======================================
--- /trunk/include/external/temperature/mcp9800.jal Fri Mar 26 14:16:03 2010
+++ /dev/null
@@ -1,90 +0,0 @@
--- Title: mcp9800
--- Author: Eur van Andel, [email protected] Copyright (c) 2010
--- Compiler: =2.4m
---
--- This file is part of jallib (http://jallib.googlecode.com)
--- Released under the ZLIB license
(http://www.opensource.org/licenses/zlib-license.html)
---
--- Description: this library works with the MCP9800 temperature sensor
form microchip
--- The MCP9800 can do 9 to 12 bit temperature measurement resolution
--- in the 12bit mode, the LSb represents 1/16ÂșC
--- only 12 bit routines are given here
-
--- Uses: i2c_hardware and i2c_level1 I2C libraries
-
--- Datasheet: DS21909B
-
-
--- MCP9800 I2C sensor
--- part used is MCP9800/02A0 with internal adress set to 0b1001_0000, last
bit is read /write
--- register pointer map:
--- 0b0000_0000 temperature register (16 bits)
--- 0b0000_0001 configuration register ( 8 bits)
--- 0b0000_0010 temperature Hysteresis register (8 bits)
--- 0b0000_0011 temperature Limit-set register (8 bits)
-
-alias i2c_scl is pin_c3
-alias i2c_scl_direction is pin_c3_direction
-alias i2c_sda is pin_c4
-alias i2c_sda_direction is pin_c4_direction
-
--- i2c setup
-const word _i2c_bus_speed = 1 ; * 100kHz
-const bit _i2c_level = true ; i2c levels (not SMB)
-
-include i2c_hardware
-
-i2c_initialize()
-
-var byte i2c_tx_buffer[10]
-var byte i2c_rx_buffer[10]
-
-include i2c_level1 -- send_receive functions
-
-
-
-const byte mcp9800_addr = 0b1001_0000 -- read/write is done by i2c
library
-
-
-function mcp9800_set_12_bits_temperature() return bit is
- var bit tx_ok
- i2c_start()
- tx_ok = i2c_transmit_byte(mcp9800_addr)
- tx_ok = tx_ok & i2c_transmit_byte(0b0000_0001) -- config register
address
- tx_ok = tx_ok & i2c_transmit_byte(0b0_11_00_000) -- config register
value
- i2c_stop()
- return tx_ok
-end function
-
-function mcp9800_celsius() return sbyte is
- var sdword temp
- var byte shift_h, shift_l
- var bit tx_ok
- tx_ok = i2c_send_receive(mcp9800_addr, 1, 2)
- temp = sdword(i2c_rx_buffer[0]) * 256 + i2c_rx_buffer[1]
- temp = temp >> 4 -- last 4 bits are zero
- temp = temp * 625
- return sbyte(temp/10_000) -- 625/0.0625 = 10.000, works below zero
too
-end function
-
-
-function mcp9800_centicelsius() return sword is
- var sdword temp
- var bit tx_ok
- var bit sign at i2c_rx_buffer[0] : 7
- tx_ok = i2c_send_receive(mcp9800_addr, 1, 2)
- temp = sdword(i2c_rx_buffer[0]) * 256 + i2c_rx_buffer[1]
- if sign then
- temp = 65536 - temp -- negative numbers in JALV2 are still a
mystery to me
- end if
- temp = temp >> 4 -- last 4 bits are zero
- temp = temp * 625
-
- if sign then
- return -sword(temp / 100) -- 625/0.0625 = 10.000, div by 100
gives centicelsius
- else
- return sword(temp / 100)
- end if
-
-end function
-
=======================================
--- /trunk/sample/18f2585_mcp9800.jal Fri Mar 26 14:15:16 2010
+++ /dev/null
@@ -1,84 +0,0 @@
--- Title: measuring temperature with the MCP9800 temperature sensor
--- Author: Eur van Andel Copyright (c) 2010, all rights reserved.
--- Compiler: 2.4m
---
--- Description: measure temperature in Celcius, show on LCD
--- uses Sterm single pin LCD/keyboard, compatible with HD44780 LCD
-
-include 18f2585 -- test platform is DB016
-pragma target clock 20_000_000
-pragma target OSC HS
-pragma target XINST disabled
-pragma target WDT disabled
-pragma target LVP disabled
-pragma target MCLR external
-
-enable_digital_io()
-
-const byte LCD_ROWS = 4
-const byte LCD_CHARS = 20
-var bit lcd_sterm_pin is pin_A0 -- ** change this for
regular HD44780 LCD **
-var bit lcd_sterm_pin_dir is pin_A0_direction -- ** change this for
regular HD44780 LCD **
-include lcd_sterm_master -- ** change this for
regular HD44780 LCD **
-
-include delay
-include print
-include format
-include mcp9800
-
-var bit tx_ok
-
--- -------------------------------------- S T A R T M A I N
--------------------
-
--- wait for STERM Slave to power-up and initialize.
-for 4 loop
- lcd_clear_screen() -- Sterm needs some time after power-up
- delay_100ms(2)
-end loop
-
-const byte str0[]="MCP9800 temperature" -- print banner
-const byte str1[]="via I2C"
-
-lcd_cursor_position(0,0) -- line 1
-print_string(lcd, str0)
-lcd_cursor_position(1,0) -- line 2
-print_string(lcd, str1)
-
-const byte str3[]="12bit temp set OK "
-const byte str4[]="Can't reach MCP9800 "
-
-lcd_cursor_position(3,0) -- line 4
-tx_ok = mcp9800_set_12_bits_temperature
-if tx_ok then
- print_string(lcd, str3) -- to see if setup went OK
-else
- print_string(lcd, str4)
-end if
-
-for 8 loop -- leave banner on
for a while
- delay_100ms(5)
-end loop
-
-lcd_clear_screen()
-
-
-forever loop -- --------------------------- M A I N L O O P
----------------------------
-
- lcd_cursor_position(0,0)
- format_sword_dec(lcd, mcp9800_centicelsius(), 6, 2)
- lcd = " "
- lcd = "C"
- lcd = " "
- lcd = " "
-
- lcd_cursor_position(1,0)
- print_sbyte_dec(lcd, mcp9800_celsius())
- lcd = " "
- lcd = "C"
- lcd = " "
- lcd = " "
-
- delay_100ms(2) -- for LCD visibility
-
-end loop
-
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.