PDA

View Full Version : My own controller project (and a couple requests)


j_c_a
12/06/2004, 07:08 AM
So, I've been hesitant to post anything about my own controller project mainly because I don't want to feel pressure to "get it done" or anything like that. Now, however, I'm at a point where I may need a little assistance.

Here's a link to the latest schematic for the project (gif)(It's not neccessarily a big file, but the dimensions of the image are big so i'm posting a link rather than an image):

http://www.vbbyjc.com/personal/aq.gif

Everything in the schematic works and has been bread-boarded, although not neccessarily as a complete unit.

Here's where I may need help. Folks may recognize the schematic as being from EagleCAD. I'm not involved professionally in electronics in any way so I don't have access to any higher-end CAD software. Does anyone have a licensed version of EagleCAD or some other CAD software, and would be willing to board this schematic when I'm done? There's no way I can get it to fit under the free version of EagleCAD (board size restriction).

The second part where I need some assistance is in my ph interface. I really don't have any electronics background and I'm struggling to get a working interface. If anyone would care to lend a hand, I'd greatly appreciate it. Also, not to be picky, but if there's any way to get it to run from a single +12V or +5V supply it would be great.

Thanks and Regards,
jca

karma
12/10/2004, 03:51 AM
jca,

Try this link. http://www.emesystems.com//OL2ph.htm

It shows how to interface a pH probe to a Basic Stamp, so you should be able to adapt it to your setup. I believe most op amp require a negative voltage if they are going to be used to read a negative voltage (such as a pH probe can put out). You can generate the negative voltage from a positive voltage using the proper chip. The schematic at the link I provided shows how to do this.

Good luck,
Michael

