Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - 16f877 adc proplems

(you are viewing a thread; or go back to list of threads)

16f877 adc proplems (by smorc)

Hi I have program with 16f877, I am having problem with isis proteus simulation. when i add adc read. program flow is broken. The output named (sgout) resets itself, it cannot be set.
I am attaching my program, if you help me I would be glad.


The program works very well when there is no adc reading. there is no error message in the simulation. When I add adc (sgout), I have a problem with exiting immediately.
Mon Sep 5 2022, 13:09:58, download attachment OC5.ld
isis preteus (by smorc)
I'm adding an isis proteus simulation
Mon Sep 5 2022, 13:11:04, download attachment OC5.pdsprj
(no subject) (by MGP)
I do not have Proteus, post a screenpicture.
Mon Sep 5 2022, 13:49:19
PNG (by smorc)

SGOUT OUTPUT DOES NOT WORK AFTER ADC READING IS ADDED....
IT WORKS WHEN I REMOVE ADC READING I think the ADC READ is preventing the program from being scanned continuously.
Mon Sep 5 2022, 14:33:32, download attachment TEST1.png
(no subject) (by Ziggy)
You may have self interference problem.

The relay coils need free wheeling diodes and or snubbers.

As is every timethe a relay is energised the switching transient is likely to cause the processor to reset.
Mon Sep 5 2022, 16:21:56
(no subject) (by MGP)
This is a drawing that can be improved:

- resistors on ports that are not used and resistors parallel on VR1 and VR2 are not common.
- forgot diodes on relays, but not important in simulation
- MRCL must go through a resistor to the V+

Also check your config. word in the settings.

BUT there is a big fault on the crystal, the capacitors must be 22pF and not 22nF.

I don't see any causes for the rest!
Tue Sep 6 2022, 03:47:57
(no subject) (by MGP)
Also V1, V2 and V3 must be DC voltage, the opto's are suitable for AC voltage.

The inputs RE1, RE2, R3 are not 0 or 5V because of the resistordividers on these inputs.
Tue Sep 6 2022, 03:57:43
(no subject) (by MGP)
Also V1, V2 and V3 must be DC voltage, the opto's are >> NOT<< suitable for AC voltage...sorry
Tue Sep 6 2022, 04:23:15
test3 (by smorc)
thanks a lot for the help

the whole problem is after analog reading is added. SGOUT is reset and cannot be set again.

MCLR P&#304;N +5 VOLT
RE0 RE1 RE2 I gave drek 5 volt dc
crystal 22nf added 22pf instead

I guess I really need to try the circuit.
Tue Sep 6 2022, 10:30:47, download attachment TEST4.png
(no subject) (by MGP)
I cannot find the problem, the program works correctly and adding the analog reading can not be the cause.

A good tip, use the same names in your drawing as in your program otherwise it is very difficult for an outsider to follow
and delete the unprogrammed buttons and resistors in your drawing.
Tue Sep 6 2022, 13:02:06
(no subject) (by smorc)
frankly, i think it is just because of simulation... i'm going to draw real and try it out there.

I created a simulation page from scratch from scratch, the same problem occurs again.

re0 re1 re2 If I remove the error checking in this port, it's fine. can take the role.

If I do a re0 re1 re2 error check, it can't pull to the role.


While checking re0 re1 re2, if I only remove the adc reading, there is no problem. Well, this part seriously surprises me.

i will try the circuit in real.. i think the result will be positive
thank you for all the help.
Tue Sep 6 2022, 13:16:47
(no subject) (by MGP)
Try with the config bits set on 0x3f62.
Tue Sep 6 2022, 13:30:51
(no subject) (by smorc)
It says 0x3ffb and I'm trying it with your code.

yes I tried 0x3F62 did not change.


I also tried various crystal speeds. I removed the leds, I thought that the current was not enough, but the result did not change.
Tue Sep 6 2022, 14:18:33, download attachment test5.png
(no subject) (by smorc)
I set up the circuit with mega2560, the same error continues. I guess this is not a CPU related issue.
Tue Sep 6 2022, 14:44:24, download attachment test6.png
(no subject) (by MGP)
It's not LDmicro, I made +50 programs for the 16F876a which has the same internal structure as the 877a and is in the same datasheetand and they all work without problems.
Wed Sep 7 2022, 05:49:30
TEST (by smorc)
I've been experimenting all week. When I add adc reading, it does its job and turns on the leds in sequence. but the program is busy with adc. I cannot activate the startset command. It doesn't need to read re0 re1 re2 ports. When I remove the adc reading, it reads the ports and works without any errors.

When I set a condition to read adc as a precaution, the other part of the program runs. If the condition is OK, when the adc reading is activated, the other part of the program does not work.

