Construction of Word Clock v1

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

Moderators: stojke369, pedja089, trax, InTheStillOfTheNight

Construction of Word Clock v1

Postby Pielo » 16-01-2013, 08:47

I do not want to spam the comments on the projectpage. http://www.elektronika.ba/841/word-clock/

i have the hardware finish and have made the first test. Your programm ist on the ATMega328. All LED's are shine sometimes white, somtimes red (reversed polarity).

I have measure:

1)
The touchsensor is not reacted on the matrix, but an H-level is at the microcontroller (pin 6 [Sens2_OUT] or Pin23 [Sens1_OUT]) when i touch the sensor.

2)
On Pin2 [32kHz] of the microcontroller or Pin5 [32kHz] of the DS3232 are not 32kHz just 1/2Hz

3)
From pin 14 comes a pulse sequence (bit sequence for the MAX7219)

4)
On the Pin 34 [DOUT] is a h-level, without a puls sequence

5)
As fusebites i have set H = D9 and L= 62 by AVR-Studio 4

What can be the Problem.

Thanks
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1


Re: Problem with wordclock

Postby trax » 16-01-2013, 10:19

Hello Pielo,

The fuse for ATmega328P that must remain set/enabled is: "SPI Enabled" and nothing else. I have a different programmer (AVRFlash from http://www.mikroe.com).
For the oscillator you must set: XTAL 8 - 16 MHz
Device freq. is 8 MHz

About the red color of your LEDs - I don't understand how that can happen. What LEDs did you use??? The LEDs are controlled with MAX7219 IC and I neved had any problems with reverse polarity. Maybe you soldered LEDs the wrong way?

Do not worry about the 32kHz pin of DS3231 - we can't control it so forget about it.

For the start, do not connect touch sensors to the microcontroller, first you should see some LEDs light up when you power it up. There is a startup sequence with scrolling text and you should see some LEDs blink for few seconds and then only some of them will remain ON.

About the corner dots - please do not connect any corner dots at this time, we will do this at the very end - when everything else is working.

********
UPDATE 2015-04-01
Please read this post for LED matrix schematics and new part of the code to run it: viewtopic.php?f=13&t=13916&p=149788#p149788
********

Regards
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Problem with wordclock

Postby Pielo » 16-01-2013, 11:19

Thanx for your answer

LED's are "Osram LUW T6SG". They have a red led antiparallel to the white led. The polarity is right, because sometime is 1 part of matrix white and sometimes is the same part red

Ich have very mutch oscillator setting on AVR-Studio. I have made a picture from Fuse Calculator is this the right setting, or a other?

Image

Uploaded with ImageShack.us

the dot corners have i disconect.
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Problem with wordclock

Postby trax » 16-01-2013, 11:27

Hello,

Everything looks OK. Just decrease Boot Size to 1024 words - just in case :-)