j_c_a
12/10/2004, 06:40 AM
Hey karma, thanks. I've actually seen that page and I think I'll have to try to follow it exactly. I've been trying to get this working w/ a single-supply opamp and just haven't had any luck. I've got several bi-polar opamps on hand that should be able to handle the high impedance, and I've ordered an IC that can create -5V from +5V (if I remember it's a maxim chip). So now, like always, I'm waiting on parts.

This is the last major piece to the puzzle, so once I get it working, I can start putting all the individual pieces into a single circuit and finish the software.

Regards,
jca

banger
12/25/2004, 02:28 PM
Hi,

You can put a negative voltage into a single voltage op amp fairly easily. Just add a voltage divider to where you are feeding in the negative voltage, to make it positive. Also remember that opamps have an inverting and non inverting side. As an example, if you have a ph probe with an output from 0-100mv. Then feed in a voltage of 2.55 volts, and your opamp will output from 2.45 to 2.55 with the ph probe. You can also increase the gain on the opamp, to change your 100mv swing to 5v swing.

j_c_a
12/28/2004, 11:42 AM
Thanks alot banger. That makes sense. I'll give it a shot.

spipedong
01/10/2005, 03:38 PM
Hi j_c_a,

I've built a few DIY electronics items as well, and it's always sort of fun to figure out how to tie the different IC's together.

I was wondering (if you're still working on this) how the project works and what it's capable of. (LCD Display, PC Control, Timed outputs?) By looking at the schematic it seems to be a pretty well designed/laid out device that would accept modification or feature additions.

No pressure, I'm just very interested in hearing about your progress.

j_c_a
01/11/2005, 07:00 AM
Hey spipedong, haven't done much since the holidays but it's still in the works. My last hurtling block is the ph interface. There's some good ideas above re: that, I just need to get back on it and apply them.

In terms of capabilities, here's a basic rundown of what it does (i've got code to do all this, but there is some tweaking needed to integrate all of it).

4x20 LCD display w/ backlight.

3-button ui (up/down/enter)

monitors 2 temp. probes (ie water and air/canopy/etc)

will monitor 2 ph sensors (ie tanks water and effluent)

controls dimmable on-demand red led nightlights

controls dimmable led moonlights according to lunar schedule

controls 3 banks of daylights according to user-defined solar schedule

monitors 4 float switches (turn on topoff, hi-water sump, low-water sump, low water makeup reservoir)

audible and visual alarms for out-of-range parameters

as configurated, capable of controlling 14 ac devices. So far:
heater, chiller, co2 soleniod, neilson stirrer, top-off pump, main pump shutdown(feeding), 3 banks of lights

^ w/ my current design, I could add control for additional ac devices, using 1-pin to drive each additional 7 devices (ie shift-register/uln2003 combination)

will also controll a DC canopy fan (haven't done code for this yet)

I've also thought about the ability to act as a wavemaker, but I reallly don't know how I'm going to work this in the new tank (ie. closed loop, powerheaders/etc) so I haven't really given it serious thought as to how to accomplish that.

I have basic one-way (out) communication w/ PC via serial port but I wouldn't mind adding some other type of communcation interface.

Eventually, I'd like to tackle some data-logging, but that's the last thing on my list.

barebottoms
01/11/2005, 10:58 AM
That might help with the ph probe. The MAX406 is a high impedance op-amp, it outputs a linear dc voltage.

If you want 2 way communications take a look at 1-wire. The WRRC (wireless recycled reef controller) I'm working on is using all 1-Wire for control and sensor network.

http://reefcentral.com/gallery/data/500/15092ph-circuit.JPG

j_c_a
01/11/2005, 11:06 AM
Hey thanks barebottoms. I'm using 1-wire for my TEMP probes. I'm getting geared up to jump back on this project so hopefully I'll start making some more progress soon.

barebottoms
01/11/2005, 11:25 AM
Cool. Good luck with your project, I'll be sure to steal idea's from yours for mine :D

I'm not sure if you're at the dimming functions yet, if you are and need help, take a look at DS2890. It's a 1-Wire digital pot.

For the lunar scale, you can use a old BSD utility called POM (phase of moon). It calculates the current phase and a percentage, then you can easily convert that to an integer for dimming control.

j_c_a
01/11/2005, 12:33 PM
Hey barebottoms, maybe we can compare notes at some time.

I've got a MAXIM digital pot (don't have the part number handy) but I found I had a lot more flexability using an DAC and them amplifying the output using a simple LM324 op amp. It's a quad-amp w/o a lot of options so I can drive a lot of LED's if need be.

Also, for the moonlighting, I settled on a simple algorythm. Basically, I need the user to supply the date of any full moon within a given month. From that I can extrapolate the % of moonlight for any given day. I'm working on the assumption that the variance is pretty linear between moon cycles. I hope that's correct. I've yet to figure out a good way to do moon-rise and set because it doesn't work on a 24-hour period like solar rise/set. For now, I've settled on just turning on the moonlights when the last daylight goes off.

spipedong
01/11/2005, 02:01 PM
Wow this is sounding really exciting. I haven't tackled any design project this complex before. I definitely commend your efforts. (Still no pressure! :) )

barebottoms
01/11/2005, 03:57 PM
spipedong,

Its the chicken and the egg senario. Eveyone seems to want a controller, but get overwhelmed with the pieces involved so no one really wants to "help" until they see something working. Which I don't blame them.

Even with the way I'm going about it, not many people have stepped up to help. Even though I'm basically using off the shelf parts and software.

It is fun, and I think if a person just goes about it piece by piece it all makes sense.

DJ88
01/18/2005, 11:21 PM
just curious as to your decision to run a BasicX microcontroller AND a PIC16F628.
:)

j_c_a
01/19/2005, 06:48 AM
Originally posted by DJ88
just curious as to your decision to run a BasicX microcontroller AND a PIC16F628.
:)

As far as the BX MC it was simply a matter of expediency. For a mass production scenario, you'd obviously go w/ a much cheaper pic or avr, but for a one-off, the ease of basic programming w/o having to buy additional compilers, was just too attractive.

Re: mixing that w/ the pic .... the pic is actually a pre-programmed serial controller for an LCD. I'm not at home right now so I don't have the exact name, but there's a professor in Baltimore that sells very inexpensive pre-programmed packages on the web (he also sells BX chips at a decent price). Once again, for a one-off project it was a quick and easy way to get the desired functionality.

DJ88
01/19/2005, 11:35 AM
ohh gotcha.. :) compilers and programmers were the reasons I asked.

Do you do much work with C? there is a C complier out there that is freeware for PICs. CCX-5 is what it is called I think. I use the CCS C compiler. Nice to work with. about $125(US) for the PIC12 and PIC16's.

