Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

NEED HELP: PING sensor on CM-700 + AVR Studio 5.1

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
2 postsPage 1 of 1
2 postsPage 1 of 1

NEED HELP: PING sensor on CM-700 + AVR Studio 5.1

Post by adamsya » Tue Jul 17, 2012 4:32 am

Post by adamsya
Tue Jul 17, 2012 4:32 am

Hi,

I have try many time using PING))) sensor on CM-700 but fail to operate.

I have connect to port PF1 (ADC1)

print the result on Roboplus terminal

I am using AVR Studio 5.1

there are 3 include file and 1 main file

and serial library for roboplus terminal (download from robotis support website)

http://support.robotis.com/en/baggage_f ... m700_v1.01).zip


Program below I refer one website, he display on LCD but I change to printf on terminal.

-----------------------------------------------------------
file name: delay_win.h (include file)

#include <avr>
void delay_025ms(uint8_t s);
void delay_us(uint8_t s);
-----------------------------------------------------------
file name: uson.h (include file)

#define DDR_Uson DDRF
#define PORT_Uson PORTF
#define PIN_Uson PINF
#define Front_Uson 1

uint8_t get_distance(char side);

-------------------------------------------------------------
file name: uson.c (include file)

#include <avr>
#include "uson.h"
#include "delay_win.h"


uint8_t get_distance(char side) // fungsi untuk mendapatkan jarak
{
uint8_t distance = 0;


DDR_Uson |=_BV(side);
PORT_Uson|=_BV(side);
delay_us(3);
PORT_Uson &=~_BV(side);
DDR_Uson &=~_BV(side);
loop_until_bit_is_set(PIN_Uson,side);


// ultasonik sudah mengirimkan sinyal


while(bit_is_set(PIN_Uson,side) && distance<254>= 254)
distance = 255;
else if (distance<8>9 && distance<=31)
distance=((distance-2)/2);
else
distance=((distance-1)/2);


return distance;
}

-------------------------------------------------------------------
file name: PING SENSOR (main file)


#include <avr>
#include <stdio>
#include <uson>
#include <uson>

#ifndef F_CPU
#define F_CPU 16000000UL // or whatever may be your frequency
#endif

#include <util>
#include <delay_win>
#include <avr>
#include "serial.h"


int main(void)
{

serial_initialize(57600);
sei();


while(1)
{

printf( "jarak = %d",get_distance(Front_Uson)); // Print Value on USART
_delay_ms(50);

}
}

---------------------------------------------------------------------------------


could someone help me, if you have working program, please share with me. sharing is caring~ thanks



http://www.free-eye-exam.info
Hi,

I have try many time using PING))) sensor on CM-700 but fail to operate.

I have connect to port PF1 (ADC1)

print the result on Roboplus terminal

I am using AVR Studio 5.1

there are 3 include file and 1 main file

and serial library for roboplus terminal (download from robotis support website)

http://support.robotis.com/en/baggage_f ... m700_v1.01).zip


Program below I refer one website, he display on LCD but I change to printf on terminal.

-----------------------------------------------------------
file name: delay_win.h (include file)

#include <avr>
void delay_025ms(uint8_t s);
void delay_us(uint8_t s);
-----------------------------------------------------------
file name: uson.h (include file)

#define DDR_Uson DDRF
#define PORT_Uson PORTF
#define PIN_Uson PINF
#define Front_Uson 1

uint8_t get_distance(char side);

-------------------------------------------------------------
file name: uson.c (include file)

#include <avr>
#include "uson.h"
#include "delay_win.h"


uint8_t get_distance(char side) // fungsi untuk mendapatkan jarak
{
uint8_t distance = 0;


DDR_Uson |=_BV(side);
PORT_Uson|=_BV(side);
delay_us(3);
PORT_Uson &=~_BV(side);
DDR_Uson &=~_BV(side);
loop_until_bit_is_set(PIN_Uson,side);


// ultasonik sudah mengirimkan sinyal


while(bit_is_set(PIN_Uson,side) && distance<254>= 254)
distance = 255;
else if (distance<8>9 && distance<=31)
distance=((distance-2)/2);
else
distance=((distance-1)/2);


return distance;
}

-------------------------------------------------------------------
file name: PING SENSOR (main file)


#include <avr>
#include <stdio>
#include <uson>
#include <uson>

#ifndef F_CPU
#define F_CPU 16000000UL // or whatever may be your frequency
#endif

#include <util>
#include <delay_win>
#include <avr>
#include "serial.h"


int main(void)
{

serial_initialize(57600);
sei();


while(1)
{

printf( "jarak = %d",get_distance(Front_Uson)); // Print Value on USART
_delay_ms(50);

}
}

---------------------------------------------------------------------------------


could someone help me, if you have working program, please share with me. sharing is caring~ thanks



http://www.free-eye-exam.info
adamsya
Robot Builder
Robot Builder
Posts: 7
Joined: Tue May 29, 2012 7:18 am

Post by Fritzoid » Tue Jul 17, 2012 12:40 pm

Post by Fritzoid
Tue Jul 17, 2012 12:40 pm

adamsya,

After it's triggered, the Parallax PING))) sensor responds with a 5V pulse until the echo is detected or a timeout occurs. So you need to connect it to a digital port and time the response. Here is an example of how that's done in c. http://www.societyofrobots.com/member_tutorials/node/194. Notice that the code waits for the signal to go high before it clears the timer and waits for the pulse to go low again.
adamsya,

After it's triggered, the Parallax PING))) sensor responds with a 5V pulse until the echo is detected or a timeout occurs. So you need to connect it to a digital port and time the response. Here is an example of how that's done in c. http://www.societyofrobots.com/member_tutorials/node/194. Notice that the code waits for the signal to go high before it clears the timer and waits for the pulse to go low again.
Fritzoid
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 331
Joined: Mon Dec 18, 2006 1:00 am


2 postsPage 1 of 1
2 postsPage 1 of 1