Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
Time = clockGetus();
What is the maximal value of the Axon clock?
Though it seems it should be around 7 minutes, not the 50 something you are getting.
webbot, did you update that page? I swear it said something else at work.
I noticed the page update as well. I'm still dealing with a problem, which is a bit of a special case and only occurs when the clock resets. I will try to explain the special case and my solution for it in pseudo-code.The special case:Timer1 = ClockGetus (when the clock is near the it's maximal value)Execute instructions (i.e. time is spent)Timer 2 = ClockGetus (after the clock has reset)Interval = Timer 2 - Timer 1 (becomes a large negative value)The only way I can see around this is to add an if statement, to check if the clock has not reset. In the case that it has, the Interval value has to be adjusted. My proposed solution:if Timer 2 > Timer 1then Interval = Timer 2 - Timer 1Else Interval = (ClockMaxValue - Timer 1) + Timer 2And the correct ClockMaxValue is 4,294,967,295 microseconds.
I think that I understand what you mean by the values being hexadecimal and the result of the subtraction being positive. That is fine, but how do I declare my variables. Currently, I've declared Timer1 and Timer2 as floats. I don't understand this TICK_COUNT variable type, nor can I find any reference to it.
Its called 'The Power of the Internet' When someone reports a documentation issue - it gets fixed !
Unfortunately, I've looked into RTCs and none that I've found have resolution under a second: I need more than that.
#include "hardware.h"//Declaring and initialising the timer variableTICK_COUNT StartTimer = 0;// Initialise the hardwarevoid appInitHardware(void) { initHardware();}// Initialise the softwareTICK_COUNT appInitSoftware(TICK_COUNT loopStart){ return 0;}// This is the main loopTICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { // -------- Start Switch/Button------- if(SWITCH_pressed(&button)){ // pressed } // To test if it is released then if(SWITCH_released(&button)){ // released } // -------- End Switch/Button------- // -------- Start Marquee------- Writer old = rprintfInit(marqueeGetWriter(&marquee)); marqueeSetEndDelay(&marquee,0); // Make sure we are in one-shot mode if(marqueeIsActive(&marquee)==FALSE){ if(loopCount==1){ //Displays the name of the program on the 7-segment LCD rprintf("DataAcq2\n"); }else{ //rprintf("Loop=%u\n",(unsigned)loopCount); // Put the loop count } } // Restore rprintf back to its previous location rprintfInit(old); // -------- End Marquee------- //declaring interval variables TICK_COUNT EndTimer; TICK_COUNT NewTimer; TICK_COUNT Interval; //declaring accelerometer variables float Ax; float Ay; float Az; //Read all sensor values //assign accelerometer values //assign gyroscope values //Get timer final value in microseconds EndTimer = clockGetus(); NewTimer = clockGetus(); //Calculate interval duration in seconds Interval = (EndTimer - StartTimer)/1000000; //Get initial timer value in microseconds StartTimer = NewTimer; //Output interval in seconds rprintf(","); rprintfFloat(7,Interval); // I know this line is wrong. return 0;}
rprintf("%lu",Interval);
#define RPRINTF_COMPLEX
I used project designer with the Axon template to generate the source code. I'm unsure which version. Is there an easy way to check?