mupham
01/26/2005, 12:31 AM
Nice project so far... If you're still interested. Another example of a pH amplifier circuit is given in the National Semiconductor datasheet for the LMC6001 high Z op-amp. Unfortunately it too requires a dual power supply but may give you another example of how it works. http://www.national.com/ds.cgi/LM/LMC6001.pdf (page11)

I had a question about using the DAC for the moonlights. Have you given any thought to possibly using PWM and changing the duty cycle to control the LED intensity? It could save you a few ICs, resistor networks, and a couple of IO ports on your MCU. I can't speak for your MCU but some PICs have a PWM module that you can configure in hardware with 10 bits of resolution. Not that it has to be that good of course, but maybe you can simulate cloudy nights too :)

j_c_a
01/26/2005, 08:05 AM
I did experiement w/ using PMW but found a couple problems w/ that:

a) it really wasn't enough power to adequately drive my led's. Even w/ a rapid pulse, you still have a fraction of the max 5V from the PWM pin. I needed to run anywhere from 2+ led's. I won't know how many until I actually setup the tank and see what looks good.

b) At least for the chip I'm using, the PWM didn't really look good. There was a noticable flicker. It may just be for my chip, but it really wasn't acceptable.

I like the DAC/AMP combination better than a digital pot as well, because I'd rather just supply less power (ie DAC/amp) than always supply the max power and have to dissipate the excess using a resistor, ie adding heat. I'm really not that educated re: elctronics, so I may be all wet w/ my reasoning, but it seems to work for me.

As for the cloudy night scenario, that's very interesting. I'd actually given some thought as to how to similate clouds in the daylight environment, but that doesn't seem doable w/ MH lights.

j_c_a
01/26/2005, 08:22 AM
Just checked out the ph interface. That looks very interesting. THanks.

DJ88
01/26/2005, 09:41 AM
I have run up to five LEDs using PWM from a PIC. Are you wiring them in series or parallel?

If you are really worried about it. send the output through an opamp(741 or 356) with it's rail voltages much higher. Say 0 and 10V. set it to a fairly high gain so the amplification of the input signal sends the output right to those rails. then wire the LEDs in parallel.

if you are seeing flickering it could be that you are running the frequency too low. What are you running it at?

j_c_a
01/28/2005, 06:51 AM
Hey DJ88, the unsatifsfactory PWM may be a limitation of the BX chip?? It's basically an AVR w/ a basic interpreter loaded in. Maybe the basic OS slows down the PWM? I don't know, but I do know that no matter which frequency I tried to use, the results we not satisfactory. I'm actually pretty satisfied w/ how the LED dimming is working now, but I'll certainly keep everyones suggestions in mind if I run into issues w/ the way I'm doing it.

Thanks all for the info. I'm getting phsyched up to dive back into this project ;)

DJ88
01/28/2005, 09:10 AM
well if ya had a programmer and C complier I'd send you the code for a PIC to do the PWM. :p that would make things really easy. I know it works as I can see it doing it's job right now. :D

you know there could be an issue with the pin not being able to source enough current for the LED/LEDs.

Take a look at that as a possibility.

I don't have the specs handy for the BX or I'd check it out myself. :)

mupham
01/28/2005, 09:31 AM
If the PWM is implemented in hardware then the BASIC interpreter shouldn't be the bottleneck. Perhaps one of the timer prescalers is set too high and lowering the frequency of the PWM output. Either way, I think you guys are correct about having some kind of driver like a transistor to supply the current rather than your MCU. The only other thing is to not have the frequency too high or the switch on/off time of the LED may become a factor. I don't really know for sure though. Probably anything around 500 Hz would be unnoticable and slow enough for the LED. Darren, I have the CCS compiler (old version though) for the 16F series and ICD2 if you don't mind sending me the code. Should be pretty straight forward with the CCP port, I think.

-Mike

DJ88
01/28/2005, 05:17 PM
Here's the code. For some reason I happened to have my USB key with me(not at home right now) :) Sorry about the formatting. guess the forum software doesn't like tabs. :mad:

I have attached the code as a txt file. Should work on any version of CCS. I didn't use any real fancy functions the newer ones have.

