Construction of Word Clock v1

Rasprava o AVR mikrokontrolerima, AVR projekti i drugo vezano za AVR...

Moderators: pedja089, stojke369, trax, InTheStillOfTheNight

Post Reply
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3509
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Haha, what have you done? :-)
attach wc2.c file here so I can check.
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3509
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

It actually seams that you have some crazy character in your code. Check this out: http://stackoverflow.com/questions/7663 ... rogram-why
Pielo
Pocetnik na forumu
Pocetnik na forumu
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Post by Pielo »

:P :P It's going!!!! THANKS (I don't have "copy&past")

Now I will change the dot's-blinking-menu in day-of-week-setting-menu. The corner LED's show by my clock the minutes. I try to programing the menu but it's very difficult for me. This is the last change on my clock.
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3509
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

To set Day Of Week in Menu, you must change the menu_set_rtc() function like this:

Code: Select all

// setting the time and date
// NOTE: RTC is being set in 24hr format as well as date in DD.MM.YYYY
void menu_set_rtc()
{
	uint8_t setup_part = 0; 							// first we are going to setup the HH

	btn_inactivity_timer = BTN_INACTIVITY_TMR;			// if the user ignores the clock

	bs(bRTC_Pause,BAPP1);								// pause reading clock data from I2C!

	display_clear(0);
	bs(bDispChg,BAPP1);

	while(setup_part < 6)								// we are setting 6 parts in total, from 0..5 (HH, MM, dd, mm, yyyy, DOW)
	{
		if(btn_inactivity_timer==0) break;				// get out at the exit point of this function

		char buff[25];									// text buffer

		// display current setting
		switch(setup_part)
		{
			// hh
			case 0:
				sprintf(buff,"%02u:",RTC[TIME_H]);		// prepare text for display
			break;
			// mm
			case 1:
				sprintf(buff,":%02u",RTC[TIME_M]);		// prepare text for display
			break;
			// DD.
			case 2:
				sprintf(buff,"%02u.",RTC[DATE_D]);		// prepare text for display
			break;
			// MM
			case 3:
				sprintf(buff,".%02u",RTC[DATE_M]);		// prepare text for display
			break;
			// (20)YY
			case 4:
				sprintf(buff,".%02u'",RTC[DATE_Y]);		// prepare text for display
			break;
			// DOW
			case 5:
				// Print SHORT day-names here! 3 letters.
				switch(dow)
				{
				  case 1:
					 sprintf(buff,"Sun");
				  break;
				  case 2:
					 sprintf(buff,"Mon");
				  break;
				  case 3:
					 sprintf(buff,"Tue");
				  break;
				  case 4:
					 sprintf(buff,"Wed");
				  break;
				  case 5:
					 sprintf(buff,"Thu");
				  break;
				  case 6:
					 sprintf(buff,"Fri");
				  break;
				  case 7:
					 sprintf(buff,"Sat");
				  break;
				}
			break;
		}

		// we need a mechanism not to flood up the display very fast because it flickers for some reason
		if( bv(bDispChg,BAPP1) )
		{
			text_to_display(buff,1,0);					// send the text to display - it will overwrite previous text
			display_progressbar(setup_part+1,6);		// also show the progressbar, it could have advanced
			bc(bDispChg,BAPP1); 						// done with updating
		}

		// BTN-A? held or pressed
		if( (btn_press|btn_hold) & 0b00000001)
		{
			bs(bDispChg,BAPP1); 							// mark that display will probably change

			uint16_t delay_value = BTN_REPEAT_RATE;			// speed of auto-increment when holding a button
			switch(setup_part)
			{
				// the HH:mm dd.mm.yyyy
				case 0:
					RTC[TIME_H] = (RTC[TIME_H]+1) % 24;		// +1
				break;
				// the hh:MM dd.mm.yyyy
				case 1:
					RTC[TIME_M] = (RTC[TIME_M]+1) % 60;		// +1
				break;
				// the hh:mm DD.mm.yyyy
				case 2:
					if(++RTC[DATE_D] > 31) RTC[DATE_D] = 1;	// +1 with check
				break;
				// the hh:mm dd.MM.yyyy
				case 3:
					if(++RTC[DATE_M] > 12) RTC[DATE_M] = 1;	// +1 with check
				break;
				// the hh:mm dd.mm.yYYY
				case 4:
					RTC[DATE_Y] = RTC[DATE_Y]+1;			// +1 .. might be boring to wait for overflow at year 2099 when setting :)
					if(RTC[DATE_Y]>99) RTC[DATE_Y]=0;		// because DS323X RTC IC can store only 00-99
					delay_value = BTN_REPEAT_RATE/2;		// so this will go twice as fast!
				break;
				// set dow
				case 5:
					dow++;
					if( dow > 7 ) dow=1;
				break;
			}

			if(btn_hold & 0b00000001)						// if the user is holding it, increment hour by 1s
			{
				delay_ms_(delay_value);						// slow down but not too much
			}

			btn_press &= ~0b00000001; 						// button handled
			if( !(BTNA_PINREG & _BV(BTNA_PIN)) ) btn_hold &= ~0b00000001; // if it is held no more, we can handle it

			btn_inactivity_timer = BTN_INACTIVITY_TMR; 		// reload
		}

		// BTN-B?
		if(btn_press & 0b00000010)
		{
			bs(bDispChg,BAPP1); 							// mark that display will probably change

			setup_part++;

			btn_press &= ~0b00000010; 						// button handled
			btn_hold &= ~0b00000010;						// also handle the hold
			btn_inactivity_timer = BTN_INACTIVITY_TMR; 		// reload to stay in programming mode
		}

	} // while(setup_part < *)

	// now we need to send settings to DS323X RTC IC!
	twi_start(DS323X_ADDR_WR);
	twi_tx_byte(0x00); // address seconds
	twi_tx_byte( 0 ); // seconds=0
	twi_tx_byte( DECTOBCD(RTC[TIME_M]) ); // minutes
	twi_tx_byte( DECTOBCD(RTC[TIME_H]) & 0b00111111 ); // hours, but clear upper two bits
	twi_tx_byte( dow ); // day of week - now used!
	twi_tx_byte( DECTOBCD(RTC[DATE_D]) ); // day
	twi_tx_byte( DECTOBCD(RTC[DATE_M]) & 0b01111111 ); // month, but clear the century bit
	twi_tx_byte( DECTOBCD(RTC[DATE_Y]) ); // year 00-99
	twi_stop();

	text_scroll("&&&&Ok",100,1);
	display_clear(0);

	bc(bRTC_Pause,BAPP1);								// continue reading clock data from I2C!

	btn_inactivity_timer = BTN_INACTIVITY_TMR; 				// reload to stay in programming mode if timeout happened above

	return;
}
Pielo
Pocetnik na forumu
Pocetnik na forumu
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Post by Pielo »

