View previous topic :: View next topic |
Author |
Message |
ThanhDan
Joined: 07 Jun 2022 Posts: 19
|
Choosing Microcontrollers |
Posted: Tue Oct 11, 2022 2:19 am |
|
|
Hi I'm choosing a microcontroller for my line following robot project. The robot is basically a small AGV that can carry a 2kg colored package. I need a color sensor to identify the color of the package and a camera to track the line. Based on the above requirements, how do I choose my microcontroller (i.e the sensors feed this much data back in 1 sec and the MCU has this much memory therefore it can handle the data sent back to it...) |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Oct 11, 2022 5:24 am |
|
|
Something like an analog RGB sensor to detect colour would need 3 analog inputs ( R,G,B ). You could use an RGB LED in 'reverse' though it'll take so bench time to get it to work,BTDT prePIC.....sigh that was a LONG time ago....
Providing that the colour 'tags' or boxes are the same distance from the vehicle, you only need to run the 'calibration function' once.
I'm sure there's probably some real fancy 'colour detectors' out there today, even using say a digicamera as the 'input', but as a 'home project' keeping it simple is best. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Tue Oct 11, 2022 7:38 am |
|
|
A 'camera', sounds a very complicated way of doing a line follower.
Normally these are done by a linear array sensor. Much easier to interface
and much simpler code.
If you do want to use a camera, you probably quadruple the amount of
storage space needed in the chip, and may well find it very difficult to
interface to a PIC. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Oct 11, 2022 9:09 am |
|
|
I 'think' he just wants the camera to detect the coloured boxes. If so, dead simple as you can buy a RGB module for <$10 ! I2C interface,so just 2 wires ! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Tue Oct 11, 2022 10:53 am |
|
|
He says: "and a camera to track the line.".... |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Tue Oct 11, 2022 11:51 am |
|
|
PIXY2 camera: https://pixycam.com/pixy2/
I have one, but I never tried to interface it with a PIC. They do offer the code for Arduino and Pi. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Wed Oct 12, 2022 1:04 am |
|
|
That is nice, since you are not dealing with the image. Problem is, even for
very small images, the PIC in general does not have the memory to cope
with images. With that you program the camera to actually do the line
detection. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Oct 12, 2022 5:04 am |
|
|
Do you HAVE to use a camera as the white line sensor ? It's tremendously far more complicated both in hardware and software to be used as a 'white line sensor (wls)' !
One of the simplest wls is a single LED and 2 photo detectors. Only requires 2 analog pins and some simple ADC code. You read the sensors and determine where the white line is. Once properly calibrated, the PIC will be able to follow the line very,very well. You could think of it as a 3 pixel wide 'camera'.
Using a real 'camera', especially any RGB (colour input) requires a LOT of code ,probably beyond the abilities of 99.44% of the current PICs.
If, IF, you can find a camera module that has 'zone' programming, can be turned into a B&W camera, then it 'may' be possible to have a PIC see the white line. Far too complicated when an EASY 'off the shelf' wls is available.
Can it be done, yes... should it be done, no. Unless you have 1-2 years to devote to this one task. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Wed Oct 12, 2022 7:31 am |
|
|
Pretty sure this is a school assignment Jay. This bit:
Quote: | ...how do I choose my microcontroller (i.e the sensors feed this much data back in 1 sec and the MCU has this much memory therefore it can handle the data sent back to it...) |
Pretty much outlines some pretty good coaching/hints in that assignment.
1. Camera/sensors are fixed. They output x bytes of data per second.
2. Microcontroller should have enough RAM to be able to buffer this much data *AND* be able to do some sort of processing on it.
Figure out the bytes/second, sum that for 1 or 2 seconds, then look for a microcontroller which has at least that much RAM (first instinct is to say it will require 1.5 - 2x that amount of RAM).
QED |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Wed Oct 12, 2022 12:42 pm |
|
|
Still an interesting topic, maybe not for the OP, but for the others.
Most likely it is a school assignment, as Newguy said. If the sensors are fixed (meaning they are provided by the school), they also must have a box of PIC's somewhere that are able to do the job at hand. It is just too hard to find anything that is readily buyable these days (that also fits your needs and one can get in a reasonable time) for the school not to provide those too. If that is the case, that PIC's are already there, it is a non-question. Just grab the fastest and biggest memory wise you can get. Possibly supported by the old MPLAB. Because in that case only your programming will frustrate you, not the environment on top of that.
BTW, as every year in this time, things are slow at work. So I had time to think about the sensors. The one from an optical mouse? For a line follower? |
|
|
ThanhDan
Joined: 07 Jun 2022 Posts: 19
|
|
Posted: Sun Oct 16, 2022 7:35 am |
|
|
PrinceNai wrote: | PIXY2 camera: https://pixycam.com/pixy2/
I have one, but I never tried to interface it with a PIC. They do offer the code for Arduino and Pi. |
Thanks, for your speedy response. Yes, I am using a Pixy2 CMUCam5 for my project since it is readily available in my school's lab. I have used the camera module to track the line by returning the three errors as shown in the figure below. My next mission is to design a controller to drive these errors to zero. And yes I am a mechatronics student at Ho Chi Minh University of technology and this is my fourth year project
[img]
https://drive.google.com/file/d/1fhWlO2ZPc1JJwiHngmdK6eYXK96jWMty/view?usp=sharing
[/img] |
|
|
ThanhDan
Joined: 07 Jun 2022 Posts: 19
|
|
Posted: Sun Oct 16, 2022 7:41 am |
|
|
Ttelmah wrote: | That is nice, since you are not dealing with the image. Problem is, even for
very small images, the PIC in general does not have the memory to cope
with images. With that you program the camera to actually do the line
detection. |
Thanks for your response, I can kinda accept the fact that the PIC does not have the memory to cope with images but can you further elaborate on this? Like what's the math to prove that the PIC wouldn't be able to handle it, let's say we're using a PIC16F877 since my school teaches the subject microcontrollers based on that chip. |
|
|
ThanhDan
Joined: 07 Jun 2022 Posts: 19
|
|
Posted: Sun Oct 16, 2022 7:54 am |
|
|
temtronic wrote: | Do you HAVE to use a camera as the white line sensor ? It's tremendously far more complicated both in hardware and software to be used as a 'white line sensor (wls)' !
One of the simplest wls is a single LED and 2 photo detectors. Only requires 2 analog pins and some simple ADC code. You read the sensors and determine where the white line is. Once properly calibrated, the PIC will be able to follow the line very,very well. You could think of it as a 3 pixel wide 'camera'.
Using a real 'camera', especially any RGB (colour input) requires a LOT of code ,probably beyond the abilities of 99.44% of the current PICs.
If, IF, you can find a camera module that has 'zone' programming, can be turned into a B&W camera, then it 'may' be possible to have a PIC see the white line. Far too complicated when an EASY 'off the shelf' wls is available.
Can it be done, yes... should it be done, no. Unless you have 1-2 years to devote to this one task. |
No I don't and most of the other students are using a row of TCRT5000 (a photoelectric sensor that emits infrared light to detect the black line) so the camera idea is quite "the bomb".
About the code, my team has used the Pixy2 to detect the line and the three errors I have mentioned in my response to PrinceNai: The camera module is connected to an Arduino Uno and most of the line tracking code has already been done for us and available online.
About the photosensors, in my country, the line following robot project has been done many times by students from many intakes. The project is so popular that they sell a PCB of five TCRT5000 sensors just for this purpose in electronics shops. Previously, the students were tasked with a line tracking race car, this year, however, I am given a line tracking color detecting AGV. Regardless, since you suggested the number of emitter and collectors used, do you know why they usually use a row of 5/7 TCRT5000 to do the line tracking task? |
|
|
ThanhDan
Joined: 07 Jun 2022 Posts: 19
|
|
Posted: Sun Oct 16, 2022 8:00 am |
|
|
newguy wrote: | Pretty sure this is a school assignment Jay. This bit:
Quote: | ...how do I choose my microcontroller (i.e the sensors feed this much data back in 1 sec and the MCU has this much memory therefore it can handle the data sent back to it...) |
Pretty much outlines some pretty good coaching/hints in that assignment.
1. Camera/sensors are fixed. They output x bytes of data per second.
2. Microcontroller should have enough RAM to be able to buffer this much data *AND* be able to do some sort of processing on it.
Figure out the bytes/second, sum that for 1 or 2 seconds, then look for a microcontroller which has at least that much RAM (first instinct is to say it will require 1.5 - 2x that amount of RAM).
QED |
Hi, thanks for your response. Your suggestions really helped me with the task at hand, here's what I've found
I'm using a Pixy2 CMUCam v5 which sends block information to Arduino at 1 Mbits/second. This is equivalent to 125kB and the Arduino Uno SRAM is 512kB => Arduino UNO is sufficient for the project?
Actually in the datasheet, they wrote 512/1K/1K/2K Bytes internal SRAM, I don't really understand why there are so many numbers here, which one is it?
[url]
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29
[/url] |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Sun Oct 16, 2022 8:21 am |
|
|
Think about it. Even a tiny picture will be perhaps 192*128 pixels. Even
in B&W, one byte per pixel. Needs then 24576 bytes to hold just a single
frame. The 877 has 192 bytes.....
Even if you have no different grey scales, just a single pixel on/off, a frame
still needs 3072 bytes. Sixteen times what the chip has. |
|
|
|