Good Morning, I follow what you said... but I've got an error and need your help...
the error is the following:
-------- begin --------
Cleaning project:
rm -f cat_toy.hex
rm -f cat_toy.eep
rm -f cat_toy.obj
rm -f cat_toy.cof
rm -f cat_toy.elf
rm -f cat_toy.map
rm -f cat_toy.obj
rm -f cat_toy.a90
rm -f cat_toy.sym
rm -f cat_toy.lnk
rm -f cat_toy.lss
rm -f a2d.o buffer.o uart4.o timerx8.o rprintf.o cat_toy.o
rm -f a2d.lst buffer.lst uart4.lst timerx8.lst rprintf.lst cat_toy.lst
rm -f a2d.s buffer.s uart4.s timerx8.s rprintf.s cat_toy.s
rm -f a2d.d buffer.d uart4.d timerx8.d rprintf.d cat_toy.d
rm -f .dep/*
Errors: none
-------- end --------
Build succeeded with 0 Warnings...
Compiling: Axon.c
avr-gcc -c -mmcu=atmega640 -I. -gstabs -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=Axon.lst -std=gnu99 -Wp,-M,-MP,-MT,Axon.o,-MF,.dep/Axon.o.d Axon.c -o Axon.o
Axon.c: In function 'main':
Axon.c:57: warning: implicit declaration of function 'timer3Init'
Axon.c:58: warning: implicit declaration of function 'timer4Init'
Axon.c:64: error: 'i' undeclared (first use in this function)
Axon.c:64: error: (Each undeclared identifier is reported only once
Axon.c:64: error: for each function it appears in.)
Axon.c:75: error: 'j' undeclared (first use in this function)
Axon.c:99: warning: implicit declaration of function 'reset_timer_3'
Axon.c:100: warning: implicit declaration of function 'reset_timer_4'
Axon.c:110: warning: implicit declaration of function 'PWM_Init_timer1_LED'
Axon.c:111: warning: implicit declaration of function 'PWM_timer1_On_LED'
Axon.c:117: warning: implicit declaration of function 'PWM_timer1_Set_LED'
Axon.c:130: warning: implicit declaration of function 'PWM_Init_timer2_C0'
Axon.c:131: warning: implicit declaration of function 'PWM_Init_timer4_C0'
Axon.c:135: warning: implicit declaration of function 'PWM_timer2_On_C0'
Axon.c:136: warning: implicit declaration of function 'PWM_timer4_On_C0'
Axon.c:141: warning: implicit declaration of function 'PWM_timer2_Set_C0'
Axon.c:142: warning: implicit declaration of function 'PWM_timer4_Set_C0'
Axon.c:158: warning: implicit declaration of function 'PWM_timer2_Off_C0'
Axon.c:159: warning: implicit declaration of function 'PWM_timer4_Off_C0'
make: *** [Axon.o] Error 1
Build failed with 4 errors and 15 warnings...
Here's my code:
/****************************************************************************
*
* Copyright (c) 2008
www.societyofrobots.com* (please link back if you use this code!)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
****************************************************************************/
//SoR Include
#include "SoR_Utils.h" //includes all the technical stuff
#include "hardware.c" //declare hardware variables and ports
//#include "CMUcam.c" //not yet written
#include "sensors.c" //not yet written, sensor libraries for sonar, sharp IR, etc.
//#include "Blackfin_Axon.c" //files for Blackfin Robot camera
#include "control.c" //your code goes in here
//#include "axon_test.c" //include this is doing a function test for the Axon
//#include "axon_oscope_test.c" //include this is doing a function test for the Axon
int main(void)
{
/****************INITIALIZATIONS*******************/
//other stuff Im experimenting with for SoR
uartInit(); // initialize the UART (serial port)
uartSetBaudRate(0, 38400); // set UARTE speed, for Bluetooth
uartSetBaudRate(1, 115200); // set UARTD speed, for USB connection
uartSetBaudRate(2, 38400); // set UARTH speed
uartSetBaudRate(3, 38400); // set UARTJ speed, for Blackfin
//G=Ground, T=Tx (connect to external Rx), R=Rx (connect to external Tx)
rprintfInit(uart1SendByte);// initialize rprintf system and configure uart1 (USB) for rprintf
timer0Init(); // initialize the timer system
timer2Init(); // initialize the timer system
configure_ports(); // configure which ports are analog, digital, etc.
a2dInit(); // initialize analog to digital converter (ADC)
a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage
LED_on();
// initialize the timer system (comment out ones you don't want)
timer0Init();
timer1Init();
timer2Init();
timer3Init();
timer4Init();
//timer5Init ();
//rprintf("\r\nSystem Warming Up");
//let system stabelize for X time
for(i=0;i<=16;i++)
{
delay_cycles(5000);
rprintf(".");
}
delay_cycles(6000);
//read each ADC once to get it working accurately
for(i=0;i<16;i++)
{
j=a2dConvert8bit(i);//read each ADC once to get it working accurately
delay_cycles(5000); //keep LED on long enough to see Axon reseting
rprintf(".");
}
LED_off();
/**************************************************/
//test programs
//while(1)
//{
//test_oscope();
//test();
//}
/*********ADD YOUR CODE BELOW THIS LINE **********/
rprintf("Initialization Complete \r\n");
//wait until user pushes button
while(!button_pressed());
reset_timer_0();
reset_timer_2();
reset_timer_3();
reset_timer_4();
//reset_timer_5();
while(1)
{
control();//use this for your code
//servo_controller();
PWM_Init_timer1_LED(
;
PWM_timer1_On_LED();
while(1)
{
for(i=90;i<255;i++)
{
PWM_timer1_Set_LED(i);
delay_ms(10);
}
for(i=255;i>90;i--)
{
PWM_timer1_Set_LED(i);
delay_ms(10);
}
}
//Initializing timer2 for PWM
PWM_Init_timer1_LED(
;
PWM_Init_timer2_C0(10);//9 doesn't work
PWM_Init_timer4_C0(10);
//Turning "ON" both PWM channels
//PWM_timer1_On_LED();
PWM_timer2_On_C0();
PWM_timer4_On_C0();
delay_ms(1000);
//Setting the PWM duty cycler or speed 01% - 49%
//PWM_timer1_Set_LED(1);
PWM_timer2_Set_C0(1);
PWM_timer4_Set_C0(1);
delay_ms(1000);
//Setting the PWM to 50% - 98% duty cycler or speed
//PWM_timer1_Set_LED(127);
PWM_timer2_Set_C0(127);
PWM_timer4_Set_C0(127);
delay_ms(1000);
//Setting the PWM to 99% - 100% duty cycler or full speed
//PWM_timer1_Set_LED(254);
PWM_timer2_Set_C0(254);
PWM_timer4_Set_C0(254);
delay_ms(1000);
//Turning "OFF" both PWM channels
PWM_timer2_Off_C0();
PWM_timer4_Off_C0();
delay_ms(1000);
delay_cycles(100);//an optional small delay to prevent crazy oscillations
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/
return 0;
}
I really need your help Admin..., I am trying to put the motor controller in only 1 port in C0 to my axon. The motor controller is composed of Y-cable...
and here's the sample code that written in Stamp 2 from solarbotics the manufacturer of the motor controller:
'{$STAMP BS2}
'Sample Code for the Parallax BS2 using the
'Solarbotics CMD Motor driver
'Rev 1.0
'(c) Solarbotics Ltd., 2006
'by Dan Gates June 12 2006
'----------------------------- Program Description -------------------------
' This CMD Sample program is for testing your CMD motor driver with a Basic
' Stamp2 or compatable.
' First we declare the motor connection pins in the "Pin Allocation category
' and create a temp register for good measure.
' Then in MAIN we turn OFF both motor enable lines for about 1 second and
' Proceed to turn each motor on in the following sequence as if they were
' driving a robot:
' Forward, Backward, LEFT, and RIGHT each for a brief period of time (about
' two and a half seconds).
' A last we jump back to the beginning of the code and start over in a never
' ending loop.
'
' This program assumes that you connect the CMD to the following BS2 pins;
' Pin7 = E 1-2
' Pin8 = E 3-4
' Pin9 = L1
' Pin10= L2
' Pin11= L3
' Pin12= L4
' Be sure to connect at least 6v to the power input and connect the motors
' to the outputs.
'----------------------------- Pin Allocations -----------------------------
'Motor control
Enable_Right CON 7 'Enable high, disable low
Enable_Left CON 8 'Enable high, disable low
'------------ Direction Truth Table -------------
'L1 & L3 | L2 & L4 | M1,M2,M3,M4 Outputs
'--------|---------|-----------------------------
M1a_Direction CON 9 ' HIGH | HIGH | Outputs = High (Motor Break)
M1b_Direction CON 10 ' LOW | LOW | Outputs = LOW (Motor Coast)
M2a_Direction CON 11 ' HIGH | LOW | Current flows POS.(Direction 1)
M2b_Direction CON 12 ' LOW | HIGH | Current flows Neg.(Direction 2)
'------------------------------------------------
Temp VAR Word 'Temp register for manipulating bits
'------------------------------ Start of main program ---------------------
MAIN:
LOW Enable_Right 'Turn off Right Motor
LOW Enable_Left 'Turn off Left Motor
PAUSE 400 'Wait 1 second
GOSUB FORWARD 'Jump to Forward Subroutine
PAUSE 1000 'Do it for 2.5 seconds
GOSUB BACKWARD 'Jump to Backward Subroutine
PAUSE 1000 'Do it for 2.5 seconds
GOSUB LEFT 'Jump to Left Subroutine
PAUSE 1000 'Do it for 2.5 seconds
GOSUB RIGHT 'Jump to right subroutine
PAUSE 1000 'Do it for 2.5 seconds
GOTO MAIN 'Go back and start again
'----------------------------- Subroutines ---------------------------------
FORWARD:
HIGH Enable_Right 'Turn on right motor
HIGH Enable_Left 'Turn on left motor
HIGH M1a_Direction 'This comination makes the right
LOW M1b_Direction 'motor turn clockwise
HIGH M2a_Direction 'This combination makes the left
LOW M2b_Direction 'motor turn Counterclockwise
RETURN 'return from this subroutine to the main
'program
BACKWARD:
HIGH Enable_Right 'Make sure motors are still on
HIGH Enable_Left
LOW M1a_Direction 'This combination makes the right motor
HIGH M1b_Direction 'turn counterclockwise
LOW M2a_Direction 'This combination makes the left motor
HIGH M2b_Direction 'turn clockwise
RETURN
LEFT:
HIGH Enable_Right 'Make sure motors are still on
HIGH Enable_Left
LOW M1a_Direction 'This combination makes the right motor
HIGH M1b_Direction 'turn counterclockwise
HIGH M2a_Direction 'This combination makes the left motor
LOW M2b_Direction 'turn counterclockwise
RETURN
RIGHT:
HIGH Enable_Right 'Make sure motors are still on
HIGH Enable_Left 'This combination makes the right motor
HIGH M1a_Direction 'turn clockwise
LOW M1b_Direction 'This combination makes the left motor
LOW M2a_Direction 'turn clockwise
HIGH M2b_Direction
RETURN
GOTO main 'We should never reach this point, but
'it's a good failsafe
'--------------------------------------------------------------------------------
' Now it's your turn to play around with this code and see if you can make it do
' other cool stuff. Try using the "Break" mode to stop the motors between direction
' changes.
'---------------------------------------------------------------------------------
Do you think, there's any way I can convert this script to C language that can synchronize to axon and the L298 motor controller...? please help