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 - DS1307

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

DS1307 (by manuel)
Hola tengo que conectar un 16f877 y u 16f876 a 1307 los dos en paralelo no se si esto puede funcionar pido ayuda alguien del foro
que saben mucho de esto
un saludo
Tue Jan 11 2022, 13:48:23
(no subject) (by José)
DS1307 Real time clock works with I2C bus ; on the bus you can have several slaves (DS1307, display, sensors...) but only one master (the µC).
So it's impossible unless one of your PICs behaves as a slave (can it ?).

José
Wed Jan 12 2022, 14:47:13
(no subject) (by manuel)
hola José
Muchas gracias por contestarme a mi pregunta
si tu me explicaras como hacerlo te lo agradeciera muchísimo
un Saludo Manuel
Thu Jan 13 2022, 05:29:47
(no subject) (by José)
Hi Manuel

Here's attached an example ld file for ldmicro which works with ldmicro32, for PIC16F877 + DS1307 (+ Uart):

https://github.com/joegil95/LdMicro32

Download and unzip version 6.0 and read Help\install-es.txt
and manuel-es.txt if you don't know ladder language.

The program displays on Uart the seconds sent by DS1307.

Then it depends what you wanna do...

BR
José
Thu Jan 13 2022, 13:07:45, download attachment test877_i2c_ds1307+Uart.ld
(no subject) (by manuel)
Hola josé
yo ya tenco foncionado el ds1307 con el pic 16f877 y queri conetar
el pic 16f876 al mimo ds1307

es decir conctar 16f877 y el 16876 al mismo ds1307

Un saludo manuel
Thu Jan 13 2022, 14:16:39
(no subject) (by José)
Hi Manuel

As said above you ain't supposed to connect 2 masters on the same I2C bus. But maybe I don't undestand what you mean. Please post a diagram of your projet and explain why you need 2 PICs ?

José
Thu Jan 13 2022, 14:55:25
(no subject) (by manuel)
Hola JOSÉ
tengo un reloj de 60 les un pic 1f877 qe me cuenta los minutos y las horas
y el días de la semana i luego otro pic 16f876 que me cuenta
el día del mes y el mes
la idea mía era hacer funcionar los dos pics con un solods1307
para los dos pics
te envió esquema esta en proteos se puede abrir con proteos
un saludo Manuel
Sat Jan 15 2022, 04:48:29, download attachment CONETOR ATMGA 2560 PRO MINI 16f877 ANODO COMUN.pdsprj
(no subject) (by manuel)
Hola JOSÉ
tengo un reloj de 60 les un pic 1f877 qe me cuenta los minutos y las horas
y los días de la semana i luego otro pic 16f876 que me cuenta
el día del mes y el mes
la idea mía era hacer funcionar los dos pics con un solods1307
para los dos pics
te envió esquema esta en proteos se puede abrir con proteos
un saludo Manuel
Hoy, 04:48:29, descargar archivo adjunto CONETOR ATMGA 2560 PRO MINI 16f87
Sat Jan 15 2022, 04:59:06, download attachment CONETOR ATMGA 2560 PRO MINI 16f877 ANODO COMUN.pdsprj
(no subject) (by José)
Hi Manuel

Could you please just post a jpg of your diagram ?

Thanks
José
Sat Jan 15 2022, 12:06:39
(no subject) (by manuel)
Hola José

No puedo enviar el diagrama por JPG eldemicro esta limitado
a 5(MB) y el diagrama mio tiene 8(MB) si puedes mandarme to correo
te enviere une foto del diagrama muchas cracias portodo
un saludo Manuel
Mon Jan 17 2022, 07:01:03
(no subject) (by José)
Hi Manuel

You may reduce the size or definition of your jpg ; if not, you can send it to this temporary address:

[email protected]

And let me know when it's done.

BR
José
Mon Jan 17 2022, 09:45:04
(no subject) (by manuel)
te Envio foto
Mon Jan 17 2022, 14:34:50, download attachment 20220115_185129_opt.jpg
(no subject) (by José)
OK

Thanks Manuel

Photo is very ugly but I can "see" the PIC16F877 on the left, driving a 4-digit 7-segt display with 4 transistors ; and on the right the same with PIC16F876.

I can't see DS1307 but it must be somewhere...

I suppose you have one 4-digit 7-segt display for HH:MM and the other for SS:?? (hundreds of seconds ?).

