Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
I just got my AxonII on Friday and this is my first foray into working with microcontrollers. I understand simple electronics and can code fairly competently in C# and java, but am just beginning to muddle my way into C.My problem is transitioning my brain from object orientated programming on PCs to non-object oriented programming on embedded platforms.
This might just be a C thing (learning as I go with the Axon, so I'm as new to C), but why does the appControl() method (which I read emulates/replaces the main() method) end and then get recursively called in the specific microseconds, as opposed to the (traditional main()) method being called once and continuously looping through it's own logic until instructed to end (user closes application/turns off robot).
- Is the appControl() method intented to contain higher level logic, or just device command logic? If the latter, where should the higher level logic code go? - Is the appControl() method meant to execute as quickly as possible, or take however long its supposed to take (like the main() method)?
- What is the TICK_COUNT object and how/why do I use it?
So what I'm wondering is... (keeping in mind this is day 3 into the MCU/webbotlib world):- What happens to events while the appControl() method is waiting to execute again? eg; If the appControl() method is set to execute every 1 second, and an event (user presses onboard button) occurs that is shorter then the cycle time, does it miss the event? (I'm guessing this would be handled by some kind of listening event, but if that's placed inside the appControl() method it not be listening during the wait time before the appControl() method is executed again!)
(just to note, I have tried painfully over the last few days to go through all the webbotlib source c/h files to try and understand better, but due to my inexperience with C, the webbotlib API, and MCU's in general it is all very overwhelming.)
appcontrol() { //acting as main() while (not maze goal reached) //do heuristics //map navigation //and so on // } return 0; //no real point as everything happens in the first call, so you might want to induce an infinite loop before so that the appControl doesn't get called again}