Help with microcontroller fuses

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

I want to copy the inverter software to atmega8 using the
RS323 programmer
Use a 16MHz crystal
You set the fuse as a picture

I have an inquiry
Do I enable bootloader options when copying, do I need a
bootloader file or is this enough?
I will use PonyProg2000
I will attach the program file using Micro C.
I have another query about the inverter program, but let's
make it later
Thank you

Attachment(s): 

This topic has a solution.
Last Edited: Wed. Jul 29, 2020 - 06:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:
Do I enable bootloader options when copying, do I need a
bootloader file or is this enough?
Doesn't look like it. It's a simple app program and if you plan to ISp it into the micro I don't see any need for involvement of a bootloader in this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you provide a link to the project, please

Jim

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Clawson for the quick reply
Yes ki0bk, i'll keep you informed, but wait a little bit
I have a question
Which is better, when the program is at 16MHz or 8MHz, of
course after modifying the program
Is performance different or remains the same?
Is the program correct or there are errors?
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:
Which is better, when the program is at 16MHz or 8MHz, of
course after modifying the program
Is performance different or remains the same?
Is the program correct or there are errors?

 

Which is better?  In what way, this depends on your definition of better! 

Performance of what? In what way, again it depends on what performance your talking about.

Is program correct?  how would we know, you should ask the author of the program! Note: it does not appear to be a GCC C program, but can be ported if that is your compiler.

Provide a link to where you found this!

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Thu. Jun 25, 2020 - 05:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the site link and explains the program wonderfully

http://tahmidmc.blogspot.com/201...
Uses atmega16
I have modified the program to work on atmega8
I was asking whether the results are the same when changing the crystal frequency and whether the program after modification is correct or has errors
This is just what I asked
Thank you 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Thanks for the link,

This seems to answer your question:

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:
I have modified the program to work on atmega8

 

I don't see any modifications that are needed to run at 8MHz. You need to divide the PWM top register by 2 to maintain PWM frequency (i.e. 499 instead of 999).

Then, this implies the sine table also needs all values divided by 2.

 

To maintain the synthesized sine wave at 50Hz, you will also need to double the frequency variable from 410 t0 820.

 

There is an error that comes from the original

OCR1AL = TBL_POINTER_SHIFT & 0x0F;

If you want to extract the low byte, then it's 0xFF and not 0x0F.

In fact you can replace

        OCR1AH = TBL_POINTER_SHIFT >> 8;
        OCR1AL = TBL_POINTER_SHIFT & 0x0F;

by

        OCR1A = TBL_POINTER_SHIFTF;

The correct code for 16 bit register access will be generated by the compiler. edit: well, at least av-gcc will, IDK about the compiler you are using.

Last Edited: Fri. Jun 26, 2020 - 09:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Thank you for your help
I have not yet modified the software to run at 8MHz
But I would have made the mistakes I mentioned
I made adjustments to the program, but the frequency became 8 kHz
Shouldn't it stay 16 kHz?
It seems that I did not understand:
This means that the sine table also needs all the values ​​divided by 2

Thank you very much

 

