The Planted Tank Forum banner

Micro-controller project

8684 36
I've been lurking on here for a long time now so i figured it's about time to post something :)

I have started working on a micro-controller project to manage/monitor my newest tank, a Fluval Edge.

Architecture
The idea is to have a modular system so that it can be "easily" modified and extended when i want to add functionality.

Controller
Atmel AVR running atomthreads, prototyping using ATMEGA1284p
RTC will be handled using a DS1307
RS-485 IC to talk to sensors and other peripherals
RS-232/USB/Bluetooth etc for status updates and to transfer logs to the computer
LCD and a joystick will be the interface at the tank.
Maybe a piezo electric speaker for audible feedback (over temp alarm, etc.)

Sensor
Atmel AVR, probably some flavor of ATtiny, all it needs to do is take commands over the RS-485 bus, collect sensor data and reply to the controller when queried.
Sensor, probably just using the ADC to get readings
RS-485 IC to talk to the controller

Actor
Atmel AVR, probably some flavor of ATtiny, all it needs to do is take commands over the RS-485 bus, trigger relays/change lighting/etc. and reply to the controller when queried.
RS-485 IC to talk to the controller

Scheduling
As for the scheduling i'm starting out with the same schedule for each day of the week, later on i may add a real schedule or at least for each day of the week to have its own list of actions where the actions are things like:
Turn CO2 relay on
Fade lighting to a specified RGB value over a specified time
etc.

Current status
FreeRTOS has been replaced with atomthreads and is running fine. The serial i/o is working fine, the LCD is also up and running with a menu system.
1 - 20 of 37 Posts

· Registered
Joined
·
42 Posts
Discussion Starter · #2 · (Edited)
Change Log
2010-07-19
Wow, been a while since i updated this. Whoops.

I've made some progress finally, my atmega1284p and other misc. junk came in and i got my prototype done up on a prototype board.
2010-05-10
Not a whole lot of progress, added some to the programming interface and are tossing some ideas around as far as overall system design.
2010-05-05
Command parsing extended, see post #20 for an example of what i'm thinking the scheduling interface may look like.
2010-05-04
Command parsing implemented, see post #19
2010-04-28
Finally figured out the serial input stuff.
Working on the serial user interface, probably going to model it after a certain router manufacturer's interface.
2010-04-27
FreeRTOS v6.0.4 running on the ATMega2560
Still can't get serial input working, posted on avrfreaks to see if anyone has seen this before.
2010-04-19
FreeRTOS v6.0.4 running.
Serial output working, input it not working for some reason.
 

· Registered
Joined
·
480 Posts
Sounds fun, I would be interested in the cost comparision of this compared to a RKE or other preassembled units.
 

· Registered
Joined
·
42 Posts
Discussion Starter · #6 ·
Sounds fun, I would be interested in the cost comparision of this compared to a RKE or other preassembled units.
Not sure if it will be cost effective or not, i'm trying to build it in a modular way so that each piece is self-contained but that will bump the cost up some. Only time will tell.

Hopefully i'll have some fun doing it and get something that does everything i want it to do :)
 

· Registered
Joined
·
46 Posts
I'll be interested in seeing how this turns out as well. I've always wanted to do something like this.
 

· Registered
Joined
·
42 Posts
Discussion Starter · #8 ·

· Registered
Joined
·
42 Posts
Discussion Starter · #9 ·
Currently working on running both FreeRTOS and FreeModbus for communication, looks like i'm going to have to upgrade to a chip with two 16-bit timers. I'll probably go with the biggest chip that is available in a DIP package so that i'm not hitting any walls while building this, i can always port it to something smaller in the end.

I have a atmega2560 that i'm using now but it is not available in a dip package so i'll probably pick up a atmega128 when it is available.

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=ATMEGA1284P-PU-ND
 

· Registered
Joined
·
42 Posts
Discussion Starter · #12 ·
Not much to take pictures of yet.... :icon_smil

