Author Topic: programming code  (Read 2657 times)

0 Members and 1 Guest are viewing this topic.

Offline dellagdTopic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 731
  • Helpful? 5
  • Come to the dark side... We have cookies!
    • Exodus Rocketry
programming code
« on: March 13, 2009, 02:02:08 PM »
is there any way the ATmega8 can multitask?
so it can drive wale taking input from IR LED on both of its sides so when an LED detects something, it will stop and and scan w/ a sonar(just an example)?

sorry I am new to robotics programming and this question is probably noobish.

please help, the science fair is on April 1st!
Innovation is a product of Failure, which leads to Success.

If I helped, +1 helpful pls

I Won!
3rd place! I'm taking $100

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: programming code
« Reply #1 on: March 13, 2009, 02:25:40 PM »
listen....
controlling these  "stuff" takes less than half a second. In reality it is not doing two things at once, but since its going so fast, to the human eye it is doing it all in the same time.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
    • Current projects
Re: programming code
« Reply #2 on: March 13, 2009, 02:36:35 PM »
It depends on what you mean by multitask. I you want to run two task in parallel you can fake it using interrupts. But the atmega8 is a single core processor, it execute 1 instruction at a time so when your IR detect code runs, the driver code will stop.

so maybe something like this would work for you:
- motor driving code in main
- every 500ms check IR LED. Setup a timer to invoke your routine every 500ms but you have to keep this as short as possible since during the execution of the interrupt handler the main code is stopped.

more info about AVR timers: http://members.shaw.ca/climber/avrtimers.html


Offline dellagdTopic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 731
  • Helpful? 5
  • Come to the dark side... We have cookies!
    • Exodus Rocketry
Re: programming code
« Reply #3 on: March 13, 2009, 03:13:42 PM »
ok thanks
Innovation is a product of Failure, which leads to Success.

If I helped, +1 helpful pls

I Won!
3rd place! I'm taking $100

 

SMF spam blocked by CleanTalk