![]() |
Re: sleep()
im sorry that i have to reiterate this, but you CAN NOT stop the program code from looping! no matter if it is with a non exastant "wait()" command or a for loop that devides PI by 100 million 50 thousand times, dont do it! it is much better, and perhaps the only viable solutuion, if you count the loops rather then trying to stop in the middle of one. each loop is ~26 ms. its not that hard to make 1 variable. comon guys.
|
Re: sleep()
It's not that, it's that the main loop has different iteration times depending on what is executed. Besides, It'd be so much cooller if we got it to work.
And like I said, just put calls to putdata and getdata in the loop. |
Re: sleep()
Quote:
Getting back to the original focus of this post ... why do you want a sleep function? If you post the reason for your request for a sleep function, you'll probably get much better help. |
Re: sleep()
if your going to the point where the diffrence between 23 and 26 ms matters, then use a timer inturupt. this is not a basic stamp lol
|
Re: sleep()
Any wait/pause code is the basis of a DriveForTime() Routine
|
Re: sleep()
Quote:
|
Re: sleep()
Quote:
Code:
if (time_from_start < time_to_drive) { put code to drive here } |
Re: sleep()
Although there are easy ways to make the processor "pause" or "wait" as described above, they are probably not the best way to implement this function on the IFI Controller. The Master processor expects to receive a data packet from the user processor every 26.2ms.
This means you cannot pause the controller for longer than 26.2ms at a time and still have the control system function. The best bet is to increment a counter every time a new data packet is received from the master processor. If you need finer control than that, use a timer interrupt. |
Re: sleep()
Quote:
Code:
while (1) /* This loop will repeat indefinitely. */One reason a delay might be useful is to reduce the frequency of calls to Generate_Pwms(). See the reply from Kevin Watson to the post mentioned above. -Norm |
Re: sleep()
Ive been wanting to scope the loop myself, but havent got to it yet- thanks for instrumenting your RC.
One thing I have not been able to figure out. The main loop looks for new input from the OI, and if it doesnt see it, it call the user_fast code I dont see anything in the fast code to throttle it back - can you put your toggles at the beginning and end of the fast section and see how fast it runs with your scope for us? I thought they said it runs every 4mS or so, and you have to be carefull not to overwhelm the pwms by changing them too fast - I also think you cannot do a get_analog_value... too quickly either? but does anyone know - is the fast code loop timed by some event (the get or put data maybe?) and is its period consistant? BTW - if you are looking at timing be sure to comment out all your printf statements - there seems to be a whole library of code behind them, I think they will make a drastic reduction in your loop speed. |
Re: sleep()
Quote:
|
Re: sleep()
Quote:
|
Re: sleep()
putting debug statements in code is a significant change to its content.
HW guys have it even worse - Every HW engineer I know can tell you about some circuit they worked on that they were testing with a scope, and as long as the scope was connected, the circuit worked, but when you remove the probe it stopped working all due to the slight capacitance of the probe altering the circuit they were trying to see. |
Re: sleep()
Quote:
Quote:
That took me a little time to figure out. The fast code (Process_Data_From_Local_IO()) is called every loop of the while(1) loop. The "slow" user code is called in addition very occasionally in the while(1) loop when new data is ready (if (statusflag.NEW_SPI_DATA) ). Quote:
...I was doing integer division in a few places in my joystick calculations and I was worried that my code was too slow, but was relieved to see that it runs in only 4 ms. Whew! |
Re: sleep()
Don't worry - for the most part, integer division is just fine. It's only when you get into floating-point numbers that math operations start to kill you.
|
| All times are GMT -5. The time now is 15:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi