Log in

View Full Version : Reading sensors with 3.3v(beginner)



tacbanon
- 20th September 2012, 02:25
Hi everyone, I'm planning to read several sensors(accelerometer, ambient, barometric, Temp and 5v battery) on PORTA using pic18F4550 on 5v supply. My first question is my accelerometer module has an analog output x, y and z with 3.3v supply...can I simply use ADCIN command for the accelerometer output pins?
6667


Thanks in advance,
tacbanon

mackrackit
- 20th September 2012, 03:31
Yes, but you may want to set the ADC reference voltage to 3.3.
But why not just run the 18F4550 at 3.3?

rsocor01
- 20th September 2012, 05:00
Yes, you can run the 18F4550 at 3.3V like Dave said. If you are concerned with the USB module in the18F4550 not working with Vin=3.3V, there is a way to make the module work at 3.3V.

tacbanon
- 20th September 2012, 06:25
Hello Dave and rsocor01, I think among the sensors (accelerometer, ambient, barometric, temperature and 5v battery) I'm planning to incorporate, the accelerometer is only the one that have 3.3v...that is why I tend to use the 5v source...any input is much appreciated on how to approach this.

Kind regards,
tacbanon

mackrackit
- 20th September 2012, 20:13
If you are concerned with the USB module in the18F4550 not working with Vin=3.3V, there is a way to make the module work at 3.3V.
USB signals are 3.3 already....

tacbanon,
Are the remaining sensors analog or I2C, or...

tacbanon
- 20th September 2012, 23:47
USB signals are 3.3 already....
tacbanon,
Are the remaining sensors analog or I2C, or...
Not really concern with the USB part as of now...

Sensors and modules:
Barometric - SPI
Ambient - Analog - (Done)
Temp (DS18B20) - Digital
Battery monitoring - Analog (Done)
Accelerometer - Analog
RTC - I2C (Done)
SDCard - SPI (Done)

I will try to look for an I2C accelerometer sensor if this will be easier...but it will take me another few days to get one. I have the ambient and Battery monitoring working. I also have an RTC and SDCARD on board running for data recording...
Thanks for the time helping.

/tacbanon

rsocor01
- 21st September 2012, 05:50
USB signals are 3.3 already....

tacbanon,
Are the remaining sensors analog or I2C, or...

Most people use this setup to make the USB module work

http://www.mecanique.co.uk/products/usb/schematic-large.gif

with Vcc = 5V. What I meant is that it can be done with Vcc = 3.3V.

tacbanon
- 21st September 2012, 09:32
I powered the accelerometer with a 3.3v with common ground to the PIC and read from its output pins (xyz) and here is the result.
6668

I noticed that even if I rotate the module in any directions, the values are much like the same...:confused:

/tacbanon

mackrackit
- 21st September 2012, 11:06
What do you read if you connect a volt meter in-place of a PIC on the outputs of the ADXL335?

tacbanon
- 21st September 2012, 15:23
What do you read if you connect a volt meter in-place of a PIC on the outputs of the ADXL335?
When reading with voltmeter varies on x,y and z pin (between 0 - 3.4v) when rotating the module.

/tacbanon

mackrackit
- 21st September 2012, 15:28
Hmmm,
The module is working.
You know how to use the ADC.

I guess we will have to see your code to spot the problem...

tacbanon
- 22nd September 2012, 12:50
Hmmm,
The module is working.
You know how to use the ADC.

I guess we will have to see your code to spot the problem...

Hi, thanks for your time. Thought it is best if I give a little description to what I'm trying to achieve. I'm setting 3 buttons to navigate to some menus to display information for the accelerometer, ambient, Temp, Barometric pressure, battery level, RTC, GPS and GSM and Bluetooth connectivity on the 4x20 LCD. SdCard is used for data logging later on.
My codes mostly came from this forum(thanks to u all!), BTW currently I'm using the hyper terminal to navigate thru the menus...so here it is.


'************************************************* ***************
asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm



DEFINE OSC 48
DEFINE HSER_RCSTA 90h ' enable serial port,
DEFINE HSER_TXSTA 20h ' enable transmit,
DEFINE HSER_BAUD 9600
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes
INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts
'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::
' Variable definition
'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::
PortB = %00000000
TRISB = %00000000
TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX output

RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)

led var PORTD.5
StatusLed var PORTD.6
StatusLed1 var PORTD.7
holdoff var word
SerialData var byte
SerialInput var byte[50]
PortB = 0
c var byte 'counter1
cnt var byte 'counter2
cnt1 var byte 'counter3
cnt1=0
i var byte
c = 0
OptionSel var byte[1]
OptionSel = "0"
flag1 var byte
flag1 = 0
'clear

'((((((((((((((((((((((((((((((((((((((()))))))))) )))))))))))))))))))))))))))))
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
INT_Handler RX_INT, _Getbytes, PBP, no
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

@ INT_ENABLE RX_INT ; enable RX_INT interrupts
'*******Internal interrupt
T1CON = $31 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts



'***LCD Definitions
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50


' Alias PIC pins and registers for SD/MMC card
SD_WE Var PORTA.7 ' SD card write protect A4
SD_WE_TRIS Var TRISA.7 ' SD card write protect direction
SDI Var PORTC.1 ' SPI data in PORTB.0
SDI_TRIS Var TRISC.1 ' SPI data in direction TRISB.0
SCL Var PORTC.2 ' SPI clock PORTB.1
SCL_TRIS Var TRISC.2 ' SPI clock direction TRISB.1
SD_CS Var PORTC.3 ' SD card chip select PORTB.3
SD_CS_TRIS Var TRISC.3 ' SD card chip select direction TRISB.3
SD_CD Var PORTB.6 ' SD card detect PORTB.4
SD_CD_TRIS Var TRISB.6 ' SD card detect direction TRISB.4
SDO Var PORTC.0 ' SPI data out
SDO_TRIS Var TRISC.0 ' SPI data out direction

Include "SDFS.PBP"
;SDC_UseHardSPI = TRUE ' Use hardware SSP port for SPI.
SDC_UseHardSPI = FALSE ' Use hardware SSP port for SPI.
'ADCON1 = 15 ' All I/O pins digital
'--Added Pic settings
UCON.3 = 0 'USB module disabled
UCFG.3 = 1 'USB transceiver disabled
CCP1CON=0 ' Capture/Compare OFF
CCP2CON=0 '
'ADCON1 = 15 ' All I/O pins digital
Pause 100
;----------------------------------------------------------------------------
;--For ADC modules
define ADC_BITS 8
define ADC_CLOCK 3
define ADC_SAMPLEUS 50
ambval var byte
batval var byte
axval var byte
ayval var byte
azval var byte
TRISA = %00111111
ADCON1 = %00001001
;----------------------------------------------------------------------------
' FSInit initializes the card and reads all the preliminary information from it
Gosub FSInit
Hserout ["Init: ", Dec FAT_error, " ", Dec SDC_status, " ", Dec SDC_response, $d, $a]
If (FAT_error != 0) Then Stop

' This section defines a specific short (8.3) filename
' Note that spaces are use in empty elements and must be upper case for Windows
FAT_FileName[0] = "R"
FAT_FileName[1] = "E"
FAT_FileName[2] = "C"
FAT_FileName[3] = "O"
FAT_FileName[4] = "R"
FAT_FileName[5] = "D"
FAT_FileName[6] = "S"
FAT_FileName[7] = " "
FAT_FileName[8] = "T"
FAT_FileName[9] = "X"
FAT_FileName[10] = "T"

' Set file time to 8:30:10 and date to 1/1/2008
FAT_seconds = 5
FAT_minutes = 30
FAT_hours = 8
FAT_day = 1
FAT_month = 1
FAT_year = 28

;-------------------------RTC--------------------------------------------------
'RTC pins on 4550
SDA Var PORTB.6
SCLA Var PORTB.7
'Try to change
;Led1 var PortB.2

