PDA

View Full Version : [Question(s)] On Bioloid: How did Robotis make the CALLBACK function in RoboPlus Task?



cybernetics
08-09-2011, 01:05 PM
How did Robotis make the CALLBACK function in RoboPlus Task? I've been trying for a while to make a function that executes every 0.1 seconds with atmega2561, but without success. Does someone know how and could share a simple code example please?

Thanks!

tician
08-09-2011, 04:25 PM
To try to make me seem a bit less like a mean little * and put my original post into some sort of perspective. I went to a very large University (~44500 people in all) where, until the last 2~3 years, >90% of everyone (students, teachers, etc.) did not know the engineering department even existed (~500 people in the southern-most academic building on main campus). Learning about microcontrollers was with assembly language on a rather obsolete Motorola 68HC11 dev board with horrible software that deleted all your work when it crashed (this was still only ~2 years ago). Learning about timers and interrupts on the system was essentially: "here's a printout of the relevant pages of the manual, and the originals are on that cabinet over there if you need them. you'll get a little bit of a hint/nudge in the right direction, but figure it out for yourselves. you're big boys and girls^." (^yes, there really are women in the engineering program and they consistently make the guys look like the idiots we are - as if we need any help with that).





It is with 'Timers' and 'Interrupts'. Otherwise, RTFM (http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf).

Why are you in college if not to learn?


alright, a small hint on Interrupts in embedded-c:

SIGNAL(WHATEVER_TIMER_vector_you_decide_upon)
{
a_call_to_your_callback_function();
}

Basically you will: 1) select a timer to use, 2) initialize it, 3) define the function to be called when the code execution jumps to the interrupt vector (a set location in memory that contains the address to another location in memory) (that little bit of code above). Every time the timer's count rolls over or reaches a target value, it will cause the AVR to dump the program counter (and perhaps a few other values/registers) to the stack and begin executing the code at the address located in the corresponding vector. You will also have to make sure that your callback function is small enough to actually complete itself within the 0.1 seconds between interrupts.

Connor
08-10-2011, 10:19 AM
It is with 'Timers' and 'Interrupts'. Otherwise, RTFM (http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf).

Why are you in college if not to learn?


alright, a small hint on Interrupts in embedded-c:

SIGNAL(WHATEVER_TIMER_vector_you_decide_upon)
{
a_call_to_your_callback_function();
}

Dude, That's just a bit harsh. We're all on this forum so we can learn, build and create. I saw nothing in that request that warranted that kind of response. He's not asking us to do his homework.. He asked for examples.

tician
08-11-2011, 11:58 PM
Since my last post wasn't originally very useful...

You will still need to check the manual for using timers (choosing a timer, setting its clock source/clock division value, and enabling the timer's interrupt).


A brief introduction to interrupts from the great and powerful lnxfergy (although it is using some Arduino specific functions)
http://forums.trossenrobotics.com/tutorials/how-to-diy-128/an-introduction-to-interrupts-3248/

All about interrupt functions included in avr-gcc
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

Specific interrupt vector names (you will want the ATmega2561)
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html#avr_signames

A short reminder when dealing with 16-bit timer values
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_16bitio

Another potentially useful reference for a callback function/16-bit values
http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html


A very useful general reference for using avr-gcc
http://www.nongnu.org/avr-libc/user-manual/modules.html

DresnerRobotics
08-12-2011, 11:50 AM
Since my last post wasn't originally very useful...

You will still need to check the manual for using timers (choosing a timer, setting its clock source/clock division value, and enabling the timer's interrupt).


A brief introduction to interrupts from the great and powerful lnxfergy (although it is using some Arduino specific functions)
http://forums.trossenrobotics.com/tutorials/how-to-diy-128/an-introduction-to-interrupts-3248/

All about interrupt functions included in avr-gcc
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

Specific interrupt vector names (you will want the ATmega2561)
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html#avr_signames

A short reminder when dealing with 16-bit timer values
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_16bitio

Another potentially useful reference for a callback function/16-bit values
http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html


A very useful general reference for using avr-gcc
http://www.nongnu.org/avr-libc/user-manual/modules.html

Kudos to you man for bringing this one around, + rep again.

lnxfergy
08-12-2011, 06:34 PM
Yep, +Rep.

Also note, Atmel publishes many appnotes, which cover specific applications of timers on certain platforms.

-Fergs

cybernetics
09-11-2011, 03:09 PM
Thanks for editing your post and for the help. It now works. :)