Micro-controller project
Planted Tank Forums
Your Tanks Image Hosting *Tank Tracker * Plant Profiles Fish Profiles Planted Tank Guide Photo Gallery Articles

Go Back   The Planted Tank Forum > Specific Aspects of a Planted Tank > DIY


Reply
 
Thread Tools Display Modes
Old 04-19-2010, 04:09 PM   #1
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Lightbulb

Micro-controller project


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.

Last edited by ullbergm; 07-20-2010 at 02:18 AM..
ullbergm is offline   Reply With Quote Quick reply to this message
Sponsored Links
Advertisement
 
Old 04-19-2010, 04:11 PM   #2
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

Change Log
2010-07-19
Quote:
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
Quote:
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
Quote:
Command parsing extended, see post #20 for an example of what i'm thinking the scheduling interface may look like.
2010-05-04
Quote:
Command parsing implemented, see post #19
2010-04-28
Quote:
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
Quote:
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
Quote:
FreeRTOS v6.0.4 running.
Serial output working, input it not working for some reason.

Last edited by ullbergm; 07-20-2010 at 02:16 AM.. Reason: Updated changelog
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-19-2010, 05:22 PM   #3
TeamTeal
Planted Tank Enthusiast
 
TeamTeal's Avatar
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Bay Area
Posts: 883
Default

sound like a great project
very interested to see how this turns out
TeamTeal is offline   Reply With Quote Quick reply to this message
Old 04-19-2010, 05:51 PM   #4
northey87
Planted Tank Obsessed
 
northey87's Avatar
 
PTrader: (6/100%)
Join Date: May 2009
Location: Dayton Pa
Posts: 480
Default

Sounds fun, I would be interested in the cost comparision of this compared to a RKE or other preassembled units.
__________________
___My 120 Gallon___ EHEIM PIMP #407, 2x 2229, 2x 1250 Hobby Pumps, 1x Ecco 2236, and 1x Eheim Sludge Extractor
northey87 is offline   Reply With Quote Quick reply to this message
Old 04-19-2010, 06:33 PM   #5
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

Quote:
Originally Posted by TeamTeal View Post
sound like a great project
very interested to see how this turns out
I have a history of not completing projects that i start so hopefully by posting my progress i'll actually finish this one
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-19-2010, 06:39 PM   #6
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

Quote:
Originally Posted by northey87 View Post
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
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-19-2010, 07:49 PM   #7
pmd5700
Algae Grower
 
pmd5700's Avatar
 
PTrader: (0/0%)
Join Date: Oct 2007
Location: Florida
Posts: 46
Default

I'll be interested in seeing how this turns out as well. I've always wanted to do something like this.
__________________
5.5G - Low-Tech Planted
20G - Nano Reef
55G - African Cichlids and Tons of Java Ferns
160G - Central/South American Cichlids
pmd5700 is offline   Reply With Quote Quick reply to this message
Old 04-19-2010, 09:21 PM   #8
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

Quote:
Originally Posted by pmd5700 View Post
I'll be interested in seeing how this turns out as well. I've always wanted to do something like this.
I know of two other similar projects here on the forum:
RobotGuy
http://www.plantedtank.net/forums/ta...cs-3-14-a.html

and

Mistergreen
http://www.plantedtank.net/forums/di...ml#post1009586

Be sure to check those out if you haven't already
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-21-2010, 02:29 PM   #9
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

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/Dk...EGA1284P-PU-ND
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-22-2010, 10:31 PM   #10
insta
Planted Member
 
PTrader: (5/100%)
Join Date: Jan 2010
Location: Overland Park, KS
Posts: 234
Default

Let me know if you need anything for lighting controllers. PWM is my specialty
__________________
SunSun Pimp #10
Journal - 29G, 130W PC lighting, Red Sea CO2 on 20# tank, SunSun 303B, Custom ferts
insta is offline   Reply With Quote Quick reply to this message
Old 04-22-2010, 11:46 PM   #11
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,327
Default

post pictures!
mistergreen is offline   Reply With Quote Quick reply to this message
Old 04-23-2010, 01:39 AM   #12
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

Not much to take pictures of yet....

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?n...wtopic&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...)
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-23-2010, 02:25 PM   #13
Joefish4jc
Algae Grower
 
PTrader: (0/0%)
Join Date: Mar 2010
Location: Atlanta
Posts: 75
Default

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!
Joefish4jc is offline   Reply With Quote Quick reply to this message
Old 04-23-2010, 02:41 PM   #14
ullbergm
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2010
Location: Wilson, NC
Posts: 40
Default

Quote:
Originally Posted by Joefish4jc View Post
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

Quote:
Originally Posted by Joefish4jc View Post
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

Quote:
Originally Posted by Joefish4jc View Post
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!
ullbergm is offline   Reply With Quote Quick reply to this message
Old 04-23-2010, 02:52 PM   #15
Joefish4jc
Algae Grower
 
PTrader: (0/0%)
Join Date: Mar 2010
Location: Atlanta
Posts: 75
Default

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)
Joefish4jc is offline   Reply With Quote Quick reply to this message
Reply

Tags
controller, lighting, schedule

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the The Planted Tank Forum forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in

Human Verification

In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.



Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Planted Tank LLC 2012