Answer:- The time period of the wave is 1/8 micro-s. For 70% DC-
ON time = 0.7*T = 0.7/8 us = 0.0875 us.
OFF time = 0.3*T = 0.3/8 us = 0.0375 us.
We never program a dc motor. We program the controller which controls the dc motor. The code is written below-
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB |= (1 << PB2); /* DC motor on pin PB2 */
while(1)
{
PORTB |= (1 << PB2); /* high pulse on pin PB2 */
_delay_us(0.0875); /* 0.0875 us delay */
PORTB &= ~(1 << PB2); /* low pulse on pin PB2 */
_delay_us(0.0375); /* 0.0375 us delay */
}
}
Get Answers For Free
Most questions answered within 1 hours.