I think I've decided to go with the ATmega1280, once it becomes available. Some of the reasons are that it has 4 timers, multiple USARTs and one of the timers is tweaked to be a real time clock (RTC).

I'm ordering a 32.768KHz crystal for the RTC and various ATmegas / ATtinys for whatever i might need them for. :) The ATtinys are more than likely what will drive the peripherals, whatever the smallest chip that i can get freemodbus running on.

Yes, i'm being lazy and 'outsourcing' as much as i can, RTOS, bus protocol, LED drivers, etc. Or at least that is the current plan since i can get some free sample ICs from the different manufacturers and they are pretty cheap (most of them are less than $1).

The current task I'm working on is getting FreeRTOS running on the ATmega2560, which is basically the same chip as the ATmega1280 but with more flash. The unfortunate thing is that the 2560 has more than the 128k flash that FreeRTOS / GCC can address so some changes has to be made to FreeRTOS to get it to work. Luckily someone has already done the work, i just need to integrate their work into my toolchain.
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=70387

After FreeRTOS and Freemodbus is working i'll be working on some of the other framework pieces, the scheduling framework, specs for the communication between components, etc.
The reason i've postponed adding more components and moving the chip to a prototype board is that in the end i plan on using the 1280 but it wont be available for a couple of months. :(
The silver lining is that i can get some of the mundane pieces done before i get the more fun and flashy stuff going, ie. less chance that i stop working on the project. (once you get the flashy stuff going you feel like you have overcome the hurdle and feel like moving on to new challenges. or atleast that is what i usually do...)
 

· Registered
Joined
·
75 Posts
Just as an FYI. You can order free sample parts from digikey, microchip, national instruments. They dont mind giving away a couple of pieces here and there, because if you invent something with their parts youre more likely to mass produce it with their parts. All you have to do is register on their websites prior to ordering.

I find that one of the most powerful and easiest to program chips is the PIC-18f4321. It has a decent amount of memory its got an adjustable internal clock, 32kHz secondary timer, high/low priority interrupt settings, decent flash space availalbe, 10 bit Analog/digital converter, fast serial connection, watchdog timer to help not waste power or get it stuck in long processes, and a great operating voltage range, and I cant remember if the I2C and serial use the same I/O pins or not.... I used the PIC18f4321 to control a self balancing robot.

Ive wanted to do this for some time as well....Ive been looking for so decent peripheral sensors for cheap but Im not seeing too many out there.

So let us know how it comes out!
 

· Registered
Joined
·
42 Posts
Discussion Starter · #14 ·
Just as an FYI. You can order free sample parts from digikey, microchip, national instruments. They dont mind giving away a couple of pieces here and there, because if you invent something with their parts youre more likely to mass produce it with their parts. All you have to do is register on their websites prior to ordering.
Hehe, yeah, i've had packages trickle in for the last couple of weeks from the different companies :)

I find that one of the most powerful and easiest to program chips is the PIC-18f4321. It has a decent amount of memory its got an adjustable internal clock, 32kHz secondary timer, high/low priority interrupt settings, decent flash space availalbe, 10 bit Analog/digital converter, fast serial connection, watchdog timer to help not waste power or get it stuck in long processes, and a great operating voltage range, and I cant remember if the I2C and serial use the same I/O pins or not.... I used the PIC18f4321 to control a self balancing robot.
I'm probably going to go with the ATmega128, i'm used to the AVR platform and i have the development tools for it. In the end they are all about the same. It's funny how people go on holy-wars defending their platform of choice, i dont really care its just what i'm used to. :)

Flash (Kbytes): 128
EEPROM (Bytes): 4096
SRAM (Bytes): 8192
Max I/O Pins: 86
F.max (MHz): 16
Vcc (V): 1.8-5.5
10-bit A/D Channels: 16
Analog Comparator: Yes
16-bit Timers: 4
8-bit Timer: 2
Brown Out Detector: Yes
Ext Interrupts: 32
Hardware Multiplier: Yes
Interrupts: 57
ISP: Yes
On Chip Oscillator: Yes
PWM Channels: 16
RTC: Yes
Self Program Memory: Yes
SPI: 1+USART
TWI: Yes
UART: 4
Watchdog: Yes

