PIC16F84A using pulsout and TMR0


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Thanks for verifying that Skimask!

    Steve, you are most certanly right about the timing, no LCD should need more than 100uS for data. But my advice of trying with 500 was not a very good one since I didn't know of the 8-bit clamp.

    All valid points from you Steve, Dragonballs problem seems to be timing related since it works when he's using a slower clock than 4Mhz. But at 4Mhz it seems to skip the first characters, if I understood it correctly.

    /Henrik Olsson.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson
    Hi,
    Thanks for verifying that Skimask!

    Steve, you are most certanly right about the timing, no LCD should need more than 100uS for data. But my advice of trying with 500 was not a very good one since I didn't know of the 8-bit clamp.

    All valid points from you Steve, Dragonballs problem seems to be timing related since it works when he's using a slower clock than 4Mhz. But at 4Mhz it seems to skip the first characters, if I understood it correctly.

    /Henrik Olsson.


    I think the 500 idea was good enough since 500-256=244. Should be more than enough for a data delay...
    Put a 5 second pause at the beginning of the program, that'll extinguish any doubt about the power up on the LCD. If that don't fix it, it's something else.
    JDG

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default not seeing some code . . .

    Hi DragonBall_6,
    As I didn't see it listed in your code, do you have appropriate define osc X in your code and question 2 is have you set config fuses to HS when trying to use fast oscillator speed?
    JS

  4. #4
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post Advancing the project:

    Thanks to all the reply,

    After I change it to PIC16F876 and 4Mhz cystal, pause 500, commandus 2000 and dataus 1000. It is work.
    I had adding 4 button to increment the hrs,minute,day and month.
    I feel happy.THANK YOU ALL THAT PROVIDE ME A LOT OF INFORMATION.

    I have thinking to advancing my project by using the A/D function.
    The idea is get the input from the solar PV and sent into the PIC16F876.
    When the voltage is lower than 2 volt then motor stop and vice versa.
    The input voltage from the solar PV is up to 15 volt.

    Can someone help and guide me thru the basic part such as the initialization of the of the PIC???
    Possible that the PIC get the analog input above 5Volt????

    Any suggestion and Please advice....Thanks

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi,
    If you look at the ADCIN command in the PBP manual you'll see how it's done in its simplest form. Basicly you set the pin you want to use to be an input via the corresponding TRIS register then you set the pin to analog via the ADCON1 register. Look up the ADCON1 register in the datasheet.

    Use a simple voltage divider between the solar PV (?) and the PIC pin. Take two resistors, one 2.2k and one 1k. Connect them in series across the 0-15V voltage with the 1k closest to ground. Connect the PIC pin to the junction between the two resistors. Don't forget that the ground from the solar PV must connected to the PICs ground. This will produce a voltage of 0 to 4.68V on the PIC pin for 0-15V from the solar PV. It will draw ~4.7mA from the solar PV.

    So....
    Code:
    DEFINE ADC_BITS 10             'Set ADC to produce 10bits
    DEFINE ADC_CLOCK 3            'Set ADC clock to internal RC
    DEFINE ADC_SAMPLEUS 50     'Set conversion time to 50uS
    
    TRISA.0 = 1                         'Set RA0 (pin2) to input.
    ADCON1 = %10001110           'Set RA0 to analog, internal Vref, result right justified. (See datasheet)
    
    SolarVoltage var WORD          'Store AD conversion result here.
    
    Loop:
    ADCIN 0, SolarVoltage                  'Read AN0, store result in SolarVoltage.
    LCDOUT $FE, 1, #SolarVoltage       'Display value on LCD
    Pause 500
    Goto Loop
    If you use the resistor values above the reading should vary somwhere around 0 - 958 give or take. (For a 0-15V input)

    /Henrik Olsson.

  6. #6
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post

    Thanks to the reply.
    Solar PV also called photovoltaic cell (direct absord sunlight and generate electricity).

    ***LCDOUT $fe,$1, #solarvoltage*****

    Thus, the LCD only can display the value not above 5 volt,am I right??
    If this is the case, if I want to display value above 5v on the LCD then is that possible.

    If I'm using 4 Mhz crystal, do I need to have this sentences ***DEFINE ADC_CLOCK 3****?????


    Thanks and please advice.
    Last edited by DragonBall_6; - 13th December 2006 at 01:40.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Maybe I am right . . .

    Quote Originally Posted by DragonBall_6
    Thanks to the reply.


    Thus, the LCD only can display the value not above 5 volt,am I right??
    If this is the case, if I want to display value above 5v on the LCD then is that possible.

    .
    Hi DragonBall_6,
    What the voltage divider does is input voltage based upon the resistors ratio into the pic pin and hopefully limit it's input voltage to TTL levels. You have to write the code to do the math and then output the voltage numbers to suit your purpose. If you store the ADC value in a byte variable then ( and I am going out on a limb here as I am as new to pic programming as you are ) you should be able to express that as a number from 0 to 255. So if 5 v = 255 (input pin at 5 v when solar panel is at 15 volts) then 255 = 15 volts.So with a given voltage divider you can express 15 volts incremented in 255 steps. Anyone out there who is more knowledgable please ring in!
    JS

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th August 2009, 00:57
  2. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 10:00
  3. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 08:12
  4. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 05:52
  5. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 03:35

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