Can you teach a PIC to learn?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2008
    Posts
    33

    Default Can you teach a PIC to learn?

    I'm thinking about starting a project that would basically mean the PIC having to learn.

    Ill explain in the simplest analagies I can think of.

    Picture a fuel guage, it works by having a variable resistor at the end, the resistance changes by going higher or lower resistance as the fuel goes higher or lower in the tank.

    What I need to do is light 3 led's one for 3/4 full, one for half full and one for 1/4 full.


    The problem I have is on each car the resistance for those measurments are totally different, and in some cases reversed.

    My solution would be have the pic read the resistance attached to a pin or air of pins? say for instance I pour 1/4 of the liquid in the tank, then press a button, the pic would measure that resistance and store it in eeprom position 3, half full measure again and store in eeprom location 4, 3/4 full and store the resistance in location 5, and full store the resistance in location 6.
    Theoretically if I can do this then when the "fuel" lever drops, I should be able to get it to compare the resistance on the pin and when it reaches the stored limits in any of the eeprom positions, It would activate one or more of the led's depending on the level.

    Sorry if I'm not explaingin it very well I'm still very new at this pic lark and not certian of the terminology and in a lot of cases I'l learning as I'm going.

    In this case I have no idea what I'd need or how to go about it, but if it is possible some ideas would be very welcome as would some sample code for those ideas, once I get the idea of what I'm actually meant to be doing I should be able to work it all out and hopefully complete it.

    Its not a commercial project or school project, it's just an idea I have that could be used on several other ideas in the back of my head.

    Any suggestions and or help very welcome.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink nice challenge !!!

    Hi, lew

    There are nots lots of solutions ...

    just put 0, X, Y, Z , Full gallons in your tank ( corresponding to your Leds ) and valid Each PIC measurement with a stupid pushbutton ...

    "Analog" display ( liters ) will need some more maths to find the best fit curve ...

    two constants ... the non linear response AND the "12v" supply voltage influence ...

    one more thing to know ... some gages output Voltage like a pot , some are variable resistors and you must create a current generator.

    That's all ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You can solve the variable 12V problem by generating Vref from a voltage divider off the 12V. If you do it this way, then the A/Ds will track. A good start would be 12V in to a 2K resistor, the other end of the 2K to Vref and that junction through a 1K resistor to GND. Put a 10uF capacitor across the 1K for a noise filter, and a diode across the 2K (cathode to the +12V end). This diode will prevent the cap from discharging into the PIC Vref pin under fault conditions. The values given will put 4V (nom) on Vref.

    Once you have calibrated your unit, save your critical variables in the chip's EEPROM. Every time you power up, read those variables and have your program act accordingly.
    Charles Linquist

  4. #4
    Join Date
    May 2008
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Maybe I didn't explain it good enough, or maybe I just don't understand what you mean.

    a hypothetical scenario - Think of a pic processor with a variable resistor attached, at 4 stages in the sweep from one end of the variable resistor, I need to take a reading of the resistance and store that vbalue in the pic in an eeprom location.

    Now everytime the resistor is turned varying the resistance, once the pic sensed the already measuered stored in eeprom values it acts and lights an led for every position.

    The main problem other than not having a clue how to go about getting the pic to "recogince and store the initial 4 values, is every pic will be attached to a different variable resistor with no idea what the values are before it is turned on, and at 4 stages the pic must take a reading and store that resistance and again act on that reading tthe next and everytime the resistance is varied, so for example if the resistor is turned 1/4 turn it measures that value and stores it, next time the resistor is turned the pic knows when that preset value is reached, ie when the resistor is in exactly the same position, and lights an led.

    Hope that made some sort of sense, If it was a case of one variable resistor with a known value it might be easier, but the variable resistors could be any initial value, which is why the 4 preset values need to be stored in the pic by pressing a button when needed, again ie say the variable resistor is turned 1/4 turn the button pressed and the value of the resistance stored.

    Something like that anyway.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You don't mention how the variable resistors are connected. If one end goes to 12V and the other end goes to GND, then as the wiper is rotated, the output will be 0-12V. You can divide that down and convert the voltage with the A/D in the PIC.

    You can use a pushbutton on one of the other pins.

    Set the variable resistor to the 1/4 position and push the button. Take an A/D reading and store the value in an EEPROM location. Advance a counter and set the variable resistor to the 1/2 position. Push the button again to take an A/D reading and write to the EEPROM location set by the counter. Advance the counter. Set the variable resistor to the 3/4 position. Push the button. Save the value.
    As a last step, write a known value to an EEPROM location to indicate that the part has been calibrated. On power up read that location. If it has already been calibrated, skip the calibration step and run normally.
    Charles Linquist

Similar Threads

  1. Want to learn GSM & PIC programming
    By financecatalyst in forum GSM
    Replies: 5
    Last Post: - 25th February 2014, 10:22
  2. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 11:00
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 22:01
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14
  5. How to learn PIC BASIC compiler in 7 days?
    By luqman83salleh in forum General
    Replies: 2
    Last Post: - 13th August 2004, 15:15

Members who have read this thread : 1

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