Hello everbody,
I wrote a program to export the X and Y position of an object with an arduino uno. The X and Y positions are transformed to two PWM-signals. These PWM-signals can be transformed by a simple RC-filter (1000 ohm; 4,7µF). I am not sure if the R and C-values are optimal. Still have to test this RC-filter (tried with 10000 ohm and 10µF but than the transient time is a little long). These analogue voltages are suited to be used by a PLC (Programmable Logic Controller). In the attachment you can find a picture that explains the RC-filter.
I made two programs: “pixy_1_object.ino” and “pixy_2_objects.ino”
In “pixy_1_object.ino” I assume pixy is trained to detect an object of one specific colour. And I also assume there is no more than one such object in the image. If such and object is detected pin 8 is high and the position is outputted as a PWM-signals at pin 3 and 5. This program has been tested and works.
In “pixy_2_objects.ino” I assume pixy is trained to detect objects of two specific colours. And I also assume there are no more than two such objects in the image (one of each colour). If such and object is detected the position is outputted as a PWM-signals at pin 3 and 5 and
a digital output (8 or 9) tells what object it is (what coloursignature). I have not been able to test this program fully.
I noticed that it takes about half a second for the analogue values to change when objects are moved. This is a little bit slow and due to the “slow” arduino uno. It would be interesting to use an arduino due and export the X and Y position directly as analogue voltages (at DAC0 and DAC1). Unfortunately the Pixy.h class doesn’t work with the arduino due (has to do with the SPI-communication). Should anybody solve this problem, please let me know.
Have fun with Pixy,
Bart