Pages: [1]   Go Down
Author Topic: Obstacle avoidence robot  (Read 1689 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can any one send me code to my obstacle detection robot
it just works on 2 IRse nsors and 2 dc motors and robotic contoller m1,my code showing errors plzzzzzz help  smiley-sad-blue
Code:
//************************************************************************************
//** 
//**  File name:     E:\pictures\Sethu\MY stufff\Projects\ODAR\Doc's\finallyigot.c
//**  Title:         Obstacle detecter and avoidance robot
//**  Description:   
//** 
//**  Generated by:  Flowcode v5.3.0.0
//**  Date:          Friday, June 21, 2013 12:41:52
//**  Licence:       Professional
//**  Registered to: nani
//**  Licence key:   AAJ2DB
//** 
//** 
//**  http://www.matrixmultimedia.com
//** 
//************************************************************************************


#define MX_AVR

#define MX_USES_UINT8 1
#define MX_USES_SINT16 0
#define MX_USES_CHAR 0
#define MX_USES_FLOAT 0
#define MX_USES_SINT32 0
#define MX_USES_BOOL 1
#define MX_USES_UINT16 0
#define MX_USES_UINT32 0
//Defines for microcontroller
#define FC_CAL_AVR
#define MX_ADC
#define MX_ADC_TYPE_2
#define MX_ADC_BITS_10
#define MX_EE
#define MX_EE_SIZE 512
#define MX_SPI_1
#define MX_SPI_1_MISO_PORT PORTB
#define MX_SPI_1_MISO_TRIS DDRB
#define MX_SPI_1_MISO_PIN 4
#define MX_SPI_1_MOSI_PORT PORTB
#define MX_SPI_1_MOSI_TRIS DDRB
#define MX_SPI_1_MOSI_PIN 3
#define MX_SPI_1_CLK_PORT PORTB
#define MX_SPI_1_CLK_TRIS DDRB
#define MX_SPI_1_CLK_PIN 5
#define MX_SPI_1_SS_PORT PORTB
#define MX_SPI_1_SS_TRIS DDRB
#define MX_SPI_1_SS_PIN 2
#define MX_UART_1
#define MX_UART_1_TX_PORT PORTD
#define MX_UART_1_TX_TRIS DDRD
#define MX_UART_1_TX_PIN 1
#define MX_UART_1_RX_PORT PORTD
#define MX_UART_1_RX_TRIS DDRD
#define MX_UART_1_RX_PIN 0
#define MX_MI2C
#define MX_I2C_1
#define MX_I2C_1_SDA_PORT PORTC
#define MX_I2C_1_SDA_TRIS DDRC
#define MX_I2C_1_SDA_PIN 4
#define MX_I2C_1_SCL_PORT PORTC
#define MX_I2C_1_SCL_TRIS DDRC
#define MX_I2C_1_SCL_PIN 5
#define MX_PWM
#define MX_PWMTYPE 1
#define MX_PWM_CNT 3
#define MX_PWM_TMR0_CNT 0
#define MX_PWM_TMR1_CNT 2
#define MX_PWM_TMR2_CNT 1
#define MX_PWM_PSCA1
#define MX_PWM_PSCA8
#define MX_PWM_PSCA64
#define MX_PWM_PSCA256
#define MX_PWM_PSCA1024
#define MX_PWM_1_PORT PORTB
#define MX_PWM_1_TRIS DDRB
#define MX_PWM_1_PIN 1
#define MX_PWM_2_PORT PORTB
#define MX_PWM_2_TRIS DDRB
#define MX_PWM_2_PIN 2
#define MX_PWM_3_PORT PORTB
#define MX_PWM_3_TRIS DDRB
#define MX_PWM_3_PIN 3

//Functions
#define F_CPU 20000000UL
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <avr\io.h>
#include <avr\interrupt.h>
#include <avr\eeprom.h>
#include <avr\wdt.h>

//Configuration data
#pragma DATA 0x0, 0xdf
#pragma DATA 0x1, 0xff

//Internal functions
#include "C:\Program Files (x86)\Flowcode(AVR)\v5\FCD\internals.c"

//Macro function declarations


//Variable declarations
#define FCV_FALSE (0)
#define FCV_TRUE (1)
volatile MX_UINT8 FCV_FIRSTSENSOR;
volatile MX_UINT8 FCV_SECONDSENSOR;



//Supplementary defines
#define OPTION OPTION_REG_REG

#include "C:\Program Files (x86)\Flowcode(AVR)\v5\CAL\includes.c"

//Macro implementations

//Supplementary implementations



int main()
{
//Initialization
MCUCSR=0x00;
wdt_disable();


//Interrupt initialization code

//Loop
//Loop: While 1
while (1)
{

//Input
//Input: D5 -> FirstSensor
DDRD = DDRD & 0xDF;
FCV_FIRSTSENSOR = ((PIND & 0x20) == 0x20);

//Input
//Input: D6 -> SecondSensor
DDRD = DDRD & 0xBF;
FCV_SECONDSENSOR = ((PIND & 0x40) == 0x40);

//Decision
//Decision: FirstSensor?
if (FCV_FIRSTSENSOR)
{

//Decision
//Decision: SecondSensor?
if (FCV_SECONDSENSOR)
{

//Output
//Output: 0x03 -> PORTB
DDRB = DDRB | 0x3F;
PORTB = (PORTB & 0xC0) | (0x03);

} else {

//Output
//Output: 0x03 -> PORTB
DDRB = DDRB | 0x3F;
PORTB = (PORTB & 0xC0) | (0x03);

}

} else {

//Decision
//Decision: SecondSensor?
if (FCV_SECONDSENSOR)
{

//Output
//Output: 0x14 -> PORTB
DDRB = DDRB | 0x3F;
PORTB = (PORTB & 0xC0) | (0x14);

} else {

//Output
//Output: 0x17 -> PORTB
DDRB = DDRB | 0x3F;
PORTB = (PORTB & 0xC0) | (0x17);

}

}


}

mainendloop: goto mainendloop;
}



Moderator edit: Download code made into visible code.

* finallyigot.c (4.1 KB - downloaded 24 times.)
« Last Edit: June 21, 2013, 02:56:31 am by AWOL » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's not an Arduino sketch.  To make it one, change "int main()" to "void setup()" and add an empty loop:

Code:
void loop() {
}
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ya its an flowcode ,,,,but if i make it arduino ,,,,,but i have an error that stk firmware update ,,,i cant even run example sketches ,,,wat to doooo
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
wat to doooo
Clean your keyboard. Your keys are missing and sticking.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have an error that stk firmware update ,,,i cant even run example sketches

I don't know what you mean by "i have an error that stk firmware update".

If you can't upload the example sketches you should probably start by re-installing the Arduino IDE.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i re installed but still it is  showing error "  avrdude: warning: cannot set sck period. please check for usbasp firmware update." ...and i did wat u said before that chainging int to void setup,,,and so,,,,wen i compile there are no errors,but wen i upload then i am geting this,and if i use arduino ide 1.0.5 then it is not showing my board(robotic controller m1) smiley-cry
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's a warning, not an error.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

then
 wat to do now  smiley-eek-blue
« Last Edit: June 23, 2013, 10:40:16 pm by sethukumar » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like the "(robotic controller m1)" is only marginally "Arduino Compatible".  It uses an ATmega8 processor so, it seems, the bootloader is not in a protected partition.  They warn that if your code grows beyond a certain size you will overwrite the bootloader and it will stop working.

Are you using a USBasp ISP to upload to your board?  That's what the warning message seems to imply. If you AREN'T using a USBasp then that might indicate a configuration problem.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ya i am using usbasp isp ,,,,than wat it means
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

" if i use arduino ide 1.0.5 then it is not showing my board(robotic controller m1) "

That would mean you don't have the Robot Controller M1 in your private "boards.txt" file.

The (incorrect) instructions on the Mlee's Robot Controller -M1 site tell you to edit the version-specific boards.txt file.  That's why it got erased when you updated to a new version.  What they SHOULD have said is:

1) Go to your sketch directory
2) Create a "hardware" directory there if it doesn't already exist.
3) In the "hardware" directory create a directory called "RobotControllerM1".
4) In the "RobotControllerM1" directory create a "boards.txt" file containing:

##############################################################
RCM1.name=Robot Controller-M1
RCM1.upload.protocol=usbasp
RCM1.upload.maximum_size=6144
RCM1.upload.speed=19200
RCM1.build.mcu=atmega8
RCM1.build.f_cpu=16000000L
RCM1.build.core=arduino
RCM1.upload.disable_flushing=true
##############################################################

Re-start the IDE.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i did wat u said ,but still getting that same" warning:cannot set sck period:please chek usbasp firmware",,and i am using arduino 1.0.1 and it has robotic controller m1 in boards,the problem is warning and also in starting wen i connect my board to pc it glows green first then to normal red,,,but now it is not glowing green wen i connect ,only the center led (ie,the led near to reset button) is glowing,is there any problem frm board smiley-roll-sweat thank u so much for replying
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I don't know FlowCode.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

its not flowcode,,,,i am using arduino only
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
ya its an flowcode
Quote
its not flowcode
What...ever.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: