Hi Micael!
On 16.10.2025 14:16, vespaman wrote:
[...]
> I think you'd have to use the settling feature to take this into
> account...
>
>
> Sorry, I don't understand - what do you mean by that?
>
I mean one of the methods to make sure the camera image is stable before
it is used for bottom vision. One is a delay which you could use to make
sure the light is on and the camera has adapted to it.
> Did you tried to configure the light as digital output? Does
> it switch faster then?
>
>
> I have not tested, no. But I can see in the code that it takes more time
> with the sw pwm vs the digital pin (which is done directly). In my case,
> I don't really use pwm on up light anymore, so I could switch to digital.
> My up light still takes 30us to switch on in hardware though, since I
> use a constant current generator. But i could easily add a delay before
> sending back 'ok'. The 'ok' also takes a few us.
> I can try that, and if this turns out OK, I'll leave light control as is.
> In the controller, the problem could also be fixed by delaying the "off"
> by e.g. 100ms, then it will receive the new "on" before going off. But
> this is also a bit of a workaround.
>
Ok, even with digital it might fail. If the light is switched while the
sensor is taking an image, this image will get distorted. With rolling
shutters this is always the case, so a delay of a full frame is required.
> Do you see a glitch in the image if you switch
> the light off and on while taking a picture?
>
>
> As it is now, first image (first nozzle) is always OK (of course), then
> it switches light off, switches light back on, and take the snap for the
> second nozzle, then light is off again. Second image is always totally
> black.
> This makes part detection fail, and a retry is issued; light on,
> capture, (black image result) and repeat. After three tries, we get the
> "No result found" exception.
>
That's what I'd expect if settling is not configured correctly for the
second camera/image: the first has some settling which works, but for
the second, there is no motion and hence one might think that no
settling is required. But in fact the switching of the light affects the
image and hence settling is required for compensation.
Your idea to keep the light on is probably the best, but also requires
extra work as the light is currently controlled by the camera itself.
You might wont to check the vacuum pump handling: there are features
like delayed switch off that could be useful here too. It somehow tracks
the number of nozzles that require vacuum and only switches the pump off
if it is guaranteed that its not needed anymore.
> I am actually not sure about when the openCV image is taken, it might
> well be the last buffered image that is returned, so that would mean
> that the light have to be on for at least one frame time (~9ms in my
> case) prior to the call, to be sure.
>
Image capture is part of the pipeline. It just requests the next image
from the camera. What ever "next" means in this context... There is also
some image capture as part of some of the settling methods which are
outside of the pipeline. (Side note: I once tried to put bottom vision
processing into a dedicated thread which fails because the image capture
requires exclusive access to the "machine" which is not available if the
machine thread forks a bottom vision thread. If at the end of your
improvements the image capture is relocated outside of the pipeline,
this would provide new opportunities...)
> > 2. The best way (IMHO) to deal with this, would be if there's a
> way to
> > peek forward to the next step in the job processor, to see if the
> next
> > step is also 'align', and if so, not switch off the up light in the
> >
> I'm sorry, I don't think that's possible.
>
>
> Ah, that's a pity.
>
The camera light is (usually) a property of the camera and hence switch
on and off by the camera as needed. If you have two cameras sharing a
light, you either get what you reported (its switched of by one and
immediately on by the other) or you have to bind the processing to some
other events. However, make sure to keep the functionality for features
like test alignment.
> > 3. Another way would be to always switch the up light off in the
> > placement steps.
> > But this is not so nice (IMO), since it is not symmetric with the
> switch
> > on. And also would leave the light on, on discard cycles etc.
> >
> That shall work. You'd need to find all possible routes after bottom
> vision to safely switch the light off.
>
>
> Yeah, I think this will work, but I think it will have a cost on the
> readability of the code, and maybe introducing bugs here or there. So
> maybe better to focus on fixing this in the controller.
> If there's more people going for multi bottom vision going forward, the
> light could also be kept on during the job. But on my machine it is
> rather irritating, since the camera is very close to the operator.
>
You might add that using scripting: switch the light on using
Camera.BeforeSettle and off at Job.Finished. In addition you could
switch it off at Vision.PartAlignment.After if you make sure its the
second bottom vision operation. This would keep the lights off as much
as possible.
> Regarding the rest, would you say that the changes I have made so far
> (functionality wise), could be good enough for me to start wrap things
> up for submitting a PR, or do you think UI elements or anything else are
> needed?
>
Starting a PR is always a good idea so that others can view/help what
you did. It also clearly indicates what changes you're proposing. A PR
is only fix if it has been merged. Until then you can change it as you
like incl. adding new stuff, rewriting stuff, reverting changes, even
reorganizing the entire PR is possible (GitHub still records the
operations as part of the PR's documentation but they do not appear in
the repro after merging).
I'd suggest to partition your changes into multiple small PRs rather
then one large which are easier to understand and quick to merge.
Jan