Problems with pic 16f628a - Page 1
Forum section: electronics / beginners

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 02:39:33 pm
content: Hello guysIm having a big trouble with the pic16f628a, i try to download the code to the pic, but the pic doesnt seem to work, it does nothing, here is the schematic of what im doingthe program is very simple, just to turn on and off a led by a switch, the problem is, that in the real world circuit, it doesnt work, it works on proteus, the pics doesnt seem to interpretate the code or somethingthis is how ive connected the pic:14pin to 5v5pin to ground4pin to 5v through a 10k resistor4mhz(internal, im not using a external crystal, although i tried with a external and dont work anyways)the 5v source has a 100nf ceramic capacitor as a filterthe output and input have each a 10k pull down resistorim programing the pic via a microprog r2, ive tried before with another pic programer, but it doesnt work too, by the way, ive tried with 2 pic16f628a and both dont work with the code im trying to put in them, what im i doing wrong?here is the hex if you want to try it::020000040000FA:100000008A110A1208280000000000000000000009:10001000283084005830A0008001840AA00B0C28EE:10002000103095002730960000308E0000308F0091:10003000013090000B30970007309F0000308500A2:100040008316F73085008312003086008316FF3058:10005000860083120C1D2A280C116400A914A9180B:100060002915A91C291105193628291129198515C1:08007000291D85118A012A28CF:02400E00623F0F:00000001FFthanks for your time :3

author: Andy Watson
author_rank: Super Contributor
timestamp: December 20, 2014, 03:36:46 pm
content: Quote from: little_carlos on December 20, 2014, 02:39:33 pmAny chance you could post the source for that code? A quick look at the disassembly suggests that the original is in C ? Also, it does not appear to be reading the input port properly - it is simply looking for a 1 on the port - if it finds zeros, nothing happens.

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 03:41:00 pm
content: ive done that code on a software called ldmicro, its a software to do a code on ladder(for plc) and it compiles into hex for a selected pic

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 04:09:32 pm
content: and how do i do that? XDim a beginner in microcontrollers, if you could help me fixing the code, that would be great :3

author: Andy Watson
author_rank: Super Contributor
timestamp: December 20, 2014, 04:27:51 pm
content: Sorry, I deleted my post. I had another look at the code and it does appear to detect both high and low states.Do you have any means of verifying that the code is being programmed into the PIC ? Can you read it back?How is the initial configuration of the PIC defined? I am guessing that this should be taken care of in the ladder software, but you need to make sure that things like port A are defined correctly, the clock configured correctly and the watchdog timer. One caveat is that the ADC setting must be defined to allow login input and outputs on port A, the default configuration is for the ADC to over-ride the logic I/O.

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 04:49:08 pm
content: this is the microprog software, it says that reading is okbelow you can see the code, but when i do it on the protoboard it does not work, is there any way that the pics are damaged or something?both pics dont work

author: dannyf
author_rank: Super Contributor
timestamp: December 20, 2014, 04:51:35 pm
content: QuoteNot starting from basics: always start from something basic, like blinking an led. Don't try to do fancy things. You need to learn to crawl before start running.Here is a piece of code that you can flash to your mcu.Code::02000000BF2F10:100F7E008301DC2F07309F000800F000F00370089B:100F8E00FF3A03190800C52F0130F3020030031C8D:100F9E00F403F402730A0319740A0319080090305B:100FAE00F1000130F200ED27CB2FC12785118316FA:100FBE0085110515E62FDC30F300F401CB27083040:100FCE00831285060519E22F3230E32F7108C427EC:100FDE007208F100F2010130F1020030031CF2033D:100FEE00F202710A0319720A03190800FF30C427AE:020FFE00F22FD0:02400E0018FF99:00000001FFReport back what you observe.

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 05:04:13 pm
content: the led blinksthanks for the support guys, now it works, il start learning more about it, will help me next semester on highschool with robotics:3

author: dannyf
author_rank: Super Contributor
timestamp: December 20, 2014, 05:08:26 pm
content: It should. More important, when you push in the button, what happens?

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 05:17:40 pm
content: it decreases the speed of the blink

author: Andy Watson
author_rank: Super Contributor
timestamp: December 20, 2014, 05:23:05 pm
content: Quote from: little_carlos on December 20, 2014, 04:49:08 pmIf you can read back the PIC in the programmer but not on the protoboard, the PIC should be ok.The use of the "ladder" is really obfuscating the problem, do yo have a means of using dannyf's suggestion of programming the PIC at a more basic level?In the past, when using In-Circuit-Programming, I have run into problems with the low-voltage programming pin - RB4. This sometimes need to be pulled down (irrespective of setting of the configuration fuse).Edit: Ah, I see I must learn to type fasterLooking at the hex-code that was produced from ladder, it looks like the comparator input is configured - I think this over-rides the logic setting of port A.

author: dannyf
author_rank: Super Contributor
timestamp: December 20, 2014, 05:25:41 pm
content: QuoteSo it can read a pin and can output to a pin.and the pic is OK, as is your programming environment / wiring.That's why blinking an led is so important.QuoteS/he wants to program it like a plc, quite popular in an industrial environment / robotics.

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 05:39:16 pm
content: so, after all of this, can i use the software ldmicro to program the pic, to use it with my plc proyects, or do i have to use c language?

author: dannyf
author_rank: Super Contributor
timestamp: December 20, 2014, 06:10:38 pm
content: It can be used to program a micro.Only you can tell if ***you*** can use it to program a micro.

author: little_carlos
author_rank: Regular Contributor
timestamp: December 20, 2014, 06:23:59 pm
content: ive tried a lot of different codes with ldmicro but noone seems to workbut why it does on proteus?

author: Andy Watson
author_rank: Super Contributor
timestamp: December 20, 2014, 06:41:07 pm
content: Quote from: little_carlos on December 20, 2014, 06:23:59 pmCan you change your design such that the switch and LED are on port B? I suspect there is some aspect of the default configuration of ldmicro that introducing a problem.

author: dannyf
author_rank: Super Contributor
timestamp: December 20, 2014, 07:10:11 pm
content: My experience with Proteus is that it is very accurate. Where it differs from reality, aside from non-implemented modules, is power supply, wiring, and oscillators.That would be where I would spend time debugging.

author: SL4P
author_rank: Super Contributor
timestamp: December 20, 2014, 10:32:52 pm
content: There are a few things wrong with that schematic.You can apply +Vcc directly to RA2 via the push buttonR3 is there for ?? what.Once you have those sorted out, you may look for others. But chances are the PIC I/O pins are fried already.Next check your clock fuses are set correctly for the external XTAL, or use INTOSC for fewer components.