Time to suffer!!!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Time to suffer!!!

Post by 407charles »

I been trying a I2C communication program to set and read the registers of a DS1307 time keeper IC. I'm starting with a simple program to write and set the register 07h, to enable the square wave and set it to 1Hz. Then the program uses this signal to set B5 HI which will lit the LED of the arduino nano on channel 13 (B5) to prove that setting is done. I did read the SPI and I2C Simplified communications blog and I did it in the same format, but I did not have a success with it.I have to mention that the component I2C calls for pins C4 and C3 for SDA and SCL respectively but when I check in the Chip view the SCL pin is C5 (in the arduino) so I decided to change the pin connection to C5. I would like to read all the registers to read all the available data but I have to comprehend the process of writing to the different registers to set the clock and date. However, If I'm not able to do this first step I won't be able to use this chip block. Please help!! Any help is greatly appreciated. I'm including my program and the IC datasheet. Thanks a lot for your time.
Attachments
DS1307.pdf
Datasheet
(215.27 KiB) Downloaded 343 times
nano.fcfx
Here is my program
(5.67 KiB) Downloaded 313 times

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

hello,
aa.gif
(15.12 KiB) Downloaded 2587 times
on the program below,
I read the registers and I 7 shipments over RS232

To you to adapt the program.
lecture.gif
(10.29 KiB) Downloaded 2587 times
Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

Hello Cubitus54, Thanks a lot for your reply. I don't understand the program very well, Do I need extra hardware to be able to communicate with the time keeper using RS232? I got a little confuse.

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Hello,

No, I use RS232 to view the values. One can also use a display ...
This is just one example.
Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

Hi Cubitus54, thanks a lot for your quick response. Obviously you are far better than me in this topic because I still lost, let me ask you, I've seen that you also showed me what I did wrong on my first attempt and some corrections done on it. This is how I should proceed? Or I should follow the second example? I will appreciate if you are more specific. thanks a lot again, I'm new in this communication components.Thanks a lot for your comprehension. See you soon.

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Hello Charles,


Sorry for my poor English, I'm French ... Thanks to Google translation ... :mrgreen:
Hard for me to make great explanation in English ... :?

Here's my program with a GLCD display.
You can get inspired to run yours.
rtc.gif
(51.16 KiB) Downloaded 2551 times
RTC_i2c+afficheur18.fcfx
(19.58 KiB) Downloaded 361 times
Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

Thanks a lot my friend, I would like to speak French as well but I just speak English and Spanish. I really appreciate that you share your work with me, I'm going to try studying the way your program is done to comprehend the dynamics of I2C communications. Right now I have a better idea. Thanks a lot again, see you soon.

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

I want to thank Cubitos54 for sharing his I2C program with me; so far I tried different ways to write to this chip to enable the SQW function by writing to register 7 a value of 16 to get a 1Hz. pulse at this pin, the positive transition will light the LED in pin 13. I tried several times without success. I even tried to write the value 16 to all registers as my last program (posted here). I got no idea of what do I'm doing wrong, anybody has an idea? Any help is greatly appreciated. Thanks a lot in advance. By the way, I'm using the Arduino nano.
Attachments
NanoI2C.fcfx
My program.
(6.21 KiB) Downloaded 296 times

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Hi,

Testing it.

Have you an oscilloscope?
NanoI2C.fcfx
(6.71 KiB) Downloaded 338 times
Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

Yes I do.

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Yes I do.
:?: :?: :!:

You have tried the program ?
he works ?
you have an oscilloscope ?
Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

Hello Cubitus54, I'm glad to tell you that finally I was able to interface with the DS1307. I could not achieve this withouth your help, Thank you!! I really thought that I had a defective DS1307, I did start with the clock program you share with me. I did some changes to be able to use it with a 4x20 display, it did work but i was getting locked up randomly at different times (just the display) I was able to control that by inserting a time delay in the main program. By the way I will appreciatte if you explain to me only one calculation box in the "Affichage" Macro, I would like to know what each line means (To learn more strategies). I did change the program to write to the register seven and enable the 1Hz signal. I just have to do some changes to the program you send me to make it work and finally is working as desired. It feels grate to accomplished this task, I tried so hard to lear how to effectively communicate using the I2C protocol. Thanks a lot for sharing your work and guiding me through. I'm posting my work to share with other users as you did with me.
Attachments
UnoI2C_Clock.fcfx
Cubitus54 clock program adapted for LCD diplay and Arduino Uno
(19.42 KiB) Downloaded 232 times
UnoI2C1Hz..fcfx
Using arduino uno
(6.16 KiB) Downloaded 225 times

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Exemple : Print hour min sec : 12:34:56
data in reg 0, 1, 2 -> data[0], data[1], data[2]
data[0], data[1], data[2]
sec nin hour

//data[2]=12
.tmp = data[2] AND 0xf0 //hour x10, mask xxxx0000 -> .tmp = 10
.tmp = .tmp >> 4 // shift right .tmp = 01
.CHR_tmp = ToString$ (.tmp) // .CHR_tmp ="1"
.CHR_aff = .CHR_aff + .CHR_tmp //.CHR_aff = "1"
.tmp = data[2] AND 0x0F //heure x1 mask 0000xxxx -> .tmp = 2
.CHR_tmp = ToString$ (.tmp) //.CHR_tmp ="2"
.CHR_aff = .CHR_aff + .CHR_tmp + ":" //.CHR_aff = "12:"

etc...
Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

Thanks a lot Cubitus54, I really appreciated. Do you have a One-Wire communications program? I'm trying to make a program that displays the humidity and temperature using the DHT11 sensor. I gives the data in a 40 bit format: 8 bit humidity+8 bit tenths humidity + 8 bit temperature + 8 bit tenths temperature and 8 bit check sequence. I did my first attempt but it did not work and there is no sample available. I ignore the strategy of this communication protocol. I will really apprciate your help in this one as well. Thanks a lot in advance.

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Hello,

Yes I do. I would put very soon.
This is not the OneWire protocol.
The function did not exist in Flowcode.
Flowcode V6.1.2.0(11 05 2015)

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times
Contact:

Re: Time to suffer!!!

Post by cubitus54 »

Flowcode V6.1.2.0(11 05 2015)

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Time to suffer!!!

Post by 407charles »

How you doing cubitus54, I'm glad to work with you again. I really appreciate your time and help. I study your program an it looks awesome. I tried to run it yesterday but it did not work, I'm not sure in what phase but is getting locked up in one of the loops because my display macro is at the end and it's not being run. I double check today and I had one of the delays in 40ms. instead of 40us. could this be the problem? I'm posting my program, could you take e look at it? You maybe able to find if I did a mistake or just not using the right settings. I appreciate your help in these topics because I'm never hed the chance of implementing them, and still some of them a mystery for me. I'm reading and studying more in my free time. I learned a lot by just studying the programs you shared with me, Thanks a lot!!
Attachments
Uno_one-wire.fcfx
here is my program
(11.71 KiB) Downloaded 177 times

Post Reply