' Allocate variables
RTCYear Var Byte
RTCMonth Var Byte
RTCDate Var Byte
RTCDay Var Byte
RTCHour Var Byte
RTCMin Var Byte
RTCSec Var Byte
RTCCtrl Var Byte

;------------------------------------------------------------------------------
SEC_O VAR BYTE: SEC_T VAR BYTE:
MIN_O VAR BYTE: MIN_T VAR BYTE
HR_O VAR BYTE: HR_T VAR BYTE:
MON_O VAR BYTE: MON_T VAR BYTE
DATE_O VAR BYTE: DATE_T VAR BYTE:
DAY_O VAR BYTE: DAY_T VAR BYTE:
YR_O VAR BYTE: YR_T VAR BYTE


CMCON = %00000111 ' Comparators = off


'--------------------------Custom characters
LCDOUT $FE,1:FLAGS=0:PAUSE 250:LCDOUT $FE,1:PAUSE 250
LCDOUT $FE,$40,$1F,$15,$11,$11,$15,$15,$15,$1F ' Cust Char #0
LCDOUT $FE,$48,$1F,$1F,$1F,$11,$15,$15,$11,$1F ' Cust Char #1
LCDOUT $FE,$50,$1F,$17,$17,$11,$15,$15,$11,$1F ' Cust Char #2
LCDOUT $FE,$58,$1F,$1F,$1F,$11,$15,$15,$11,$1F ' Cust Char #3
LCDOUT $FE,$60,$1F,$1B,$1B,$11,$1B,$1B,$19,$1F ' Cust Char #4
LCDOUT $FE,$68,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F ' Cust Char #5
LCDOUT $FE,$70,$1F,$1F,$1F,$15,$15,$15,$1B,$1F ' Cust Char #6
LCDOUT $FE,$78,$1F,$13,$1B,$1B,$1B,$1B,$11,$1F ' Cust Char #7
pause 300

' Initialize LCD
;LCDOUT $FE,1:FLAGS=0:PAUSE 250:LCDOUT $FE,1:PAUSE 250

'Set initial time `
RTCYear = $12
RTCMonth = $09
RTCDate = $20
RTCDay = $18
RTCHour = $21
RTCMin = $55
RTCSec = 0
RTCCtrl = 0


goto mainloop

' Subroutine to write time to RTC
set:
I2CWrite SDA,SCLA,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCY ear,RTCCtrl]
return

' Subroutine to read time from RTC
gettime:
I2CRead SDA,SCLA,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCY ear,RTCCtrl]
;--------------------------------------------------------------------------------------------
; we prepare this for later use
SEC_T = RTCSec & $70
SEC_T = SEC_T>>4
SEC_O = RTCSec & $0F

MIN_T = RTCMin & $70
MIN_T = MIN_T>>4
MIN_O = RTCMin & $0F

HR_T = RTCHour & $70
HR_T = HR_T>>4
HR_O = RTCHour & $0F

MON_T = RTCMonth & $70
MON_T = MON_T>>4
MON_O = RTCMonth & $0F

DATE_T = RTCDate & $70
DATE_T = DATE_T>>4
DATE_O = RTCDate & $0F

DAY_T = RTCDay & $70
DAY_T = DAY_T>>4
DAY_O = RTCDay & $0F

YR_T = RTCYear & $70
YR_T = YR_T>>4
YR_O = RTCYear & $0F
pause 500
;-------------------------------------------------------------------------
' FSInit initializes the card and reads all the preliminary information from it
' Open a file for write
FAT_mode = "a" ' Write mode
Gosub FSfopen ' Open file pointed to by Byte array FAT_FileName
hserout ["Open for write: ", Dec FAT_error, $d, $a]
If (FAT_error != 0) Then Stop
FAT_src[0] = ">"
FAT_src[1] = "T"
FAT_src[2] = "E"
FAT_src[3] = "S"
FAT_src[4] = "T"
FAT_src[5] = "D"
FAT_src[6] = "A"
FAT_src[7] = "T"
FAT_src[8] = "A"
FAT_src[9] = 13
FAT_src[10] = 10

