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: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Hello,

That is correct, I didn't make an alarm function... I just don't see it in this kind of clock. But, it can be added!

Can you post pictures of your build-progress?

Trax
vszabi
Posts: 17
Joined: 03-10-2013, 13:08

Re: Construction of Word Clock v1

Post by vszabi »

Can you help me to accomplish this? (alarm, etc.)

http://www.qlocktwo.com/Q2Tfunktionen.php?lang=en


Of course, I take pictures, even videos can also be arranged that is where I'm going.

Moreover, while there is only small red LEDs are assembled, they are just buttons instead of the touch buttons. (Recently I ordered the missing parts)

One question! In the menu bar when the 5X3 LED indicates where you are to where you are as in C?

Szabi
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 Trax,

my exactly problem is:

I can change the day of week in the menu, but when a day is over, the day of week does not change to the next.


set day of week

Code: Select all

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 - not used
	twi_stop();	

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

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

Re: Construction of Word Clock v1

Post by trax »

Pielo, after you set the day-of-week in the menu, and when clock returns to normal mode, does the clock display correct time, date, and day of week during normal operation?

For example: When you set Tuesday in the settings, does the clock display Tuesday in normal operation? If it always displays the same day of week then there must be a problem in the display_dow function (or whatever you called it).

I can't see the problem in code :oops:

The IC DS323X advances to next day of week automatically on midnight as it says in the datasheet:
The day-of-week register increments at midnight.
Values that correspond to the day of week are user-
defined but must be sequential (i.e., if 1 equals
Sunday, then 2 equals Monday, and so on). Illogical
time and date entries result in undefined operation.
so it should work automatically.
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

hibs wrote: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
Sorry for the late reply... Great news! I am glad they liked your implementation :)
I hope I will find the time to make that temperature offset...
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

saturno wrote: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.
Well, I didn't use magnets. I actually glued the vinyl to the wood! We will see how vinyl will hold it in a few years :-)
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 can't find anything what is wrong, in the displayfunction.

Code: Select all

