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 - problem with pic 16f876a

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

problem with pic 16f876a (by claudio calcagno)
Hello, thank you all for the advice but it doesn't work the same, rel. ldmicro 5.4.1.1. Greetings.
Tue Oct 12 2021, 02:21:33
(no subject) (by MGP)
Your program is ok...so I think you have a hardware problem.
Tue Oct 12 2021, 03:18:22
(no subject) (by Calubert)
I have attached a new program to understand it better, I put a letter in each input and outputs such as internal relays and timings since variables cannot be started with numbers I don't think it is, but sometimes the logic can change, I suppose you have put it the 20,000000 crystal, Mhzh, try it and tell me if it went well for you.

I made you .hex, load this .hex to the micro chic

Te adjunto programa le hice nuevo para entenderlo mejo te puse una letra en cada entrada y salidas como relés internos y temporizaciones ya que no se pueden comenzar las variables con números no creo que sea pero a veces la lógica puede cambiar, supongo que le has puesto el cristal 20,000000, Mhzh, pruébalo y me dices si te fue bien.

te hice .hex, carga este .hex al micro chic
Tue Oct 12 2021, 09:40:17, download attachment GSM3.ld.rar
(no subject) (by José)
I persist to advocate to have a look at REFS field.

Here's a portion of code in ldmicro's source file Pic16.cpp concerning READ_ADC:

if
(
McuAs(" PIC16F819 ") || //
McuAs(" PIC16F873 ") || //
McuAs(" PIC16F874 ") || //
McuAs(" PIC16F876 ") || //
McuAs(" PIC16F877 ") || //
McuAs(" PIC16F72 ") //
)
{
adcsPos = 6; // in REG_ADCON0
WriteRegister(REG_ADCON0, //
(adcs << adcsPos) | //
(MuxForAdcVariable(a->name1) << chsPos) | //
(0 << goPos) | // don't start yet
(1 << 0) // A/D peripheral on
);

WriteRegister(REG_ADCON1, //
(1 << 7) | // right-justified
(refs << 0) //
);
}

It shows that the REFS field is written in ADCON1 register
to set A/D configuration of Port A, according to the table in the datasheet.
REFS= 0 means all pins can be used as Analog pins.

BR
José

PS (in datasheet):

Note 1: When reading the port register, any pin
configured as an analog input channel will
read as cleared (a low level). Pins configured
as digital inputs will convert an analog
input.
Tue Oct 12 2021, 15:06:46
(no subject) (by MGP)
@José,

Weird to write something like this, but I hope you're wrong, that would be a disaster for LDmicro because very few LDmicro users know what the REFS registry does and don't know what to write in that field.

I don't quite understand what you're saying, I've already made dozens of programs using a 16F876a with mixed inputs on the same port, they all work.

You're the first to write something about that and I'll give you the benefit of the doubt, but that's where it ends for me.
Tue Oct 12 2021, 16:05:28
(no subject) (by Calubert)
Someone tried. GSM3.ld.rar I can't test it since I don't have this type of controller.hex.
Jose I agree with you, but the truth is that all the updates from ldmicro never talk about it.

MGP, you have this chic to test you can modify the program with PUL-daun resistors on the chic like crystal oscillator.
Because the truth is I do not know what error happens since all my tests work for me and I see everything correct unless I am using the reset pin or it does not power the reset pin.

Alguien probo. GSM3.ld.rar yo no lo puedo probar ya que no tengo este tipo de controlador.hex.
Jose estoy de acuerdo contigo, pero la verdad que todas las actualizaciones de ldmicro nunca hablo de ello.

MGP, tienes este chic para probar se puede modificar el programa con resistencias PUL-daun en el chic como el cristal oscilador.
Porque la verdad no se a que error le sucede ya que yo todas mis pruebas me funcionan y lo veo todo correcto a no ser que este usando la patilla de reset o no le da la corriente a la patilla de reset.
Wed Oct 13 2021, 06:10:50
(no subject) (by claudio calcagno)
Hi, Calubert I tried your file but it doesn't change anything, I attach electrical diagram, but I thinks it's all ok, as I already wrote the same problem I also give it with pic 16f877a , thanks to everyone.
Wed Oct 13 2021, 08:18:03, download attachment gsm2.PNG
(no subject) (by Calubert)
OK lo miro y funcionara.
QUE USAS LCD O ESPLICA QUE FUNCION HACE ulnXXX.


