Shop OBEX P1 Docs P2 Docs Learn Events
Time for running a program — Parallax Forums

Time for running a program

gonweigonwei Posts: 14
edited 2006-12-11 07:00 in Learn with BlocklyProp
Hi,

Can i ask how·can i get the information of how much time is used to run the whole program?

Thanks in advance! smilewinkgrin.gif

Kevin

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-21 21:13
    Hello,
    ·
    ·· Without knowing the nature of the program that would be hard to answer.· Most programs on an embedded controller never end.· They continuously run in a loop so there is no end, per se. ·If you have a very short program that runs a calculation, you could gauge time by making a pin go HIGH, then at the end of the program LOW and see this on a scope.· If the program runs for more than a few mS though you would probably need an RTC.· It really depends on the program.· What does it do?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Steve JoblinSteve Joblin Posts: 784
    edited 2006-11-25 15:51
    can't you just calculate it based on how many instructions are in your program?· Remember that remark statements are not tokenized, so they don't count.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-11-25 16:12
    If you have a O-scope or a multimeter with a frequency counter on it, you could use an output bit and toggle it, then measure the pulse duration or the frequency with a meter.

    Also, you can use StampPlot (lite or Pro) to send a byte of data ( DEBUG DEC 0,CR), and have it log the time to hundreths of second. Then look at the logs to see the interval between them.

    Counting instructions doesn't work because each instruction takes a different amount of time. This isn't assembler [noparse]:)[/noparse]

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • gonweigonwei Posts: 14
    edited 2006-11-26 07:30
    Thanks for all the replies. Appreciate them!

    My program·should be·running in loops continuously. I need the information of the time needed to run one single loop so that i can get its frequency. What the program will do is it will obtain sensor data and do calculations and output a 6-channel PWM to a transmitter via trainer port to control a remote control car. I can foresee that my entire program will hav more than 50 lines of instructions. As i know,·duration·of a·PWM is about 20ms, each pulse varies from 1-2ms. Has anyone foresee any problem, e.g. the·signal·update rate? Please let me noe your valuable opinions, any comments or opinions or ideas are most welcomed!!

    Kevin smile.gif
  • gonweigonwei Posts: 14
    edited 2006-12-11 03:17
    is there anyone who can lend me a hand with the problem as mentioned above?

    Thanks in advance!!

    Kevin
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-12-11 07:00
    Kevin -

    Martan has given you the best answers available just above. Short of doing it by that fairly exacting method, I suppose you could estimate it if you wanted to go through the time and trouble of examining exery instruction that gets executed, and sum all of the individual instruction times used in the loop(s).

    Martin's method is far more exacting, and permits simple re-measurment if the program changes any.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.