PDA

View Full Version : Help with remote control



Clodoaldo
- 6th July 2009, 19:52
Hello everyone, I'm trying to build a simple remote control but I am beginner in programming and need help ...
Please note, I read a value between 0 and 5 volts and then transmitted via the RF result of AD conversion ...
Believe me, worked ... However the battery discharges very fast ... I need the transfer happen only with a change in the result of conversion ...
I am using this code:

@ DEVICE PIC12F683,FCMEN_OFF
@ DEVICE PIC12F683,IESO_OFF
@ DEVICE PIC12F683,BOD_OFF
@ DEVICE PIC12F683,CPD_OFF
@ DEVICE PIC12F683,PROTECT_OFF
@ DEVICE PIC12F683,MCLR_OFF
@ DEVICE PIC12F683,WDT_OFF
@ DEVICE PIC12F683,INTRC_OSC_NOCLKOUT

OSCCON = %01100000
TRISIO = %00001111
GPIO = %00000000
WPU = %00000000
OPTION_REG = %10000000
ANSEL = %00000001
VRCON = %10101100

DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

adpot var byte

start:

ADCIN 0, adpot1
serout 5, 1200, [adpot]
pauseus 200
goto start
END

_Somebody help me?

Archangel
- 7th July 2009, 02:34
If I understood correctly:


@ DEVICE PIC12F683,FCMEN_OFF
@ DEVICE PIC12F683,IESO_OFF
@ DEVICE PIC12F683,BOD_OFF
@ DEVICE PIC12F683,CPD_OFF
@ DEVICE PIC12F683,PROTECT_OFF
@ DEVICE PIC12F683,MCLR_OFF
@ DEVICE PIC12F683,WDT_OFF
@ DEVICE PIC12F683,INTRC_OSC_NOCLKOUT

OSCCON = %01100000
TRISIO = %00001111
GPIO = %00000000
WPU = %00000000
OPTION_REG = %10000000
ANSEL = %00000001
VRCON = %10101100

DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

adpot var byte
dummy var byte
start:


dummy = adpot
ADCIN 0,adpot
if adpot = dummy then start
serout 5,1200,[adpot]
pauseus 200
goto start
END

I did NOT compile or test this, it serves as an idea as to what to do, rather than example

dhouston
- 7th July 2009, 13:59
I doubt that limiting the transmissions will make much difference in battery life. You need to calculate the current for the PIC and determine the maximum life given the mAH rating of the battery.

PAUSEUS does not put the PIC into low power mode. You would do better using the watchdog timer and putting the PIC to SLEEP (using ASM) between readings. But, you really need longer periods at ultra low power to make much of an impact on battery life.

Also, the type of battery makes a difference. BR type lithium cells retain near rated voltage until just before falling off rapidly while most other types have a steeper discharge curve so that they fall below useful levels much earlier.

Clodoaldo
- 7th July 2009, 23:24
Sorry friends,:D looking closely i see the error :confused:it made, if the TX stop for any reason the device is lost and is not good :eek:...
So I followed the advice of "DHOUSTON" and rethink about the batery and limits. Thank you for your attention.