Revision: 1717
Author: vsurducan
Date: Sat Feb 27 09:22:28 2010
Log: [No log message]
http://code.google.com/p/jallib/source/detail?r=1717
Added:
/trunk/sample/18F25J10_test_MLX90615.jal
=======================================
--- /dev/null
+++ /trunk/sample/18F25J10_test_MLX90615.jal Sat Feb 27 09:22:28 2010
@@ -0,0 +1,144 @@
+-- ------------------------------------------------------
+-- Title: Test program MLX90615 IR thermometer
+--
+-- Author: Vasile Surducan, Copyright (c) 2010...2012, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: >=2.4m
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: MLX90612 test program
+-- interact with an IR senzor on SMbus
+-- --
+-- This file defines a test for JALLIB testing, using a test-board
+--
+--
+-- Sources:
+--
+-- Notes:
+-- setup:
+-- this test program require a 20x4 HD44780 compatible LCD
+-- and a MLX90515 IR sensor connected on a SMbus
+-- both SMbus data and SMbus clk must be pulled up to 3.3V
+-- ------------------------------------------------------------------
+--
+-- This file has been generated for:
+-- *test SMbus_MLX90615.jal
+--
+
+;@jallib section chipdef
+ include 18f25j10 -- include file definition
+
+
+pragma target clock 10_000_000
+pragma target OSC HS -- run in HS mode at 10Mhz
+pragma target FOSC2 OSC
+pragma target WDTPS P128 -- watch dog saler setting
+pragma target WDT DISABLED -- no watchdog
+pragma target CCP2MUX pin_C1 -- CCP2 pin io muxed with RC1
+pragma target STVR DISABLED -- reset on stack over/under flow
+pragma target DEBUG DISABLED -- background debugging
+pragma target CP0 DISABLED -- code block 0 not protected
+pragma target FCMEN DISABLED
+pragma target IESO DISABLED
+pragma target XINST DISABLED -- extended instruction set
disabled
+
+----------------------------------------------------------------------------
+-- board LCD IO definition
+----------------------------------------------------------------------------
+
+var bit lcd_rs is pin_b2 -- LCD command/data select.
+var bit lcd_rs_direction is pin_b2_direction
+var bit lcd_en is pin_a3 -- LCD data trigger
+var bit lcd_en_direction is pin_a3_direction
+
+
+var bit lcd_d4 is pin_B4 -- databit d4 pin
+var bit lcd_d5 is pin_B5 -- databit d5 pin
+var bit lcd_d6 is pin_B6 -- databit d6 pin
+var bit lcd_d7 is pin_B7 -- databit d7 pin
+
+const byte LCD_ROWS = 4 -- 4 lines
+const byte LCD_CHARS = 20 -- 20 chars per line
+
+
+enable_digital_io() -- make all AD/comparator IO as digital IO
+
+
+lcd_rs_direction = output -- set data pins output
+lcd_en_direction = output
+
+pin_B4_direction = output
+pin_B5_direction = output
+pin_B6_direction = output
+pin_B7_direction = output
+
+;@jallib section lcd
+include lcd_hd44780_4 -- LCD library with 4 data lines
+;@jallib section jal
+include print
+include format
+lcd_init() -- initialize LCD
+----------------------------------------------------------------------------
+
+
+-----------------------------------------------------
+-- board MLX90615 definitions
+-----------------------------------------------------
+var volatile bit SM_SCL is pin_C3
+var volatile bit SM_SCL_direction is pin_C3_direction
+var volatile bit SM_SDA is pin_C4
+var volatile bit SM_SDA_direction is pin_C4_direction
+
+SM_SDA_direction = input
+SM_SCL_direction = input
+-----------------------------------------------------
+;@jallib section temperature
+include SMbus_MLX90615
+
+
+
+forever loop
+
+if nack_counter == 0 then
+ read_MEM (0x5b, RAM_access + raw_IR_data) ; read RAM, IR data
+ lcd_cursor_position(0,0)
+ print_byte_hex ( LCD, MEM_high )
+ lcd = " "
+ print_byte_hex ( LCD, MEM_low )
+ lcd = " "
+ print_byte_hex ( LCD, PEC ) ; read PEC
+
+ read_MEM (0x5b, EEPROM_access + config_reg); read EEPROM, MX90615
config_reg
+ lcd_cursor_position(1,0)
+ print_byte_hex ( LCD, MEM_high )
+ lcd = " "
+ print_byte_hex ( LCD, MEM_low )
+ lcd = " "
+ print_byte_hex ( LCD, PEC ) ; read PEC
+
+ read_MEM (0x5b, RAM_access + Tobject) ; read RAM, Tobject
+ calculate_temp_C
+ lcd_cursor_position(2,0)
+ format_sword_dec ( LCD, temperature_C, 5, 1 )
+ lcd_cursor_position(2,6)
+ lcd = 0b_1101_1111 -- celsius (square) symbol
+ lcd = "C"
+
+ read_MEM (0x5b, RAM_access + Tambiant) ; read RAM, Tambiant
+ calculate_temp_K
+ lcd_cursor_position(3,0)
+ format_word_dec ( LCD, temperature_K, 3, 0 )
+ lcd_cursor_position(3,4)
+ lcd = 0b_1101_1111 -- Kelvin (square) symbol
+ lcd = "K"
+else
+ lcd_clear_screen
+ lcd_cursor_position(0,0)
+ lcd = "E" lcd = "r" lcd = "r"
+end if
+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.