Society of Robots - Robot Forum
Software => Software => Topic started by: ukesh on July 09, 2009, 09:54:59 AM
-
hi!
I'm planning to make an line follower bot using the axon mcu and some Ir sensors. For the programming part i referred the photovore program and i found the libraries are specific for ATmega8 uC. So i need to edit the library files according to ATmega640 rite? and according to the pins i connect the sensors to the mcu board, say if i connect the left sensor to ADC pin 1 & right sensor to ADC pin2, left servo to pin E2 & right servo to pin E3, what are all the things do i need to change in the library files? and this is my program
[code]#include "SoR_Utils.h"
int main(void)
{
int sensor_left=0;
int sensor_right=0;
configure_ports();
a2dInit();
a2dSetPrescaler(ADC_PRESCALE_DIV32);
a2dSetReference(ADC_REFERENCE_AVCC);
LED_off();
while(1)
{
sensor_left=a2dConvert8bit(1);
sensor_right=a2dConvert8bit(2);
if(sensor_right<sensor_right)
turn right;// needs modification
else if(sensor_left<sensor_right)
turn left;//needs modification
else
go straight;//needs modification
return 0;
}
[/code]
sorry for not writing comments in the programs!
-
Hmmmm I don't understand your question.
The default Axon software and the default $50 Robot software are both photovore programs. You don't have to write a single line of code if you want a photovore :P
-
well , I'm going to make a line follower bot. In my program im calling certain functions which are specific for ATmega8 uC. for my program do i need to edit any libraries??
-
Ehhhh what functions? If you have an Axon, why not use Axon functions?
(I think we are having just a communication issue here . . .)
-
guess so!
well for example if i want to get an reading from the IR sensor and control a servo, what must be the program?
-
Its all on this page:
http://www.societyofrobots.com/axon/axon_function_list.shtml (http://www.societyofrobots.com/axon/axon_function_list.shtml)
-
okay, I wrote this program by referring the functions list and i ended up with this
#include "SoR_Utils.h"
int main(void)
{
int left sensor=0;
int right sensor=0;
configure_ports();
a2dInit();
a2dSetPrescaler(ADC_PRESCALE_DIV32);
a2dSetReference(ADC_REFERENCE_AVCC);
LED_off();
while(1)
{
left sensor=a2dConvert8bit(1);
right sensor=a2dConvert8bit(2);
if(right sensor<right sensor)
{
left servo(20);
right servo(40);
}// needs modification
else if(left sensor<right sensor)
{
left servo(40);
right servo(20);}//needs modification
else
{
left servo(20);
right servo(20);//needs modification
return 0;
}
And i know for sure that something is wrong in the servo code and i cant understand the method for commanding a servo. It says servo(PORTA,7,position). I referred the datasheet and found that pin 44 corresponds to port A, pin 7. Pls correct me if i am wrong. So in which pin do i connect the servo in the axon mcu?
Admin thnx for u help so far. Please bear with my noobishness! :'(