<< return to Pixycam.com

getBlocks(false) - Still taking way too long - Why?

hi all,

I was also struggling a bit with getBlocks(false) still seeming slow (I need a very fast loop() execution). then I came across discussions about how the builtin Wire library is not fully non-blocking… and played around with nI2C or non-blocking I2C: https://github.com/nitacku/nI2C. that worked out rather well, and my loop() is now much much faster (though to be honest, I may not have used the Pixy2 library correctly; OTOH, I really like it if everything is non-blocking… :P). here is an simple sketch that I made today to call getblocks on two pixies: https://github.com/srepmub/tacovr.

thanks, cheers,
mark.

Hello,
Have you timed how long getBlocks(false) takes? A few milliseconds is reasonable.

Edward

hi edward, thanks. I need to call the accelstepper run() functions thousands of times per second, so blocking for a few milliseconds is not that great… I did not know how to measure time before, but using micros() an ni2c read/write call takes about 50 microseconds for me.

Hello,
Look at the source code for getBlocks:

On line 140, there is a delay command to prevent someone from thrashing Pixy with lots of requests per second. You can remove this delay (modify Pixy2CCC.h) and as long as you keep things reasonable with Pixy (no more than a few hundred requests per second). Pixy will then be able to process frames and find objects in a timely manner and you’ll be able to run more things in your polling loop.

Edward