You should also try to avoid doing anything else but the absolute
necessity in your loop.
I think you can write a second routing dmm.getBusVoltageFast(), that
does nothing more than the absolute necessity, which is reading the 2
bytes from the INA219. No conversion or anything else needs to be done
at his stage, just read the 2 bytes and square them as quick as you
can.
You could optimize your routine like this:
for (int x = 0; x < 1000; x++){
//sum += sq(dmm.getBusVoltageFast());
}
Nothing more, just that because anything else you put there is going
to be done 1000 times and chewing up time. Making
dmm.getBusVoltageFast a local procedure will also make it faster to
call than a procedure of an object. Writing it as z=getBusVoltageFast;
z *= z will most likely also be faster than sq(getBusVoltageFast), try
it out!
I think you can get double the speed if you optimize it properly.
You don't need to check the state of the encoder 1000 times per
second, just once or twice a second will be just fine.
Michel
--
You received this message because you are subscribed to the Google Groups
"neonixie-l" group.
To post to this group, send an email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/neonixie-l?hl=en-GB.