Society of Robots - Robot Forum

Software => Software => Topic started by: NOOBinDistress on June 10, 2007, 07:37:01 PM

Title: Programing help!!!
Post by: NOOBinDistress on June 10, 2007, 07:37:01 PM
After the 50 dollar robot I intend on starting another robot like project!!! YAAAAY. I need help with programing! I need to know how to be able to program 2 servos and a sensor. The sensor has to sense motion then wait 60 seconds and then tell both servos to move for about 5 seconds (I will have to be able to test around with the exact amount of time). And thats it! I know I cant ask anyone to do this for me because "your here to help, not build the bot for me". So if Anyone could tell me or help me program this myself!!! Ok please help me!! thanks.
Title: Re: Programing help!!!
Post by: Admin on June 11, 2007, 07:29:28 AM
you will need to use timers (http://www.societyofrobots.com/programming_timers.shtml)

I dont have $50 robot source code for timers at the moment . . . but Im sure someone does and will post it (hint hint)

Do a google search on atmega8 timer sourcecode . . .
Title: Re: Programing help!!!
Post by: rgcustodio on June 11, 2007, 09:05:34 AM
I'm assuming you have a correct installation of WinAVR (or gnuavr). WinAVR includes avr-libc which is a set of libraries that'll make your life definitely easier. It has several macros that deals with delays.

First include delay.h into your source code then add a call to delay_ms().

Lookie here for details:
http://www.nongnu.org/avr-libc/user-manual/group__util__delay.html

Goodluck!

- Rommel
Title: Re: Programing help!!!
Post by: Admin on June 11, 2007, 09:09:31 AM
rgcustodio, I actually misread his post at first too, thinking he wants delays.

but actually he wants his robot to be active for X seconds, then swap to a different task for another Y seconds.

but yea, avrlib should have the timer functions you want . . . and it has some example code, too
Title: Re: Programing help!!!
Post by: rgcustodio on June 11, 2007, 09:29:28 AM
Quote
but actually he wants his robot to be active for X seconds, then swap to a different task for another Y seconds.

Actually you can do something like that using comparators and interrupts. Look into the PWM code of orangutan-lib.

- Rommel
Title: Re: Programing help!!!
Post by: NOOBinDistress on June 11, 2007, 05:59:16 PM
Alright thanks. I will try that out when my board is ready... Also Can you use a rs232 thingy and will that be able to do the same task?
Title: Re: Programing help!!!
Post by: NOOBinDistress on June 17, 2007, 08:00:30 AM
one more question.... should I try to buy a book that may teach me how to make a source code like this or meybe one that already has one... Thnks.
Title: Re: Programing help!!!
Post by: Admin on June 19, 2007, 06:28:23 PM
Quote
Can you use a rs232 thingy and will that be able to do the same task?
The rs232 thingies are for transmitting data to and from your PC.

Quote
should I try to buy a book that may teach me how to make a source code like this or meybe one that already has one
I recommend both reverse engineering source code as well as buying a book and/or reading tutorials on C programming (search this forum for both).
Title: Re: Programing help!!!
Post by: NOOBinDistress on June 19, 2007, 06:45:27 PM
b4 I do so which one of those is most worth while to learn about... I want to know which to start with if I m using avr...
Title: Re: Programing help!!!
Post by: Eco19R on June 19, 2007, 07:05:05 PM
I am not sure if you know all the steps from writing a program to inputing it into the MCU - so here they are


1. Write a program, to do that you need a compiler that creates code for the MCU you are using - ( I use PIC chips and I like Pic Basic Pro - it does everything I need it to do and its fairly simple which is a good thing).

2. Compile the program once its written using the compiler you have.

3. Program the MCU using a programmer that is capable of programming the MCU you created the program for. (I use Melabs USB programmer which I purchased from them for 100$ which works with most PIC chips)

So if you have extra cash (400 dollars worth) I would recommend you purchase Pic Basic Pro along with the USB programmer if you want to use PIC chips - it will all work together and has been tested many times before. - I am sure admin can direct you to the correct Compiler and Programmer for AVR chips 

http://www.melabs.com/


Title: Re: Programing help!!!
Post by: NOOBinDistress on June 19, 2007, 07:24:48 PM
yah umm... right now 400 bucks sound like alot :o! I might back away from that offer for a little while ;D
Title: Re: Programing help!!!
Post by: Eco19R on June 19, 2007, 07:45:50 PM
The process is the same no matter what  Compiler and programmer you use
Title: Re: Programing help!!!
Post by: Admin on June 19, 2007, 08:09:35 PM
CCSC is a much cheaper C compiler and I highly recommend it . . . but its still kind of expensive . . .

I would recommend just using AVR cause compilers are free. (search the forum about it)
Title: Re: Programing help!!!
Post by: sotu on June 21, 2007, 01:30:22 AM
Do you have the microcontroller for the robot yet?
Title: Re: Programing help!!!
Post by: NOOBinDistress on June 21, 2007, 08:47:25 AM
No but I have the parts to make another 50 buck robot board I was hoping that would work.