New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using two optical flow sensors simultaneously #228
Comments
Looks like we're lacking on the documentation front here. The line: flo = FlowSensor() Can take arguments to specify the SPI bus. You can - in theory - connect multiple sensors to the same SPI bus and nominate a different chip-select pin for each. If you keep the default SPI bus, that's as simple as (the below are the pins for the Front/Back slots on Breakout Garden): flo1 = FlowSensor(cs=17)
flo2 = FlowSensor(cs=22) You can specify different SPI pins altogether if you're wiring directly to a different bus: flo = FlowSensor() Is equivalent to: flo = FlowSensor(
cs=17,
sck=18,
mosi=19,
miso=16,
interrupt=20
) |
Awesome, thanks! I'll look forward to testing it out and let you know how it pans out! |
As long as the chip-select pins are different you should be getting results from each sensor in turn, with no need to provide different SPI pins. This assumes the chip-select behavior is implemented correctly in our library, of course 😬 What results are you seeing running the two sensors? Is there anything else to your "TypeError: can't convert" error, it looks cut short? It might be related to this line:
I've ran into problems recently using an inline The pimoroni-pico/micropython/modules/breakout_paa5100/breakout_paa5100.cpp Lines 52 to 126 in 665ed08
If there's one argument it assumes you're supplying a "slot", ie: |
SO FAST! Thanks, that's amazing support!
The Traceback (most recent call last):
File "<stdin>", line 37, in <module>
TypeError: can't convert � to float I also tried supplying flo = FlowSensor(
cs=17,
slot=BG_SPI_FRONT
) ...but in return I get: Traceback (most recent call last):
File "<stdin>", line 11, in <module>
NameError: name 'BG_SPI_FRONT' isn't defined |
Also, brief side question; is there any way of turning off the PAA LEDs when not running the script in the REPL? They remain on after stopping, and when I try restarting the script, they blink briefly and then remain on. |
There seems to be a maybe possibly undocumented way to control the LEDs but it's unimplemented in this library at the moment. See: pimoroni/pmw3901-python#4 Looks like we don't define You can add them at the top of your code like so for now:
Note that they include the chip-select pin, so I think the init is just: flo = FlowSensor(
slot=BG_SPI_FRONT
) That cryptic |
Haha, brilliant! The Traceback (most recent call last):
File "<stdin>", line 37, in <module>
TypeError: can't convert tuple to float I think the reason I might have a bad feeling about the readings comes down to implementation - and they are definitely off for the back sensor. Currently I'm testing with: while(True):
delta = flo1.get_motion()
delta2 = flo2.get_motion()
if delta is not None and delta2 is not None:
x = (delta[0] + delta2[0]) // 2
y = delta[1]
z = delta2[1]
tx += x
ty += y
tz += z
print("A Relative, rel: x {}, y {}, z {} | Absolute: tx {}, ty {}, tz {}".format(x, y, z, tx, ty, tz))
time.sleep(0.05) The front sensor seems much more sensitive - I guess because I run them sequentially and it's first in line? Do you happen to have an idea of how it could be achieved to |
Hi @Gadgetoid - just a quick follow-up, do you know when you'll have time to look at this? Just trying to figure out if I should be looking for an alternative hardware solution. :-) |
Oof, the last couple of weeks have been chaos and I'd lost the plot here sorry. I'll try and expedite this! |
If you're logged into GitHub you can download a possibly fixed build here - https://github.com/pimoroni/pimoroni-pico/actions/runs/1994051353 Grab the version applicable to your board, or just "pimoroni-pico-7d39788b73a244077495793c27f5673aae281ff1-micropython.uf2" if in doubt. |
Was about to comment no worries - but wow, that was proper expediting! Really appreciate it! I'll give it a spin tomorrow and report back🤞🏼 |
Tested out, and it seems to have solved the issues. 👍 |
Whew truly a lucky coincidence I’d encountered this issue! I’ll get it merged and released post haste. |
PAA5100/PMW3901 Fix default float argument bug for #228
I am really excited that the optical flow sensors (PMW3901 & PAA5100) are now supported on the Pico. I was wondering if it is possible to use two sensors simultaneously? The "normal" PMW3901 library lets you set arguments including slots and ports, which opens the option of having 2 sensors recording simultaneously which I've used before, but it's not clear from the Pico example how to achieve this. I'm not a wiz' in
.cpp
, but it seems that it might be possible from the source code, but I'm not sure how. Any ideas?The text was updated successfully, but these errors were encountered: