Pages: [1]   Go Down
Author Topic: MPL115A1 pressure sensor integration  (Read 1673 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I am new to Arduino (uno). I have some experience with C++ but am still learning a lot. My project is an automated distilling system that will read a temperature input and pressure input and then based on those inputs, turn on or off electromechanical valves (actually they are fuel injectors). I started testing out my code and got my thermistor to work correctly. I purchased a MPL115A1 pressure sensor for absolute pressure readings. It was talked about before on the following forum:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290784855
I modified his code for the uno and am not getting anything. Based on the data sheets he provides, are the registers correct (read and write as well as all the variable mappings)?

I attached what I have done so far because it is too long for this forum.

* Dist_Code.pde (9.95 KB - downloaded 21 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I decided to try and find code that will just make it work. I can work on integrating the code into my project later. I found the following example code:
http://forum.sparkfun.com/download/file.php?id=574
When I go to compile it there are two issues:
1) I do not have (or know how to make) the MPL115A1.h library
2) It does not like the line:
Code:
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

Here is general program with out the functions:
Code:

#include <avr/io.h>
#include <stdio.h>
#include "MPL115A1.h"

#define PRESH 0x00 // 80
#define PRESL 0x02 // 82
#define TEMPH 0x04 // 84
#define TEMPL 0x06 // 86

#define A0MSB 0x08 // 88
#define A0LSB 0x0A // 8A
#define B1MSB 0x0C // 8C
#define B1LSB 0x0E // 8E
#define B2MSB 0x10 // 90
#define B2LSB 0x12 // 92
#define C12MSB 0x14 // 94
#define C12LSB 0x16 // 96
#define C11MSB 0x18 // 98
#define C11LSB 0x1A // 9A
#define C22MSB 0x1C // 9C
#define C22LSB 0x1E // 9E



//======================//
// Macros //
//======================//
#define sbi(var, mask)   ((var) |= (uint8_t)(1 << mask))
#define cbi(var, mask)   ((var) &= (uint8_t)~(1 << mask))

//======================//
// MPL115A1 Defines //
//======================//
#define CS 8 //pin for chip select
#define SDN 9 // pin for interrupt

//======================//
// General Functions //
//======================//
void ioinit(void);
void delay_ms(uint16_t x);
void delay_us(uint16_t x);
static int uart_putchar(char c, FILE *stream);
uint8_t uart_getchar(void);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

Any suggestions on how to convert this code to the Arduino Uno?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26530
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
2) It does not like the line:

Code:
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

Well, probably I'd say something like "Serial.begin (9600);"
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: