![]() |
|
|||||||
| General Electronics Chat Discussion forum for general chat about anything electronics related, including asking questions about material in the All About Circuits E-book, Worksheets, and Videos. |
|
|
|
Thread Tools | Display Modes |
|
#11
|
|||
|
|||
|
yupp I heared the beep sound every time but no motion on the motor
|
|
#12
|
|||
|
|||
|
I don't know codevision but it looks like you have several problems.
All of your ports are configured as inputs and are in tri state mode. What port/pin are you using for the output on the AVR? Your Timer mask register is set to 00000000 meaning the timer interrpupt is not enabled. TCCRO needs some help. If I'm reading it correctly the only thing you have changed is cs02bits which is the 256 prescale. Com01 com00 need to be set according to where and how you want the output. The DDR for the output port needs to be set as an output. The way you have it now there is no output; it is set for normal port operation. I'm assuming you are using timer0. Timer0 with a prescale of 256 @ 8mhz overflows every 8 milliseconds. Using a compare match of 100 with a top of 255 and that prescale gives you a 3ms duration. Not gonna work. So break out the data sheet for the chip and look at: DDRx TCCRO TIMSK TCNTO OCRO Also make sure your fuse bit clkdiv8 is not set on your chip or you will be running at 1mhz instead of 8mhz and you will pull all of your hair out. |
|
#13
|
|||
|
|||
|
PORTB pin 3 is actually configured as output.
But yes, you have several problems. You have no WGM bits set, these registers is what decides what mode your timer is in. In your case, for fast PWM the bits WGM00 and WGM01 should be set to 1. You still have a PWM frequency of 120Hz which is more than double what the ESC is expecting. And you should really read those hints posted earlier on initializing an ESC, I was not aware of this! And, your pulses is varying from 4 to ~7 milliseconds, if my math is correct, which the ESC don't understand, it needs 1-2ms pulses. |
|
#14
|
|||
|
|||
|
okkk I got your statement .and thnx to u all for their suggestions.
but tell me one thing if I am wrong about the ESCs. there are 3 pins out from the ESC and 2 pins for the battery for Li-Po battery.these 3 pins which are connected to atmega16 are PWM Pulse Vcc and Gnd pin I connected the PWM pin to Timer0 which is 8 bit timer at Pin no. 4 and Vcc, Gnd to their pins 10,11. Do I really need to initialise the port should I ?. because I did the PWM pulses generation in Dc motor controll also and I did nothing like initialising of port in dc motor ...or do I need to initialise the 16 bit timer for ESC....please help .....!!!!! |
|
#15
|
|||
|
|||
|
void main ()
{ TCCR0|= (1<<WGM00)| (1<<WGM01) | (1<<COM00)| (1<<CS02)| (1<<CS00); TCNT0=0x00; OCR0=0x00; //Set OC0 PIN as output. It is PB3 on ATmega16 DDRB|= (1<<PB3); while (1) { Delay_ms(20); OCR0=10; Delay_ms(20); OCR0=12; Delay_ms(20); OCR0=0; Delay_ms(20); } I made this effort by reading last all for your post prescaling timer0 by 1024 and giving the pulse after every 20 ms. and also use the WGM bit, COM and CS bit ...please tell me the error ...I did not burn this program yet !!! |
|
#16
|
|||
|
|||
|
The 16bit timer you can just leave ut of the picture, continue with the 8 bit timer 0. I don't have the time to re-calculate your new timer values, but I can see your code is not yet implementing the initialization of the ESC.
I added initialization routine before main-loop. I edited OCR0 values to values I think are more correct. I also upped your delay times in the main loop, did you expect to see any change in speeds with 20 ms delays between changes? Or, did you might think that the pulses need to change values every 50Hz (thus 20ms delays)? In either case, the frequency is fixed by the CS-bits, you only set the duty cycle with OCR0 register. I also removed last delay in loop because you had one on the top also making it delay two times , one right after the other. Only setting COM00 bit is a reserved setting with fast PWM mode, referring to the datasheet. I set COM01 instead, which clears OC0 at top of counter and sets it at the bottom, this is called non-inverting PWM. void main () { TCCR0|= (1<<WGM00)| (1<<WGM01) | (1<<COM01)| (1<<CS02)| (1<<CS00); TCNT0=0x00; OCR0=0x00; //Set OC0 PIN as output. It is PB3 on ATmega16 DDRB|= (1<<PB3); //ESC initializing OCR0 = 7; //0-speed signal at div1024 according to my calculations Delay_ms(5000); //wait 5 seconds for beep while (1) { Delay_ms(2000); OCR0=7; Delay_ms(2000); OCR0=14; Delay_ms(2000); OCR0=0; } |
|
#17
|
|||
|
|||
|
okkk
let me try this one I will tell you tomorrow it works or not thnx for your reply and code |
|
#18
|
|||
|
|||
|
not again still there is something missing in this code.. please look that code one more time . I am still not getting the movement in ESC.. pleaseeee....help .........
|
|
#19
|
|||
|
|||
|
Sorry pal. I'm not saying my code is guaranteed to work, and I can not program this for you. If you have access to an oscilloscope that would be handy, if not it's just a shot in the dark when you simply connect the ESC (btw we can not be sure your wiring is okay either).
Read this page http://extremeelectronics.co.in/avr-...crocontroller/ See that code? I can not guarantee it to work, but it's the first hit when googling "servo control avr" (what we told you to do, implicitly). Now delete the whole of main() function and replace with Code:
void main()
{
//Configure TIMER1
TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11); //NON Inverted PWM
TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10); //PRESCALER=64 MODE 14(FAST PWM)
ICR1=4999; //fPWM=50Hz (Period = 20ms Standard).
DDRD|=(1<<PD4)|(1<<PD5); //PWM Pins as Out
OCR1A = 250;
_delay_ms(5000);
while(1)
{
OCR1A=250; //no speed
_delay_ms(3000);
OCR1A=500; //full speed
_delay_ms(3000);
}
}
Select All
|
|
#20
|
|||
|
|||
|
o.k. thanx a lot for your effort let me try My best this time
I tell you tomorrow ....whether its gonna work... Hope at last something works....
|
|
| Tags |
| atmega16, brushless dc motor, controlling, esc |
Related Site Pages
|
||||
| Section | Title | |||
| Worksheet | Servo motor systems | |||
| Worksheet | AC motor control circuits | |||
| Textbook | Synchronous Motors : Ac Motors | |||
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| servo motor controlling with atmega16 | stylediva | Embedded Systems and Microcontrollers | 1 | 01-31-2012 04:23 PM |
| Controlling a 12V load - simple transistor or SSR? | BurninBri | General Electronics Chat | 7 | 11-10-2011 06:29 PM |
| video camera for atmega16 | mihaio07 | Embedded Systems and Microcontrollers | 1 | 03-09-2011 12:03 AM |
| Controlling 12V with 0.5V signal | Georacer | The Projects Forum | 19 | 09-23-2010 04:14 PM |
| How to configure ATmega16 to run with external crystal oscillator | sinoj | Embedded Systems and Microcontrollers | 4 | 06-06-2007 12:38 AM |
| Thread Tools | |
| Display Modes | |
|
|