PIC16F84A Questions

Discussion in 'Homework Help' started by jw223, Jan 3, 2009.

  1. jw223

    Thread Starter New Member

    Jan 3, 2009
    9
    0
    Hi

    I need some assistance with the following PIC16F84A questions!

    Question 1

    A PIC16F84A based circuit is connected to various sensors and acruators through interface electronics such that the sensors produce PIC compatible logic levels and the actuators respond to PIC logic levels. They are connected in the following way:

    Port B bit 0 to a pressure sensor.
    Port B bit 2 to a green status LED.
    Port B bit 3 to a yellow status LED.
    Port B bit 4 to a Red status LED.
    Port A bit 0 to a solenoid operated valve.
    Port A bit 1 to a motor-operated pump.
    Port A bit 3 to a liquid level detector.

    The other port pins are not connected to anything. Write, in PIC assembly code, the appropriate port intialisation for this system.

    My attempt to this question!
    bcf status rpo ; set bank 1
    movlw B'00011111' ;all as inputs
    movwf TrisA ;writing to tris A register
    movlw B'00000000' ;all as outputs
    movwf TrisB ;writing to tris B register
    bsf status rpo ; set bank 0 to configure ports A & B.


    I am not sure whwther this is a correct initialisation for the above system but my main problem is on the follow up question as shown below;

    Question2 (follow up question)

    The system in question 1 above is shown in figure 6 below. Write a pseudo-code description of the continuously operating process desribed below. Do not consider initialisation of the PIC in your pseudo-code and do not write any assembly code.

    The yellow LED must be on only when the pump is on.
    The Green lED must be on only when the valve is open.
    The Red LED must be on only if the pressure level is too high.
    When the liquid level is too low, close the valve then turn on the pump.
    when the liquid level is too high, turn the pump off then open the valve.
    If the pressure is too high turn the pump off then open the valve.

    The other part of the question which I could not understand reads!

    Briefly explain what the directive below tells the assembler to do:

    CBLOCK 0x0C,...............ENDC

    What does this sturcture do in a Pic program?

    Yours

    jw223






     
    Last edited: Jan 3, 2009
  2. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Hmm... how much are you offering for the solution? This looks like a homework question-- might get more help there.
     
  3. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,677
    900
    While we wait for this post to be moved, here are some suggestions to get started.

    Question 1: Please post your exact code using the appropriate code tags.

    Question 2: I find it easiest to flowchart what I am doing using rectangles for actions and diamonds for decisions. That makes it easy to see what is happening so you don't end up at a dead end.

    Question 3: cblock...endc is an easy way to write a list of equates beginning at a certain location and continuing sequentially without you having to look up each register location.

    John

    John
     
  4. jw223

    Thread Starter New Member

    Jan 3, 2009
    9
    0

    how much do you want for the solution?
     
  5. jw223

    Thread Starter New Member

    Jan 3, 2009
    9
    0

    Hi

    I think you can help me on this mate I am really stuck and desparate and I am supposed to answer a very similar question in an exam in a week's time. May you help please! If you need any more information I can look for that and provide you.

    Jw223
     
  6. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,677
    900
    Why do you think PortA is all output and PortB all input? For PortB, bits 2,3, and 4 are for leds and are outputs. Similarly, for PortA, bit 3 is mostly likely an input.

    It seems the point of the first part of the question is simply for you to write the binary with the proper configuration. For PortA, Bits 7, 6, and 5 are unimplemented; bits 4 and 2 are not defined in the question. Bit 3 is input and bits 0 and 1 are outputs. So, the word looks like: b'xxxx1x00' Since you can't use an "x", I would make the x's all 1's to enable weak pull-ups on them (where applicable). The word then is:
    b'11111100' You can do the same for PortB.

    You also need to read about Bank switching. Clearing the Status bit RPO with bcf should put you in Bank 0, not Bank 1. You probably mean bsf.

    Have you looked up any of the many led flashing programs for the 16F84A that are on the Internet? They will show you exactly how to set the ports. Some older tutorials will do that too, but more recent ones will use the 16F628A. Nevertheless, setting the ports for the two processors is similar. Remember, the 16F84 doesn't have comparators, so if you are studying a program for the 16F628, you should skip the lines that read:
    Code ( (Unknown Language)):
    1.  
    2. movlw     0x07
    3. movwf     CMCON
    4.  
    John
     
  7. jw223

    Thread Starter New Member

    Jan 3, 2009
    9
    0

    Hi John

    Thanks very much for your help and I was indeed right that you would help me. On the initialisation the bsf and bcf for bank switching was my mistake thanks for the correction. On the second part you did set me off and I will give it a go and come back for more help. I am a student and just started the pic. How do I access the led flashing programs? Any clues on the specific websites? Thanks John I will keep in touch and learn a lot from you.

    Coincidentally

    John
     
  8. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,677
    900
    Just search on 16F84 or 16F84A. If that doesn't get good results, then do the same search and add "tutorial" or "LED." I don't think there is a tutorial written that doesn't start with blinking an LED.

    John
     
  9. jw223

    Thread Starter New Member

    Jan 3, 2009
    9
    0
    Hi John

    I find the LED section more illustrative and I will work on that. Thanks very much for that.

    John
     
Loading...