Referral to ULPWU/PLVD code per AN879??


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Dec 2013
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Referral to ULPWU/PLVD code per AN879??

    Hello I've just recently joined and found this post after a lot of research because I am wanting to do the same. I am using the chip 16F690 and I want to detect low battery also. I would be using 5volts to power on the chip and would want to detect 3.7volts or any voltage as long as its lower than 5volts when the voltage has dropped and the led would be used as the output to indicate this or a multimeter showing the voltage if possible. I have Implemented the code that has been provided by 'jelliss00' in the MPLAB software to build but the program but isn't working. If any of you can give guidance to me on developing the program I would really appreciate.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Referral to ULPWU/PLVD code per AN879??

    It would help if you posted your entire code, which PBP version and assembler. A schematic of your circuit is always a good idea.

    Robert

  3. #3
    Join Date
    Dec 2013
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Referral to ULPWU/PLVD code per AN879??

    Name:  schematic of voltage.jpg
Views: 965
Size:  23.3 KB

    Hi sorry about the late reply I have added the schematic and included the programming below. The Led would turn on when the potentiometer has been adjusted and the voltage comes to 2.5volts as I would be using comparator to detect voltage. The software I am using is MPLAB IDE version 8.92. The program doesn't seem to work I would appreciate your help on this.

    list p=16F690
    include "p16F690.inc"
    radix dec

    ;***** CONFIGURATION
    ; ext reset, no code protect, no watchdog, 4 MHz int clock
    __CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _IOSCFS_OFF & _IntRC_OSC_RB4EN
    ; pin assignments
    #define LED PORTC,3 ; indicator LED on RC3
    constant nLED=3 ; (port bit 3)

    ;***** RC CALIBRATION
    RCCAL CODE 0x3FF ; processor reset vector
    res 1 ; holds internal RC cal value, as a movlw k
    ;***** RESET VECTOR ************************************************** ***
    RESET CODE 0x000 ; effective reset vector
    movwf OSCCAL ; apply internal RC factory calibration

    ;***** MAIN PROGRAM ************************************************** ***
    ;***** Initialisation
    start
    ; configure ports
    movlw ~(1<<nLED) ; configure LED pin (only) as an output
    tris PORTC

    ; configure comparator 1
    movlw 1<<C1PREF|1<<C1NREF|1<<C1POL|1<<C1ON
    ; +ref is C1IN+ (C1PREF = 1)
    ; -ref is C1IN- (C1NREF = 1)
    ; normal polarity (C1POL = 1)
    ; comparator on (C1ON = 1)
    movwf CM1CON0 ; -> C1OUT = 1 if C1IN+ > C1IN-

    ;***** Main loop
    main_loop
    ; display comparator output
    btfsc CM1CON0,C1OUT ; if comparator output high
    bsf LED ; turn on LED
    btfss CM1CON0,C1OUT ; if comparator output low
    bcf LED ; turn off LED
    ; repeat forever
    goto main_loop

    END

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Referral to ULPWU/PLVD code per AN879??

    To start:

    Labels end with colons.

    Assembler must be delimitted with ASM.

    Is this really PIC BASIC?

    Robert

    Edit: PORTC.3 <--- period, not comma
    Last edited by Demon; - 22nd December 2013 at 18:50.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 18:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts