Home - Search - Members
Full Version: Sensors
Pages: 1, 2, 3, 4, 5, 6
Amit Radha
Apr 6 2008, 8:38 AM
Hi Ajay,
How am i supposed to do that?
I checked it for a simple message display and it work so i assumed it is fine.
But i dint know i need to check for both lines and for all the locations on the LCD!

Is there something specific needed to be done. Pls tell me

Was busy today, done nothing... time is running out...

Just when i thought it was all falling into place this had to happen!
Chiru
Apr 7 2008, 1:39 AM
Hi Amit, use and amend this routine to check ur LCD. It is for 16X2 in 8 bit mode.


; LCD Example Program
; Works with P1 as data port, R/W connected to P3.2, Enable to P3.4, RS to P3.3
;*****
#INCLUDE "8051EQU.INC" ;include predefined constants
;
;**************************************************************************
; VARIABLES AND CONSTANTS
;
; The LCD Buffer is 16 memory locations (enough for one LCD line).
; To write a line, the characters are put in the buffer and then
; the whole line is written to the LCD.
B0 .EQU 070H ;BUFFER POSITION 1
B1 .EQU 071H ;
B2 .EQU 072H ;
B3 .EQU 073H ;
B4 .EQU 074H ;
B5 .EQU 075H ;
B6 .EQU 076H ;
B7 .EQU 077H ;
B8 .EQU 078H ;
B9 .EQU 079H ;
B10 .EQU 07AH ;
B11 .EQU 07BH ;
B12 .EQU 07CH ;
B13 .EQU 07DH ;
B14 .EQU 07EH ;
B15 .EQU 07FH ;BUFFER POSITION 16
;
;**************************************************************************
;
; RESET ;reset routine

.ORG 0H ;locate next command at 00H
AJMP START ;jump to START (first command of program)
;
;**************************************************************************
;
; INTERRUPTS ;place interrupt routines at appropriate
;memory locations
.ORG 03H ;external interrupt 0
RETI
.ORG 0BH ;timer 0 interrupt
RETI
.ORG 13H ;external interrupt 1
RETI
.ORG 1BH ;timer 1 interrupt
RETI
.ORG 23H ;serial port interrupt
RETI
.ORG 2BH ;locate beginning of rest of program
;
;**************************************************************************
;
INITIALIZE: ;set up control registers
;
MOV TCON,#00H
MOV TMOD,#00H
MOV PSW,#00H
MOV IE,#00H ;disable interrupts
RET
;
;**************************************************************************
;
DELAYMS: ;millisecond delay routine
; ;uses R7
MOV R7,#00H ;put 00H in register R7
LOOPA:
INC R7 ;increment R7
MOV A,R7 ;move R7 to Accumlator
CJNE A,#0FFH,LOOPA ;jump to LOOPA if R7 not equal to #FFH
RET ;return
;
;**************************************************************************
;
DELAYHS: ;half second delay using milsec delay
; ;uses R5 R6 (R7)
MOV R6,#00H
MOV R5,#002H
LOOPB:
INC R6
ACALL DELAYMS
MOV A,R6
JNZ LOOPB
DEC R5
MOV A,R5
JNZ LOOPB
RET
;
;**************************************************************************
;
DELAYS: ;delay for a second or two
; ;uses (R5 R6 R7)
ACALL DELAYHS
ACALL DELAYHS
ACALL DELAYHS
ACALL DELAYHS
RET
;
;**************************************************************************
;
;
;**************************************************************************
;
WRITELCD:
SETB P3.4 ;enable LCD
ACALL DELAYMS ;wait for write completion
CLR P3.4 ;disable LCD
RET
;
;**************************************************************************
;
EXECUTELCD:
CLR P3.3 ;ditto
SETB P3.4 ;enable LCD
ACALL DELAYMS
CLR P3.4
SETB P3.3 ;Make rs=1
RET
;
;**************************************************************************
;
LCDSETUP:
;
MOV P1,#03CH ;set up LCD 8 bits and 2 lines
ACALL EXECUTELCD
MOV P1,#00DH ;turn on display and cursor off
ACALL EXECUTELCD
MOV P1,#006H ;set increment one and shift
ACALL EXECUTELCD
MOV P1, #02H ; Home Display
ACALL EXECUTELCD
RET
;
;***************************************************************************
;
CLEARBUFFER: ; uses R0
;
MOV R0,#070H
CBONE:
MOV @R0,#' ' ; put a blank in the memory address specified in R0
INC R0 ; go to next memory address
CJNE R0,#080H,CBONE ; stop when address is 80H
RET
;
;***************************************************************************
;
WRITEBUFFER: ;uses R0
;
MOV R0,#070H
WBONE:
MOV P1,@R0 ; get character stored in the memory address specified in R0
ACALL WRITELCD
INC R0 ; go to next memory address
CJNE R0,#080H,WBONE ; stop when address is 80H
RET
;

