| | why doesn't this work?
|
|
I've written a program to record the timing of a rotation sensor changing in an array, but all I get out is zero's and the occaisonal 1 or 4. I've checked several things but can't find any obvious problem. The program compiles and runs perfectly and (...) (20 years ago, 30-Nov-04, to lugnet.robotics)
|
|
| | Re: why doesn't this work?
|
|
(...) What is the value of inc when you're done? And, is SENSOR_1 defined as a rotation sensor? (and active?) Steve (20 years ago, 30-Nov-04, to lugnet.robotics)
|
|
| | Re: why doesn't this work?
|
|
(...) 2000 (...) Yes (it shows up fine on the watch graph) Steve here's the whole program #define TRUE 1 #define FALSE 0 int Vvariable; int Aforward=1; int speed; int maxspeed=0; int timeout=0; int array[27]; task main() { //start speedcontrol; (...) (20 years ago, 30-Nov-04, to lugnet.robotics)
|
|
| | Re: why doesn't this work?
|
|
(...) I think that means for the first 27 times through the loop, the value for SENSOR_1 changes every time. So all the values would be 0 or 1. Instead of storing the timeout, try creating a seperate counter that's incromented each time through the (...) (20 years ago, 30-Nov-04, to lugnet.robotics)
|
|
| | Re: why doesn't this work?
|
|
(...) Your exactly right, the results are a sequence 1-20, meaning that it takes 20 sensor changes to go from full speed to stop. The rest of the array is zero's as it should be, so the program works perfectly. I'm amazed though that the rotation (...) (20 years ago, 30-Nov-04, to lugnet.robotics)
|
|
| | Re: why doesn't this work?
|
|
(...) That doesn't totally seem right. I would think it would slow, before stoping. One last thing to try is actually storing sensor value in the array. Also, in the Checkvar function, it looks like the line: if(temp<27) temp=0; should say (...) (20 years ago, 1-Dec-04, to lugnet.robotics)
|
|
| | That doesn't totally seem right.
|
|
(...) That occured to me after my last posting, but I can't think why it wouldn't slow. (...) Yes, your right. I've switched to the 10x Swan firmware, and stored the results in the datalog. Here they are Variable 4: 4 Variable 4: 0 Variable 4: 3 (...) (20 years ago, 1-Dec-04, to lugnet.robotics)
|
|
| | Re: That doesn't totally seem right.
|
|
(...) If you're storing this all in the datalog, you should be able to go much farther than 27 times through the loop. Try storing a couple hundred values (how big is the datalog?) Then, you should see the time-between-changes get bigger. Also, it (...) (20 years ago, 1-Dec-04, to lugnet.robotics)
|
|
| | Re: That doesn't totally seem right.
|
|
(...) The datalog was 27 but is now 100 (I was pushed for time earlier). (...) That's exactly what happens now. (...) I can now see that the zero's fade over time. Here's the latest results. Variable 4: 1 Variable 4: 5 Variable 4: 0 Variable 4: 4 (...) (20 years ago, 1-Dec-04, to lugnet.robotics)
|