01-04-2011 08:33 AM - edited 01-04-2011 08:34 AM
Remember the en masse operations I talked about?
Well, use that to your advantage.
Simply take your array of angles, as read from the device, and subtract the "zero" point from the whole array.
Example: If your array of angles is [ 28.1, 29.3, 30.2, 30.9, 31.8. 32.7 ]
And you decide your "zero" point is 29.3, then subtract that from the array, which gives you another array:
[ -1.2, 0.0, 0.9, 1.6, 2.5, 3.4 ]
Now you have the angles in "normalized" form, relative to the start of the pad.
If you're careful, you don't need to zero the stage before a reading. The only "gotcha" is where 359 wraps around to 0.
If your hardware will rotate continuously, then your angle will wrap around, and you need to detect the sudden change (359-->0) and have an "adder" term of 360 that you add from then on.
That is so that the angle will go from 350 - 440 or something, and your arithmetic will still work.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-04-2011 08:42 AM
Yeah, that's basically the idea I tripped to right after I hit "Post". I don't have to worry about >360 degree rotation at the moment, or at all, I don't think. All of these parts (that I know of, anyways) are not full circles, they all have an open bore.
Thanks a lot for your help, I really appreciate it. For some reason arrays and array operations really bake my noodle. No idea why, but these types of problems end up taking me much longer than they should. I'll let you know how this turns out.
01-04-2011 09:00 AM
I don't have to worry about >360 degree rotation at the moment, or at all, I don't think. All of these parts (that I know of, anyways) are not full circles,
It's not the part I was referring to but the stage.
In my mind it would be better to avoid the "zeroing" operation, and tell the user to plop the part down anywhere.
But that might happen to span the 359--> 0 mark on the stage.
You can handle it if you're looking for it: just have the ADDER variable, initially zero, and always add it to the angles.
Go thru the angles and if you see a transition from large (350+) to small (<10) then add 360 to the ADDER and keep going.
That removes the sudden step from your angle array and your arithmetic still works. Your ANGLE array might go from 350 to 550, but you don't care - you're going to normalize it to zero anyway.
Blog for (mostly LabVIEW) programmers: Tips And Tricks