Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
But every so often when I power on and off using the switch on the 4.8V pack, a servo twitches.
//*********SIMPLIFIED FUNCTIONS**********//functions to make coding easier for a beginner//but could cause port mixup confusion for intermediate usersvoid LED_on(void) { PORT_OFF(PORTB, 0);//turn LED on }void LED_off(void) { PORT_ON(PORTB, 1);//turn LED off }void servo_left(signed long int speed) { PORT_ON(PORTD, 1); delay_cycles(speed); PORT_OFF(PORTD, 0);//keep off delay_cycles(200); }void servo_right(signed long int speed) { PORT_ON(PORTD, 1); delay_cycles(speed); PORT_OFF(PORTD, 0);//keep off delay_cycles(200); }//***************************************
# Processor frequency.# This will define a symbol, F_CPU, in all source code files equal to the # processor frequency. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done# automatically to create a 32-bit value in your source code.# Typical values are:# F_CPU = 1000000# F_CPU = 1843200# F_CPU = 2000000# F_CPU = 3686400# F_CPU = 4000000# F_CPU = 7372800# F_CPU = 8000000# F_CPU = 11059200# F_CPU = 14745600# F_CPU = 16000000# F_CPU = 18432000# F_CPU = 20000000F_CPU = 3686400
So this is the code that I came up with per Admin's response.Code: [Select]//*********SIMPLIFIED FUNCTIONS**********//functions to make coding easier for a beginner//but could cause port mixup confusion for intermediate usersvoid LED_on(void) { PORT_OFF(PORTB, 0);//turn LED on }void LED_off(void) { PORT_ON(PORTB, 1);//turn LED off }void servo_left(signed long int speed) { PORT_ON(PORTD, 1); delay_cycles(speed); PORT_OFF(PORTD, 0);//keep off delay_cycles(200); }void servo_right(signed long int speed) { PORT_ON(PORTD, 1); delay_cycles(speed); PORT_OFF(PORTD, 0);//keep off delay_cycles(200); }//***************************************Still no go. Am I supposed to change anything else (setting wise in programming software/code), or any other files? Also when I check the pins, I am just checking for 5 volts on the legs used right?
void LED_on(void) { PORT_ON(PORTB, 1);//turn LED on }void LED_off(void) { PORT_OFF(PORTB, 1);//turn LED off }void servo_left(signed long int speed) { PORT_ON(PORTD, 1); delay_cycles(speed); PORT_OFF(PORTD, 1);//keep off delay_cycles(200); }void servo_right(signed long int speed) { PORT_ON(PORTD, 0); delay_cycles(speed); PORT_OFF(PORTD, 0);//keep off delay_cycles(200); }
# Place -D or -U options hereCDEFS =
# Place -D or -U options hereCDEFS = -D F_CPU=$(F_CPU)
F_CPU = 1000000# F_CPU = 1843200# F_CPU = 2000000# F_CPU = 3686400# F_CPU = 4000000# F_CPU = 7372800# F_CPU = 8000000# F_CPU = 11059200# F_CPU = 14745600# F_CPU = 16000000# F_CPU = 18432000# F_CPU = 20000000# F_CPU = 3686400
# F_CPU = 1000000# F_CPU = 1843200# F_CPU = 2000000# F_CPU = 3686400# F_CPU = 4000000# F_CPU = 7372800 F_CPU = 8000000# F_CPU = 11059200# F_CPU = 14745600# F_CPU = 16000000# F_CPU = 18432000# F_CPU = 20000000# F_CPU = 3686400
// project/system dependent defines// CPU clock speed//#define F_CPU 16000000 // 16MHz processor//#define F_CPU 14745000 // 14.745MHz processor//#define F_CPU 8000000 // 8MHz processor//#define F_CPU 7372800 // 7.37MHz processor//#define F_CPU 4000000 // 4MHz processor#define F_CPU 3686400 // 3.69MHz processor
#ifndef F_CPU#error Your makefile doesn't define the processor clock speed in F_CPU#endif
but wont they work at 4.8 v ?? coz there rating is in betn 4.8-6v