FAT_count = 11
Gosub FSfwrite
hserout [ "Write ", Dec FAT_error, $d, $a]
If (FAT_error != 0) Then Stop
' Close file
Gosub FSfclose
hserout [ "Close ", Dec FAT_error, $d, $a]
;--------------------------------------------------------------------------
Return



mainloop:

'Gosub gettime ' Read the time from the RTC
c = 0 ' counter
Select case OptionSel
case "0"
gosub page0
case "1"
gosub page1
case "2"
gosub page2
case "3"
gosub page3
case "4"
gosub page4
case "5"
gosub page5
case "6"
gosub page6
End select


Goto mainloop


'((((((((((((((((((((((((((((((((((((((()))))))))) )))))))))))))))))))))))))))))
'ISR for RX_int interrupt
'((((((((((((((((((((((((((((((((((((((()))))))))) )))))))))))))))))))))))))))))

Getbytes:

While RCIF = 1 ' clear the buffer
c = c + 1
HSERIN 100,error,[Serialdata] ' take it
'--HSEROUT [Serialdata] ' take it out
SerialInput[c] = Serialdata

LCDOUT
select case Serialdata ' What to do with that data???
case "0"
Hserout ["Option 0",13]
OptionSel = "0"
flag1 = 0
case "1"
Hserout ["Option 1",13]
OptionSel = "1"
flag1 = 0
case "2"
Hserout ["Option 2",13]
OptionSel = "2"
flag1 = 0
case "3"
Hserout ["Option 3",13]
OptionSel = "3"
flag1 = 0
case "4"
Hserout ["Option 4",13]
OptionSel = "4"
flag1 = 0
case "5"
Hserout ["Option 5",13]
OptionSel = "5"
flag1 = 0
case "6"
Hserout ["Option 5",13]
OptionSel = "6"
flag1 = 0
End select
Wend

@ INT_RETURN


error:
Toggle led
@ INT_RETURN
end

'---[TMR1 - interrupt handler]--------------------------------------------------
' We try to place the module reading process here
ToggleLED1:
cnt = cnt + 1
if cnt = 10 then
TOGGLE StatusLed ' slower process
cnt = 0
Endif

cnt1 = cnt1 + 1
if cnt1 = 5 then
TOGGLE StatusLed1 ' faster process
ADCIN 0, ambval
'-------------
ADCIN 1, batval
'-------------
ADCIN 2, axval
ADCIN 3, ayval
ADCIN 5, azval
hserout ["Light ", DEC ambval," Bat ", Dec batval, " X: ",Dec axval," Y: ",Dec ayval," Z: ",Dec azval, 13] ' just to see it on the hyperterminal

cnt1 = 0
Endif

@ INT_RETURN

'---[TMR1 - interrupt handler]--------------------------------------------------



page0:
if flag1 < 1 then
gosub LcdClear
flag1 = flag1+1
endif
LCDOUT $fe,$80,0,1,2,3,4,5,6,7,5,5,5,5,5,5,5,5,5,"[1]"
LCDOUT $fe, $C0, "School Demo"
LCDOUT $fe, $94, "Designer: Tacbanon"
LCDOUT $fe, $D4, "Command: "
PAUSE 100
Return

page1:

Gosub gettime ' Read the time from the RTC
pause 100
if flag1 < 1 then
gosub LcdClear
flag1 = flag1+1
endif
LCDOUT $fe, $80, "RTC and BAT",5,5,5,5,5,5,"[2]" ' Display PULSVARs
LCDOUT $fe, $C0, "Date:",HEX DATE_T, Hex DATE_O,"/",Hex MON_T,Hex MON_O,"/",Hex YR_T, Hex YR_O
LCDOUT $fe, $94, "Time:",hex2 RTCHour, ":", hex2 RTCMin, ":", hex2 RTCSec
LCDOUT $fe, $D4, "Bat1: "
LCDOUT $fe, $D4, "Bat1: ", Dec batval
Pause 50
Return

