0
\$\begingroup\$

I'm hoping that this question doesn't come off as too general/opinion based, and will attempt to focus it.

I recently completed a project for a rocketry competition in which we controlled a pan/tilt camera on the bottom of a lander ejected from a rocket. We had to control the camera to aim at targets on the ground, image them, process the images and identify the targets by color. We used two servos (pan/tilt), a GPS module, and a 10 DOF board(Gyro/Acc/Temp).

The approach we took was to use a Arduino to handle the pan/tilt, the GPS, and the 10DOF board. This was communicating with a raspberry pi via I2C and acted as the master while the Arduino was the slave. The pi handled the image taking and processing.

In doing this, we had issues with the overall memory usage on the microcontroller(the code for the pan/tilt was quite intensive) and being able to get all the needed data from the different sensors and communicate it back to the Pi. We used interrupts and tried to optimize the code as efficiently as possible.

My question is, for projects like this where there are many sensors and a lot of processing, is it in my best interest to make up a custom board with separate atmega328's for each sensor(or at least one for sensors, other for logic)? If so, is I2C the recommended protocol to be used?

As I work on a lot of computer vision type projects where I will need to use a PI or other computer to process the images, and also be able to obtain sensor data and calculate quicker than the Pi can handle, a elegant and fast solution to this would be much appreciated.

Thank you

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

You basically have two choices.

  1. Select a more capable controller device that has the functionality and memory you need.

or

  1. As you intimated, break up the system to use multiple controllers.

The latter of course requires a bit more development and is harder to maintain, but it does buy you the ability to modularize the design so one micro can do one job really well as opposed to sharing resources in a big single device. Once that sub-system works, you can rely on it to continue to do so when you add different micros for other sub-systems.

You may not need one micro per sensor though. Consider grouping "like" functions into separate micros, if they fit.

If you go the multi-micro way you also have to come up with some form of a communication protocol between those and whatever is acting as the supervisor device.

That could be I2C or some other true communication method. It could be as simple as a few logic lines to force the sub-ordinate processor to enter some state or do some task, with reciprocal return signals or interrupts. It really depends on the functionality required.

Whether you make up your own board, or stack a deck of Arduinos is up to you. There is some investment required if you go the custom route, with a definite possibility of having to go round a few design loops.

However it also sounds like you probably have a tight space limitation so a big stack of Arduinos may be out of the question. However, if you want to stick to that micro, the stack would probably be the best bet for the initial proof of concept development. Once you prove the system works, then you can think about tight integration.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you very much for your detailed response, good to know I was on the right track. Yeah space/weight is definitely an issue so multiple arduino's wouldn't work. What would be an example of a more capable controller? \$\endgroup\$ Apr 10, 2017 at 12:00
  • \$\begingroup\$ @KyleHunter Re example, I'm afraid I am not the best person to ask that question. I'm retired now, so my knowledge of what's the latest and best CPU is rather dated. Perhaps someone younger will point you in an appropriate direction, though that is frowned upon in here. \$\endgroup\$
    – Trevor_G
    Apr 10, 2017 at 18:08
0
\$\begingroup\$

I'd suggest that you took the right approach for low speed data by having the cameras on the 'Pi and the Arduino for the sensors.

I'd further suggest that you should consider multiple ATMega328's for your sensors. This will significantly reduce the software development time, codebase size (memory pressure) and any process interaction problems/bugs that might occur. Minimizing the number of interrupts handled in each micro is also beneficial, especially if you are using sleep states to reduce power. Within each Arduino you can disable peripherals you don't need to reduce the power for each processor if that is a concern.
Providing that your data rates from sensors is low I2C is ideal with multiple Arduinos as slaves.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks a lot for your input! If the data rate happens to be high, what is a faster protocol that I2C? \$\endgroup\$ Apr 10, 2017 at 12:01
  • \$\begingroup\$ Your I2C limit is 400 kHz (or KBaud) on the Raspberry Pi and the actual data rate is of course not efficient since you send Address and Command bytes for each data byte (or multiple). If you want to go faster then you can use the SPI 4 wire interface (data efficiency higher than I2C), that works well with clock rates of 1, 2, 4, 8, 16 MHz (there is a 32 MHz rate, but many report errors, most probably poor track layout). Now the ATMega328 is only guaranteed to work at Fosc/4 when an SPI Slave, so for a 16 MHz clock ...4 MHz is your limit. \$\endgroup\$ Apr 10, 2017 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.