Sorry I expressed myself not correctly. :oops:

I will instead of the "corner-dot's-blinking-menu" (menu #4) the "day-of-week-menu". I don't use the "corner-dot's-blinking-menu". :roll: :wink:
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3509
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Or you can just use the function I provided in previous post and you don't need to do anything else. :D
Pielo
Pocetnik na forumu
Pocetnik na forumu
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Post by Pielo »

I changed the code so that it's in a own menu. I can go in to the menu, but i have now the problem that the buttons not save the settings. Who is my error?

Code: Select all

// setting day of week
void menu_set_dow(void)
{
	uint8_t dow = 0; 							

	btn_inactivity_timer = BTN_INACTIVITY_TMR;			// if the user ignores the clock

	bs(bRTC_Pause,BAPP1);								// pause reading clock data from I2C!

	display_clear(0);
	bs(bDispChg,BAPP1);

	while(dow < 7)								// we are setting 7 parts in total, from 0..6 (Son, Mon, Die, Mit, Don, Fre, Sam)
	{

		if(btn_inactivity_timer==0) break;				// get out at the exit point of this function

		char buff[10];									// text buffer

		// display current setting

				switch(dow)
				{
					case 0:
						sprintf(buff,"Son");
					break;
					case 1:
						sprintf(buff,"Mon");
					break;
					case 2:
						sprintf(buff,"Die");
					break;
					case 3:
						sprintf(buff,"Mit");
					break;
					case 4:
						sprintf(buff,"Don");
					break;
					case 5:
						sprintf(buff,"Fre");
					break;
					case 6:
						sprintf(buff,"Sam");
					break;	
		}

		// we need a mechanism not to flood up the display very fast because it flickers for some reason
		if( bv(bDispChg,BAPP1) )
		{
			text_to_display(buff,1,0);					// send the text to display - it will overwrite previous text
			display_progressbar(dow+1,6);		// also show the progressbar, it could have advanced
			bc(bDispChg,BAPP1); 						// done with updating
		}

		// BTN-A? held or pressed
		if( (btn_press|btn_hold) & 0b00000001)
		{
			bs(bDispChg,BAPP1); 							// mark that display will probably change

			uint16_t delay_value = BTN_REPEAT_RATE;			// speed of auto-increment when holding a button
			switch(dow)
			{
				case 1:
					dow++;
					if(dow > 7) dow=1;
				break;
			}

			if(btn_hold & 0b00000001)						// if the user is holding it, increment hour by 1s
			{
				delay_ms_(delay_value);						// slow down but not too much
			}

			btn_press &= ~0b00000001; 						// button handled
			if( !(BTNA_PINREG & _BV(BTNA_PIN)) ) btn_hold &= ~0b00000001; // if it is held no more, we can handle it

			btn_inactivity_timer = BTN_INACTIVITY_TMR; 		// reload
		}

		// BTN-B?
		if(btn_press & 0b00000010)
		{
			bs(bDispChg,BAPP1); 							// mark that display will probably change

			dow++;

			btn_press &= ~0b00000010; 						// button handled
			btn_hold &= ~0b00000010;						// also handle the hold
			btn_inactivity_timer = BTN_INACTIVITY_TMR; 		// reload to stay in programming mode
		}

	} // while(setup_part < *)

	// now we need to send settings to DS323X RTC IC!
	twi_start(DS323X_ADDR_WR);
	twi_tx_byte(dow); 	// day of week - now used
	twi_stop();

	text_scroll("&&&&Ok",100,1);
	display_clear(0);

	bc(bRTC_Pause,BAPP1);								// continue reading clock data from I2C!

	btn_inactivity_timer = BTN_INACTIVITY_TMR;

	return;
}
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3509
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

It is all wrong :shock:

Code: Select all

while(dow < 7)								// we are setting 7 parts in total, from 0..6 (Son, Mon, Die, Mit, Don, Fre, Sam)
	{
is bad. You can't say while(dow < 7) because "dow" variable is something you are setting. Take a look at my function and see what I use here (setup_part variable).

Code: Select all

	// now we need to send settings to DS323X RTC IC!
	twi_start(DS323X_ADDR_WR);
	twi_tx_byte(dow); 	// day of week - now used
	twi_stop();
here you are writing "dow" as an address to the DS3231 and not saving anything. Try this instead:

Code: Select all

	// now we need to send settings to DS323X RTC IC!
	twi_start(DS323X_ADDR_WR);
	twi_tx_byte(0x03); // address DOW register
	twi_tx_byte(dow); 	// day of week - now used
	twi_stop();
Or please, use my function for menu_set_rtc() that I gave you previously. :D
saturno
Posts: 3
Joined: 08-02-2013, 14:01

Re: Construction of Word Clock v1

Post by saturno »

Hello Everyone,

I'm in the process of trying to gather all the bits to make one of these awesome Word Clocks.
Meanwhile, I downloaded the code and did not understand the touch operation completely.
Do the capacitive snesors (AT42QT1011) use any specific library?
My question is because it seems that they don't, but my thought was that they would use a library.

Can anyone help me on this?

Thanks
hibs
Posts: 8
Joined: 29-01-2013, 20:34

Re: Construction of Word Clock v1

Post by hibs »

Hi

No, the capacitive touch sensors don't require any library. If you look at the datasheet they simply output a logic high or low dependant on whether your hand is near the sensor or not. Infact, if you want you can simply replace the capacitive touch sensor with a momentary pushbutton switch and a resistor (wired appropriately to +5V and ground) which will also provide the same logic high or low signals when the switch is pressed/not pressed.

Hibs
saturno
Posts: 3
Joined: 08-02-2013, 14:01

Re: Construction of Word Clock v1

Post by saturno »

Hello Hibs,

Thank you very much for your input.
I see that for basic operation (e.g.: detect on/off state) they do not need a library.
But, for example to adjust the sensing distance, to adjust them to detect the touch through the glass, vinyl, wood or whatever, I thought this was done through a library.

After reading the datasheet, it became clear that the sensitiveness of this sensors is achieved making the sensing plate/area bigger or smaller.

Thank you once more.
Alen+
Posts: 2
Joined: 07-06-2013, 17:12

Re: Construction of Word Clock v1

Post by Alen+ »

trax, imam problem! pošto sam se okušao u izradi tvoga sata nespreman, nisam razmišljao o programiranju ATmege328P te sam zapao u probleme. Trebala bi mi pomoć kako je programirati, jer kad se stavi u univerzalni programator i pokuša ubaciti program preko njega, pokazuje error. Ni sam ne znam čime je taj problem izazvan! Iako da ti budem iskren nisam sam programirao, već sam to odnio liku da mi napravi, ni on ne zna šta bi napravio. Može li pomoć? Hvala. :?
maliiva
Posts: 2
Joined: 08-06-2013, 20:23

Re: Construction of Word Clock v1

Post by maliiva »

Davno nisam video ovako dobar projekat, svaka cast!!! Od ponedeljka pocinjem sa radom :)))
maliiva
Posts: 2
Joined: 08-06-2013, 20:23

Re: Construction of Word Clock v1

Post by maliiva »

Cao Trax!!
Ja sam potpuno odusevljen ovim projektom sata sa recima!!!

Voleo bih i sam da izradim ovakav jedan samo imam malih poteskoca da nadjem RTC i onaj Tach sensor ali cim ih nadjem pocinjem sa izradom. Imam jedno pitanje u startu, cime bi mi bilo najpametnije da programiram Atmel, jel to programirano nekim ISP i pomocu AVR studija?? nisam bas nesto radio u njemu pa me interesuje da li je problem da zatrazim pomoc ako negde zapnem oko programiranja a i same izrade i povezivanja elektronike? da li mozda moze za programiranje da se koristi EASYAVR5 koji imam na poslu?

U napred hvala!
Nadam se da cu i ja imati ovaj fantastican sat :)

Pozdrav!!!
Alen+
Posts: 2
Joined: 07-06-2013, 17:12

Re: Construction of Word Clock v1

Post by Alen+ »

maliiva

RTC možeš nabaviti na e-bay-u, touch senzor također.
ATmega168P se može programirati s običnim programatorom za koji se shema može pronaći u bug-u i programom PonyProg. Ja sam napravio sat, ali na početku nisam razmišljao o tome te sam zapeo s programiranjem i obratio se kolegi. On je, koliko znam, program sredio u avr studiu te ga ubacio u ATmegu168P putem takvog programatora složenog na univerzalnoj pločici.
Ako zapneš slobodno se obrati i meni, pošto vidim da trax i nije baš često ovdje.
hibs
Posts: 8
Joined: 29-01-2013, 20:34

Re: Construction of Word Clock v1

Post by hibs »

Hi Trax

I took my version of your Word Clock to a 'Maker Faire' here in the U.K. that encourages people to build things for themselves. Your clock got the most attention on my stand and people absolutely loved it and wanted one. There loved the fact that you also had 5x7 character fonts as well as individual letters, and also the scrolling date impressed people too. Obviously I have passed onto any interested people your website address.

I still have the problem where my displayed temperature is 2 degrees higher than it actually is in reality. Do you think it's possible to help me adjust the source code such that the clock displays a temperature that is 2 degrees lower than the DS3232 is reporting?

many thanks

Hibs
saturno
Posts: 3
Joined: 08-02-2013, 14:01

Re: Construction of Word Clock v1

Post by saturno »

Hello Trax,

Based on your idea, I'm working on a similar project.
Can you please tel how did you put together/attached the clock face (glass + vinil) to the MDF?

I am thinking about to use some kind of magnets, but I'm not sure if it is a good idea to glue something (metal or magnet) to the back side of the vinil...

It would be very nice to hear your experience and/or if possible some pictures.
Thank you.
Pielo
Pocetnik na forumu
Pocetnik na forumu
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Post by Pielo »

Hello,

i again...

The clock is complete and works very great, except for a little thing :oops:

The Day of week doesn't change.

This is the function of this part

Code: Select all

// set day of week
void menu_set_dow(void)
{
	uint8_t setup_part = 0; 							// first we are going to setup the HH

	display_clear(0);

	btn_inactivity_timer = BTN_INACTIVITY_TMR;			// if the user ignores the clock

	bs(bDispChg,BAPP1);

	while(setup_part < 1)								// we are setting 1 part in total, on/off value actually
	{
		if(btn_inactivity_timer==0) break;				// get out at the exit point of this function

		char buff [25];

		//display current setting
		switch(setup_part)
		{
		//dow
		case 0:
			switch(dow)
			{
			case 1:
				sprintf(buff,"So");
			break;
			case 2:
				sprintf(buff,"Mo");
			break;
			case 3:
				sprintf(buff,"Di");
			break;
			case 4:
				sprintf(buff,"Mi");
			break;
			case 5:
				sprintf(buff,"Do");
			break;
			case 6:
				sprintf(buff,"Fr");
			break;
			case 7:
				sprintf(buff,"Sa");
			break;
			}
		break;
	}

		if( bv(bDispChg,BAPP1) )
		{
			text_to_display(buff,1,0);
			display_progressbar(dow+1,6);
			bc(bDispChg,BAPP1);
		}


		// BTN-A? held or pressed
		if( (btn_press|btn_hold) & 0b00000001)
		{
			bs(bDispChg,BAPP1);

			uint16_t delay_value = BTN_REPEAT_RATE;
			switch(setup_part)
			{
				//set dow
				case 0:
					dow++;
					if( dow > 7 ) dow=1;
				break;
			}

			if(btn_hold & 0b00000001)
			{
				delay_ms_(delay_value);
			}

			btn_press &= ~0b00000001; 
			if( !(BTNA_PINREG & _BV(BTNA_PIN)) ) btn_hold &= ~0b00000001;

			btn_inactivity_timer = BTN_INACTIVITY_TMR; 		// reload
		}

		// BTN-B?
		if(btn_press & 0b00000010)
		{
			bs(bDispChg,BAPP1);

			setup_part++;

			btn_press &= ~0b00000010; 						// button handled
			btn_hold &= ~0b00000010;						// also handle the hold
			btn_inactivity_timer = BTN_INACTIVITY_TMR; 		// reload to stay in programming mode
		}

	} // while(setup_part < *)

	twi_start(DS323X_ADDR_WR);
	twi_tx_byte(0x03); // address seconds

	twi_tx_byte( dow ); // day of week - used

	twi_stop();	


	text_scroll("    Ok",100,1);
	display_clear(0);

	return;
}

//##############################
// Displaying stuff functions //
//##############################
// display date, in scrolling fashion
void display_date(void)
{
	char buff[20];

	char day_name[20];

	{
	switch(dow)
	{
		case 1:
			sprintf(day_name,"Sonntag");
		break;
		case 2:
			sprintf(day_name,"Montag");
		break;
		case 3:
			sprintf(day_name,"Dienstag");
		break;
		case 4:
			sprintf(day_name,"Mittwoch");
		break;
		case 5:
			sprintf(day_name,"Donnerstag");
		break;
		case 6:
			sprintf(day_name,"Freitag");
		break;
		case 7:
			sprintf(day_name,"Samstag");
		break;
	}
	}
	sprintf(buff,"    %02u/%02u/%04u %s",RTC[DATE_D],RTC[DATE_M],(2000+RTC[DATE_Y]),day_name);




	// clear all but dots in the corners
	display_clear(0);

	// scroll this stuff
	text_scroll(buff,100,1);




	return;
}

Can you say me, what can be wrong?

Thanks
Pielo
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3509
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Where exactly do you have a problem? In settings menu, or when clock works and displays time/day of week.

Can you record a video of your bug, so I can see what is happening?
vszabi
Posts: 17
Joined: 03-10-2013, 13:08

Construction of Word Clock v1

Post by vszabi »

Greetings to all!
I also had built this great clock in Hungarian. Is not yet complete, but works great with electronics.
I saw the Beigert & Funk qlocktwo touch which is an alarm clock function and also other manifestations. (alarm, snooze, nightlight, night touch)
My question, request that you could not help to realize these functions? :oops: Unfortunately we could not go to the C language, I do not know how to get to it, to revive and expand the menu functions.
I would really appreciate every helping hand!

thanks
Szabi
Post Reply