Society of Robots - Robot Forum

Software => Software => Topic started by: Roboteccan on October 27, 2010, 06:19:06 PM

Title: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Roboteccan on October 27, 2010, 06:19:06 PM
is compatible SRF04 and SRF08 with the axon microcontroller? I have those sensor and I want know if this sensors are  compatible with axon microcontroller
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Metal Slug 2 on October 27, 2010, 06:35:02 PM
Yes to both.

Any sensor can be compatible with just about any microcontroller so long as you know how to utilize it (i.e. know which, if any, communication protocols it uses (I2C, SPI, UART etc.), and/or whether it provides analog and/or digital feedback).
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Admin on October 28, 2010, 02:34:32 PM
If your question was 'is there example source code to use these specific sensors?', then the answer is also *yes*. :P
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Roboteccan on October 29, 2010, 10:37:35 AM
plese give me the link for the example source code for those censor.
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Admin on October 29, 2010, 12:08:13 PM
See any or all of these:

1) Axon II source code zip file
2) WebbotLib manual
3) WebbotLib Project Designer

run a search and you can find them
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Roboteccan on November 01, 2010, 08:37:15 PM
hi, I am novise to program in AVR Studio 4 I watch a lot code of SRF04_Sonar.h, but I need to confirm if the sensor is working with a program that if the objective is more than 15cm turn off and if the objective is less than 15cm turn on the led.

#include "sys/axon.h"
#include "C:\WebbotLib\Sensors\Distance\Devantech\SRF04_Sonar.h"
#include "C:\WebbotLib\led.h"
//#include<avr/IO.h> for work the port C

//DDRC = 0xFF; I am try declare the port c is working

Devantech_SRF04 sensor = MAKE_Devantech_SRF04(ADC0D,ADC1D);

void appInitHardware(void){
     distanceInit(sensor);
}


TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    return 0;
}



TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
distanceRead(sensor);
while (1)
{
double cm = sensor.distance.cm;
if(cm<15)
   {
    //PORTC = 1; I am try the port C1 turn on the led
   }
}
}

please help me.
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Webbot on November 01, 2010, 10:34:47 PM
I suggest you use Project Designer with WebbotLib (its on my site http://webbot.org.uk (http://webbot.org.uk)) as it will make sure you connect the device properly and show some example code.
Looking at your code then:-
Code: [Select]
Devantech_SRF04 sensor = MAKE_Devantech_SRF04(ADC0D,ADC1D);..probably doesn't compile. What are pins ADC0D and ADC1D ??

In your appControl you need to get rid of the while(1)
appControl is called repeatedly anyway. And the while is messing up your code...you read the sensor once (and never again) and then the while loop is repeatedly doing something with that value

As for 'Trigger pulse' and 'echo pulse' then thats all happening for you inside the 'distanceRead'
Title: Re: is compatible SRF04 and SRF08 with the axon microcontroller?
Post by: Roboteccan on November 02, 2010, 04:45:54 PM
it work, thanks for all friend  ;D