Author Topic: Program & libraries doubt!  (Read 1968 times)

0 Members and 1 Guest are viewing this topic.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Program & libraries doubt!
« 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: [Select]
[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!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Program & libraries doubt!
« Reply #1 on: July 09, 2009, 06:35:13 PM »
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

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Program & libraries doubt!
« Reply #2 on: July 09, 2009, 06:46:17 PM »
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??

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Program & libraries doubt!
« Reply #3 on: July 09, 2009, 07:27:11 PM »
Ehhhh what functions? If you have an Axon, why not use Axon functions?

(I think we are having just a communication issue here . . .)

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Program & libraries doubt!
« Reply #4 on: July 10, 2009, 05:27:11 AM »
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?


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Program & libraries doubt!
« Reply #5 on: July 10, 2009, 06:49:14 AM »

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Program & libraries doubt!
« Reply #6 on: July 10, 2009, 08:26:03 AM »
okay, I wrote this program by referring the functions list and i ended up with this

Code: [Select]
#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! :'(

 


Get Your Ad Here