void display_date(void)
{
	char buff[20];

	char day_name[20];

	switch(dow)
	{
		case 1:
			sprintf(day_name,"Montag");
		break;
		case 2:
			sprintf(day_name,"Dienstag");
		break;
		case 3:
			sprintf(day_name,"Mittwoch");
		break;
		case 4:
			sprintf(day_name,"Donnerstag");
		break;
		case 5:
			sprintf(day_name,"Freitag");
		break;
		case 6:
			sprintf(day_name,"Samstag");
		break;
		case 7:
			sprintf(day_name,"Sonntag");
		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;
}
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Can you copy-paste the interrupt service routine ISR() that loads data into variable "dow"? Maybe it isn't loading it there...
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 »

Do you mean this? I hope this ist the right part.

Code: Select all

//##########################
// Interrupt: PCINT2_vect //
//##########################
// called on PCINT2_vect - pin change interrupt
ISR(PCINT2_vect, ISR_NOBLOCK) // this interrupt routine can be interrupted by any other
{
	// we will get here on every 1Hz signal transition (high->low, and low->high) since it is interrupt on change
	// and also on button/sensor B press/release!

	// if we are not paused and if this was low->high transition, do it
	if( !bv(bRTC_Pause,BAPP1) && (SQW32KHZ_PINREG & _BV(SQW32KHZ_PIN)) )
	{
		// read time from DS323X RTC IC
		twi_start(DS323X_ADDR_WR);
		twi_tx_byte(0x00); 						// address the beginning
		twi_start(DS323X_ADDR_RD); 				// now we are going to read from it
		// time
		uint8_t temp_secs = twi_rx_ack();
		uint8_t temp_mins = twi_rx_ack();
		uint8_t temp_hours = twi_rx_ack();
		// skip this one
		//uint8_t dow = twi_rx_ack(); 			// dummy read Day Of Week
		twi_rx_ack(); 			// dummy read Day Of Week
		// date
		uint8_t temp_day = twi_rx_ack();
		uint8_t temp_month = twi_rx_ack();
		uint8_t temp_year = twi_rx_nack();
		twi_stop();

		// lets read the temperature also
		twi_start(DS323X_ADDR_WR);
		twi_tx_byte(0x11);								// address the upper temperature byte
		twi_start(DS323X_ADDR_RD);
		uint8_t temp_tMSB = twi_rx_ack(); 				// read the temperature
		uint8_t temp_tLSB = twi_rx_nack(); 				// read 1/4 fraction
		twi_stop();

		// here we will check if seconds, minutes, hours,... changed, this will alert the main "while" to send display_matrix[] to MAXes. this prevents the main "while" to overwhelm the MAXes with data constantly
		if( RTC[TIME_S] != BCDTODEC(temp_secs))
		{
			bs(bRTC_SecChg,BAPP1); // set it here, and it will be cleared withing the function that actually sends the display_matrix[] to MAXes - it will probably be the display_seconds() function
		}
		if( RTC[TIME_M] != BCDTODEC(temp_mins))
		{
			bs(bRTC_MinChg,BAPP1); // set it here, and it will be cleared withing the function that actually sends the display_matrix[] to MAXes - it will probably be the display_time() function
		}
		if( (RTC[TEMP_LSB] != BCDTODEC(temp_tLSB)) || (RTC[TEMP_MSB] != BCDTODEC(temp_tMSB)) )
		{
			bs(bRTC_TempChg,BAPP1);
		}

		// convert from BCD to normal
		// time
		RTC[TIME_S] = BCDTODEC(temp_secs);
		RTC[TIME_M] = BCDTODEC(temp_mins);
		RTC[TIME_H] = BCDTODEC(temp_hours);		// NOTE: it is always 24hr format inside the DS323X RTC IC, so we can do this without additional checks
		// date
		RTC[DATE_D] = BCDTODEC(temp_day);
		RTC[DATE_M] = BCDTODEC((temp_month & 0b01111111)); // clear the possible Century bit and convert
		RTC[DATE_Y] = BCDTODEC(temp_year);

		// temperature also
		RTC[TEMP_LSB] = temp_tLSB;
		RTC[TEMP_MSB] = temp_tMSB;

		disp_duration_timer++; 								// we need this counter for main()
	}

	// Note: there is no button debounce code required, since the buttons are actually the touch-sensors and they don't bounce

	// check to see if sensor B is active-high
	if( (BTNB_PINREG & _BV(BTNB_PIN)) )
	{
		// see if it wasn't pressed at all
		if( !(prev_btn & 0b00000010) )
		{
			prev_btn |= 0b00000010; 						// remember it was pressed
			btn_hold_timer[1] = BTN_HOLD_TMR; 				// load this counter for press/hold decision

			bc(bSleepMode,BAPP1);							// wakeup on any key touch
		}
	}
	// button not pressed at this ISR event
	else
	{
		prev_btn &= ~0b00000010;
	}

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

Re: Construction of Word Clock v1

Post by trax »

Yes, there is your problem :-)

Replace this line:

Code: Select all

//uint8_t dow = twi_rx_ack();          // dummy read Day Of Week
with this one:

Code: Select all

dow = twi_rx_ack();          // REAL read Day Of Week
After that, find where the variable "dow" in wt.c is declared. It should be something like this:

Code: Select all

volatile uint8_t dow;
around the beginning of file. Copy it here so I can check it out.
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Oh, one more thing. Remove this line also:

Code: Select all

twi_rx_ack();          // dummy read Day Of Week
sorry :-)
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 »

Yes, this was the problem :D :D

BUT, when I change this line
dow = twi_rx_ack(); // REAL read Day Of Week
the day-of-week-setting-menu does'nt work correctly. The left button reacts not always and the sequence from the days is random.

When i does'nt set this line is the menu normal and the day does'nt change ist on 0'clock.
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Did you also delete this line:

Code: Select all

    twi_rx_ack();          // dummy read Day Of Week
so that section of code looks like this:

Code: Select all

// read time from DS323X RTC IC
      twi_start(DS323X_ADDR_WR);
      twi_tx_byte(0x00);                   // address the beginning
      twi_start(DS323X_ADDR_RD);             // now we are going to read from it
      // time
      uint8_t temp_secs = twi_rx_ack();
      uint8_t temp_mins = twi_rx_ack();
      uint8_t temp_hours = twi_rx_ack();
      // skip this one
      dow = twi_rx_ack();          // dummy read Day Of Week
      // date
      uint8_t temp_day = twi_rx_ack();
      uint8_t temp_month = twi_rx_ack();
      uint8_t temp_year = twi_rx_nack();
      twi_stop();
---- now there is one more thing to change: -----
Change menu_set_dow() function to look like this:

Code: Select all

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(bRTC_Pause,BAPP1);								// pause reading clock data from I2C!

   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 - not used
   twi_stop();   

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

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

   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 »

:ohno: :lol: :ohno: :lol: :ohno: :lol: :ohno: :lol: :ohno:

You are so beautiful!!!!!!! :wink:

Thank you for the verry good support!!!!

I will post photos or a video in the next days.
User avatar
trax
Administrator sajta
Administrator sajta
Posts: 3508
Joined: 08-01-2005, 18:04
Location: 75k, BA
Contact:

Re: Construction of Word Clock v1

Post by trax »

Haha, I am glad it works! :-)
Send photos of finished clock, and video :-)
vszabi
Posts: 17
Joined: 03-10-2013, 13:08