Of course you must only have one DS1307 to drive the whole.

If I had to do it, I think I would drive DS1307 with I2C bus on PIC16F877, getting all the informations, and set another communication channel between both PICs.
The simplest would be a UART communication to send HH and MM from PIC16F877 to PIC16F876 (because HH and MM change very slowly and there's no emergency to update them).

Are the TX/RX pins (RC6/7) free on your PICs?
UART is well supported by ldmicro and it's not very difficult to do.

You can't use SPI because it's mixed with I2C on PICs.

What do you think of it ?

José
Mon Jan 17 2022, 15:08:58
(no subject) (by manuel)
hola José
hacer esto Hera lo que yo pretendía hacer me gustaría que tu me explicaras como se puede hacer
te mando ora foto perece que es de mejor cálida
el 16f877 me cuenta los días dela semana y los minutos u las horas
y el 14f876 cuenta los días del mes y el mes
estos dos pics era hacerlos trabajar con un solo ds1307

UN saludo Manuel
Tue Jan 18 2022, 07:05:38, download attachment 20220115_185129.jpg
(no subject) (by manuel)
hola José
hacer esto Hera lo que yo pretendía hacerme quisiera que tu me explicaras como se puede hacer
te mando ora foto perece que es de mejor cálido
el 16f877 me cuenta los días de la semana y los minutos u las horas
y el 16f876 cuenta los días del mes y el mes
estos dos pics era hacerlos trabajar con un solo ds1307
Tue Jan 18 2022, 07:07:54, download attachment 20220115_185129.jpg
(no subject) (by José)
Hi Manuel

The last image is much much much better !
And explainations help too.

So I think you can use, as is, PIC16F877 to drive the first display with days and hours/minutes and PIC16F876 to drive the second one with months and days.

To use UART on both you should move your led outputs on 877/RC5+6+7 to 877/RD0+1+2 or other pins ; to set free the UART pins TX/RX = RC6/7. TX/RX on 876 are free yet.

Connect 877/TX to 876/RX and 877/RX to 876/TX.

Then modify your ladder to use UART instructions as in attached example but split into 2 parts:
For 877 (which sends data): UART_Is_Ready + UART_Send
For 876 (which receives data): UART_Is_avail + UART_Recv

You'll have to send month (1-12) + day (1-31) ; to do it you can send only one byte at each cycle on 877: for odd cycles you send month + '0' (to use printable chars ; easier to debug if need be) and for even cycles you send day + '0' + bit 7 (0x80). Bit 7 at 0 / 1 enables receiver (876) to know if its a month or a day.

Verify that you have the same UART speed in config panel for both ladders (9600 bauds should be sufficient - but what is your cycle time ?)

And I2C bus is only used by 877 + DS1307. You must disconnect 876 from the clock (RC/3+4).

As far as I know, it should work without pb.

BR
José
Tue Jan 18 2022, 13:04:52, download attachment test877_uart_echo2.ld
(no subject) (by manuel)
Hola José
esto es lo que yo quería hacer te pido un favor
temando el programa del 16f877 pre que me puedas colocar este programa tuyo en el que te mendo yo
yo lo ice pero neme deja copilar
muchas gracias
Un Saludo Manuel
Wed Jan 19 2022, 05:51:53, download attachment SIETESEGMENTOS16F876_Full_DS1307 with Day PUEBA DE HOTAS.ld
(no subject) (by José)
Manuel

I can help you to finalize but I can't do the job for you...
Both ld files for 876 and 877 must be modified together:


1) first of all, open and save your 877 ld file in ldmicr0.2 format to be able to configure I2C pins (it's in 0.1 format)

2) in 876.ld / 877.ld
- remove from 876.ld all the code concerning DS1307 and place it in 877.ld
- move your SW4 + SW5 buttons to 877.ld too

3) in 877.ld
- after displaying minutes / hours on PORTA, prepare in a variable the value to send on UART as said above, according to C6 (CTC) ; for instance if C6=0 or 2 => variable= month + '0' ; if C6=1 or 3 => variable= date + '0' + bit7
- on a same line, test if UART is ready with UART_SEND/Is ready and then send the variable on UART with UART_SEND (1 byte)

4) in 876.ld
- instead of reading DS1307 registers (done in 877), you place on a same line UART_RECV/IsData followed with UART_RECV (1 byte) in a variable
- and then test bit 7 of variable to know what it is
- decode month or day by removing bit7 and substract '0' to get the right value
- send the value on the display as done yet

To test, modify cabling diagram as said yet.

Send me the files after modification if you want a piece of advice ?

Jose
Wed Jan 19 2022, 11:38:42
(no subject) (by manuel)
HOLA José
te mando el programa del 16f 877 solo para que me lo mires
seguro que debo tener algún error por que no deja copilar
cundo tenga el 16f876 te lo pasare
UN saludo Manuel
Thu Jan 20 2022, 12:27:40, download attachment SIETESEGMENTOS16F876_Full_DS1307 with Day 01.ld
(no subject) (by José)
OK

Very well Manuel ; I have a look at it and let you know.

Beware:
remove spaces ' ' in your ld name ; it's not good at all for compilers ! (May explain your compiling pb)

José
Thu Jan 20 2022, 13:49:05
(no subject) (by José)
Manuel

I have looked at your ld file.
It should look like that -> attached file

Note that:

- I2C rather than I2C1
- C6 must be in 0->3 (not 0->9)
- You can't use RC3+4 (I2C)
- You can't use RC5+6 (UART)

So have I modified your pin assignment.

It can be compiled and built (using ldmicro325.5b).

Waiting for your 876 file...

BR
José
Thu Jan 20 2022, 15:56:23, download attachment Manuel-877-v2.ld
(no subject) (by José)
To manuel:

Here's a better version with all 4 cases for C6.
Fri Jan 21 2022, 02:06:16, download attachment Manuel-877-v2b.ld
(no subject) (by manuel)
Hola José
te envió el programa 16f876 para que Melo mires

un saludo MANUEL
Sun Jan 23 2022, 07:58:08, download attachment SIETESEGMENTOS16F876_Full_DS1307 with Day Manuel pereira.ld
(no subject) (by manuel)
(sin tema) (por manuel)
Hola José
te envió el programa 16f876 para que Melo mires

un saludo MANUEL
Ayer a las 07:58:08 descargue adjunto SIETESEGMENTOS16F876_Full_DS1307 con Day Manuel pereira.ld
Mon Jan 24 2022, 06:00:09
(no subject) (by José)
Hi Manuel

I have adapted receiving and decoding in 876 ld file and modified a bit more 877.ld

I don't know why you use ADC in 876.ld ?
I have removed all pull-ups in config panel as I think you don't need it ?
I let you manage the remainder of your programs...

Of course it needs to be tested and maybe improved !
I show you the idea to make both PICs communicate with UART.

Verify and let me know if you encounter pbs ?

José
Mon Jan 24 2022, 09:41:41, download attachment Manuel_876+877.zip
DS1307 (by Manuel Pereira)
Hola José
e probado los archivos 16f977 y 16876 en protoboard pero
ami nome an foncionado no se por que no foncionan
en las pntallas de 7 segmentos ni se encienden
el adc era para un regulador de temperatura eso ya lo e qutado
temendo los archibos para que le deas un vitazo cuado puedas
michisamas gracias portu colboracion
un salodo Manuel
Tue Jan 25 2022, 12:52:44, download attachment Manuel_876877.zip
(no subject) (by José)
OK

I'll test on my own boards.

How did you modify your electronic diagram ?
Can you post the new one ?

For the time being, try to have the first program working, on 16F877: ds1307 and 1st display should work (did they before ?)

To be continued
José
Tue Jan 25 2022, 14:49:05
(no subject) (by José)
Manuel:

I think there's a pb in your display schematic:

If you want to use common cathode displays in normal logic, you should use the attached schematic.
In yours, RA2-5 will work in reverse logic.
Wed Jan 26 2022, 03:53:42, download attachment MPX4-CC.jpg
(no subject) (by José)
Manuel:

Why do you set TRISB= 0 and then TRISB=OXFO ???

I think TRISB should be set to 0 to use PORTB as 8 outputs
and OXFO (not 0xF0 !) doesn't exist...
Wed Jan 26 2022, 04:29:28
(no subject) (by José)
To manuel:

I have achieved tests (with another target) and there are pbs between displays management, which requires fast cycle time because of multiplexing ; and I2C, which has time constraints and is very slow...

So, I think the solution is to do like that:

1st PIC (876) manages I2C clock (2 pins / RC), buttons (5 pins / RA) and leds (8 pins / RB) + UART (2 pins / RC)

2nd PIC (877) manages 2 x 4 displays with transistors (16 pins + 8 pins RA + RB + RD) + UART (2 pins / RC)

They communicate via UART.

This way, displays and I2C are completely separate => no more timing pbs.
Your schematic must be completely modified.

To do it you must first of all be able to have your displays working : remove I2C and program your PIC877 to display "0000" without flickering.

I can't do it for you because I only have 2 digit displays with common Anode ; and no time to do it...

If OK, let me know when it's done and post the ld program ?

José
Wed Jan 26 2022, 06:33:44
DS1307 (by Manuel)
Hola José

yo no tego capacida para aregler estos archivos lo veo muy complicado
lo siento por darte tanta faena te pido desculpas
si qieres me mandas un correo tuyo y ablamos de esto
entiedo que en el 876 iria relo i pulsadore y 12c
y en 877 qitqr 12c averda nolo entieno mucho

un Salado Manuel
Wed Jan 26 2022, 14:32:44
(no subject) (by José)
Hi Manuel

Don't apologize !
I try to help you, but to aim the goal you must help yourself.
It can be done with your PICs but there's a few work:

- schematic
- ladder
- tests

Do you have the material (displays, PICS, etc.) or only a simulator ?

If you're not very aware, you can test things separately:

- displays + leds + buttons (876)
- I2C + DS1307 (877)
- UART (Both)

And when it's ok you can merge to finalize.

BR
José
Thu Jan 27 2022, 03:00:22
DS1307 (by Manuel)
hola José
que buena persona eres
los micros los tengo y las pantallas también
te mando los programas para que loe mires haber si hatean bien
un saludo Manuel gracias
Fri Jan 28 2022, 14:38:08, download attachment ds1307.rar
(no subject) (by José)
Hi Manuel

I have worked for you ; hope it'll be usefull.

You'll find in the attached zip several files:

- 2 ld files for PIC876 and PIC877
- display schematic

It's not intended to be tested as is.
Before testing you must beware of several things:

1)
What is the exact model of your 7-Seg displays ?

>>> Please post the reference.

Are they really Common Cathode displays ?
If yes, you must use the attached schematic for cabling.
PIC877 Program is intended this way.

2)
The programs are designed to have the PIC876 driving DS1307 (RC3+RC4 as I2C), UART (RC6 as TX), 5 buttons (RA0 to RA4 as inputs) and 7 leds (RB0 to RB6 as outputs)

And the PIC877 driving 2 displays with 4 transitors only.
Displays and bound to PORT B and port D (as outputs) driven by 4 transistors (RA0 to RA3 as outputs).
Each transitor's ouput is bound to a pin (1-4) of the fist display and to the same pin (1-4) of the second.
UART is used to receive data sent by PIC876 (RC7 as RX).

>>> Please post a photo of your cabling.

3)
DS1307 must be set up at each first use (unless you have a battery on it) ; if not it'll display wrong values.

4)
If you modify the programs, please ONLY USE my attached programs because yours have several config pbs ; I won't correct them again.


FIRST OF ALL:
-------------

You must first test your displays : load the corresponding program in PIC877 and test it with displays and transistors connected (and nothing else).
If I haven't made mistakes, and are Common cathode ones, they should display "0000".

>>> Please post a photo of displays working


NEXT STEPS:
-----------

To be developped when displays will be OK !


BR
José
Sat Jan 29 2022, 15:11:18, download attachment Manuel-v6.zip
ds1307 (by Manuel)
Hola José
temando la foto delas conexiones
las pantallas que tengo son de ánodo común
muchas gracias portado
si las conexiones son carretas lo iré a
probar
en 16f 876 al abrirlo me dice no 12c
Un saludo Manuel
Mon Jan 31 2022, 06:44:50, download attachment 20220131_115624_opt.jpg
(no subject) (by José)
Hi Manuel

Never mind with PIC876 for the time being.
Displays must work with PIC877.

but your attached shematic is wrong ; read my explainations again and look at schematic in zip file...

José
Mon Jan 31 2022, 07:49:44
(no subject) (by Manuel)
Hola José
me e dado cuenta delas conexiones
temando foto haber si están bien

