Can you teach a PIC to learn?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    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

  2. #2
    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.

  3. #3
    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, 09:22
  2. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10: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, 21:01
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14
  5. How to learn PIC BASIC compiler in 7 days?
    By luqman83salleh in forum General
    Replies: 2
    Last Post: - 13th August 2004, 14:15

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