;
;***************************************************************************
;
WRITEAmit_Radha: ;write Amit Radha to LCD
;
ACALL CLEARBUFFER
MOV B0,#'A' ;write A
MOV B1,#'m' ;write m
MOV B2,#'i' ;write i
MOV B3,#'t' ;write t
MOV B4,#' ' ;write
MOV B5,#'R' ;write r
MOV B6,#'a' ;write a
MOV B7,#'d' ;write d
MOV B8,#'h' ;write h
MOV B9,#'a' ;write a
MOV B10,#'*' ;write *
ACALL WRITEBUFFER
RET
;
;***************************************************************************
;
WRITELCD_Example: ;write Example to LCD
;
ACALL CLEARBUFFER
MOV B0,#'L' ;write L
MOV B1,#'C' ;write C
MOV B2,#'D' ;write D
MOV B3,#' ' ;write
MOV B4,#'E' ;write E
MOV B5,#'x' ;write x
MOV B6,#'a' ;write a
MOV B7,#'m' ;write m
MOV B8,#'p' ;write p
MOV B9,#'l' ;write l
MOV B10,#'e' ;write e
ACALL WRITEBUFFER
RET
;
;**************************************************************************
;
BEGLINEONE:
;
MOV P1,#080H ;go to beginning of line one
ACALL EXECUTELCD
RET
;
;***************************************************************************
;
BEGLINETWO:
;
MOV P1,#0C0H ;go to beginning of line two
ACALL EXECUTELCD
RET
;
;***************************************************************************
;
CLEARDISPLAY:
;
MOV P1,#001H ;clear display
ACALL EXECUTELCD
ACALL BEGLINEONE ;go to beginning of line one
RET
;
;***************************************************************************
;
;***************************************************************************
;
START: ;beginning of main program
;
MOV SP,#02FH ;initialize stack pointer to 2FH
ACALL INITIALIZE ;initialize registers
ACALL DELAYHS
CLR P3.2 ;make LCD R/W low (Stays low since we are just writing to LCD)
ACALL LCDSETUP ;initialize LCD
LCDLOOP:
ACALL CLEARDISPLAY ; erase LCD screen
ACALL DELAYHS
ACALL BEGLINEONE ; move cursor to beginning of top line
ACALL WRITEAmit_Radha
ACALL DELAYHS
ACALL BEGLINETWO ; move cursor to beginning of bottom line
ACALL WRITELCD_Example
ACALL DELAYHS
AJMP LCDLOOP ; go to LCDLOOP: (repeat)
;
.END ;end program
Amit Radha
Apr 7 2008, 7:39 AM
Hey Chiru,
Thanks so much for making this code. Helped me to understand some stuff... but i am unable to follow parts of it. Its so nice of you to take all the trouble to do it!

I have sorted out my LCD problem, I am able to display on both lines now. I just used a few LCALLs instead of ACALLs. And also included a delay between E high and low.

This is my finally corrected code
http://paste2.org/p/19269

But now i am facing 2 problems with display and interrupt basically.
1. When the LCD mode button is pressed, it displays the actuator status, waits 5sec then clears and displays the sensor data (only the temp as of now) but on that screen it sometimes displays C twice or the temp again on the right side. Basically it is displaying junk also! and then it gets corrected from the next time and the display is ok.

2.When the LCD mode button is pressed, it displays the actuator status, waits 5sec then clears and displays the sensor data, then it displays the actuator status screen again! And then the sensor data screen again with the same problem i faced in point 1. Then it continues to display teh sensor data screen normally thereafter.

I made a video of it and posted on google video. but it will take time for approval. If u know any site pls tel me il upload it again so ul be able to understand wat exactly is the prblem.

I am still stuck up. was hoping to complete the whole code by tonight and i still have my seminar on display devices to prepare!!! going mad now!!!!

Pls do reply asap...
pdi33
Apr 7 2008, 8:21 AM
hello bro! was not available for some time as net was down for a few days. well, glad to see that u have indeed made some progress. anyways, ur problem is simple. just imagine that ur main code had displayed half of your lcd display when u pressed the button. here the control would go to the interrupt and display sensor_data. but what would happen once the control exitted the interrupt?. well it would try to complete the other half of the lcd display which makes your display show junk. got it? . the solution is simple.
just remove the statements
ACALL data_display ;Call LCD display routine (for actuator status)
CLR LCD_INTR ;Clear interrupt check flag
from the interrupt and add the statement
CLR LCD_INTR
below the statement
JNB LCD_INTR, sensor_display ;if ACT=0, jump to display sensor data label
and now check the logic. Now if u see there would be no conflict in displaying the
LCD data as 'data_display' is only called in main loop and not in the interrupt.
Amit Radha
Apr 7 2008, 9:01 AM
Hey pdi33!!!
Back after a long time!!! And you solved my problem in a jiffy!!!! Thanks a million bro!!!
So that means i can remove all those push and pop instructions also from the isr as i am not manipulating them by any chance when the interrupt occurs.

I also have 1 doubt, now as i am reading only 1 sensor, the delay involved from when the button is pressed to when the actuator status is diaplayed is not much, but when i include all 4 sensors and if i also implement Shyams barrel shifter algorithm, then wont there be a noticeable lag between pressing the button and the actuator status being displayed?

Also, a small concern, the heat sink on the 7805 is heating up quite a bit, is it because my adapter o/p is ~12V? But its rating says its a 9V 500mA adapter (Panasonic cordless phone adapter) .

Btw, my groupmate feels you guys are angels, who solve all the problems we face so easily.

Thanks once again pdi33!!! I can now move on to the other sensors
pdi33
Apr 7 2008, 9:21 AM
i don't think u will face any lag problems .
as for the 7805, don't worry, it will heat up a bit as the power dissipated is high. as i mentioned earlier, take care that the current thro it is always less than 500~600mA and relax,
pdi33
Apr 7 2008, 9:42 AM
try not to read all the sensors in one routine. try the following logic:
ch-no: equ 31h
temperature_data: equ 51h ; (uses locations 51h to 57h for storing temperature data for eight channels)

main:
.....
...
lcall adc_read
mov a,#temperature_data
add a,ch-no
mov r0,a
mov @r0,buffer
inc ch-no
mov a,ch-no
anl a,#07h
.....
.....
sjmp main



here in one loop execution, u are reading temperature of only one channel,
so the lag would be exactly the same as now with a single sensor.

Note that u have to store the various channel readings in seperate locations foractuator logic.
Amit Radha
Apr 7 2008, 11:05 AM
hey pdi33,
Well I am using a 500mA adapter so i dont think there is any danger of drawing excess current. Still, il check the entire setup in college again and remove any excess baggage of the setup.

I am a bit confused about the logic u have mentioned.
Correct me if I am wrong.
1. Read ADC data
2. Mov 51H (#temperature_data) to A
3. Add A, ch_no ; ie. add 00 to 51
4. Store it to R0 (pointer)
5. Store the buffer data obtained from adcread routine into address pointed by R0
6. Inc ch_no

why do u mov ch_no to A and then And it to 07h? (so that when it exceeds 7 it is converted back to 0 i guess) but then after that shouldnt it be stored back into ch_no?

So basically wat i need to do is read 1 sensor at a time by the ADC routine store it in a separate location and then read the next sensor right? Il follow that logic. Thanks

Another thing is that i am using only 4 sensors and i have tied ADDC to Vcc and am using IN4 to IN7 of the ADC so i need to only supply ADDA and ADDB by the uC. I did this basically to save 1 pin of the uC for my actuators.
pdi33
Apr 7 2008, 11:49 AM
u r right. i missed the mov ch-no,a part .
anyways, the important part is that u got the idea. .
well if u are using only four sensors then and the ch-no with #03h instead of 07h, simple.
In fact u can use the last two bits of ch-no and directly output them to the ADDA and ADDB pins for selecting the appropriate channel before calling the ADC_read routine.

As far as the transformer is concerned,the transformer can supply more current even if the rating is 500mA but it's output voltage will drop due to loading.
In any case, i don't think u are using more than 200~300mA of current max. so stop worrying . The 7805 (If it is of good quality) has an iinternal thermal shutdown safety, so it will just switch off if its temperature exceeds max. ratings, so uwill know if your circuit is loading it if it suddenly outputs 0V after sometime.
Amit Radha
Apr 7 2008, 1:30 PM
hey pdi33,
I tried using ur loginc to extend the code. Made a few changes to it and tried implementing it. Basically i thought, il read all the sensors and store in the buffer then display it. and the time involved in reading al the sensors is not much. Because reading each sensor and then displaying the whole thing makes the code redundant. what do u feel?

i have changed the code as required. few more changes are needed to it basically for the light and soil moisture i wont be using look up tables, i will only check if the i=ADC o/p is between those thresholds and separate them into each level and use some thing like an if else if loop to display the level.

But when i just tried running it, it dint work it just displayed the initialisation message and then stopped. Even the interrupt button changed nothing. Resetting the system also just redisplayed the initialisation message. wat is wrong? any idea?

This is my updated code
http://paste2.org/p/19313

Good night
Amit Radha
Apr 7 2008, 1:34 PM
hey pdi33,
I tried using ur loginc to extend the code. Made a few changes to it and tried implementing it. Basically i thought, il read all the sensors and store in the buffer then display it. and the time involved in reading al the sensors is not much. Because reading each sensor and then displaying the whole thing makes the code redundant. what do u feel?

i have changed the code as required. few more changes are needed to it basically for the light and soil moisture i wont be using look up tables, i will only check if the i=ADC o/p is between those thresholds and separate them into each level and use some thing like an if else if loop to display the level.

But when i just tried running it, it dint work it just displayed the initialisation message and then stopped. Even the interrupt button changed nothing. Resetting the system also just redisplayed the initialisation message. wat is wrong? any idea?

This is my updated code
http://paste2.org/p/19313

good nit
pdi33
Apr 7 2008, 9:05 PM
make the following changes:
1. change the follwing jump
CJNE R1, #04h, adc_main ;Check for chanel no. not exceeding 7
to Cjne r1,#04h,adc_ret
mov ch-no,#00h
adc_ret: ret

2. change sensor_data assignment to some other location other than 50h which is already used by ASCII-RESULT.


hope u underatand why i am suggesting the changes
pdi33
Apr 7 2008, 9:11 PM
hint:
say u want to output the status of 3rd bit of register 'ch-no' tp port p2.1 use the following instructions:
clr c
mov acc,ch-no
mov c,acc+3
mov p2.1,c
simple isn't it?
sashijoseph
Apr 7 2008, 9:25 PM
Hi PDI.......about the changes you suggested.
The Ascii_Result has been commented out if you observe closely.
The 1st change you suggested is a good one coz it'll reduce the time delay when the switch interrupt occurs (as now only 1 channel is being read and displayed at a time).

But apart from the 'lag' the code seems ok and should have worked.
Anyways lets hope the change works...
Amit Radha
Apr 8 2008, 8:43 AM
Hey pdi33!
Thanks for correcting me. Now i know what i was doing wrong! My system was in an infinite loop of reading the ADC only and that is why it was just showing the LCD initialisation message. How dumb could i be!!
But i dint understand how this can work pdi, it is a very helpful piece of info u have given though! Can simplify the problem of Setting and Clearing the address bits of the ADC:
pdi33 wrote ...

hint:
say u want to output the status of 3rd bit of register 'ch-no' tp port p2.1 use the following instructions:
clr c
mov acc,ch-no
mov c,acc+3
mov p2.1,c
simple isn't it?


Btw, When the code i posted last nit dint work, i recoded using a different logic (nothing new ) I just extended the code of the temp sensor read logic and changed the Address lines every tie stored them in different buffer locations and it worked. I could see results for 3 of my sensors.(4th one i did not connect as checking soil moisture is a dirty job )

But there was a hiccup i faced, I got an error message
*** FATAL ERROR L250: CODE SIZE LIMIT IN RESTRICTED VERSION EXCEEDED
(il upload a screenshot of the entire o/p window as it is long) and it did not create the target file. I deleted quite a ew lines from my look up table and it then created the hex file. Could it be because i am using an evaluation version of keil and my code exceeded 2K?
Il also upload the code i had used.
I know it is a very foolish and wasteful way of coding but i was desperate to see the o/p on the LCD and couldnt figure out what was wrong in the code i did last night! (I was half asleep when i was doing it i guess!!)
codev0.3.zip

Amit Radha
Apr 8 2008, 8:45 AM
oops thats the error message screen shot.
codev0.3.zip is my code i used to get the o/p today and i cut short the LUT to have it working...
pdi33
Apr 8 2008, 12:08 PM
hmmm, i don't see any way to reduce ur code further except that u can remove the push and pops in interrupt service routine as they are unneccessary now.
another way is to use asm51 assembler downloadable from atmel site which is a free version. else check PM
sashijoseph
Apr 8 2008, 6:28 PM
Yup ASM51 is neat.Use Keil's IDE to create the source only.
Amit Radha
Apr 9 2008, 6:13 AM
Hey thanks il check them out... I tried Ride, it came on the disk i got with my programmer but that was really wierd! It gave me errors in the include file itself!
I used the same code i just put $include (reg51.inc) as teh 1st line. (That is how i did it in college last sem for my 8051 lab!) and it was showing hundreds of errors! Even in the included file!

Guess il stop bothering about that for now!

Wel regarding optimising the code, i can still do it if i implement ur(pdi33) logic of using the consecutive memory and looping the ADC read operation. If u see my v0.3 code, i just repeated the same code i used for the lm35 for all sensors and its due to that i think the code size exceeded!

Regarding h/w i still have a few concerns! My moisture sensor seems to be wierd. It is not very precise and the difference in o/p voltage for a moist and totally wet soil is hardly .3V. Any ideas on how do i improve it? my main concern is that i need to turn on a pump when it is dry and switch off when it reaches an optimum level of moistness.

Also regarding the Actuators, I am using BC547 to switch on/ off the relays. (I had posted the ckt few days back, should i do it again?) will it be safe to connect it like that to the uC? there will be no problems regarding drawing excess current etc right? any other protection ckt i should involve?
Amit Radha
Apr 9 2008, 6:27 AM
Sorry i forgot to ask,
Now since i can remove the push and pop instructions, the only thing left in the isr is
CODE:
SETB LCD_INTR

So shall i put it at org 03H only, followed by RETI, instead of a jump instruction to int_isr?
sashijoseph
Apr 9 2008, 7:37 AM
Yeah....that will save you a ljmp.
Amit Radha
Apr 9 2008, 7:53 AM
Thanks shashi, Pls have a look at my last post on page 22 also.
Aso regarding ASM51. I have it but unable to asemble. when i enter the file path and name it gives some error which i cant see the cpu beeps and the window shuts down with lightening speed. can just make out some "errors" dunno how many or what!
sashijoseph
Apr 10 2008, 12:56 AM
Amit Radha wrote ...

Hey thanks il check them out... I tried Ride, it came on the disk i got with my programmer but that was really wierd! It gave me errors in the include file itself!
I used the same code i just put $include (reg51.inc) as teh 1st line. (That is how i did it in college last sem for my 8051 lab!) and it was showing hundreds of errors! Even in the included file!

Guess il stop bothering about that for now!

Wel regarding optimising the code, i can still do it if i implement ur(pdi33) logic of using the consecutive memory and looping the ADC read operation. If u see my v0.3 code, i just repeated the same code i used for the lm35 for all sensors and its due to that i think the code size exceeded!

Regarding h/w i still have a few concerns! My moisture sensor seems to be wierd. It is not very precise and the difference in o/p voltage for a moist and totally wet soil is hardly .3V. Any ideas on how do i improve it? my main concern is that i need to turn on a pump when it is dry and switch off when it reaches an optimum level of moistness.

Also regarding the Actuators, I am using BC547 to switch on/ off the relays. (I had posted the ckt few days back, should i do it again?) will it be safe to connect it like that to the uC? there will be no problems regarding drawing excess current etc right? any other protection ckt i should involve?


With a 0.3V difference and a slope of 30mv/%RH you still have around 10 steps to use for your go-nogo logic.That should be enough.And like the temp. sensor use averaging to smoothen up the values a bit.

The relay ckt is fine.Just don't ever forget the protection diode across the coil.

As for ASM51 you need to copy the reg51.inc file from RIDE to the ASM51 directory(if not already present).And use the command prompt to work with asm51.
I compiled your code with asm51 and the only error I got was the double quotation marks in the initialisation strings(should be single quotes).
And to check for error reports see the .LST file generated.
Amit Radha
Apr 10 2008, 7:57 AM
sashijoseph wrote ...

With a 0.3V difference and a slope of 30mv/%RH you still have around 10 steps to use for your go-nogo logic.That should be enough.And like the temp. sensor use averaging to smoothen up the values a bit.


Hey shashi I think u mistook me. I was mentioning about the soil moisture sensor not humidity. IL post the ckt again. got it at robfaludi.com

Yeag regarding the RH also, i tried NaCl today, and i could only get a 60% reading that too it took time to show that value. And i was told that its not a safe way to demonstrate the HIH as salt particles will get stuck in the sensor window. Wat should i do? We thought of using a metal hollow tube spraying it a little water in it and sealing and then heating it (externally) using a blower. that should increase the humidity inside right? How would that be?

And thanks for the info on ASM51. I could get a full ver of keil so il use that

pdi33
Apr 10 2008, 11:02 AM
well, this is not the right time to suggest, but i feel seeing ur project, the ideal choice of microcontroller would have been the ATmega series AVRs. they have exactly all the features required by u in the project. Maybe u could suggest this upgradation in ur project report for further enhancement .
Features that could be used from the AVR:(not present i traditional 8051)
1. inbuilt 10 bit ADC (min. 6 channels input)
2. faster execution time.
3. inbuilt eeprom. (u need one to store the actuator set points.!)

This would have drastically reduced ur hardware and a simple 28pin ATmega8L would have done the trick.
Amit Radha
Apr 10 2008, 11:45 AM
Well even i was told the same. But dint want to get into learning the nitty grities of a new controller. With the 8051 i have some good knowledge so it was easy to code. If i had taken up AVR i would stil have been figuring out what to do. Well i had already projected it as an improvement in my 1st seminar

There is stil loads to do, my soil mositure sensor seems to be behaving wierd now.
Need to complete my code today and try it out on the entire setup with the relays and all sensors and buzzer so then i can then get to the finishiung touches. The sem is coming to an end and loads of other things to do. Not yet prepared my non project seminar .... and reports!!!! Huh thats another daunting task!

But thanks a ton to u guys, I atleast reached till here!!! Now hoping theentire system works...
shyam
Apr 10 2008, 11:49 AM
hey amit,
u are a quick learner,
i still remember your first topic on using keil.....
nobody catches up so fast good going buddy
Amit Radha
Apr 10 2008, 11:54 AM
Thanks Shyam!
Well, i had a very good teacher who taught me 8085,86,8051 and VHDL. So i have always had interest in processors and controllers.
I have another project idea but it involves image processing and networking and stuff. Il post it after i complete this!

Thanks once again... and il continue to bug you all untill my system works perfectly...
Chiru
Apr 10 2008, 9:27 PM
Good luck
Amit Radha
Apr 11 2008, 6:58 AM
Thanks Chiru,
Tested with 3 sensors today. Working just fine... had a mnd boggling time trying to figure out why the pins for the actuators were always on and then few were ok. Later i realinsed, all the ports are pulled high!!! I need to clear those actuator control pins in the beginning.

Not tested with the relays and actuators, il probably do it on tuesday now as monday is a holiday. need to correct the code over the weekend and am itching to see the whole thing work as one unit!

Hey any ideas on demonstrating the humidity sensor and also to make the soil moisture ckt (posted above) more reliable???
Chiru
Apr 11 2008, 1:14 PM
Well, demonstrating a humidity sensor, other than the chemical process, is difficult. Otherwise, what I could have done, put a commercial hygrometer by the side and compare the results
An electronic controlled humidifier (from Honeywell) in a closed chamber is an ideal device for demonstration, but is very very costly (i had seen this at someone's place, have no details right now).
As for the soil moisture, make a simple potential divider network.A 1M pot from +5V, other end to one of the soil probe. Other soil probe to GND. The resistance of the soil will give some value of voltage against soil moisture, adjust it with 1M pot. You have to adjust the ADC ref accordingly. There is scope of little improvisation, hope it works for you.
Amit Radha
Apr 12 2008, 12:13 AM
Hey Chiru,
Thanks for the idea... but frankly its too expensive for my final yr project i think I am planning to use a metal tube spray with water seal it and heat. That should increase the humidity inside. I just need to simulate change in humdisy afteral! Hope this works, il try it in a few days.

Regarding the soil moisture sensor, shal i ditch this sensor that i have? Another thing is if i use that 1M pot wont i start drawing more current? (I modified the light sensor ckt as it was drawing lot of current.) And another problem is, i have made 6 look up tables (all depend on the Vref of the ADC). Now if i change the Vref, il get into big time soup
pdi33
Apr 12 2008, 1:28 AM
what is the problem with the method suggested using different chemicals? . i have tried it before on a commercal humidity sensor (which gives a 0~1V output) and it gave excellent results. The only thing u have to make sure is that the solution is a saturated solution. A dilute solution takes eons to bring the environment above it to the desired humidity level.
pdi33
Apr 12 2008, 1:31 AM
and, about the current being used by 1M pot,well the max. current take by it ould still be in microamperes so do not wory about the current consumption
Amit Radha
Apr 12 2008, 2:04 AM
Hey pdi33,
Well there is no problem regarding the solutions u mentioned. I ntried NaCl, it was taking time to increase, and it only reached 60%. But the lab foreman said that its not too safe to use NaCl solution like that as the sensor is very sensitive and flimsy, it could get spoilt by crystalisation of NaCl by exposing it to such a concentated air above a saturated soultion. Wel, if u say its safe then il stick to ur idea. Its far easier and looks professional too Il get some brownie points for my demo.

Regarding the soil moisture sensor, il try this new method. But where do i read the o/p voltage? across the 2 sensor probes and the gnd? is this how the ckt should look?
pdi33
Apr 12 2008, 3:31 AM
let me tell u why i insisted on the idea;
actually, when we (our company first designed a RH indicator, we too faced the same problem but in a different sense. Actually, we had no method to calibrate the sensor. We needed atleast three different humidity points to calibrate the sensor. So we asked the sensor main distributor the solution to this problem. He told us that there is a cost effective solution to this problem. actually some rh manufacturers give economical vials with some solutions whose RH have a fixed value.u introduce the solutions into an airtight enclosure along with the sensor and the air aove it reaches the required RH just like i explained about the NaCl solution. but this cost efeective solution in a vial of hardly 10ml costs around 900INR. not so cost efective is it? so i stuck to the procedure using common salts. In fact some pharmaceutical companies calibrate their humidity sensors (where accuracy is not critical) using this method usually to measure the air humidity inside their buildings . they usually require a temperature of 25 degrees and relative humidity of 98%. So go ahead , in fact u have access to more sulphates and chlorides than us.
pdi33
Apr 12 2008, 3:32 AM
about the moisture sensor, i am sorry but i have little idea about the principle of operation of such sensors.
sashijoseph
Apr 12 2008, 3:31 PM
Amit Radha wrote ...

Regarding the soil moisture sensor, il try this new method. But where do i read the o/p voltage? across the 2 sensor probes and the gnd? is this how the ckt should look?


Yeah your ckt is more or less correct.Or look at the one below.
For the probes try using thick copper wires around 6-8cm long and separated by ~3-4cm.
For the 1M pot,keeping its res. ~3-4k will give you a voltage ~1v or so in a fully wet condition and ~4v in dry condition.Enough range for your purpose.These are just ballpark figures though...you need to test for your soil sample.
Another point of concern is corrosion of the electrodes due to passing of a dc voltage for long periods.A better alternative would be using ac voltage from the transformer and then rectifying and rc averaging before feeding to the ADC.
For now though you may stick to dc and check if it's working ok.

And for demonstrating the RH sensor,like Pdi mentioned,many manufacturers themselves suggest using sat. salt solns. for calibration.So I guess it should be safe.Here's a pdf from Smartec outlining the process of calibrating it's capacitive rh sensor....


apphs1002.zip
Amit Radha
Apr 13 2008, 1:29 AM
Hey pdi,
That was really informative thanks a lot Your idea was the best way we had but since we were told that the sensor could get damaged we thouht of anther option! But now since you say thats how its done commercially! Il do it the professional way

Thanks Shashijoseph,
Il try out this ckt on tuesday. Hope it solves my problem. Il keep in mind ur specifications for the probes. Actually i was unable to get those thick copper wire (they are called AWG wires right if am not mistaken?) but just couldn lay my hands on them, so i was using my pcb board as the probes after cutting it out into 2 strips nearly 5 cms long (the gap b/w the, was too less... ~5mm!!!)

Il try out ur suggestions asap...
Amit Radha
Apr 22 2008, 2:32 AM
Hi,
Back after a long time. Sorry for not logging in, been busy with other college work!

I have almost completed my entire system. Just interfacing it with AC devices is left. That too is almost done. Need to do the phase and line wiring to fan and bulbs etc.

Everything seemed to be working fine untill today There are a few funny problems I am facing and no matter how much i try I am unable to find out what is wrong!

1. In my actuator status, in the 1st line it must display "C: *** PU:***" where *** is either "ON" or "OFF". Initially it was working perfectlybut after making a few modifications in my code for other purposes (and no change made in the display part) it is diaplaying some junk instead of "C:". Everytime i reset, it changes. Its either "GC" or yen symbol etc... What has gone wrong?

2. I have connected a buzzer in my ckt (u can see the ckt below) connected to P3.6 which i am using to give a small buzz everytime any actuator is turned on. But since the uC internally pulls the ports high, the buzzer is continuously ON untill it is turned off in the code. To solve this problem, I tried to first make P3 low in the beginning but it dint work. So i then tried making only P3.6 low, even that dint work so i introduced a delay after it. The delay is noticable but the buzzer does not turn off! It only turns off in the code when it is turned ON and OFF when an actuator is turned on. So i did that also, ie. SETB P3.6, delay and then CLR P3.6 but it still does not work in the bigging. P3.6 is high untill the condition as i mentioned above!

I thought i have conked my uC (as i happend to invert it on my board once) so i burnt the code on another uC but it is still the same. Both the problems exist. I also have a feeling that the buzzer is not buzzing when the actuator for the temp sensor (ie. Cooler) is turned on.

I am uploading my latest code also. Pls do have a look.

I shall be waiting eagerly... my submission is in 2 weeks!!! :'(

code_v0.5.zip
Ajay
Apr 22 2008, 4:33 AM
shortage of ram can cause a problem like this and there is hardly any solution to this problem. Try some of these...
Change controller with better ram.
Change optimization technique of code generation.
Optimize the way you are defining local variables and strings, either small or large.
Amit Radha
Apr 22 2008, 4:39 AM
But if u check my code, i am hardly using my RAM!
especally location 60h to 80h used for the actuator status is not touched at all, and some part of it is static and does not change.

And what about the pin for the buzzer?

Shall i put a not gate between p3.6 and the base of transistor? then i can turn it on by doing CLR and off by SETB. ALso since p3.6 will be high by default, that will cause it to be off only|?
Amit Radha
Apr 22 2008, 11:07 PM
Hey sorted out that problem
I had made a collosal blunder. Realised it when i tried debugging the code and used the logic analyser feature..

I had put 3 instructions ie >10bytes after org 00h and that was overlapping with the isr for INT0.

So i made the necessary change and it is working perfectly!!
Amit Radha
Apr 24 2008, 3:11 AM
Just when things seemed to be going in the right direction, I am back to square one!!!

My humidity sensor HIH4000 seems to be in a foul mood all of a sudden. Was testing the entire setup together when i noticed that its o/p is varying alot! It was not so before. Infact by just bringing my hand close to it, the humidity reading changes from 26 to 35 and by cupping it within my hands it crossed 46!!!

The problem is not the code. I disconnected it and checked its o/p voltage and performed the calculation and it was nearly same as the setup showed me.

Do you think it has got spoilt. I have very rarely handled it and my other groupmates also vouch that they did not interchange the Vcc and Gnd.

What could be wrong? Also i just touched its plastic body and it was not heating up.

Pls do give me a solution to this problem... I dont think i can afford another HIH now!!!
Chiru
Apr 24 2008, 3:29 PM
Keep the sensor in a charged silica gel jar over-night to remove moisture (contact chemistry lab technicion for the silica). Moisture trapped in the humidity sensor can cause such problems. Take care with the chemicals used to calibrate the sensor (do not make contact). Particles of salt may destroy the sensor in long run. Hope this solves the problem.
Amit Radha
Apr 25 2008, 12:20 AM
Hey Chiru,
Back after long? How are u?
Il try it out with the silica gel. Just dint strike that it moisture could be the problem even though i knew its very sensitive if brought in contact with excess moisture.
I have not brought it in contact with any solution. Even while testing the humidity it was kept in the NaCl solution's environment for not more than 5 - 10 minutes. Il check it out with the silica over the weekend. Hope that solves the problem.

Progress with the proj:
Everything seems to be working just fine. Presently working on the beautification part. Placing the entire boards etc on to PVC board with spacers etc. Shold be ready by next week then planning to get a transparent box (not glass, acrylic or similar material) by an aquarium maker. Need to hunt out that after this

Hey chiru, could u provide me with the source for the document regarding the humidity values u mentioned? I could include it in my Appindex and its source in my references in the documentation...
Amit Radha
Apr 28 2008, 12:41 AM
Hey Chiru,

The Silica gel dint seem to work I bought 2 fresh sachets of silica gel and put them in a small air tight container over the weekend. Today i tried it out in the lab and the result was same. The o/p voltage just increases rapidly from 1.8V (in open air, nothing near the sensor) to 2.7V or more (i dont remember) when i bring my hand near it!

Isnt this a bad sign?? What is wrong?? Am getting desperate. 11th May is the date for my project demo with report and presentation etc!!!

Also i tried interfacing the entire system with AC bulbs and Fan and the result was not too wncouraging either. Sometimes i can hear the relays switch but there is no change in the state of the bulbs.

Also sometimes the o/p at the pins for turning on the relays is at ~2 to 3V why is that!!! it should be close to 0 (which it is) and above 3V atleast right to be consodered as logic high?

What do you think is going wrong? Tension seems to be getting the better of me now!
pdi33
Apr 28 2008, 1:17 AM
hi amit,
the output of your relay port pin being 2~3V is perfectly o.k.. Actually, the reason of this is that the ports of 89c51 (except P0 which is open collector) are weakly pulled up and the output volatge at logic 1 will progressively decrease as u increase the sourcing current to the transistor. A best way to avoid the problem is to use a PNP transistor in between the BC547 and port pin.But in that case u have to invert the relay logic in ur software because a logic 1 would turn OFF the relay and logic 0 would turn ON the relay.
Another solution is to use a buffer/driver like ULN 2003. In fact ,it is highly recommended if u are using more than one relay as it would save u a lot of hardwiring and trouble shooting. .
As far as the HIH is concerned, i have not used it so far so cannot comment on it. Have u checked whether another HIH sensor creates a same response??
Amit Radha
Apr 28 2008, 1:30 AM
Oh ok. yeah i can try using PNPs.well i have done all the wiring now... and it all seems to be working right and when i checked them individually they were turing on when the base of each 547 was given 5V and off when 0V. But with all together and in the code its behaving a bit conked...

I need to check tehm individually with the uC now i think..

Well regarding the HIH i have only 1 (which seems to be conked now) and it costs 800 bucks!!! so i have not bought another! I think Chiru and Shashi will be having an idea about it.. thay had only sugested the HIH to me...
sashijoseph
Apr 28 2008, 1:37 PM
Hi Amit.
What value base resistors have you used for the relay drivers?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007