PIC12F675 Development Board

Discussion in 'The Projects Forum' started by RodneyB, Feb 7, 2014.

  1. RodneyB

    Thread Starter Active Member

    Apr 28, 2012
    633
    13
    I am trying to make a development board for a PIC12F675 and am concerned that something is incorrect in my circuit. I have attached the PCB layout and drawing.

    I don't have a problem getting the outputs to come on from the PIC BUT, not for the life of me can I get the Inputs to work. I do not have a switch that isolates the inputs from the outputs as I thought in code that was taken care of. I just need some advice as its horrible not knowing if its a hardware or software problem. If I know my hardware is in order then at least I can concentrate on the code.
     
    • pdb.jpg
      pdb.jpg
      File size:
      141.6 KB
      Views:
      61
  2. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,729
    758
    Post the code.
     
  3. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    According to your switch arrangement on the right side, you would have to switch one
    to an output, another as an input, then press 2 buttons to get an input.

    I would just connect one side of your switch to Vdd since you ready have the inputs pulled low. Atleast the right side anyway.
     
  4. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    @BMorse
    Although the schematic shows no 5v rail on the three switches... The PCB has the 5v rail attached!!!

    Unless of course this is still on a prototype board...
     
  5. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    There are a couple of issues here. It is mostly a question of choice but I write my opinion.

    1. Stretching out a low pincount device more than neccessary (use a SOIC14).

    2. The 12f675 is around for some years- how about a 16f1503/16f1824?

    3. You could use WPU (internal pullup) if you use more than one key.

    4. How about modern LEDs (either 0805 SMD or high eff. 3mm or Straw hat). They work fine with 2.2k or even 4.7K, and you can short that down with a key (blue LEDs are your friend here with 3V since the level after the resistor is still a H somehow).

    5. Why a developement board for a small pincount IC which is not new?

    Some specific purpose? My experience with low pin count (8 pin) is for small number of PCBs there is no advantage to a 14pin SOIC or a 20pin TSSOP. Even a TQFP44 (easy to handle) is not much larger.

    6. In case of doubt, breadboard with just ONE I/O line until it works properly.

    Give as much info about your projecct as possible so forum can find the best solution and write as much information in return as possible.

    That mean for instance the source, MPLAB version C compiler version, sillicion issue, programmer, power supply, a photo or two.
     
  6. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    The circuit has a serious fault! If the button is pressed while the PIC output is LOW, it will force 5v into the LOW output pin and damage the PIC.

    To fix that I would add a 220 ohm resistor in series with each button.

    Then you will also need to increase the LED series resistor to about 1.5k (1k5). The LEDs will still be bright enough. :)
     
  7. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    The 12F675 is known for being unstable, which is why Microchip replaced it with the far superior 12F683.

    Edited February 9, 2014 to add the following.

    The statement above is just my opinion based on what I have read on the internet. Here is an example: http://melabs.com/samples/LABX4-12F675/ \

    I consider MELABS to be a reputable source of information about Microchip microcontrollers, and I believe what they posted, but they could be wrong. Other people on the internet have also reported similar problems, but I don't have any infallible and unquestionable proof that any of this is correct, so it's just my opinion.

    Microchip lists the 12F675 as still in production, so I was wrong about it having been replaced; superseded would have been a better choice of words. I could also be wrong in my opinion that the internal oscillator is unstable and hard to use. Digi-key sells the 12F675 for $1.21 and the 12F683 for $1.42. For my money, I'll take the 12F683.
     
    Last edited: Feb 8, 2014
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Ahh, what are you talking about? The 12F675 is still in production, and the 683 was introduced at about the same time.

    If there were stability problems with it, wouldn't you think that they would fix it rather quickly?
     
  9. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Of course we don't know exactly what the original poster has in mind for this circuit but it looks like a standard circuit for using a momentary contact push button switch to emulate a lighted toggle switch. If that's the case then the outputs would never output a low. Instead the output pins would be set as inputs at some debounce interval (20-ms) to sample the active high switches and apply the switch state logic and then switched to either output high (LED on) or left as an input (LED off) to match the switches toggled state. The code might look something like this;

    Code ( (Unknown Language)):
    1. /********************************************************************
    2.  *  main loop                                                       *
    3.  ********************************************************************/
    4.  
    5.    while(1)
    6.    { delay_ms(25);              // 25-msec sample intervals
    7.  
    8.   /*                                                                *
    9.    *  Lighted Push Button Switches (emulated toggle switches)       *
    10.    *                                                                *
    11.    *  swnew  ____---____-----___   sample active hi switches        *
    12.    *  swold  _____---____-----__   switch state latch               *
    13.    *  swnew  ____-__-___-____-__   changes, press or release        *
    14.    *  swnew  ____-______-_______   filter out 'release' bits        *
    15.    *  flags  _____-------_____--   toggle flag bits for main        *
    16.    *  trisio -----_______-----__   toggle tris bits for LEDs        *
    17.    *                                                                */
    18.      trisio = 0b00111111;       // set all GPIO pins to inputs
    19.      swnew = gpio;              // sample active hi switches
    20.      swnew ^= swold;            // changes, press or release
    21.      swold ^= swnew;            // update switch state latch
    22.      swnew &= swold;            // filter out 'release' bits
    23.      flags ^= swnew;            // toggle flag bits for main
    24.      gpio = 0b00110111;         // set GPIO output latches
    25.      trisio ^= flags;           // light only active sw LEDs
    26.    }                            //
    27.  }                              //
    28.  
    So, it's difficult to support an opinion that there's a "serious fault", however, until the original poster comes back, we're all just guessing.

    Cheerful regards, mike
     
    Last edited: Feb 8, 2014
  10. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Here's one source, but I have read this other places.

    http://melabs.com/samples/LABX4-12F675/
     
  11. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    "I saw it on the internet so it must be true". LOL...

    Unfortunately, when you present an opinion disguised as an authoritative conclusion instead of a conclusion based on an argument that includes premises and proof, it affects the authors credibility and may negatively impact perception of the site.
     
  12. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    A lot of what is posted here is simply opinion, and that includes your opinion as posted above. I didn't disguise anything; I simply stated my opinion. I lack the time or the inclination to find scientific premises and proof for everything that I believe; instead, I consider the source. And in this case, I think the source that I linked to is reputable, and I chose to believe it. Can I prove it beyond a reasonable doubt? No. Could it be wrong? Yes, but it could be right.

    However, in the interest of full disclosure, I have gone back and edited my post.

    And by the way, I didn't say that I believe everything that's posted on the internet, and I resent the insult to my intelligence.
     
    Last edited: Feb 8, 2014
  13. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    FWIW I've had a product in production for going on near 5 years now based on the PIC12HV615, same guts as the '12F675 but with a shunt voltage regulator built in to it.

    Nothing "finicky" has been noted.

    Zero funny observed, and I have the blank notebook to back up this claim.
     
    BMorse likes this.
  14. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Ditto, a product here using 12F675 too from years ago with all good news.

    The "finicky" comment on that webpage is a personal opinion, and seems based on the idea that the internal oscillator "needs calibration" (his words).

    But the 12F675 is supplied with the 4MHz calibration constant pre-programmed, so all that is required is to NOT overwrite that constant, and to load it in code which is two ASM instructions.

    If I was to fault the 12F675 internal oscillator compared to newer 8pin PICs it would be that the 12F675 internal osc can only do 4MHz, where newer PICs int osc can do 8Mhz or more. Since the 12F675 is fully capable of 20Mhz operation having the internal osc stuck at 4MHz max is a big "flaw". :)
     
    BMorse likes this.
  15. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    I sort of agree!! I use the pic12f675 extensively, But I don't need a precise oscillator... I use it as a quad encoder and the 'finiky' calibration has no bearing on the operation whatsoever!!! There must be quite a few applications that do not need the precision that other chips give... Putting the cal value in isn't a biggy and getting a new cal from PK2 is easy as well...

    I'll keep on using it!!
     
  16. RodneyB

    Thread Starter Active Member

    Apr 28, 2012
    633
    13
    I must firstly thank everyone for the replies and apologise for the schematic I attached, It had serious mistakes which I did not check.

    I am trying to basically get a switch to work. I want to push the button and then an LED comes on for 30 seconds.

    Where the biggest problem comes in for me is that I am very; very new at this and basically as I am given code I research it and try and teach myself. I would be better off having someone who can explain the code line by line. Often to nervous to ask for fear of annoying people who help on the forum.

    Where I was concerned was on my development board because if the code is right and the board is wrong especially if your unsure you never know where to look.

    I managed to run some code that made sure that the PIC12F675 runs and the outputs do come on.

    But not for the life of me can I get a push button to turn on and LED. I am at my wits end and blank. And cant understand why I cant get a simple thing to work.

    A friend has given me the below code, But it may as well be in hieroglyphics as I cant follow it and when I program it into the PIC12F675 nothing happens.

    so any help will be a massive help.

    Code ( (Unknown Language)):
    1.  
    2.  
    3.  void interrupt ISR(void)    {  
    4.  
    5.   char flicker;  
    6.    
    7.       INTCONbits.T0IF = 0;        // Clear timer IF flag    
    8.      TMR0 = T_CONST;             // Reload timer    
    9.      ticks++;                            // Adjust tick counter    
    10.       flicker = (ticks >> 2);        // Slow flicker rate down    
    11.       GPIO = flicker;    
    12.  }  
    13.    
    14.  void main (void) {    
    15.  
    16.        ANSEL = 0;                // Config as digital IO    
    17.       CMCON = 0x07;            // Config as digital IO    
    18.        GPIO  = 0;                // Start with outputs off    
    19.            
    20.     OPTION_REG = 0x87;        // Pullups disabled, prescaler 1:256    
    21.     INTCON = 0xE0;            // Enable GIE, PEIE, T0IE    
    22.      
    23.  while(1);
    24.      
    25.  }  
    26.  
    27.  
     
  17. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    Have you the rest of the code... The config bits may not be set correctly...
     
  18. RodneyB

    Thread Starter Active Member

    Apr 28, 2012
    633
    13
    That is all the code I was given. The config bits; is that where you set the inputs and outputs?
     
  19. RodneyB

    Thread Starter Active Member

    Apr 28, 2012
    633
    13
    1. I cant see in the code where the individual bits are made inputs or outputs.
    2. The Character flicker I don't understand what it does.
    3. Do I have to define each of the bits and then set them as outputs?
    4. after the while(1); statement the code that follows will be in a loop forever if my understanding is correct.
    5. I think most of my confusion rises from not understanding flicker and the bits not being defined which makes me stumble at this point
     
  20. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    There must be more code... The variable "ticks" must be global!!! and there has to be #include<> statements!!

    The config bits allow the OSC to be set.. Internal or external... and whether the MCLR is on or off...
     
    RodneyB likes this.
Loading...