[moderator note: it's easier if you post the code you are talking about inline like this...]

unsigned int sin_table[32]={0, 49, 97, 145, 191, 235, 277, 317, 353, 386, 415, 440, 461, 478, 489, 497, 499, 497, 489, 478, 461, 440, 415, 386, 353, 317, 277, 235, 191, 145, 97, 49};

#define MOSA PORTD0_bit
#define MOSB PORTD1_bit
#define MOSC PORTD2_bit
#define MOSD PORTD3_bit

unsigned char FlagReg;
#define Direction FlagReg.B0
//0 -> MOS A + D
//1 -> MOS B + C

unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
unsigned int TBL_temp;
unsigned char DUTY_CYCLE;

void interrupt() org IVT_ADDR_TIMER1_OVF{
     TBL_POINTER_NEW = TBL_POINTER_NEW + SET_FREQ;
         if (TBL_POINTER_NEW < TBL_POINTER_OLD){
           if (Direction == 0){
              MOSA = 0;
              MOSD = 0;
              MOSB = 1;
              MOSC = 1;
              Direction = 1;
           }
           else{
                MOSB = 0;
                MOSC = 0;
                MOSA = 1;
                MOSD = 1;
                Direction = 0;
           }
        }
        TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 11;
        DUTY_CYCLE = TBL_POINTER_SHIFT;
        TBL_POINTER_SHIFT = sin_table[DUTY_CYCLE];
        OCR1AH = TBL_POINTER_SHIFT >> 8;
        OCR1AL = TBL_POINTER_SHIFT & 0xFF;
        TBL_POINTER_OLD = TBL_POINTER_NEW;
}

void main() {
     SET_FREQ = 820;
     TBL_POINTER_SHIFT = 0;
     TBL_POINTER_NEW = 0;
     TBL_POINTER_OLD = 0;
     DUTY_CYCLE = 0;
     DDRB = 0xFF;
     DDRD = 0XFF;
     OCR1AH = 0;
     OCR1AL = 0;
     //ICR1 = 499 -> TOP -> 16kHz
     TCCR1A = 0x82;
     ICR1H = 0x03;
     ICR1L = 0xE7;
     TIMSK = 0x04;
     TCCR1B = 0x19;
     SREG_I_bit = 1;
     while(1);
}

Use the icon on the toolbar that looks like  to do this.

 

Attachment(s): 

Last Edited: Fri. Jun 26, 2020 - 01:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:

     //ICR1 = 499 -> TOP -> 16kHz
     TCCR1A = 0x82;
     ICR1H = 0x03;
     ICR1L = 0xE7;

 

The problem is that you just changed 999 -> 499 in the commented code, which does nothing. You need to change

     ICR1H = 0x03;
     ICR1L = 0xE7;

This is the high and low parts of ICR1, which together make 0x03E7 which is 999 decimal. You need to change this to 499 which is 0x1F3, so replace these lines by

     ICR1H = 0x01;
     ICR1L = 0xF3;

and the PWM frequency will go back to 16kHz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
     OCR1AH = 0;
     OCR1AL = 0;

in many C compilers for AVR can be:

     OCR1A = 0;

and

     ICR1H = 0x01;
     ICR1L = 0xF3;

can be

     ICR1 = 0x01F3;

or of possibly more use to the reader (who more likely understand the significance of "499"):

     ICR1 = 499;

There's little need to delete with xxxH/xxxL pairs separately when you can usually make direct 16 bit read/writes with just xxx.

 

BTW do NOT use all upper case for anything but preprocessor macro names.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the help
I modified as mentioned ICR1 = 0x01F3;
The result was


I modified SET_FREQ = 410;
ICR1 = 0x01F5;
The result was

Thanks to all

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

ICR1H = 0x01;
ICR1L = 0xF4;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A question that comes to mind
What is the result when (sin_table) doubles
If you have reached 64 instead of 32
Will the signal result be better, or will the beep sound appear in the converter file as I expect?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you double the table the sine wave will be better defined. Probably you will need to double SET_FREQ to 820.

 

You will need to change

TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 11;

to

TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10;

to increase the range of the pointer from 0-31 to 0-63.

 

The PWM frequency is in the audible range, especially for younger people, so if it's not filtered completely you may hear a high pitch sound, I don't really expect this to change from 32 to 64 samples, but experimentation is better than speculation smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for help
I will try 8 MHz later
Now I will start programming the 16 MHz program because it is my first experience
I will provide you with the results
Thank you to everyone who helped me

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have not yet been able to copy the program to the microcontrollar
PonyProg doesn't seem to be running on Windows 7
What do you recommend another program?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:
PonyProg doesn't seem to be running on Windows 7

 

Did you try to run it in compatibility mode?  https://www.howtogeek.com/howto/10436/using-program-compatibility-mode-in-windows-7/

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all
Today the program was successfully burned
The problem was with one of the welding points on the board
I will start designing the inverter circuit and experimenting with 16 MHz then I will try 8 MHz
Many thanks to everyone who helped me

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The rest is now here https://www.avrfreaks.net/forum/... but it may get locked as you have already a thread on the same https://www.avrfreaks.net/forum/...

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:
Today the program was successfully burned
The problem was with one of the welding points on the board

Jolly good - thanks for feeding back.

 

now please mark the solution - see Tip #5 in my signature, below, for instructions:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil: Please help me split up the topic
Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

somar1 wrote:
Please help me split up the topic

You can't - it has to be done by a moderator.

 

See #20 - it has been done for you.

 

It helps if you just keep to one question per thread - so that the thread title is an accurate description of the topic or problem being discussed.

 

Once the issue is resolved, mark the solution (as you have now done)

 

This makes it easier for other people who may come along with the same question 

 

As shown in #20, you can easily give links when you want to refer to other threads or specific posts.

 

See: https://www.avrfreaks.net/commen...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jul 29, 2020 - 08:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

     OCR1AH = 0;
     OCR1AL = 0;

in many C compilers for AVR can be:

     OCR1A = 0;

 

Thanks for clarifying that, Cliff.  I have done both and they both seemed to work fine, but I have always been a little nervous about not using the H and L.  Now I wont worry.