by adamsya » Tue Jul 17, 2012 4:32 am
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