I used LEDs from China (http://www.ebay.com) and they are very very cheap. I don't know about the reverse red led in your white led, I don't know if that can cause some problems with MAX7219 - I never tested it with that kind of LEDs!

Also, make sure you connected MAX7219 ICs correctly to the ATmega328P before you power it up!

Just a note: To connect LED matrix to MAX7219 chip, you must connect LED ANODES to "SEG" outputs, and LED CATHODES to "DIG" outputs, like in this example: http://bit.ly/Y8YT2o
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Problem with wordclock

Postby Pielo » 16-01-2013, 11:54

is there a possibility to test the MAX7219 single. in my opinion is that correct connect
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Problem with wordclock

Postby trax » 16-01-2013, 11:59

You can just connect 1 MAX on the data-bus and see how it works. No need to change the code.
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Problem with wordclock

Postby Pielo » 16-01-2013, 12:59

is it right to the Pin24 [DOUT] from the first MAX7219 an h-signal is present and no an impulse
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Problem with wordclock

Postby trax » 16-01-2013, 14:13

DOUT pin will transfer data from DIN pin after 16 bytes (if I remember correctly), so it will be HIGH most of the time when data is not being transferred. You must look at this line with an oscilloscope if you want to examine it.
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Problem with wordclock

Postby Pielo » 17-01-2013, 14:47

Thanks for your infos. i have found the problem, the red led was it. I must short the red led's with overload and it was.

Now I must change the "7x5 Font.h" so that correct letters are visible, right? Than I must change the "wc.c" so that the words in the menu are in german, right? At last I must change the "lang_ba.h" so that reasonable times are visible.
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Problem with wordclock

Postby trax » 17-01-2013, 15:31

Great that you managed to find and fix the problem!

Now I must change the "7x5 Font.h" so that correct letters are visible, right? Than I must change the "wc.c" so that the words in the menu are in german, right? At last I must change the "lang_ba.h" so that reasonable times are visible.

That will be the last step for you.
You will add "lang_de.h" file for your own front plate with german letters. But, you will do that AFTER you design your front board with all "times" that will be displayed on the clock. Have you done that already?

Now you have a much more complicated job, you must "re-map" indices (indexes) of rows and columns in the source-code and this is done manually by trial and error method. But first, did you solder your LED matrices to MAX ICs? Do you have some pictures or schematics so I could help?

edit: you will not need to change 7x5 font.h file!!!
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Re: Problem with wordclock


Re: Construction of Word Clock v1

Postby Pielo » 18-01-2013, 08:35

I have make two schenmatics. one from full-matrix and one from matrix with coner led's.

where must i change the sorce code?

http://imageshack.us/a/img94/9161/max7219full.png

http://imageshack.us/a/img685/310/max7219cornerleds.png
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Problem with wordclock

Postby trax » 18-01-2013, 10:28

The schematics are kind of correct - take look at my schematics that I attached here. That's how you need to connect it.

When you connect everything up you will need to change the body of function "max72xx_send_matrix()". There you will see this part of the code:

For MAX 1 and MAX 4 it is the same:
Code: Select all
         // MAX1 and MAX4 are soldered in the same fashion
         if(max_id==0 || max_id==3)
         {
            uint8_t old_byte = display_matrix[max_id][j];

            // now rearrange the bits into a new byte
            uint8_t new_byte = 0;
            new_byte |= (old_byte & 0b00000001);
            new_byte |= (old_byte & 0b00000010) << 4;
            new_byte |= (old_byte & 0b00000100) >> 1;
            new_byte |= (old_byte & 0b00001000) << 3;
            new_byte |= (old_byte & 0b00010000) >> 1;
            new_byte |= (old_byte & 0b00100000) << 2;
            new_byte |= (old_byte & 0b01000000) >> 4;
            new_byte |= (old_byte & 0b10000000) >> 3;

            // now rearrange the indexes
            uint8_t new_index;
            switch (j)
            {
               case 0: new_index=0; break;
               case 1: new_index=4; break;
               case 2: new_index=6; break;
               case 3: new_index=2; break;
               case 4: new_index=3; break;
               case 5: new_index=7; break;
               case 6: new_index=5; break;
               case 7: new_index=1; break;
            }

            display_matrix_new[max_id][new_index] = new_byte;
         }


What we do here is "move" the data rows to the appropriate rows in the actual LED order that you made for your LED matrix. We also "move" the data columns to columns in the display.
The first part, for example:
Code: Select all
new_byte |= (old_byte & 0b00000010) << 4;

moves the bit 00000010 to this location 00100000 in the display.
The second part, for example:
Code: Select all
case 1: new_index=4; break;

moves the entire row from index 1 to index 4.

If you arrange your LEDs like in the schematics that I am sending you, then I will be able to tell you what bit to move where, and what row to move to what index!

And for MAX 2 and MAX 3 it is the same:
Code: Select all
         // and MAX2 and MAX3 are soldered in the same fashion
         else
         {
            uint8_t old_byte = display_matrix[max_id][j];

            // now rearrange the bits into a new byte
            uint8_t new_byte = 0;
            new_byte |= (old_byte & 0b00000001) << 4;
            new_byte |= (old_byte & 0b00000010) << 1;
            new_byte |= (old_byte & 0b00000100) << 5;
            new_byte |= (old_byte & 0b00001000);
            new_byte |= (old_byte & 0b00010000) << 2;
            new_byte |= (old_byte & 0b00100000) >> 4;
            new_byte |= (old_byte & 0b01000000) >> 1;
            new_byte |= (old_byte & 0b10000000) >> 7;

            // now rearrange the indexes
            uint8_t new_index;
            switch (j)
            {
               case 0: new_index=1; break;
               case 1: new_index=5; break;
               case 2: new_index=7; break;
               case 3: new_index=3; break;
               case 4: new_index=2; break;
               case 5: new_index=6; break;
               case 6: new_index=4; break;
               case 7: new_index=0; break;
            }

            display_matrix_new[max_id][new_index] = new_byte;
         }


The story here is the same as for the MAX 1 and MAX 4...

Take look at the schematics I am sending you here.
Attachments
word_clock_1.jpg
(777.63 KiB) Downloaded 4 times
max_orders.jpg
(99.04 KiB) Downloaded 4 times
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Construction of Word Clock v1

Postby Pielo » 18-01-2013, 11:13

Thanks for this info

Sorry, but i can't change the connections. the cable is to short.

my pictures are wrong. here are the right.

Image

Image

I'm testing to change the code.
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Postby trax » 18-01-2013, 11:21

Did you rotate the matrices like I showed you in my schematics?
Do you have some pictures of your hardware so I can take a look?
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Construction of Word Clock v1

Postby Pielo » 18-01-2013, 11:50

Here is one part of hardware the other part is the same

Image
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Problem with wordclock

Postby Pielo » 18-01-2013, 11:57

trax wrote:For MAX 1 and MAX 4 it is the same:
[code] // MAX1 and MAX4 are soldered in the same fashion
if(max_id==0 || max_id==3)
{
uint8_t old_byte = display_matrix[max_id][j];

// now rearrange the bits into a new byte
uint8_t new_byte = 0;
new_byte |= (old_byte & 0b00000001);
new_byte |= (old_byte & 0b00000010) << 4;
new_byte |= (old_byte & 0b00000100) >> 1;
new_byte |= (old_byte & 0b00001000) << 3;
new_byte |= (old_byte & 0b00010000) >> 1;
new_byte |= (old_byte & 0b00100000) << 2;
new_byte |= (old_byte & 0b01000000) >> 4;
new_byte |= (old_byte & 0b10000000) >> 3;


is this the SEG - Pins and the ohter table for the DIG-Pins, or it is very different
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Postby trax » 18-01-2013, 12:53

I have looked at your picture - you soldered it correctly. Great! :)

The easiest way to do this is to delete the entire main() function, and put this one instead:

Code: Select all
//############
// Main app //
//############
int main(void)
{
   // Initialize Timer0 overflow ISR
   TCCR0A = 0;
   TCCR0B = _BV(CS00);                            // no prescaling, but timer started!
   TIMSK0 |= _BV(TOIE0);                            //-for-> ISR(TIMER0_OVF_vect)

   // Interrupts ON
   sei();

   // turn on pin-change-interrupts
   pin_interrupt_init();                            // this will set the DDRs for button/sensors and prepare the interrupts

   STATUS_LED_PORT |= _BV(STATUS_LED_PIN);               // led on

   // initialize the MAX72XX chips
   max72xx_init_hw();                              // init the hw for MAX72XX

   // RTC init
   rtc_init();                                  // init the DS323X RTC IC

   // Light sensor init
   light_sensor_init();                           // init the light sensor

   // MAX72XX inits
   max72xx_init_all();                              // init all MAX chips in the system

   // Check to see if there is something valid in EEPROM
    uint8_t *pEE = (uint8_t *)EEPROM_START;
   if( eeprom_read_byte(pEE++) == 0xAA ) // 0xAA is my "valid flag"
   {
      calib_light_sens_min = eeprom_read_word((uint16_t *)pEE);
      pEE+=2;
      calib_light_sens_max = eeprom_read_word((uint16_t *)pEE);
      pEE+=2;
      eeprom_read_block((void *)&disp_duration,pEE,DISP_THINGS);
      pEE+=DISP_THINGS;
      bools[BUSR1] = eeprom_read_byte(pEE);
   }

   // falsify RTC changes so it display whatever is required immediatelly
   bs(bRTC_MinChg,BAPP1);
   bs(bRTC_SecChg,BAPP1);
   bs(bRTC_TempChg,BAPP1);

   delay_ms_(1000);                              // startup delay

   STATUS_LED_PORT &= ~_BV(STATUS_LED_PIN);            // led off

   // scroll some intro text...
   max72xx_write(MAX72XX_COUNT+1, MAX72XX_intensity, 0x07); // set brightness to half initially



   // FINDING ROWS
   // max72xx_write(MAX ID 1..4, CLOCK LED ROW ADDRESS 1..8, DATA_HERE);         
   max72xx_write(1, 1, 0b11111111); // turn on MAX 1 - address of DIGn (this is actually a ROW in the clock)
   while(1); // stop here
   



   return 0;
}

Focus on the line "// FINDING ROWS". This should turn ON row 1 (upper row) of the clock in the BOTTOM LEFT quarter (if you are looking at the clock from the front). If it doesn't (if it turns ON row number 5 for example), then you need to go to the "max72xx_send_matrix()" function, at the
Code: Select all
// MAX1 and MAX4 are soldered in the same fashion
section, and adjust this part of the code:
Code: Select all
            // now rearrange the indexes
            uint8_t new_index;
            switch (j)
            {
               case 0: new_index=0; break;
               case 1: new_index=4; break;
               case 2: new_index=6; break;
               case 3: new_index=2; break;
               case 4: new_index=3; break;
               case 5: new_index=7; break;
               case 6: new_index=5; break;
               case 7: new_index=1; break;
            }

There we change that row index from 1 to 5 and for every other row (8 in total). Of course, you will have to change this line
Code: Select all
max72xx_write(1, 1, 0b11111111);
to
Code: Select all
max72xx_write(1, 2, 0b11111111);
to see where row 2 will be turned ON and so on for remaining 6 rows.

After you find those rows, you must also find the columns with this code:

Code: Select all
//############
// Main app //
//############
int main(void)
{
   // Initialize Timer0 overflow ISR
   TCCR0A = 0;
   TCCR0B = _BV(CS00);                            // no prescaling, but timer started!
   TIMSK0 |= _BV(TOIE0);                            //-for-> ISR(TIMER0_OVF_vect)

   // Interrupts ON
   sei();

   // turn on pin-change-interrupts
   pin_interrupt_init();                            // this will set the DDRs for button/sensors and prepare the interrupts

   STATUS_LED_PORT |= _BV(STATUS_LED_PIN);               // led on

   // initialize the MAX72XX chips
   max72xx_init_hw();                              // init the hw for MAX72XX

   // RTC init
   rtc_init();                                  // init the DS323X RTC IC

   // Light sensor init
   light_sensor_init();                           // init the light sensor

   // MAX72XX inits
   max72xx_init_all();                              // init all MAX chips in the system

   // Check to see if there is something valid in EEPROM
    uint8_t *pEE = (uint8_t *)EEPROM_START;
   if( eeprom_read_byte(pEE++) == 0xAA ) // 0xAA is my "valid flag"
   {
      calib_light_sens_min = eeprom_read_word((uint16_t *)pEE);
      pEE+=2;
      calib_light_sens_max = eeprom_read_word((uint16_t *)pEE);
      pEE+=2;
      eeprom_read_block((void *)&disp_duration,pEE,DISP_THINGS);
      pEE+=DISP_THINGS;
      bools[BUSR1] = eeprom_read_byte(pEE);
   }

   // falsify RTC changes so it display whatever is required immediatelly
   bs(bRTC_MinChg,BAPP1);
   bs(bRTC_SecChg,BAPP1);
   bs(bRTC_TempChg,BAPP1);

   delay_ms_(1000);                              // startup delay

   STATUS_LED_PORT &= ~_BV(STATUS_LED_PIN);            // led off

   // scroll some intro text...
   max72xx_write(MAX72XX_COUNT+1, MAX72XX_intensity, 0x07); // set brightness to half initially



   // FINDING COLUMNS
   // max72xx_write(MAX ID 1..4, CLOCK LED ROW ADDRESS 1..8, DATA_HERE);         
   max72xx_write(1, 1, 0b00000001); // turn on MAX 1 - this will turn on one column (Row-ID not important here)
   while(1); // stop here
   



   return 0;
}

and now you will go to the "max72xx_send_matrix()" function, at the line
Code: Select all
// now rearrange the bits into a new byte
and move the turned ON led to the appropriate position. For example, if the code above turned on LED nr. 5 (from the right-to-left order) you must "move" it left 4 times with this:
Code: Select all
new_byte |= (old_byte & 0b00000001) << 4;
and so on.

It is kind of difficult to explain but that's about it.
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Construction of Word Clock v1

Postby trax » 18-01-2013, 14:58

Pielo, what kind of wood panel did you use for your clock, what wood is this?
User avatar
trax
 
Posts: 3464
Joined: 08-01-2005, 18:04
Location: 75k, BA

Re: Construction of Word Clock v1

Postby Pielo » 19-01-2013, 20:41

trax wrote:Pielo, what kind of wood panel did you use for your clock, what wood is this?


A 20 mm thick plywood panel overlaid with a phenol film (spruce)
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Re: Construction of Word Clock v1

Postby Pielo » 21-01-2013, 10:52

I have a problem with these code's ...

STATUS_LED_PORT |= _BV(STATUS_LED_PIN); // led on
STATUS_LED_PORT &= ~_BV(STATUS_LED_PIN); // led off

I become again and again the same error message and I have no idea what the problem is.


Build started 21.1.2013 at 08:13:20
avr-gcc -mmcu=atmega328p -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT wc.o -MF dep/wc.o.d -c ../../../original/wc.c
../../../original/wc.c: In function 'main':
../../../original/wc.c:130:8: error: 'STATUS_LED_PORT' undeclared (first use in this function)
../../../original/wc.c:130:8: note: each undeclared identifier is reported only once for each function it appears in
../../../original/wc.c:130:27: error: 'STATUS_LED_PIN' undeclared (first use in this function)
make: *** [wc.o] Fehler 1
Build failed with 2 errors and 0 warnings...



Did you have ideas, what can be the problem?
Pielo
 
Posts: 37
Joined: 15-01-2013, 13:23
Location: Germany, Thüringen

Next

Return to Mikrokontroleri - AVR

Who is online

Users browsing this forum: No registered users and 1 guest

GOOGLE