I am running a fairly recent version. I can't remember the ver. No off the top of my head. I do have it at home tho. (obviously)

I used a 16F818 as I had a bunch handy. tho I know it works on any CCP module. I was running this on an 877A for a while when I was writing some other code I threw it in for fun.



#include <16F818.h>
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT
#fuses MCLR,CCPB2, NODEBUG,NOLVP,NOCPD,NOWRT
#use delay(clock = 4000000)

#define INTERRUPT_DELAY_TMR1 0x7FF9 //250ms prescale of 8
#define ON TRUE

int COUNTER, SECONDS, MINUTES, HOURS, DAYS;
int LED_intensity = 0;

BOOLEAN UP = TRUE;
BOOLEAN LED_cycle = TRUE;

void main(void){

setup_timer_1( T1_INTERNAL | T1_DIV_BY_8);
output_low(PIN_B2);
setup_ccp1(ccp_pwm);
set_pwm1_duty(1);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);

while(1);
}
/************************INTERRUPTS****************************/
#int_TIMER1
void TIMER1_isr(){

set_timer1( get_timer1() + INTERRUPT_DELAY_TMR1);

if (++counter >= 4){
counter = 0;
output_toggle(PIN_B0);
if(++seconds >= 60){
seconds = 0;
if (++minutes >= 60){
minutes = 0;
if(++hours >= 24){
hours = 0;
if(LED_cycle == UP){
LED_intensity = LED_intensity + 10;
set_pwm1_duty(LED_intensity);
}
else{
LED_intensity = LED_intensity - 10;
set_pwm1_duty(LED_intensity);
}
if(++days >= 14){
days = 0;
LED_cycle ^= 1;
}
}
}
}
}
}

DJ88
01/28/2005, 05:19 PM
lets try that attachment again...

barebottoms
01/28/2005, 05:56 PM
[ c o d e ]
[ / c o d e ]

Without the spaces, does preformatted.



Like this:

(. \
\ |
\ |___(\--/)
__/ ( . . )
"'._. '-.O.'
'-. \ "|\
'.,,/'.,,mrf

DJ88
01/28/2005, 06:29 PM
oh nice.. I did not know that.. Well on here at least. I knew about that on the CCS forum. Did I think that it would do it here? no..

#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT
#fuses MCLR,CCPB2, NODEBUG,NOLVP,NOCPD,NOWRT
#use delay(clock = 4000000)

#define INTERRUPT_DELAY_TMR1 0x7FF9 //250ms prescale of 8
#define ON TRUE

int COUNTER, SECONDS, MINUTES, HOURS, DAYS;
int LED_intensity = 0;

BOOLEAN UP = TRUE;
BOOLEAN LED_cycle = TRUE;

void main(void){
delay_ms(500);
setup_timer_1( T1_INTERNAL | T1_DIV_BY_8);
output_low(PIN_B2);
setup_ccp1(ccp_pwm);
set_pwm1_duty(1);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);

while(1);
}
/************************INTERRUPTS****************************/
#int_TIMER1
void TIMER1_isr(){

set_timer1( get_timer1() + INTERRUPT_DELAY_TMR1);

if (++counter >= 4){
counter = 0;
output_toggle(PIN_B0);
if(++seconds >= 60){
seconds = 0;
if (++minutes >= 60){
minutes = 0;
if(++hours >= 24){
hours = 0;
if(LED_cycle == UP){
LED_intensity = LED_intensity + 10;
set_pwm1_duty(LED_intensity);
}
else{
LED_intensity = LED_intensity - 10;
set_pwm1_duty(LED_intensity);
}
if(++days >= 14){
days = 0;
LED_cycle ^= 1;
}
}
}
}
}
}

Sandman3467
07/30/2005, 11:50 PM
I'd like to know how your controler is comming along????

Cichlidius
04/17/2006, 05:27 PM
any updates? sounds like a good one.

chup90
11/04/2012, 01:45 AM
hi i have atlas pH stamp, arduino duemilanove.

i want to trigger some LEDs, buzzer,when certain pH is reached. i also want to display the pH reading on LCD display.

please help me with the code. any reference would also be really helpful.

this is my first time doing such project.

thanks