Ive wanted to do this for some time as well....Ive been looking for so decent peripheral sensors for cheap but Im not seeing too many out there.

So let us know how it comes out!
 

· Registered
Joined
·
75 Posts
Yeah Ive been a defender of the microchip products since Ive taken a couple of classes at GaTech. Its their holy grail next to the Arduino (which I think is powerful but the programming interface confuses the be-jesus out of me).

My idea for senior design a few years ago was a fully automated tank, but my team shot me down.

I wanted it to include:
daytime/nightime light simulation with the lunar phases programmed in (use an LED array across the whole hood)
temperature control
co2 controller
Auto dosing
pH monitor (via sensor, also any other water parameter you can monitor via sensor)
possibly a pushbutton chemical tester (a machine to extract tank water and add the testing chemicals automatically)
web cam monitoring of the tank/ live feed of parameters
remote/web control capabilities
and auto feeder (not just flakes, but algea wafers too for my pleco)
 

· Registered
Joined
·
42 Posts
Discussion Starter · #16 ·
Yeah Ive been a defender of the microchip products since Ive taken a couple of classes at GaTech. Its their holy grail next to the Arduino (which I think is powerful but the programming interface confuses the be-jesus out of me).

My idea for senior design a few years ago was a fully automated tank, but my team shot me down.

I wanted it to include:
daytime/nightime light simulation with the lunar phases programmed in (use an LED array across the whole hood)
temperature control
co2 controller
Auto dosing
pH monitor (via sensor, also any other water parameter you can monitor via sensor)
possibly a pushbutton chemical tester (a machine to extract tank water and add the testing chemicals automatically)
web cam monitoring of the tank/ live feed of parameters
remote/web control capabilities
and auto feeder (not just flakes, but algea wafers too for my pleco)
Same things that i want to do, basically control everything about the aquarium as well as detailed monitoring/graphing.

I'd like to have multiple temperature sensors and use the average to control the heaters, not just the water around the heater it self. Also i think it would be interesting to have inlet temperature vs outlet temperature if you have a inline heater.

The sky is the limit :)
 

· Registered
Joined
·
42 Posts
Discussion Starter · #18 ·
finally got the input working as well, working on the serial interface now.

i've got it to where i can prompt the user for input and they can type a answer and even use backspace, etc. to edit their input.

working on the menu / command syntax now.
 

· Registered
Joined
·
42 Posts
Discussion Starter · #20 ·
Sorry for the non-aquarium updates, but i think documenting my work will help me keep motivated to actually finish this thing... :)

Still working on the configuration interface, here is the current idea as far as configuring the schedule.

Each entry in the schedule has a line number, that way i can do things like "schedule delete 104" to remove a entry from the schedule.

Each entry also has a time, a module and a command to send to that module. For now i'm not going to worry about the weekday, i'm just going to have the same schedule every day.

Code:
[*] Aquarium Brain Initializing                                                 
[*] Version: 1.0                                                                
                                                                                
[?]: show version                                                               
Aquarium Brain Version 1.0                                                      
                                                                                
[?]: show schedule                                                              
Line            Time            Module          Command                         
----            ----            ------          -------                         
 100            07:00           Lights          RGB|300|255255255                   
 101            07:00           CO2             ON                              
 102            09:00           FEED            1                               
 103            19:00           FEED            1                               
 104            22:00           CO2             OFF                             
 105            22:30           Lights          RGB|300|000000000  

[?]:
In this example the lights would fade to bright white over the course of 5 minutes starting at 7am, and the CO2 would also be turned on at the same time.
At 9am and 7pm the feeder would dump food in to the aquarium.
At 11pm the CO2 would turn off
And at 11.30pm the lights would start to fade to black and be completely out 300 seconds (5 minutes) later.

This is obviously subject to change :icon_smil
 
1 - 20 of 37 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top