1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

characteristics and apps: PIC16F870

Discussion in 'Microcontrollers' started by sardineta, Oct 1, 2004.

  1. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    could you post it.??
     
  2. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    here is the code, well I would like to know if there is any observation that can be important to change.
    For example the definitions of goto's in the ISR routine, and how about the complexity of the ISR routine, and some others at the begining of the code, like ORG 0x00, ORG 0x05, ORG 0x04

    well, this code should done the following read 3dip switches at RB7,6,5
    111, set a delay of 20ms
    110, set a delay of 100ms
    101, set a delay of 300ms
    100, set a delay of 500ms
    011, set a delay of 1000ms=1sec
    x, don't care
    x
    x

    RB4, define a manual mode or automatic mode, auto=1 manual=0

    RB3 and 2
    11 set the ADC to detect 1.25v aprox
    10 set the ADC to detect 2.5v
    01 set the ADC to detect 3.25v
    00 x

    RB0 is an external interrupt that will increment C_DF

    if C_DF =>31 the system will stop to enclave

    AN0 is the analog input
    RA1, led system on
    RA2, led TM, a TM event occurs
    RA3, LED DF, a DF event occurs
    RA4, turns on a relay for about 50ms to close an interruptor
    RA5, turns on a relay for about 50ms to open an interruptor

    TM events occurs without notice, so by polling the firmware a TM event is detected

    I think that's all, see you
     

    Attached Files:

  3. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    thanks ..i'm looking at it now.. :)
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK

    In your section of code above, the address of MAIN is 0x0005 (as the address of the GOTO ISR is 0x0004 - so 0x0005 is commonly the start address of your actual code, as the reset vector at 0x0000 usually just jumps to 0x0005.
     
  6. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    thanks to all, so in other words it is ok, isn't it?
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    Yes!.
     
  8. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    returning with one of my last questions
    This is what the list file says
    Program Memory Words Used: 431
    Program Memory Words Free: 1617


    I have attached the list file, does I have 1671 adresses available?
    what about the free flash memory in PIC?
     

    Attached Files:

  9. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    yes you have 1617 program locations left...
    that IS the flash memory..
     
  10. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    Except for the 'spelling' mistake, you do indeed have 1617 words free.
     
  11. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    i cut him a break on his spelling because english isnt his first language :wink:
     
  12. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
  13. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    sorry :)
     
  14. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    Thanks for your answers! :)
     
  15. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    Hello.

    I found that pin RA4 does not work as a normal output, (I can't read 5 volts) I read the datasheet and it says that as OUTPUT it is open drain, so what you recomment me to do? I am thinking in fixing a resistor of 10k from this pin to Vdd, but correct me if I am wrong, please.

    Can I connect the output of an op-amp directly to the RA0/AN0 pin, where I configured it as an input for the ADC?, or I need a resistor from here to VSS.

    The pins I am not using from port A and C what do I have to do with them? do them grounded?

    Thanks!!
     
  16. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    No, that's fine, that's what you need to do.

    You can connect it direct.

    You can just leave them, it makes very little difference - it varies from person to person, but some people set them as outputs. Personally I don't pay the slightest attention to how they are set, I just ignore them.
     
  17. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    Thank you, Nigel.
    :)
     
  18. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    Does the stack has to do with the interrupts I am using?
    I hahe vonfigured two interrupts one of them is by using timer0 and the other one is by RB0.
    Inside the ISR the program saves the W register and the Status register.

    When I have a signal in the input at the op amp it works but when there is no signal I see at the output of the op amp a signal that is different from zero, what can I do to get a 0 volts or gnd while there is no signal at the input of the opamp.

    I have realized that when the AN0 (analog input) has no signal it behaves as if it sees a voltage different from zero (ground). because I am changing my point of observations I have a deal with this changes.
    This pin RA0/AN0 always should be connected to a voltage point?

    thanks
     
  19. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    sardinetta , how have you wired the op amp inputs?
     
  20. sardineta

    sardineta New Member

    Joined:
    Sep 27, 2004
    Messages:
    131
    Likes:
    0
    Location:
    Cuernavaca Morelos
    This is the circuit I want to connect to the pic 16F870, at pin RA0/AN0.

    The problem as I mentioned above is that when there is no signal I have a DC voltage level at the output.

    the gain at output is 1.5

    Thanks a lot for your help
     

    Attached Files:

  21. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    As you're powering the opamps off +/-9V you MUST add a series resistor between the output of the opamp and the input of the A2D. PIC inputs have clipping diodes between the input pin and Vdd/Vss, to prevent the inputs going outside permitted limits. Feeding directly from the opamp could cause too much current to flow.

    It sounds like you have a DC offset at the output of the opamp, you need to correct it - probably using a preset resistor so you can adjust it.
     

Share This Page