+ Reply to Thread
Results 1 to 6 of 6

Thread: liquid level controller project

  1. #1

    Default liquid level controller project

    hie im doing a project on liquid level controller,can any one help me with a code.im using a continouos liquid level sensor made by Milone technologies. im using the adc converter on PIC16F887. the level of the liquid should be displayed on an lcd.

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Super Moderator johntabb's Avatar
    Join Date
    Mar 2002
    Location
    Ilkley, West Yorks
    Posts
    491


    Default Re: liquid level controller project

    have you tried anything yourself yet?
    do you have any idea what you would like to do within the controller.
    a 16f887 is quite a big chip for just a level controller and a display.

    You will get a better response if you show what you have done so far, and what you are trying to achieve.
    including a reasoned description of how you think the project will work.

    regards John

  4. #3


    Default Re: liquid level controller project

    hie thanks yaah this pic is a big chip to use my supervisor advised me to use this chip for scalability. this controller must send a control signal to a relay to either start or stop a motor pump.

    i had come up with a program to first come up with the voltage levels that would be send to the pic by the sensor, i need to then convert these voltage levels to percentages. when tank is full the voltage level should be 0.145V and when its empty it should be 1.078V.

    here is the code that i came up with
    Device 16F887
    Xtal 4

    LCD_DTPin = PORTC.0
    LCD_RSPin = PORTC.4
    LCD_ENPin = PORTC.5
    LCD_Interface = 4
    LCD_Lines = 2
    LCD_Type = 0

    Declare Adin_Res 8
    Declare Adin_Tad 8_FOSC
    Declare Adin_Stime 100

    Dim ADC_RESULT As Float
    Dim ADC_TOTAL As Float
    Dim ADC_CHANNEL As Byte
    Dim ADC_LOOPS As Word
    Dim TEMP As Word
    Dim LAST_RESULT As Float
    TRISA = %00000001 ' Configure AN0 (PORTA.0) as an input

    ADCON1 = %10000000


    DelayMS 150
    Cls

    ADC_LOOPS = 200

    LAST_RESULT = 0
    Main:
    Print At 1,1, "TESTING..."


    ADC_CHANNEL = 0


    ADC_RESULT = ADIn ADC_CHANNEL

    Print At 2,1,Dec3 ADC_RESULT, " Volts"

    GoTo Main

    ADC_AVERAGE:
    ADC_TOTAL = 0
    For TEMP = 1 To ADC_LOOPS

    ADC_TOTAL = ADC_RESULT + ADC_TOTAL
    Inc TEMP
    Next
    ADC_RESULT = ADC_TOTAL / ADC_LOOPS
    Return

  5. #4
    Super Moderator wastrix's Avatar
    Join Date
    May 2008
    Location
    Sydney, Australia
    Posts
    2,555


    Default Re: liquid level controller project

    You can use this expression to get a percentage from that voltage range you specified:

    percent = 100-((x-0.145)*107.18)

    Where x is the voltage.

    Note:
    - at 8 bit resolution over the range 0.145-1.078V, you will get fairly poor resolution.
    - you will need to split the expression above over two or more lines.
    - you may find that you will need to round the result.
    - the code you have retrieves a number from 0-255, not volts. You should modify the above expression to work with the raw data.
    "If you have an important point to make, don't try to be subtle or clever. Use a pile driver."
    - Winston Churchill
    If you want to contact me, please email me, don't PM me.

  6. #5
    Super Moderator johntabb's Avatar
    Join Date
    Mar 2002
    Location
    Ilkley, West Yorks
    Posts
    491


    Default Re: liquid level controller project

    These may be the ramblings of a Mad Man,
    I haven't checked, but most big chips of this nature allow you to use a reference voltage to extens the scale of the AD port.

    If you were to create a reference voltage, with say a Reverse biassed Zener, or a Forward Biassed LED. and connect this to the reference port, then configure the chip to use the reference to scale the AD port, your full scale reading on the AD port would be Reference voltage, not supply votlage so if you used a RED LED, the reference voltage would be in the region of 1.8volts,

    and your level measurement voltage would have much better resolution.

    to activate the motor, use an N channel FET, as a lOW SIDE SWITCH to drive the relay, it's likely that a 1megohm pull down resistor between the Gate and ground will stop the relay accidentally switching on, and if you drive the Gate from a Pic Pin, the FET should switch on when the output port goes high...
    make sure that the 0volts of thge pic circuit is connected to the 0volts of the relay control circuit. and it's good policy to have a reverse biassed diode in parallel with the relay coil, to absorb any back emf when the relay switches.

    regards JOhn
    Last edited by johntabb; 26th May 2011 at 01:37.

  7. #6
    Super Moderator wastrix's Avatar
    Join Date
    May 2008
    Location
    Sydney, Australia
    Posts
    2,555


    Default Re: liquid level controller project

    I haven't checked, but most big chips of this nature allow you to use a reference voltage to extens the scale of the AD port.
    This can be done, but be VERY careful that you read the electrical specifications in the datasheet, there is a minimum value for VREF, usually around 2.5-3V but different devices have different specs. If you go below this VREF voltage you just get garbage.
    "If you have an important point to make, don't try to be subtle or clever. Use a pile driver."
    - Winston Churchill
    If you want to contact me, please email me, don't PM me.

+ Reply to Thread

Similar Threads

  1. Level Shifter
    By wastrix in forum The Lounge
    Replies: 8
    Last Post: 28th August 2010, 15:55
  2. Voltage level
    By fanie in forum The Lounge
    Replies: 9
    Last Post: 15th December 2009, 13:21
  3. Level sensor
    By Johnhaz in forum The Lounge
    Replies: 25
    Last Post: 5th July 2008, 08:39
  4. Level shift or not to level shift?
    By the.fox in forum quickBlue Bluetooth Development
    Replies: 2
    Last Post: 20th July 2007, 03:43
  5. Max sound level from a piezo
    By Tim in forum The Lounge
    Replies: 13
    Last Post: 22nd January 2007, 16:02

Members who have read this thread since 2nd May 2012, 14:29 : 2

Actions :  (Set Date)  (Clear Date)

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