Template for LPC1768

Dependencies:   Gimbal MLX90620 Socket lwip-eth lwip-sys lwip mbed-rtos mbed

Fork of EkkoEye by EkkoSense

Files at this revision

API Documentation at this revision

Comitter:
gardnmc
Date:
Thu Apr 14 13:02:29 2016 +0000
Parent:
53:72f350a6d09c
Commit message:
libs

Changed in this revision

CGimbal.cpp Show diff for this revision Revisions of this file
CGimbal.h Show diff for this revision Revisions of this file
CMLX90620.cpp Show diff for this revision Revisions of this file
CMLX90620.h Show diff for this revision Revisions of this file
Gimbal.lib Show annotated file Show diff for this revision Revisions of this file
MLX90620.lib Show annotated file Show diff for this revision Revisions of this file
--- a/CGimbal.cpp	Thu Apr 14 13:45:38 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-/*
- * CGimbal.cpp
- *
- *  Created on: 15 Feb 2016
- *      Author: mike
- */
-#include "base.h"
-#include <CGimbal.h>
-#include <math.h>
-int debug = 0;
-
-extern Serial pc;
-
-/*
- * The way-points required when performing a sweep of the room, moves from Home to a mid-point of the left-most x,y coords
- * Then moves at 60 degree increments to the right-most position
- * Then moves down at 15 degree increments
- * Uses meander-scan technique rather than raster-scan to reduce motor loading and risk of skipping steps
- */
-static const float ScanArray[36][2] =
-{
-	{30, 7.5}, {90, 7.5}, {150, 7.5}, {150, 22.5}, {90, 22.5}, {30, 22.5},
-	{30, 37.5}, {90, 37.5}, {150, 37.5}, {150, 52.5}, {90, 52.5}, {30, 52.5},
-	{30, 67.5}, {90, 67.5}, {150, 67.5}, {150, 82.5}, {90, 82.5}, {30, 82.5},
-	{30, 97.5}, {90, 97.5}, {150, 97.5}, {150, 112.5}, {90, 112.5}, {30, 112.5},
-	{30, 127.5}, {90, 127.5}, {150, 127.5}, {150, 142.5}, {90, 142.5}, {30, 142.5},
-	{30, 157.5}, {90, 157.5}, {150, 157.5}, {150, 172.5}, {90, 172.5}, {30, 172.5}
-};
-
-
-
-CGimbal::CGimbal(DigitalOut * pXStepPin, DigitalOut * pXDirPin, DigitalOut * pYStepPin, DigitalOut * pYDirPin)
-{
-	//	Zero the tracking parameters
-
-	m_StepInterval = DFT_STEP_INTERVAL;		//	Determines the default motor speed (10us Ticks between each step pulse)
-	m_AbsoluteXPos = 0;						//	Always starts at 0 point
-	m_AbsoluteXAngle = 0.0;					//	Ditto
-	m_AbsoluteYPos = 0;
-	m_AbsoluteYAngle = 0.0;
-	m_xDir = FORWARD;						//	Always initialised in forward direction
-	m_yDir = FORWARD;						//	Ditto
-
-	m_xSteps=0;								//	Nothing to do immediately after being constructed
-	m_ySteps=0;
-
-	m_pXStepPin = pXStepPin;				//	Initialise Pointers to each pin
-	m_pXDirPin = pXDirPin;
-	m_pYStepPin = pYStepPin;
-	m_pYDirPin = pYDirPin;
-
-	m_pXStepPin->write(0);					//	Set all motor driver signals to a known state (LOW)
-	m_pXDirPin->write(0);
-	m_pYStepPin->write(0);
-	m_pYDirPin->write(0);
-
-	m_NumWaypoints = 2;						//	Start with 2 waypoints
-
-	m_TickCount=0;							//	Start at 0
-}
-
-//	Destructor
-CGimbal::~CGimbal()
-{
-
-}
-
-/*
- *	Perform a vectored move, relative to the current x,y position and update internal tracking parameters
- */
-int	CGimbal::MoveRel()
-{
-
-	if (m_xSteps > 0)					//	Determine which direction the motors needs to move
-		m_xDir = FORWARD;
-	else
-		m_xDir = REVERSE;
-	if (m_ySteps > 0)
-		m_yDir = 1;
-	else
-		m_yDir = 0;
-	m_pXDirPin->write(m_xDir);
-	m_pYDirPin->write(m_yDir);
-
-	if (m_xSteps > 0)					//	Absolute number of pulses is always positive regardless of directiong
-		m_xPulses = m_xSteps;
-	else
-		if ((m_xSteps < 0))
-			m_xPulses = -m_xSteps;
-		else
-			m_xPulses = 0;				//	If no steps, do nothing
-
-	if (m_ySteps > 0)					//	Absolute number of pulses is always positive regardless of directiong
-		m_yPulses = m_ySteps;
-	else
-		if ((m_ySteps < 0))
-			m_yPulses = -m_ySteps;
-		else
-			m_yPulses = 0;				//	If no steps, do nothing
-
-	//	Wait for the Ticker to complete this move
-	while (m_xPulses > 0 || m_yPulses > 0);
-
-	m_AbsoluteXPos += m_xSteps;			//	Track the new absolute x position
-	m_AbsoluteYPos += m_ySteps;			//	Track the new absolute y position
-	m_AbsoluteXAngle = (float) ( (float) m_AbsoluteXPos * DEGREES_PER_STEP);	//	Track the new absolute x angle
-	m_AbsoluteYAngle = (float) ( (float) m_AbsoluteYPos * DEGREES_PER_STEP);	//	Track the new absolute y angle
-
-	return(0);
-
-}
-
-/*
- *	Work through the pre-defined tour points to conduct a sweep of the scene in 3 60-degree steps by 12 15-degree steps
- *	Uses a meander-scan rather than raster-scan technique to reduce motor loading
- *	Covers a total scene angle of 180 x 180 (Presently, some points may be occluded by the gimbal housing)
- */
-void CGimbal::MeanderScan(void)
-{
-	int i;
-
-		for (i=0; i<36; i++)
-		{
-			RotateAbs(ScanArray[i][X_AXIS], ScanArray[i][Y_AXIS] );
-		}
-}
-
-/*
- *	Move to absolute x,y position in steps
- */
-int	CGimbal::MoveAbs(float x, float y)
-{
-	m_xSteps = x - m_AbsoluteXPos;
-	m_ySteps = y - m_AbsoluteYPos;
-
-	MoveRel();
-
-	return(0);
-}
-
-/*
- *	Move to absolute x,y angle in degrees
- */
-int	CGimbal::RotateAbs(float xAngle, float yAngle)
-{
-	m_xSteps = (float) ((float) ((xAngle - m_AbsoluteXAngle) / (float) DEGREES_PER_STEP));
-	m_ySteps = (float) ((float) ((yAngle - m_AbsoluteYAngle) / (float) DEGREES_PER_STEP));
-
-	MoveRel();
-
-	return(0);
-}
-
-/*
- *	Calculate how far away from the home position
- *	Then move there.  Note speed is reduced during homing
- */
-void	CGimbal::Home(void)
-{
-	int	oldSpeed = m_StepInterval;
-
-	m_StepInterval = HOME_STEP_INTERVAL;
-
-	m_xSteps = -m_AbsoluteXPos;
-	m_ySteps = -m_AbsoluteYPos;
-	MoveRel();
-
-	m_StepInterval = oldSpeed;
-
-}
-
-/*
- * Rotate to waypoint n.  x,y angle parameters are stored in the member array
- */
-int CGimbal::TourPoint(int n)
-{
-	RotateAbs(m_TourPoints[X_AXIS][n], m_TourPoints[Y_AXIS][n]);
-	return(0);
-}
-
-/*
- * Define the current point as the home reference
- */
-void	CGimbal::Zero(void)
-{
-	int	oldSpeed = m_StepInterval;
-	int timeout = 0;
-
-
-	//	Move at normal speed until 20 steps away from opto switch
-	m_xSteps = (-m_AbsoluteXPos) - 20;
-	m_ySteps = (-m_AbsoluteYPos) -20;
-	MoveRel();
-
-	// Now move at Homing (slow) speed until X opto reached
-	m_StepInterval = HOME_STEP_INTERVAL;
-
-	for (timeout = 0; timeout < 10; timeout++)
-	{
-
-	}
-	//	Move at normal speed until 20 steps away from opto switch
-	//m_xSteps = -(sgn(m_AbsoluteXPos) - 20);
-
-
-	m_StepInterval = oldSpeed;
-
-}
-
-
--- a/CGimbal.h	Thu Apr 14 13:45:38 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * CGimbal.h
- *
- *  Created on: 15 Feb 2016
- *      Author: mike
- */
-#ifndef CGIMBAL_H_
-#define CGIMBAL_H_
-
-#include "mbed.h"
-
-#define FORWARD	0				// Used for the direction pin
-#define REVERSE 1				// Used for the direction pin
-#define	CLOCKWISE 0				// Used for the direction pin
-#define	ANTICLOCKWISE 1			// Used for the direction pin
-#define DFT_STEP_PULSE 0.00002	// 20us is recommended pulse width for most stepper drivers
-#define X_AXIS 0				// Used for Tour array indexing
-#define	Y_AXIS 1				// Used for Tour array indexing
-#define NUM_AXES 2				// Used for Tour array indexing
-#define DEGREES_PER_STEP 	.1125	//	0.45 & 200 steps per revolution give 360/3200 degrees per step (1/16microsteps)
-#define	DFT_STEP_INTERVAL	250 // Normal time interval between pulses (5ms =  250 * 20us)
-#define	HOME_STEP_INTERVAL	500 // Moves more slowly when homing (10ms = 250 * 20us)
-#define MAX_TOUR 10				// Maximum number of way-points that can be performed in a single tour
-
-class CGimbal
-{
-	public:
-
-	DigitalOut * m_pXStepPin;					//	Pointer to the X axis step pin
-	DigitalOut * m_pXDirPin;					//	Pointer to the Y axis step pin
-	DigitalOut * m_pYStepPin;					//	Pointer to the X axis direction pin
-	DigitalOut * m_pYDirPin;					//	Pointer to the Y axis direction pin
-
-	//	Constructor
-	CGimbal(DigitalOut * pXStepPin, DigitalOut * pXDirPin, DigitalOut * pYStepPin, DigitalOut * pYDirPin);
-
-	//	Destructor
-	~CGimbal();
-
-	void Zero(void);
-	void Home(void);							//	Move to the Home position
-	int MoveRel();								//	Move (x, y) relative to current position
-	int MoveAbs(float x, float y);				//	Move to Absolute (x,y) position
-	int	RotateAbs(float xAngle, float yAngle);	//	Rotate to Absolute (x,y) angle in degrees
-	int TourPoint(int n);							//	Execute a tour using n stored waypoints
-	void MeanderScan(void);						//	Perform a full sweep at increments of (60, 15) degrees
-
-	int	m_StepInterval;							//	The time in 10us increments between each Step pulse (ie 100 = 1ms)
-	int m_AbsoluteXPos;							//	The current motor x axis position in steps (800 per revolution)
-	int m_AbsoluteYPos;							//	The current motor y axis position in steps (800 per revolution)
-
-	float m_AbsoluteXAngle;						//	The current motor x axis angle in degrees
-	float m_AbsoluteYAngle;						//	The current motor y axis angle in degrees
-
-	int m_xSteps;								//	Tracks the number of required x steps (+/-) when moving relative or absolute
-	int m_ySteps;								//	Tracks the number of required y steps (+/-) when moving relative or absolute
-	int m_xPulses;								//	Tracks the number of required x pulses when moving (always a positive value)
-	int m_yPulses;								//	Tracks the number of required y pulses when moving (always a positive value)
-	int	m_xDir;									//	X Direction: Used internally when moving, calculated from m_xSteps 1 to move ccw, 0 to move cw
-	int	m_yDir;									//	Y Direction: Used internally when moving, calculated from m_xSteps 1 to move ccw, 0 to move cw
-
-	int	m_NumWaypoints;
-	float m_TourPoints [NUM_AXES] [MAX_TOUR];	//	Used to store the x,y way-points received from the server
-	float m_PointTemperature [MAX_TOUR];	//	Used to store the x,y way-points received from the server
-
-
-	int m_TickCount;							//	Used to track the number of 10us Ticks that have occurred to ensure consistent motor speed
-
-};
-
-
-
-
-#endif /* CGIMBAL_H_ */
--- a/CMLX90620.cpp	Thu Apr 14 13:45:38 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,275 +0,0 @@
-/*
- * CMLX90620.cpp
- *
- *  Created on: 12 Mar 2016
- *      Author: mike
- */
-
-//NOTE:  "Step Measurement Mode" was removed from new MLX90620 data sheet, page 22 dated Sept 19 2012
-//       which is used in this implementation
-
-#include "mbed.h"
-#include "CMLX90620.h"
-
-extern char* EEbuf;
-extern char* RamBuf;
-extern char* RamCmmd;                       //must reside in main.cpp
-
-const int PTATSENS  = 0x90;                 //ram offset = 0x90, PTAT sensor reading, 16b
-const int TGCSENS   = 0x91;                 //ram offset = 0x91, TGC sensor reading, 16b
-const int MLXCONFIG = 0x92;                 //ram offset = 0x92, config register, 16b
-const int MLXTRIM   = 0x93;                 //ram offset = 0x93, oscillator trim, lsb>6b of 16b
-const int EETRIM    = 0xf7;                 //eep offset = 0xf0, 1 byte, oscillator trim value
-
-unsigned short Config = 0;                  //MLX90620 configuration register
-unsigned short OscTrim = 0;                 //MLX90620 oscillator trim register
-unsigned short PtatD = 0;                   //MLX90620 PTAT data register
-short VCP = 0;                              //VCP / TGC
-short Vth25X = 0;
-float TaXX = 0.0;
-
-//For To
-signed char AcpX = 0;
-signed char BcpX = 0;
-float Kt1fX = 0.0;
-float Kt2fX = 0.0;
-signed char TGCX = 0;
-char BiScaleX = 0;
-unsigned short theta0X = 0;
-char theta0ScaleX = 0;
-char deltaThetaScaleX = 0;
-unsigned short elipsonX = 0;
-signed char AiPixelX = 0;                   //eeprom address range 0x00 - 0x3f
-signed char BiPixelX = 0;                   //eeprom address range 0x40 - 0x7f
-char dThetaPixelX = 0;                      //eeprom address range 0x80 - 0xbf
-short VirPixelX = 0;
-double TempPxlX = 0;
-const int TOINDEX =  0xd4;                  //eep offset = 0xD4 and 0xE0 (0xD4 + 0x0C), 6 bytes + 6 bytes
-const int TAINDEX =  0xda;                  //eep offset = 0xDA, 6 bytes
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-// Constructor
-
-MLX90620::MLX90620(PinName sda, PinName scl, const char* name) : _i2c(sda, scl){
-    _i2c.frequency(100000);                 //set up i2c speed
-    _i2c.stop();
-
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//copy contents of EEPROM inside the MLX90620 into a local buffer.  Data is used for lookup tables and parameters
-
-int MLX90620::LoadEEPROM() {
-    //clear out buffer first
-    for(int i = 0; i < 256; i++) {
-        EEbuf[i] = 0;
-    }
-
-    //load the entire EEPROM
-    EEbuf[0] = 0;
-    if(!_i2c.write(0xa0, EEbuf, 1, true)) {                //0 returned is ok
-        _i2c.read(0xa0, EEbuf, 256);                       //load contents of EEPROM
-    } else {
-        _i2c.stop();
-        return(1);
-    }
-    return(0);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//copy oscillator offset from EEbuf to MLX90620 (MS byte = 0)
-
-int MLX90620::SetOscTrimReg() {
-    RamCmmd[0] = 4;                          //command
-    RamCmmd[1] = EEbuf[EETRIM] - 0xaa;       //LS byte check
-    RamCmmd[2] = EEbuf[EETRIM];              //oscillator trim value
-    RamCmmd[3] = 0x100 - 0xaa;                   //MS byte check
-    RamCmmd[4] = 0;                          //MS byte = 0
-    int r = _i2c.write(0xc0, RamCmmd, 5, false);
-    return(r);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//get oscillator offset register from MLX90620
-
-unsigned short MLX90620::GetOscTrimReg() {
-    RamCmmd[0] = 2;                          //command
-    RamCmmd[1] = MLXTRIM;                    //address of register
-    RamCmmd[2] = 0;                          //address step
-    RamCmmd[3] = 1;                          //# of reads
-    _i2c.write(0xc0, RamCmmd, 4, true);
-    _i2c.read(0xc0, RamCmmd, 2);
-    OscTrim = (RamCmmd[1] << 8) + RamCmmd[0];
-    return(OscTrim);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//initialize the configuration register
-//******* NOTE: Step measurement mode was removed from new data sheet dated   Sept 19 2012
-
-int MLX90620::SetConfigReg() {
-    RamCmmd[0] = 3;                         //command
-//    RamCmmd[1] = 0x14c - 0x55;            //LS byte check
-//    RamCmmd[2] = 0x4c;                    //LS config value, step meas mode, 4Hz array  *******
-    RamCmmd[1] = 0xf9;		                //LS byte check
-    RamCmmd[2] = 0x4e;                      //LS config value, step meas mode, 4Hz array  *******
-    RamCmmd[3] = 0x27;                		//MS byte check
-    RamCmmd[4] = 0x7c;                      //MS config value, 2Hz Ta, 400k i2c
-    int r = _i2c.write(0xc0, RamCmmd, 5, false);
-    return(r);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//get configuration register from MLX90620
-
-unsigned short MLX90620::GetConfigReg() {
-    RamCmmd[0] = 2;                          //command
-    RamCmmd[1] = MLXCONFIG;                  //address of register
-    RamCmmd[2] = 0;                          //address step
-    RamCmmd[3] = 1;                          //# of reads
-    _i2c.write(0xc0, RamCmmd, 4, true);
-    _i2c.read(0xc0, RamCmmd, 2);
-    Config = (RamCmmd[1] << 8) + RamCmmd[0];
-    return(Config);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//get PTAT register from MLX90620
-
-unsigned short MLX90620::GetPTATReg() {
-    RamCmmd[0] = 2;                          //command
-    RamCmmd[1] = PTATSENS;                   //address of register
-    RamCmmd[2] = 0;                          //address step
-    RamCmmd[3] = 1;                          //# of reads
-    _i2c.write(0xc0, RamCmmd, 4, true);
-    _i2c.read(0xc0, RamCmmd, 2);
-    PtatD = (RamCmmd[1] << 8) + RamCmmd[0];
-    return(PtatD);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//get VCP / TGC register from MLX90620
-
-short MLX90620::GetTGCReg() {
-    RamCmmd[0] = 2;                          //command
-    RamCmmd[1] = TGCSENS;                    //address of register
-    RamCmmd[2] = 0;                          //address step
-    RamCmmd[3] = 1;                          //# of reads
-    _i2c.write(0xc0, RamCmmd, 4, true);
-    _i2c.read(0xc0, RamCmmd, 2);
-    VCP = (RamCmmd[1] << 8) + RamCmmd[0];
-    return(VCP);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//get RAM dump from MLX90620
-bool firstDump = false;
-
-void MLX90620::LoadMLXRam() {
-    RamCmmd[0] = 2;                          //command
-    RamCmmd[1] = 0;                          //start address
-    RamCmmd[2] = 1;                          //address step
-    RamCmmd[3] = 0x40;                       //# of reads
-    _i2c.write(0xc0, RamCmmd, 4, true);
-    _i2c.read(0xc0, RamBuf, 0x80);
-    PtatD = MLX90620::GetPTATReg();
-    VCP = MLX90620::GetTGCReg();
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-//start measurement MLX90620
-
-int MLX90620::StartMeasurement() {
-    RamCmmd[0] = 1;                         //command
-    RamCmmd[1] = 8;                         //address of config register
-
-    int r = _i2c.write(0xc0, RamCmmd, 2, false);
-    return(r);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-// Initial Calculations for Ta and To
-
-float MLX90620::GetDieTemp() {
-    PtatD = MLX90620::GetPTATReg();
-    float TaX = (-Kt1fX + sqrtf(powf(Kt1fX, 2.0) - 4.0 * Kt2fX * (Vth25X - PtatD)))/(2.0 * Kt2fX) + 25.0;
-    return(TaX);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-// Initial Calculations for Ta and To
-
-void MLX90620::CalcTa_To() {
-    //Calculate Ta first
-    Vth25X = (EEbuf[TAINDEX + 1] << 8) + EEbuf[TAINDEX + 0];
-    short Kt1   = (EEbuf[TAINDEX + 3] << 8) + EEbuf[TAINDEX + 2];
-    short Kt2   = (EEbuf[TAINDEX + 5] << 8) + EEbuf[TAINDEX + 4];
-    Kt1fX = Kt1 / 1024.0;
-    Kt2fX = Kt2 / 1048576.0;
-    TaXX = MLX90620::GetDieTemp();
-
-    //Calculate To
-    AcpX = EEbuf[TOINDEX + 0];
-    BcpX = EEbuf[TOINDEX + 1];
-//    unsigned short thetaCPX = (EEbuf[TOINDEX + 3] << 8) + EEbuf[TOINDEX + 2];
-    TGCX = EEbuf[TOINDEX + 4];
-    BiScaleX = EEbuf[TOINDEX + 5];
-    theta0X = (EEbuf[TOINDEX + 13] << 8) + EEbuf[TOINDEX + 12];
-    theta0ScaleX = EEbuf[TOINDEX + 14];
-    deltaThetaScaleX = EEbuf[TOINDEX + 15];
-    elipsonX = (EEbuf[TOINDEX + 17] << 8) + EEbuf[TOINDEX + 16];
-/*
-        printf("Vth(25) = %6d 0x%x\nTa1     = %6d 0x%x\nTa2     = %6d 0x%x\n", Vth25X, Vth25X, Kt1, Kt1, Kt2, Kt2);
-        printf("Kt1fX   = %f\nKt2fX   = %f\nTaXX    = %f\n\n", Kt1fX, Kt2fX, TaXX);
-        printf("Acp     = %6d 0x%x\nBcp     = %6d 0x%x\nThCP    = %6d 0x%x\n", AcpX, AcpX, BcpX, BcpX, thetaCPX, thetaCPX);
-        printf("TGC     = %6d 0x%x\nBiS     = %6d 0x%x\nTh0     = %6d 0x%x\n", TGCX, TGCX, BiScaleX, BiScaleX, theta0X, theta0X);
-        printf("T0s     = %6d 0x%x\nDts     = %6d 0x%x\nelip    = %6d 0x%x\n\n", theta0ScaleX, theta0ScaleX, deltaThetaScaleX, deltaThetaScaleX, elipsonX, elipsonX);
-*/
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-// Pixel Temperature Calculation
-
-double MLX90620::CalcPixel(int Pixel) {
-    AiPixelX = EEbuf[Pixel];                                        //eeprom address range 0x00 - 0x3f
-    BiPixelX = EEbuf[Pixel + 0x40];                                 //eeprom address range 0x40 - 0x7f
-    dThetaPixelX = EEbuf[Pixel + 0x80];                             //eeprom address range 0x08 - 0xbf
-    VirPixelX = (RamBuf[Pixel * 2 + 1] << 8) + RamBuf[Pixel * 2];   //ram address range 0x000 - 0x08f, 16b
-    float Vcp_off_comp = VCP - (AcpX + BcpX / powf(2.0,BiScaleX) * (TaXX - 25.0));
-    float VirPixel_off_comp = VirPixelX - (AiPixelX + BiPixelX / powf(2.0,BiScaleX) * (TaXX - 25.0));
-    float VirPixel_off_comp2 = (float(AiPixelX) + float(BiPixelX) / float(1 << BiScaleX) * (TaXX - 25.0));
-    VirPixel_off_comp2 = VirPixelX - VirPixel_off_comp2;
-    float VirPixel_tgc_comp = VirPixel_off_comp - TGCX / 32.0 * Vcp_off_comp;
-    float elipsonf = elipsonX / 32768.0;
-    float VirPixel_comp = VirPixel_tgc_comp / elipsonf;
-    double theta28 = theta0X / powf(2.0, theta0ScaleX) + dThetaPixelX / powf(2.0, deltaThetaScaleX);
-    double TempPxl = powf((VirPixel_comp / theta28 + powf((TaXX + 273.15), 4.0)), (1.0 / 4.0)) - 273.15;
-/*
-        printf("pixel = %d\n", Pixel);
-        printf("Acp   = %d\nBcp   = %d\nBiS   = %d\n", AcpX, BcpX, BiScaleX);
-        printf("Vcp   = %d\neps   = %d\nTGC   = %d\n", VCP, elipsonX, TGCX);
-        printf("Vcp_off_comp      = %f\n", Vcp_off_comp);
-        printf("VirPixel_off_comp        = %f\n", VirPixel_off_comp);
-        printf("VirPixel                 = %d\n", VirPixelX);
-        printf("AiPixel                  = %d\n", AiPixelX);
-        printf("BiPixel                  = %d\n", BiPixelX);
-        printf("BiScale                  = %d\n", BiScaleX);
-        printf("2^BiScale                = %f\n", (powf(2.0,BiScaleX)));
-        printf("1 << BiScale             = %d\n", (1 << BiScaleX));
-        printf("Ta-25.0                  = %f\n", (TaXX - 25.0));
-        printf("BiPix/2^BiScale          = %f\n", (BiPixelX / powf(2.0,BiScaleX)));
-        printf("AiP+BiP/2^BiScale)*(Ta-25= %f\n", (AiPixelX + BiPixelX / powf(2.0,BiScaleX) * (TaXX - 25.0)));
-        printf("VirPixel_off_comp again  = %f\n", (VirPixelX - (AiPixelX + BiPixelX / powf(2.0,BiScaleX) * (TaXX - 25.0))));
-        printf("VirPixel_off_comp2 step  = %f\n", VirPixel_off_comp2);
-        printf("VirPixel_tgc_comp        = %f\n",  VirPixel_tgc_comp);
-        printf("elipsonf                 = %f\n", elipsonf);
-        printf("VirPixel_comp            = %f\n",  VirPixel_comp);
-        printf("theta28                  = %f  << double print problem\n", (theta28 * 100000000.0));  //<<< can't print a double
-        printf("TempPxl                  = %f\n",  TempPxl);
-*/
-    return(TempPxl);
-}
-
-
-
-
--- a/CMLX90620.h	Thu Apr 14 13:45:38 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-/*
- * CMLX90620.h
- *
- *  Created on: 12 Mar 2016
- *      Author: mike
- */
-
-#ifndef MLX90620_H
-#define MLX90620_H
-
-#include "mbed.h"
-
-/** Software routines to access the Melexis MLX90620 64 pixel (4 X 16) infrared sensor array
- *   The MLX90620's internal RAM has different i2c behavior than it's internal EEPROM
- *   As a result, the MLX90620's RAM uses more primitive mbed i2c commands than does the EEPROM.
- *
- * @code
- * #include "mbed.h"
- * #include "MLX90620.h"
- *
- * char* EEbuf = new char[256];     //buffer for contents of EEPROM
- * char* RamCmmd = new char[8];     //holds / sends MLX90620 RAM commands
- * char* RamBuf = new char[128];    //0x3f words, values are 'unsigned short'
- *
- * Serial pc(USBTX, USBRX);
- * MLX90620 mlx(p9, p10, "mlx");
- * //MLX90620 mlx(PTE0, PTE1, "mlx");
- *
- * float Ta = 0.0;
- * float TempPxl = 0.0;
- *
- *
- * int main() {
- *     pc.baud(115200);
- *     mlx.LoadEEPROM();         //if returns non 0, MLX90620 may not be unconnected to i2c bus
- *     mlx.SetOscTrimReg();      //if returns non 0, MLX90620 is having RAM access problems with i2c bus
- *     mlx.SetConfigReg();       //if returns non 0, WTF?? - shouldn't be any i2c problems at this point
- *     mlx.StartMeasurement();   //if returns non 0, WTF??
- *     wait(0.5);
- *     mlx.CalcTa_To();          //if returns non 0, WTF??
- *     Ta = mlx.GetDieTemp();
- *     pc.printf("\nTa = %f\n\n", Ta);
- *     //simplistic dump of pixel array. Any terminal character
- *     //generates another acquisition cycle.
- *     //allows the program to run at maximum refresh rate of 4Hz
- *     //In order to save time, mlx.StartMeasurement(); is done
- *     //just after mlx.GetMLXRam();. This way the CPU can process
- *     //lots of floating math while the MLX90620 gets another round.
- *     while(1) {
- *         int config = mlx.GetConfigReg();
- *         int chk = config & 0x0300;
- *         if(chk == 0) {
- *             pc.printf("\nIR Array Capture\n");
- *             mlx.LoadMLXRam();         //if returns 0, WTF??
- *             mlx.StartMeasurement();   //if returns 0, WTF??
- *             for(int i = 0; i < 64; i++) {
- *                 TempPxl = mlx.CalcPixel(i);
- *                 pc.printf("Pix %2d   Temp %.3f\n", i, TempPxl);
- *             }
- *         } else {
- *             wait_ms(100);
- *         }
- *     }
- *}
- * @endcode
- */
-/* MLX90620 controller class
- */
-class MLX90620 {
-
-public:
-
-    /** Create a MLX90620 object using the specified I2C object
-     *
-     * @param constructor, - the I2C object to communicate with
-     */
-    MLX90620(PinName sda, PinName scl, const char* name);
-
-
-    /** Copy the contents of the MLX90620 EEPROM into local buffer for later use
-     *    Returns '1' if i2c error, '0' if ok.
-     *  Only done at initialization.  MUST be the first thing you do in MAIN.
-     *
-     * @param NONE, - loads all 256 bytes from EEPROM into local buffer
-     */
-    int LoadEEPROM();
-
-
-    /** Initialize the MLX90620's Oscillator Trim Register
-     *    Data is derived from values received from the EEPROM
-     *    Returns '1' if i2c error, '0' if ok.
-     *  Register is only set once during initialization
-     *
-     * @param NONE, - 7 lsb bits from 16 bit value, set by EEPROM value at initialization
-     */
-    int SetOscTrimReg();
-
-
-    /** Get the MLX90620's Oscillator Trim Register
-     *    Returns the Oscillator Trim Register value
-     *
-     * @param NONE, - 7 lsb bits from 16 bit value, Read from MLX RAM
-     */
-    unsigned short GetOscTrimReg();
-
-
-    /** Set the MLX90620's Configuration Register
-     *    Returns '0' if i2c error, '1' if ok.
-     *  Register is set only during initialization. Inital setup:
-     *  1. ADC low reference
-     *  2. Ta Ref Rate 8Hz
-     *  3. I2C FM+ mode enabled
-     *  4. MD / Brownout bit set
-     *  5. Normal Operation (non-Sleep) mode
-     *  6. Step(Melexis reserved) mode. (removed from later datasheets, but used in this code)
-     *  7. IR refresh rate 4Hz
-     *
-     * @param NONE, - 16 bit value set by code at initialization
-     */
-    int SetConfigReg();
-
-
-    /** Get the MLX90620's Configuration Register
-     *    Returns the Configuration Register value
-     *  periodic check for Ta ready, IR Array ready and brownout conditions
-     *
-     * @param returns unsigned short, - 16 bit value, Read from MLX RAM
-     */
-    unsigned short GetConfigReg();
-
-
-    /** Get the MLX90620's PTAT register. Register read at every Ta cycle
-     *    Returns the Proportional To Ambient Temperature Register value
-     *
-     * @param returns unsigned short, - 16 bit value, PTAT sensor, Read from MLX RAM
-     */
-    unsigned short GetPTATReg();
-
-
-    /** Get the MLX90620's TGC register
-     *    Returns the Temperature Gradient Coefficient Register value
-     *
-     * @param returns short, - 16 bit value, TGC, Read from MLX RAM
-     */
-    short GetTGCReg();
-
-
-    /** Get the MLX90620's IR pixel array and dump into local buffer
-     *    Returns nothing
-     *
-     * @param NONE, - loads IR Pixel array into buffer (0x7F bytes, 0x3f Pixels), Read from MLX RAM
-     */
-    void LoadMLXRam();
-
-
-    /** Start a Ta and IR array conversion update cycle
-     *    Returns '1' if i2c error, '0' if ok.
-     *  Also calls GetPTATReg() and GetTGCReg()
-     *
-     * @param NONE, - MLX90620 starts aquiring data, takes about 250mS /w 4Hz refresh rate
-     */
-    int StartMeasurement();
-
-
-    /** Get the MLX90620's die temperature in degC
-     *    Returns MLX90620 die temperature
-     *  Needs to be performed before every array update calculation
-     *
-     * @param returns, - float of die temperature of MLX90620 in degC
-     */
-    float GetDieTemp();
-
-
-    /** Calculate initial MLX90620 offsets. Performed only at initialization
-     *    Returns nothing
-     *
-     * @param NONE, - sets the MLX90620 with die correcting factors at initialization
-     */
-    void CalcTa_To();
-
-
-    /** Calculate temperature of any pixel within the array (0 - 63)
-     *  after an IR array dump into local buffer,
-     *
-     * @param set int(0-63) of pixel to convert, returns double of temperature in degC of pixel
-     */
-    double CalcPixel(int Pixel);
-
-private:
-    I2C _i2c;                   //local i2c communication interface instance
-    unsigned short Config;
-    unsigned short OscTrim;
-    unsigned short PtatD;
-    short VCP;
-    short Vth25X;
-    signed char AcpX;
-    signed char BcpX;
-    float Kt1fX;
-    float Kt2fX;
-    float TaXX;
-    signed char TGCX;
-    char BiScaleX;
-    unsigned short theta0X;
-    char theta0ScaleX;
-    char deltaThetaScaleX;
-    unsigned short elipsonX;
-    signed char AiPixelX;
-    signed char BiPixelX;
-    char dThetaPixelX;
-    short VirPixelX;
-    double TempPxlX;
-
-};
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Gimbal.lib	Thu Apr 14 13:02:29 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/EkkoSense/code/Gimbal/#d8882b039bf5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MLX90620.lib	Thu Apr 14 13:02:29 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/EkkoSense/code/MLX90620/#40a0d2ebd023