In fact, while there is adc reading (if suhata) (if &#305;shata) this section is working. And I think it's a bit exaggerated. When I add re0 re1 re2 readings, I think there is a buildup.

The program occupancy rate is only 10%. Even though I put a filter on the adc reading, the startset command unfortunately still doesn't work. I bought arduino nano and tried it on real circuit. ldmicro does not show any errors in the simulation, the tasks are active.
Sat Sep 10 2022, 10:49:35
(no subject) (by smorc)
10's set reset commands are running without adc reading.
I did not add adc reading, I equipped almost all pins with set reset commands and they worked without any problems.

my program version is the latest version v5.4.1.1. do I have to try this in another version?

I am programming plc industrially, gmt model using st32 cpu.. ldmicro is very nice, a great convenience. i don't think i made a mistake and i would appreciate if someone can help me i have time i will try all your thoughts


my program has 5 bug checks.
water bug
heat error 1/0
rst errors 1/0
r 1/0
s 1/0
t 1/0

ignoring error in on position
There is a fault in the closed position and the start command must be reset.

adc reading actually I need to use 2 pieces 1 as vumeter to compare the 2nd adc current read with the 1st adc

I think lastly I will use 2 processors, I plan to read adc with 1 processor and do error control with 2ci with ldmicro
Sat Sep 10 2022, 11:01:37
(no subject) (by MGP)
I will try it this week.
Sun Sep 11 2022, 11:25:02
test (by smorc)
Dear MGP, have you tried it? I checked for a long time. Multiple set resets can be used when adc is not available.
With adc, the set reset command can be used less

I'm thinking of doing the error check and set reset program on one processor and the process on reading adc on the other processor.

I need to print cards according to this program situation.. I don't want to throw it away. I don't want to take risks. I tried many formulas but it didn't work

your opinion is important to me and finally I am waiting for your opinion.
Thu Sep 15 2022, 05:10:56
(no subject) (by MGP)
Sorry, I had to make a video.

Everything works as you programmed it, see the video.
You probably made a mistake but I can't see it from here.


https://www.youtube.com/watch?v=MyUDnG0jFT0
Thu Sep 15 2022, 12:30:16
(no subject) (by smorc)

Thank you very much for your interest Mr. adc0 vu meter adc1 power led this part works for me too. After the start tag, the output named SG is reset, can you take a look at it.


When you press the start button, the output named sgout is not set. 16f877 pin 15 is not controlled.


running adc process. The start button and pin 15, which is the set pin, do not work.
Thu Sep 15 2022, 13:14:20
(no subject) (by smorc)
I gave you a lot of trouble, Mr. MGP, I am very happy that you tried it. Thank you very much.


power led output is a direct output.. works super together with adc reading. With the start button error checks, pin 15 sgout does not work, but remove the adc reading from the program and try again, then it works.

I'm using translate, that's why I can't be full-blown. my problem is reset when i add set command adc read on pin 15.
Thu Sep 15 2022, 13:19:57
(no subject) (by MGP)
Now i see what you want to say.

Indeed it doesn't work if you use AD pins for XR, XS, XT, it does work if you use other pins, probably a bug.

If I have time this weekend I'll investigate why.
Thu Sep 15 2022, 18:35:14
(no subject) (by smorc)
Mr. mgp is in the program I added. The set reset error checks are working properly.

So far, I can use my program without any errors

now if i add adc read. the program is not running. There will be no RE1,RE2,RE3 pin control and the set output will be reset.

Burada küçük bir hata var ama bulam&#305;yorum. Program&#305; birçok kez yeniden yükledim ama bulam&#305;yorum.

Please try this if you have time. The program works super. When I add adc, the program is bullshit.
Sat Sep 17 2022, 02:42:24, download attachment OC5.ld
(no subject) (by smorc)
Reducing the ADC read sample time. or I have to call the main program again. the program seems to remain read-locked on adc.

still some part of the program is running while there is adc reading. so I don't know if calling subroutine will work.

How did you follow the path here in the programs that you used the set reset command many times together with the adc reading.

I believe we can solve this. Using 2 processors will be quite difficult. CPU is mostly empty already.

I'll be constantly trying new things this weekend.
Sat Sep 17 2022, 02:55:13
(no subject) (by MGP)
You cannot use RA0..5 and RE0..2 as inputs when you add ADC, it seems that the registers are not set properly.

I have a busy weekend and don't know if I'll manage to check that.

If you change your program so that you are using different pins for the inputs than the ADC pins then everything will work.
Use port RB en RC as input pins.
Sat Sep 17 2022, 03:27:44
(no subject) (by smorc)
Dear mgp, I tried now, I removed the vu meter. I'm using port b for xr xs xt and it's successful, I think I can get it together now.

Thank you very much for this information. I can't review pdf file because of my bad english.
Sat Sep 17 2022, 04:13:39
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):