Menu

HELP! How to configure PIC16F505 using single input pin reading multiple signals

Phil D
2020-04-07
2020-04-09
1 2 > >> (Page 1 of 2)
  • Phil D

    Phil D - 2020-04-07

    How can a PIC16F505 use just RB1 input to read 3 states, (i.e 0Volts, 6V or 12V)? Based on the input, the output would be 0V=Do nothing, 6V=Output to RC3, 12V=Output to RC2. 0V=all LED's off. Any help is very much appreciated!

     

    Last edit: Phil D 2020-04-07
  • Anobium

    Anobium - 2020-04-07

    Welcome Phil.

    No schematic.

     
  • Phil D

    Phil D - 2020-04-07

    Thank you Anobium - Apologies, now attached.

     
  • Anobium

    Anobium - 2020-04-07

    This makes a little more sense. :-)

    Is this an existing project? Can you share the code?

     
  • JANIS

    JANIS - 2020-04-07

    If I understood the idea correctly , then measure the voltage level, it is necessary to use a voltage divider so that the input of the microcontroller does not exceed 5V and the input of the microcontroller must support the A / D function.

     
  • JANIS

    JANIS - 2020-04-07

    If I understood the idea correctly , then measure the voltage level, it is necessary to use a voltage divider so that the input of the microcontroller does not exceed 5V and the input of the microcontroller must support the A / D function.

     
    • Anobium

      Anobium - 2020-04-07

      This one.... ?

       
      • Phil D

        Phil D - 2020-04-07

        Thank you very much for your advice, it really is very helpful - I will look into these 'exchanges' :) I really appreciate you (and Janis) helping me with this!

         
    • Phil D

      Phil D - 2020-04-07

      Thanks for the feedback Janis and Anobium. You are correct regarding the ADC comment and the required voltage scaling. What confuses me is how the heck it works as my professor demonstrated a working example before we went into COVID-19 lockdown - so it does work based on all the hardware shown in the schematic. My task is to figure out the PIC instructions just for RB1 input and split the two incoming +V signals into two outputs (RC2 & RC3). I have been banging my head on the wall for nearly a week to get my head around this and I can't for the life of me see how. We are not allowed to change, add or remove any components - Arrrg :(

       

      Last edit: Phil D 2020-04-07
      • Anobium

        Anobium - 2020-04-07

        Can I just check....... first name of the professor is? I do not want to hack someone off. :-)

        So, look at http://ww1.microchip.com/downloads/en/DeviceDoc/01146B.pdf Any hints in this document?

         
        • Phil D

          Phil D - 2020-04-07

          LOL - Pawel is his name. I will have a look over the Tips and Hint sheet tonight. Thanks!

           
  • Anobium

    Anobium - 2020-04-07

    But, this chip does not have ADC. I would simply pull of the old PIC16F505 chip and replace with PIC16F15324 then using the voltage divider use the ADC to read the value.

     
  • JANIS

    JANIS - 2020-04-07

    Anobium, yes. I therefore mentioned in my comment that the PIC must support an A / D converter. I saw that the PIC16F505 has no analog input, I guess maybe I was wrong ... But it really isn't. Like the traditional 16F628 :). Look for another microcontroller

     
  • JANIS

    JANIS - 2020-04-07

    Explain to the professor 1) PIC16F505 does not support A / D converter. 2) the voltage level must be changed. Without it, nothing can be done. A voltage divider with resistors is the simplest option. You may not need transistor Q1, and replace the resistors R6 and R7 with the required ratings that Anobium drew. Instead of capacitor C8, zener diode 5.1V are inserted. This way, nothing will be added or subtracted, but exchanged.

     
    • Phil D

      Phil D - 2020-04-07

      Thank you very much for the recomendations, it really is very helpful - I will look into these 'exchanges' :) I really appreciate you helping me with this!

      But how in the heck did my professor make this ciruit work during his live demostration??!! I ask when i speak to him next...

       
  • JANIS

    JANIS - 2020-04-07

    I think it will be too difficult for the guy. It is easier to change the microcontroller and use the ADC. The circuit needs to be redesigned anyway, a voltage divider is needed.

     
    • Anobium

      Anobium - 2020-04-07

      I am with Chris. The resistor and cap circuit should be in the tips and tricks, however, I did not check... and, I did not want to do his homework! lol

       
  • Geoffrey Younger

    Am I missing something here ! Isn't this just the POT command in GCB aka the BUTTON command in Basic Stamp - with a scaling resistor on the input.

     
    • Anobium

      Anobium - 2020-04-07

      @Geoffrey.. well remembered. Glad someone knows the system and the Help!!!

       
      • Chris Roper

        Chris Roper - 2020-04-07

        Yes, well spotted, I didn't know that existed and Evan had forgotten that he had written it.

         
  • Geoffrey Younger

    In the days before ADC keypads became fashionable, Parallax put out an app note pdf with an app in it called " One Input - Many Switches" . I used this with great success.

     
  • Hugh Considine

    Hugh Considine - 2020-04-08

    Saw this after a day of online meetings, and thought it was a good challenge. I've built the circuit almost as shown (different transistor and a pot instead of the fixed resistors, and 12F509 rather than 16F505) and it does work as described.

    I don't want to give too much away, but some hints. Resistor and capacitor circuit is the way, but you can't add any. So, you have to use what you have. The chip has weak pull ups, which can give you the equivalent of a voltage source with a fairly high value resistor in series, and all microcontroller pins naturally have some capacitance. Look at the links above to see how the pot commands work. Let us know when you work it out!

     
  • mkstevo

    mkstevo - 2020-04-08

    This command [Pot] seems very useful. I'll try to add that to the memory bank for next time I need it.

     
  • stan cartwright

    stan cartwright - 2020-04-08

    I looked up pot in help and there is trigonometry circle.
    It doesn't need #include <trig2places.h></trig2places.h>

    ;Circle and filled circle commands on a graphic LCD.
    ;This uses the 2-place trigonometric routines found in the include file.
    
    ;Thomas Henry -- 4/17/2014
    
    ;----- Configuration
    
        #chip 16F88, 8              ;PIC16F88 running at 8 MHz
        #config mclr=off            ;reset handled internally
        #config osc=int             ;use internal clock
    
        #include <GLCD.h>
        #include <Trig2Places.h>
    
        ;----- Program
    
        GLCDCLS
    
        circle(10,10,10)                  ;upper left
        circle(117,10,10)                 ;upper right
        filledcircle(63,31,10)            ;center
        circle(63,31,20)                  ;center
        filledcircle(10,53,10)            ;lower left
        filledcircle(117,53,10)           ;lower right    
    
     
1 2 > >> (Page 1 of 2)

Log in to post a comment.