Re: Construction of Word Clock v1

Post by vszabi »

trax wrote:Hello,

That is correct, I didn't make an alarm function... I just don't see it in this kind of clock. But, it can be added!

Can you post pictures of your build-progress?

Trax
Hello!

Here's the promised video! I'm here .. Still needs to improve the accent on the menu that is not only a point. Points at the corners to light up one by one, each one Pernet. Rako picture of the tree will work well, but suddenly I do not know where it could spend the pictures.

I decided to prepare it certainly is small, has it started to design the PCB.

Only the alarm function can anyone help me ... :oops:

http://www.youtube.com/watch?v=-iI-afcArtw
hibs
Posts: 8
Joined: 29-01-2013, 20:34

Re: Construction of Word Clock v1

Post by hibs »

trax wrote:
hibs wrote: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
Sorry for the late reply... Great news! I am glad they liked your implementation :)
I hope I will find the time to make that temperature offset...
Any help would be greatly appreciated. I know you had previously mentioned implemently this feature within an additional menu. Maybe adding this capability within the source code itself so that the user simply changes one (temperature offset) number in the code before it is compiled. Would this be an easier option for you?

many thanks

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

Re: Construction of Word Clock v1

Post by trax »

Hibs, if you want an offset the displayed temperature use this function instead of the original:

Code: Select all

// display the temperature
void display_temp(void)
{
	// if we have something new to display / if the temperature has changed inside the RTC chip
	if( !bv(bRTC_TempChg,BAPP1) )
	{
		return; // we don't, so get outa here
	}

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

	/*
		// code from my "Warm Tube v2" project
		temp_MSB = temp_MSB & 0b01111111; // make it positive
		uint8_t fract = (temp_LSB >> 6);
		fract = fract * 25;
		display_digits[0] = (temp_MSB / 10);			// [D]D,D_
		display_digits[1] = (temp_MSB % 10);			// D[D],D_
		display_digits[2] = (fract / 10);				// DD,[D]_
		display_digits[3] = (fract % 10);				// DD,D[D]
	*/

	char temperature[10];
	sprintf(temperature,"%d^", (int8_t)RTC[TEMP_MSB] -2 ); // ^ - is a degree symbol :) HIBS INFO: Here you put offset you want, currently it is -2

	// finally send the text to display
	text_to_display(temperature,1,0);

	bc(bRTC_TempChg,BAPP1); // clear and wait for another second-change
	// we need to falsify other changes, so that the next function in line executes at least once
	bs(bRTC_MinChg,BAPP1);
	bs(bRTC_SecChg,BAPP1);
	// next one...

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

Re: Construction of Word Clock v1

Post by trax »

vszabi wrote:Only the alarm function can anyone help me ... :oops:
http://www.youtube.com/watch?v=-iI-afcArtw
Hello,
I can see that one LED is not working: row 7 - column 3 8)
About the alarm function, it can be done. Do you know how to program in C language? There is an alarm function in my previous clock project here: http://www.elektronika.ba/800/warm-tube ... xie-clock/ maybe you can copy it from there and adjust in code?
vszabi
Posts: 17
Joined: 03-10-2013, 13:08

Re: Construction of Word Clock v1

Post by vszabi »

trax wrote:
vszabi wrote:Only the alarm function can anyone help me ... :oops:
http://www.youtube.com/watch?v=-iI-afcArtw
Hello,
I can see that one LED is not working: row 7 - column 3 8)
About the alarm function, it can be done. Do you know how to program in C language? There is an alarm function in my previous clock project here: http://www.elektronika.ba/800/warm-tube ... xie-clock/ maybe you can copy it from there and adjust in code?
hello

Sorry for the typing errors, it is the poor English tudásomért. After I dropped my message, I have seen just a typing error.

Yeah, I noticed that one LED is not working, but I did not bother to deal with it. Anyway white SMD LEDs to be put together when you arrive on e-bay from :D

Unfortunately, I can not program in C language, which is why I asked for help. Thanks for the tip, but if some one could also apply to parts that alarm clock, you can not get along with those tubes hour project. :oops:

Can you help?
The menu should poke it to build up the alarm function ... I take it?

I'll try to link to photos you yesterday failed.

https://docs.google.com/file/d/0B-5kNfZ ... sp=sharing
https://docs.google.com/file/d/0B-5kNfZ ... sp=sharing
https://docs.google.com/file/d/0B-5kNfZ ... sp=sharing
https://docs.google.com/file/d/0B-5kNfZ ... sp=sharing
https://docs.google.com/file/d/0B-5kNfZ ... sp=sharing
https://docs.google.com/file/d/0B-5kNfZ ... sp=sharing

Of course there is still room to work on the tree. :)
Post Reply