OK I look at it and it will work.
WHAT DO YOU USE LCD OR EXPLAIN WHAT DOES ulnXXX DO?
Wed Oct 13 2021, 12:18:30
(no subject) (by MGP)
I think there is an error in the schematic, D3 makes that you not have a common GND to measure analog signals.
Better to place D3 in the + line if you want to make a reverse polarity protection.

Q1 is misplaced, emitter must go to GND.

R1, R2, D1 and D2 may be removed, serve no purpose.

A good practice when dealing with problems is to delete all rungs that have nothing to do with the error, so only keep the rungs where it goes wrong, much easier to spot errors.

But I maintain that your program has no programming errors, which does not mean that it works as it should.

@Paulino, no need to start each timer, relay with a letter, LDmicro automatically puts the letter Tx, Rx before it.
I always only use numbers for the names of Timers, very easy and clear
Thu Oct 14 2021, 05:22:44
(no subject) (by Calubert)
I attach a photo for the hardware modifications.
explanation: transistor BC337 (Q1) you should change pin # 1 for 3 and 3 for 1 (it is wrongly connected since it is NPN and is connected as PNP) as you have it at this time, Q1 will always be active.
and at the output of the PIC16F to the inputs of the ULN28xx if you put a resistor at each input (U3) of 10K to ground or negative.
these resistors will make that when (U2) commands 0 it will be real 0 and not floating.
By not having these resistances it can cause you false by the residual currents that to place these resistances are eliminated.

When it is simulated everything works fine but in reality it does not work for you since we do not leave an absolute 0 in Hardware.
try it with my LDMicro program. .hex

Tell me if when you try it it worked for you

Te adjunto foto para las modificaciones hardware.
explicacion: el transistor BC337 (Q1) deberas cambiar la pata nº1 por la 3 y la 3 por la 1 (esta mal conectado ya que es NPN y esta conectado como PNP)tal como lo tienes en este momento te quedara activo siempre el Q1.
y en la salida de la PIC16F a las entradas del ULN28xx si le pones una resistencias a cada entrada (U3) de 10K a masa o negativo.
estas resistencias harán que cuando (U2 )manda 0 será 0 real y no flotante.
al no tener esta resistencias te puede causar falso por la corrientes residuales que a colocar estas resistencias se eliminan.

cuando se simula todo funciona correcto pero en la realidad no te funciona ya que no dejamos 0 absoluto en Hardware.
pruébalo con mi programa LDMicro. .hex
Thu Oct 14 2021, 08:38:01, download attachment Inkedgsm2_LImodi.jpg
(no subject) (by claudio calcagno)
Good evening, in response to Mr. MGP I dont'n think it has well interpreted my wiring diagram, downstream of D3 the GND does not involve problems with analog inputs, R1-R2-D1-D2 are used to limit contacts against embankment, for Q1 is perfect so I attach scheme, thank you all for the collaboration.
Thu Oct 14 2021, 10:34:21, download attachment ra4b.PNG
(no subject) (by Calubert)
Adjunto de MGP: que hacen R1, R2, D1 y D2 + C.
según sensor utilizado si es por corriente se nota muy poco (no haría falta pero mejora y / o tenemos un filtrado, de interferencias)
si es por frecuencia si hace falta ya que actúa como amortiguador en la descarga (off) como (ON).

MGP adjunto: que hacen R1, R2, D1 y D2 +C.
según sensor utilizado si es por corriente se nota muy poco (no haría falta pero mejora y/o tenemos un filtrado, de interferencias)
si es por frecuencia si hace falta ya que actúa como amortiguador en la descarga (off) como (ON).
Thu Oct 14 2021, 11:22:42, download attachment WhatsApp Image 2021-10-14 at 17.07.37.jpeg
(no subject) (by Calubert)
I understand that it works the way you wanted

entiendo que le funciona como usted deseaba
Thu Oct 14 2021, 11:29:28
problem pic. (by claudio calcagno)
Hi Calubert, I posted an incorrect diagram regarding Q1 thank you again.
Thu Oct 14 2021, 11:49:13
(no subject) (by MGP)
The RA4b.PNG diagram is not equal to the big schematic.

If you want a analog RC inputfilter, then remove D1 and D2.

With D3 you have a floating GND not only for te AD inputs but also for the contacts.

D7 is also a bad thing to do, remove the diode because the controller uses te Vcc as Vref.

No need for external resistors with a ULN2803a, they are already incorporated and specially designed for IO ports.

Make a program of 2 or 3 rungs that make the error, then you can follow much better of what is going wrong.
Thu Oct 14 2021, 12:47:34
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):