te pregunto si podía cambiar la pantallas catado común a
añado común yo tengo ánodo común
si no se puede compre de catado común
un saludo Manuel
Tue Feb 1 2022, 05:46:52, download attachment imagecompressor (1).zip
(no subject) (by José)
Dear Manuel


It's better to use common anode displays because µC doesn't have to supplie current (it receives current).
But I'll have to change the program again...
Make your choice and be sure about it !

Your schematic is much better, but for common anode displays, your transistors must be inverted (C / E pins) and bound to VCC instead of ground. They will work in reverse logic on B pin.

I'll send you the new PIC877 program soon.

BR
José
Tue Feb 1 2022, 10:16:13
(no subject) (by José)
Manuel:

Here's the new ladder for common anode displays.

Please post your modified schematic so that I can verify.

To be tested of course...
It should display "0000" because when no UART is connected
all variables remain 0

BR
José
Wed Feb 2 2022, 03:52:05
(no subject) (by José)
PS the attached file !
Wed Feb 2 2022, 03:52:42, download attachment Manuel-877-v6-CA.ld
ds1307 (by Manuel)
HOLA
José
te mando foto probado en simulador también le probé en protoboard
y me sale igual como en la foto
dime si es correcto o falta algo
un saludo Manuel
Wed Feb 2 2022, 07:34:20, download attachment 20220202_131650.jpg
(no subject) (by José)
Hi Manuel

It becomes good !
But there's just a little (last) pb:

You must replace your 4 NPN transistors with PNP ones.
Ie replace BC547 with BC557 for instance.
Connect E pins to Vcc and C pins to the displays

So that 1 display is on at a time, but it goes so fast that
when running they seem to be all four on.

Retry and post your results...
Wed Feb 2 2022, 12:55:21
(no subject) (by Manuel)
Hola José
te mando foto del cambio de transistores
en principio se enciende todos y después se apagan quedan dos
encendidos
yo creo que avía que poner un TDY en serie con el CTC
para que las pantallas se queden en encendidas
corrígeme se no es así
un saludo Manuel
Thu Feb 3 2022, 05:24:21, download attachment compressjpeg.zip
(no subject) (by José)
Hi Manuel

I just didn't notice that the CTC was working on rising edge (/) ; there's just to change it to true input (-) in its dialog box and it should be OK !

Let me know ; if OK we'll be able to work on PIC876...

BR
José
Thu Feb 3 2022, 12:41:02, download attachment Manuel-877-v6-CA.ld
(no subject) (by Manuel)
HOLA José
ES CORRETO
TE NEVIO IMSGEN PARA QUE TU LA VEAS UN SALUDO Manuel
Thu Feb 3 2022, 14:28:53, download attachment 20220203_201157_opt.jpg
(no subject) (by José)
OK

Now you can test PIC876 and connect its UART-TX to PIC877 UART-RX. Post your global schematic.

There's the same pb with the CTC ; see attached file.

If you have pbs with I2C name, rename I2C as I2C1 in all the contacts.

Buttons are deactivated for the time being.

Beware that your DS1307 is probably not configured and may return wrong values.

José
Thu Feb 3 2022, 15:09:07, download attachment Manuel-876-v6.ld
Ds1307 (by Manuel)
Hola José
teeEnvioo foto de las conexiones
Un saludo Manuel
Fri Feb 4 2022, 07:39:26, download attachment 20220204_125357-min.jpg
(no subject) (by José)
OK Manuel

At first glance it seems to be OK.

Test the programs and let us know if it displays anything ?

José
Fri Feb 4 2022, 10:09:05
(no subject) (by Manuel)
Hola José
no puedo probarlo por que no madeja compilar
me sale una ventana dice invalid name in lader
te envió foto
Fri Feb 4 2022, 12:59:34, download attachment 20220204_183423.jpg
(no subject) (by José)
That's because you use Ldmicro version 5.4.0

You can solve this by renaming all I2C contacts as I2C1 ;
or by using Ldmicro32 version 5.5b
That's the one I have developped and use:

https://github.com/joegil95/LdMicro32

Don't use version 6.0 ; it's not adapted to your little targets.
Fri Feb 4 2022, 13:29:04
(no subject) (by José)
Manuel:

Download and install Ldmicro32 ; there are some pbs with I2C in some LDmicro 5.4 versions. It may not work at all.

You must at least replace exe file and libraries.

José
Sat Feb 5 2022, 03:12:24
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):