12F675 compare voltage help.


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Try this;
    Code:
    X VAR WORD
    Y VAR WORD
    
    AD_10BIT:
        FOR X = 0 TO 1023  ' Simulate 0 TO 5V
        Y = X */ 1251      ' For 10-bit A/D (5V/1023)*256 = 1.251
        SEROUT GPIO.1,N2400, ["X = ",DEC X," : = ",DEC Y DIG 3,".",DEC3 Y,"V",13,10]
        NEXT
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    This is what I came up with.
    Code:
    adval0 = 4828
    adval0 =adval0/151
    'should give me 31 in this example.
    
    if adval0 > 99 then
                   'if adval was say 131 result would be 1. and remainder should calculate to 3*10+1 being 31. total of 1.31
    
    result= adval0 dig 2
    remainder= adval0 dig 1*10
    remainder= remainder + adval0 dig 0
    else
    if adval0 < 99 then
    result= 0
    remainder= adval0
    endif
    endif

    Look about right?

Similar Threads

  1. high voltage high frequency H-Bridge
    By George in forum Off Topic
    Replies: 6
    Last Post: - 27th April 2009, 11:50
  2. Expanded Scale Voltmeter
    By Pic_User in forum Schematics
    Replies: 6
    Last Post: - 8th February 2008, 20:32
  3. make a low voltage output from a PIC pin
    By emptyset in forum General
    Replies: 1
    Last Post: - 8th February 2008, 19:20
  4. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35
  5. Low Voltage Detection
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th January 2005, 18:29

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