page2:
if flag1 < 2 then
gosub LcdClear
flag1 = flag1+1
endif
LCDOUT $fe, $80, "ACCELEROMETER",5,5,5,5,"[3]"
LCDOUT $fe, $C0, "x: ",Dec axval
LCDOUT $fe, $94, "y: ",Dec ayval
LCDOUT $fe, $D4, "z: ",Dec azval
PAUSE 50
Return

page3:
if flag1 < 2 then
gosub LcdClear
flag1 = flag1+1
endif
LCDOUT $fe, $80, "MISC SENSORS",5,5,5,5,5,"[4]"
LCDOUT $fe, $C0, "Temp: "
LCDOUT $fe, $94, "Amb: "
LCDOUT $fe, $94, "Amb: ",Dec ambval
LCDOUT $fe, $D4, "Bmtr: "
PAUSE 50
Return

page4:
if flag1 < 2 then
gosub LcdClear
flag1 = flag1+1
endif
LCDOUT $fe, $80, "POSITIONING",5,5,5,5,5,5,"[5]"
LCDOUT $fe, $C0, "Lat: "
LCDOUT $fe, $94, "Lng: "
LCDOUT $fe, $D4, "Knot: "
PAUSE 50
Return

page5:
if flag1 < 2 then
gosub LcdClear
flag1 = flag1+1
endif
'LCDout $Fe, 1
LCDOUT $fe, $80, "GSM and BT",5,5,5,5,5,5,5,"[6]"
LCDOUT $fe, $C0, "Man: "
LCDOUT $fe, $94, "Sig: "
LCDOUT $fe, $D4, "BT stat: "
PAUSE 50
Return

page6:
if flag1 < 2 then
gosub LcdClear
flag1 = flag1+1
endif
LCDOUT $fe, $80, "SDCARD Info",5,5,5,5,5,5,"[7]"
LCDOUT $fe, $C0, "No. write: "
LCDOUT $fe, $94, "No. dump: "
LCDOUT $fe, $D4, "Status: "
PAUSE 50
Return

LcdClear: ' clear LCD
LCDOUT $fe, $80, " "
LCDOUT $fe, $C0, " "
LCDOUT $fe, $94, " "
LCDOUT $fe, $D4, " "
pause 400
return


/tacbanon

mackrackit
- 22nd September 2012, 17:52
I am going to suggest writing a test code with that only reads the ADC in a loop with a serial output to the terminal. No interrupts.


TestLoop:
TOGGLE StatusLed1 ' faster process
ADCIN 0, ambval
'-------------
ADCIN 1, batval
'-------------
ADCIN 2, axval
ADCIN 3, ayval
ADCIN 5, azval
hserout ["Light ", DEC ambval," Bat ", Dec batval, " X: ",Dec axval," Y: ",Dec ayval," Z: ",Dec azval, 13] ' just to see it on the hyperterminal
PAUSE 250
GOTO TestLoop


I see in your code a couple of things that might be causing an issue.



@ INT_RETURN Remove this.


error:
Toggle led
@ INT_RETURN


And the TMR1 interrupt may not be long enough time wise for everything to happen that you have in it. The test code if it works will help track down the problem.

Maybe someone else sees what I am missing though.

tacbanon
- 23rd September 2012, 16:34
Hi Dave, thanks for helping me out, I did what you suggested unfortunately the same result...I will try to change some pin assignment and see if it will help.

kind regards,
tacbanon

tacbanon
- 25th September 2012, 00:56
Hi, I did some testing but this time using PIC16F887 on 5v just to isolate the specific program which is to read the accelerometer module on 3.3v..using the following code.


'' Program Start Here ''

DEFINE osc 20 ' We're using a 4 MHz oscillator
DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
DEFINE ADC_CLOCK 3 ' Set A/D clock Fosc/8
DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS

ANSEL = %11111111 ' Make AN0-AN7 Analog
ANSELH= %00000000 ' Make AN8-AN13 digital

accx var byte
accy var byte
accz var byte

DataOut var Byte
DataOut = 0

' PORT setting
' ============
'
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %0001001 ' Set PORTA.0,1,2,4,5,6 = A/D, PortA.3 = +Vref
TRISC = %10000000 ' RC.7 => USART RX pin set to input
' all other pin set to output
'OPTION_REG = $7f ' Enable PORTB pull-ups
'
TRISB=%00000000 ' RB<7:0> set to output
TRISD=%00000000

' USART setting
' =============
' Since we will not use HSERIN/HSEROUT, we must
' write directly to internal PIC register
'
TXSTA=$24 ' enable transmit and SPBRGH=1
RCSTA=$90 ' Enable USART and continuous receive
SPBRG=129 ' BAUD RATE = 9600 BAUDS

' Interrupt definition
' ====================
'
PIE1.5 =1 ' enable USART receive interrupt
INTCON.6 =1 ' enable peripheral interrupt

' Alias definition
' ================
'
RCIF var PIR1.5 ' receiver interrupt
UserLED1 var PORTB.0 ' the LED who show a 'running process'
UserLED2 var PORTB.1 ' the LED1 that user want to control
UserLED3 var PORTB.2 ' the LED2 that user want to control


' Variable definition
' ===================
'
Delay var word '
DataIn var byte ' use to store RCREG content
Discard var byte ' use to erase RCREG register

' Hardware/software initialisation
' ================================
'
PORTB=0 ' clear PORTB
PORTC=0 ' dlear PORTC
on interrupt goto USARTInterrupt



PAUSE 500 ' Wait .5 second

loop1:
ADCIN 0, accx: ADCIN 1, accy: ADCIN 2, accz
Hserout["Data receive: X:",Dec accx," Y:",Dec accy," Z:" ,Dec accz, 13]
Pause 200

GOTO loop1 ' Do it forever

END

disable interrupt
USARTInterrupt:
' Here's the interrupt routine who will make the user
' much happy by giving him the feeling to have the
' control on the machine when the status of the user
' LED will change
'
RCSTA=0 ' Disable serial port AND
' clear possible error (FERR,OERR)

datain=RCREG ' Get data

while RCif ' wait untill the RCREG is empty
discard=RCREG ' by reading it and store result in a
wend ' don't care variable

select case datain ' What to do with that data???

case "1" ' User selection = 1
userled1=1 ' => Enable the LED

case "2" ' User selection =2
userled1=0 ' => disable the LED

case "3" ' User selection =2
userled2=1 ' => disable the LED

case "4" ' User selection =2
userled2=0 ' => disable the LED

case "5" ' User selection =2
userled3=1 ' => disable the LED

case "6" ' User selection =2
userled3=0 ' => disable the LED

case "a" ' User selection =2
PortB=%00000111 ' => disable the LED
case "d" ' User selection =2
PortB=%00000000 ' => disable the LED



end select
RCSTA=$90 ' Re-enable the serial PORT AND
resume ' get out of here
enable interrupt

I have the following reading:

6678
and I think I'm not getting the right output...what might causing it?

Kind regards,
tacbanon

tacbanon
- 25th September 2012, 22:40
Hi all, I'm gonna try to use an i2c accelerometer but from where I'm located (province) it will take some days to arrive...then post here my inquiries :).
I'm gonna try to move on to another sensor(barometric) while waiting for the accelerometer.

Regards,
tacbanon

Ramius
- 26th September 2012, 01:51
Hi Tacbanon!
I would be very interested in your results with your accelerometer as I am in need of a tilt sensor (pitch and roll). I see you are looking for a barometric sensor and you may wish to look at http://www.picbasic.co.uk/forum/showthread.php?t=16457 which is a depth sensor which should work for altitude as well. If nothing else there is a 3.3v to 5.0v level converter that may be useful for your project.

Best, Ed

tacbanon
- 26th September 2012, 07:14
Greetings Ramius!
Thanks for your interest, and very thankful for the guide, and I will try this(3.3v to 5.0 converter).

regards,
tacbanon