How do I design a low cost Ammonia level detector for a mini fish pond?

jayanthd

Joined Jul 4, 2015
945
Then I will settle for the LTC2053. How much will it be with the shipping?
I don't knwo how much is shipping now. I purchased from linear 2 years back. You send email to them and enquire about it.

Decide about which version you need and tell me and I will do the project tomorrow.
 

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
LTC2053 is needed for all versions.

Will you go with non speaking PIC18F26K22 based or PIC16F18877 (replacing and cheaper then PIC16F877A in few months) for the project with 10 leds bargraph or LCD with free circuit and code but 50 USD for PCB layout designing project ?

You can get the PCB layout designed by any other person or you can design it yourself if you want to save 50 USD.
I would have loved it designed by you, but aside needing it for personal use, I have to carry out the practical under the supervision of someone, from component acuqisition to coupling. So doing it from outside won't be totally advisable.
But can you do me the favor of sending the circuit diagrams so I can pick one, do my research and familiarise myself with it?
 

jayanthd

Joined Jul 4, 2015
945
I would have loved it designed by you, but aside needing it for personal use, I have to carry out the practical under the supervision of someone, from component acuqisition to coupling. So doing it from outside won't be totally advisable.
But can you do me the favor of sending the circuit diagrams so I can pick one, do my research and familiarise myself with it?

Ok. I will send you the diagrams and .hex files for micocontroller based non speaking version tonight (approx after 4 hours).
 

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
Ok. I will send you the diagrams and .hex files for micocontroller based non speaking version tonight (approx after 4 hours).
You don't an idea of how relieved I am. Thank you so much, I would be expecting them. I would also appreciate some explanations where you feel they would be necessary.
 

jayanthd

Joined Jul 4, 2015
945
You don't an idea of how relieved I am. Thank you so much, I would be expecting them. I would also appreciate some explanations where you feel they would be necessary.
Do you also want to add 2x pumps (dc or ac) which remove the ammonia water and fill with fresh water using two small float switches or ultrasonic sensor for water level detection to turn ON/OFF the pumps ?

I need to know this to make circuit.
 

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
Do you also want to add 2x pumps (dc or ac) which remove the ammonia water and fill with fresh water using two small float switches or ultrasonic sensor for water level detection to turn ON/OFF the pumps ?

I need to know this to make circuit.
I dont think that would be necessary, let me save you that stress.Thanks alot
 

jayanthd

Joined Jul 4, 2015
945
This is Non-Speaking version with Led bargraph. I will make Lcd version tomorrow. If you have Proteus then test simulation. Simulation runs slow on my PC.

You can build hardware and test it. It will work. Code is compiled for external 4 MHz Crystal. I can change it to use Internal 4 MHz Oscillator.

Check the schematic. You have to use Buzzer in hardware. Sounder should not be used in hardware. It is only for simulation.

Test it on hardware and tell me how it works.

It has two modes. Dot and Bar modes for display.
 

Attachments

jayanthd

Joined Jul 4, 2015
945
You don't an idea of how relieved I am. Thank you so much, I would be expecting them. I would also appreciate some explanations where you feel they would be necessary.
Check the circuit. Build it and test on hardware. Morning I will send Lcd version. Ammonia Level Speaking Basic Version is simple circuit. MP3 Player version needs MP3 module. I can't dare MP3 module circuit in Proteus. I can however give you links to buy mikroE MP3 Click and also provide you MP3 module circuit (not Proteus).

I need two days to draw the Speaking version circuits.

When is the date of submission of the project ?

In LCD versions I can additionally implement bargraph but I charge 100 USD for it.
 

jayanthd

Joined Jul 4, 2015
945
There was a bug related to alarm code. I have fixed it.

C:
#define max_value 10
#define adc_resolution 1023
#define pH_probe_channel 0
#define BARGRAPH_DATA_PORT LATC
#define alarm_value 8

sbit dot_bar_mode_select_button at RB0_bit;
sbit bargraph_9th_led at LATB4_bit;
sbit bargraph_10th_led at LATB5_bit;

unsigned char flags = 0;
unsigned int dot_mask[11] = {0x000, 0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x040, 0x080, 0x100, 0x200};
unsigned int bar_mask[11] = {0x000, 0x001, 0x003, 0x007, 0x00F, 0x01F, 0x03F, 0x07F, 0x1FF, 0x3FF, 0x7FF};
unsigned int bargraph_data = 0;
unsigned char mask_index = 0;
unsigned int raw_adc_value = 0, previous_raw_adc_value = 1024;

sbit dot_bar_mode_flag at flags.B0;

//Timer1
//Prescaler 1:1; TMR1 Preload = 60536; Actual Interrupt Time : 5 ms
void InitTimer1() {
    T1CON = 0x01;
    TMR1IF_bit = 0;
    TMR1H = 0xEC;
    TMR1L = 0x78;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
}

void Interrupt(){
    if((TMR1IE_bit) && (TMR1IF_bit)) {
        //Enter your code here
       
        BARGRAPH_DATA_PORT = (unsigned short)bargraph_data;
        bargraph_9th_led = (bargraph_data & 0x100) >> 8;
        bargraph_10th_led = (bargraph_data & 0x200) >> 9;
       
        TMR1H = 0xEC;
        TMR1L = 0x78;
        TMR1IF_bit = 0;
    }
}

void ToneA() {
    Sound_Play( 880, 50);
}
void ToneC() {
    Sound_Play(1046, 50);
}
void ToneE() {
    Sound_Play(1318, 50);
}

void Melody2() {
    unsigned short i;

    for (i = 9; i > 0; i--) {
      ToneA(); ToneC(); ToneE();
    }
}

void main() {

    asm clrwdt
   
    /*
    OSCCON = 0x57;
    OSCTUNE = 0x00;
    */
   
    CM1CON0 = 0x00;
    CM2CON0 = 0x00;
   
    SLRCON = 0x00;
   
    ADCON1 = 0x80;
    ADCON2 = 0b10110101;
   
    ANSELA = 0x01;
    ANSELB = 0x00;
    ANSELC = 0x00;
   
    TRISA = 0xC1;
    TRISB = 0x01;
    TRISC = 0x00;
   
    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
   
    LATA = 0x00;
    LATB = 0x00;
    LATC = 0x00;
   
    Sound_Init(&LATA,5);
    Delay_ms(100);
   
    InitTimer1();
   
    while(1) {
   
         asm clrwdt
         
         if(!dot_bar_mode_select_button) {
             Delay_ms(50);
             while(!dot_bar_mode_select_button)asm clrwdt;
             
             dot_bar_mode_flag = ~dot_bar_mode_flag;
             previous_raw_adc_value = 1024;
         }

         raw_adc_value = (unsigned int)ADC_Read(0);
         Delay_us(20);
         //if(previous_raw_adc_value != raw_adc_value) {
             mask_index = raw_adc_value * max_value / adc_resolution;
             
             if(dot_bar_mode_flag == 0) {
                 bargraph_data = bar_mask[mask_index];
             }
             else if(dot_bar_mode_flag == 1) {
                 bargraph_data = dot_mask[mask_index];
             }
             
             asm clrwdt
             
             if(mask_index >= alarm_value) {
                 Melody2();
             }
             
             //previous_raw_adc_value = raw_adc_value;
         //}
    }
}
 

Attachments

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
Okay,
Hi , For All Designed projects , you can use Mean Well SMPS
all docs and info are listed below
MEAN WELL POWER
Okay, I would check it out. Thank you so much.
This is Non-Speaking version with Led bargraph. I will make Lcd version tomorrow. If you have Proteus then test simulation. Simulation runs slow on my PC.

You can build hardware and test it. It will work. Code is compiled for external 4 MHz Crystal. I can change it to use Internal 4 MHz Oscillator.

Check the schematic. You have to use Buzzer in hardware. Sounder should not be used in hardware. It is only for simulation.

Test it on hardware and tell me how it works.

It has two modes. Dot and Bar modes for display.
Woooow. Thanks so very much, I would check it out very soon, would get back to you.
 

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
Oka
There was a bug related to alarm code. I have fixed it.

C:
#define max_value 10
#define adc_resolution 1023
#define pH_probe_channel 0
#define BARGRAPH_DATA_PORT LATC
#define alarm_value 8

sbit dot_bar_mode_select_button at RB0_bit;
sbit bargraph_9th_led at LATB4_bit;
sbit bargraph_10th_led at LATB5_bit;

unsigned char flags = 0;
unsigned int dot_mask[11] = {0x000, 0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x040, 0x080, 0x100, 0x200};
unsigned int bar_mask[11] = {0x000, 0x001, 0x003, 0x007, 0x00F, 0x01F, 0x03F, 0x07F, 0x1FF, 0x3FF, 0x7FF};
unsigned int bargraph_data = 0;
unsigned char mask_index = 0;
unsigned int raw_adc_value = 0, previous_raw_adc_value = 1024;

sbit dot_bar_mode_flag at flags.B0;

//Timer1
//Prescaler 1:1; TMR1 Preload = 60536; Actual Interrupt Time : 5 ms
void InitTimer1() {
    T1CON = 0x01;
    TMR1IF_bit = 0;
    TMR1H = 0xEC;
    TMR1L = 0x78;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
}

void Interrupt(){
    if((TMR1IE_bit) && (TMR1IF_bit)) {
        //Enter your code here
      
        BARGRAPH_DATA_PORT = (unsigned short)bargraph_data;
        bargraph_9th_led = (bargraph_data & 0x100) >> 8;
        bargraph_10th_led = (bargraph_data & 0x200) >> 9;
      
        TMR1H = 0xEC;
        TMR1L = 0x78;
        TMR1IF_bit = 0;
    }
}

void ToneA() {
    Sound_Play( 880, 50);
}
void ToneC() {
    Sound_Play(1046, 50);
}
void ToneE() {
    Sound_Play(1318, 50);
}

void Melody2() {
    unsigned short i;

    for (i = 9; i > 0; i--) {
      ToneA(); ToneC(); ToneE();
    }
}

void main() {

    asm clrwdt
  
    /*
    OSCCON = 0x57;
    OSCTUNE = 0x00;
    */
  
    CM1CON0 = 0x00;
    CM2CON0 = 0x00;
  
    SLRCON = 0x00;
  
    ADCON1 = 0x80;
    ADCON2 = 0b10110101;
  
    ANSELA = 0x01;
    ANSELB = 0x00;
    ANSELC = 0x00;
  
    TRISA = 0xC1;
    TRISB = 0x01;
    TRISC = 0x00;
  
    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
  
    LATA = 0x00;
    LATB = 0x00;
    LATC = 0x00;
  
    Sound_Init(&LATA,5);
    Delay_ms(100);
  
    InitTimer1();
  
    while(1) {
  
         asm clrwdt
        
         if(!dot_bar_mode_select_button) {
             Delay_ms(50);
             while(!dot_bar_mode_select_button)asm clrwdt;
            
             dot_bar_mode_flag = ~dot_bar_mode_flag;
             previous_raw_adc_value = 1024;
         }

         raw_adc_value = (unsigned int)ADC_Read(0);
         Delay_us(20);
         //if(previous_raw_adc_value != raw_adc_value) {
             mask_index = raw_adc_value * max_value / adc_resolution;
            
             if(dot_bar_mode_flag == 0) {
                 bargraph_data = bar_mask[mask_index];
             }
             else if(dot_bar_mode_flag == 1) {
                 bargraph_data = dot_mask[mask_index];
             }
            
             asm clrwdt
            
             if(mask_index >= alarm_value) {
                 Melody2();
             }
            
             //previous_raw_adc_value = raw_adc_value;
         //}
    }
}
Okay, Thank you.
 

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
Check the circuit. Build it and test on hardware. Morning I will send Lcd version. Ammonia Level Speaking Basic Version is simple circuit. MP3 Player version needs MP3 module. I can't dare MP3 module circuit in Proteus. I can however give you links to buy mikroE MP3 Click and also provide you MP3 module circuit (not Proteus).

I need two days to draw the Speaking version circuits.

When is the date of submission of the project ?

In LCD versions I can additionally implement bargraph but I charge 100 USD for it.
Thank you so much Jayanthd, I sincerely appreciate, we are due to begin the lab practical late next week, so I need to start gathering the components and familiarising myself with the circuitry.
When you done with the speaking version circuit, you can get it across.

Once again, I am indeed grateful.

Hope you wouldn't mind me getting in touch for more consultation incase of any difficulty?
 

jayanthd

Joined Jul 4, 2015
945
Thank you so much Jayanthd, I sincerely appreciate, we are due to begin the lab practical late next week, so I need to start gathering the components and familiarising myself with the circuitry.
When you done with the speaking version circuit, you can get it across.

Once again, I am indeed grateful.

Hope you wouldn't mind me getting in touch for more consultation incase of any difficulty?
Morning I will give you Non-Speaking LCD version without bargraph and Basic Speaking version with LCD circuits. I need two days to make the code for MP3 player version.

No problem, you can ask all my circuits related questions.
 

jayanthd

Joined Jul 4, 2015
945
Here is the Proteus simulation video and Proteus simulation files for LM3914 based Level Indicator. You can also use this level indicator for other purpose.

Now in LM3914 version dot and bar modes are implemented.
 

Attachments

Last edited:

Phil-S

Joined Dec 4, 2015
241
I can throw some light on this from an industrial standpoint.
Ammonia is an important indicator of pollution in waste and drinking water.
In a laboratory, ammonia is measured colorimetrically where a single sample is treated with reagents and the result read.
Industries generally need an on-line measurement that is done at the process.
Sometimes, ammonia (expressed as total ammonia or free and saline ammonia) is measured by an on-line colorimeter, but more often as not, is done by an ammonia specific ion electrode.
Now it just happens that an ammonia electrode is simply a modified pH electrode, which in itself is a specific ion electrode.
All you do to measure ammonia is to modify the pH electrode so that it sits in a buffer solution, generally potassium chloride and a PTFE membrane separates the sample from the glass membrane. Ammonia quickly diffuses through the membrane and being alkaline in solution, raises the pH. To measure the dissolved ammonia in the sample, strong sodium hydroxide solution is added to the sample line.
It is one of the easier measurements to do on-line. I used to experiment with these things and got perfectly good results just using plumbers PTFE joint tape.
If you want to test the idea, you could lash up a little cap with the electrolyte solution and tip of the probe in it, and seal the whole thing by stretching PTFE tape across a small whole in the cap.Get some ammonium sulphate powder, dissolve it in some water, add a small amount of sodium hydroxide (caustic soda) solution and watch how quickly the gas phase a ammonia affects the pH. Industrial probes are normally flat ended and just a drop of electrolyte is used between the glass and the PFTE.
A lot will depend on how often you need to check as to which technology you use and I'm a bit out of touch with current methods.
There are a lot of electronic sensors around now or test strips which might be better bet.
If in the past I had had a bit more time and MCU's and stepper motors were more easily obtainable, I wold have gone down the automated discrete sampling method with stepper controlled syringes for reagents etc.
Do a search for water testing methods and equipment to get some more ideas. Maybe have a look at fish farming equipment
 

Thread Starter

Patrickjnr

Joined Aug 28, 2017
20
Good day Jayanthd, I hope you doing very fine and I know you would be surprised that I've not been giving you any feedback on the project am embarking on with your immense support.
I fell very sick the day after you gave me the final circuit that I was to begin gathering the equipments and I had no choice but to put the project on hold while I attended to my ailing health.
Am so glad that am back to begin from where I stopped, but my only problem now is how to put the puzzles together, especially where the pH sensors would come into the circuit and how the circuits would be put together to make a whole bunch.
I seem so confused now, maybe its because I've left the project for too long.
I would appreciate any further clarification on this particular issue and once again am indeed very sorry for the inconvenience.
Thank you so very much.
 
Top