Electronic protoglaz on the microcontroller v.1

Hello, Community! The article is a classic "bicycle", but for beginners in electronics and robotics it may be interesting.

As you know, the smallest and simplest robotics are now being assembled on Atmega or STM microcontrollers. Here in the article, I basically do not take the level of mini-computers like Raspberry.

In robotics, in addition to movements, it is necessary to do at least an assessment of the surrounding space. So - the optical raster sensor for simple MK I did not come across. The popular “line sensor” is not that. A search for Hiktaims and similar resources gave links to video cameras, but they are too fast for simple MCs and one article about using 8 pcs. LEDs as photodiodes.

image

Therefore, the idea was born to make a primitive raster sensor - a proto-eye, by analogy with the first living organisms. Everything that is written below was done by me only for my own entertainment, with minimal costs and practical application was not supposed. Albeit a bicycle again, but with respect to Nipkov and the fathers of mechanical television.
Details under the cut ...

There was one BPW85C photo transistor available. It is logical that you can make a scanner-radar with it focusing the light on the photosensor.

Option 1


For focusing, you can use a rotary parabolic mirror, and place a fixed phototransistor in focus. I did not have a mirror, but there was a flat leaf of tin. For 3 hours of work with my hands it turned out a mirror with a size of 10 kopecks and almost parabolic shape.


Parabolic mirror. It is difficult to take a picture of the mirror))

After assembling the rotary installation, it was found that the light falls not only from the mirror, but also from all sides. The sensor does not close the screen, as it closes and most of the review. I had to refuse.

Option 2


To focus use a collecting lens, collecting an analogue of the camera.

The lenses of the required diameter (12 mm) were not found, I also had to make my hands from a compact disc (there is plastic with good optical properties). Yes, it is a harsh childhood, wooden toys. It turned out that the focusing is acceptable, the focal spot is even smaller than the phototransistor crystal.

View of the lens

Rotary installation - on a miniature 15mm stepper motor. Belt downshift from the same series - "out of nothing." The angle of rotation left and right is about 45 °.

General form

The stepper motor through the driver A4988 is controlled by the MC Amtega328P. The half-step mode is used, and for each half-step a signal is read from the ADC of the MC. Before the ADC, there is still an amplifier on the transistor, because the signal of the phototransistor is weak. The received data without processing is immediately transmitted via RS-232 to the computer. On the computer already built light diagram.

General form

Total: while lower case scanning. The resolution of 320 lines when reading, the real resolution is difficult to measure, on the test with one point light source it turned out 6/320, that is, approximately 53 lines per raster.

But this is the first model, the second (for 2D) will be in the next article.

Tests:



Test for different lighting. The green diagram is the voltage level on the ADC, the black and white image is the result of the signal conversion that the MC sees.


Test single point. The actual resolution is about 53 lines.


"Shooting" of three finger-type batteries on a light background

The speed of "video" 4 frames (cycle) per second and is determined by the capabilities of the SM. For a hypothetical use (?) In the simplest robot is enough.

The main thing is that video shooting takes up little of the microcontroller's resources; there are still opportunities for other actions and even for image recognition, if necessary.

There was another attempt to make AGC (auto exposure), but the gain turned out to be too nonlinear. On the operational amplifier can be done in the following versions.

Sources:

Archive with source codes for CodeVisionAVR and VBasic 6 receiver



Alexander

Source: https://habr.com/ru/post/411227/


All Articles