sashijoseph
Mar 4 2008, 10:51 AM
that opamp is for calibrating the LM35 to obtain precise results.If one ortwo degree error will do for your application,then you don't need it.
abbas1707
Mar 4 2008, 12:59 PM
yes opmp is needed to fulfill the "signal conditioning"
you can also use a divider network for this.
but as sashi said , you can connect lm35 directly with adc
you can also use a divider network for this.
but as sashi said , you can connect lm35 directly with adc

Amit Radha
Mar 5 2008, 6:22 AM
Thanks a lot. il keep that in mind. wil be caliberating my sensors tomorrow for use wit the adc. and the next step is the programming.
I wanted to know. do i need to provide the OE, START, ALE signals from the uC or can i do them as i did in the stand alone mode and only supply the addresses A, B , C by the uC and read the data thro it? after reading the data from the ADC i plan to cyclicly display them onto the display or to use buttons for each sensor so that when u press a button, that sensors reading is shown in the display. Also an actuating mechanism wil be controlled by the uC for each sensor such as artificial lights, motors, pumps etc.
I wanted to know. do i need to provide the OE, START, ALE signals from the uC or can i do them as i did in the stand alone mode and only supply the addresses A, B , C by the uC and read the data thro it? after reading the data from the ADC i plan to cyclicly display them onto the display or to use buttons for each sensor so that when u press a button, that sensors reading is shown in the display. Also an actuating mechanism wil be controlled by the uC for each sensor such as artificial lights, motors, pumps etc.
Chiru
Mar 5 2008, 8:43 PM
Hi Amit, to start with PIC, download the book "PIC in Practice A Project based Approach 2nd Ed." Its available for download in this site itself (in fact there are others too)
Do not jump to 16F74, start with simpler ones like 12F675, 16F88 16F818 etc (they all have build in ADC)
.
If you are using a uC, why to feed control signals manually
of course you can have switches for data out.

Do not jump to 16F74, start with simpler ones like 12F675, 16F88 16F818 etc (they all have build in ADC)
. If you are using a uC, why to feed control signals manually
of course you can have switches for data out.
sashijoseph
Mar 5 2008, 8:51 PM
Yup Chiru is right......with a uc there's no point doing it manually and moreover in free running mode how will you decide exactly when to read in the data?So do it the right way and believe me it's very simple too. 

Amit Radha
Mar 6 2008, 8:49 AM
Hmmm oki. Il keep that in mind. the basic reason i thought of not giving al signals to the uC was to save the i/o pins as il be needing quite a few. I was thinking of only controlling the address lines by the uC and obviously data lines also wil go to it. Since my ALE is connected to CLOCK in the free running mode i thought of keeping it that way only. Do u think its not right? can u pls tel me the basic part of the code... (dont get me wrong) i just mean the sequence of the control signals. Or can i use the same as mentioned by Mazzidi in his book?
Also i felt that since OE and START can be always connected to +5V and i can just read the o/p as and when i need by changing the Address lines. But then wont my EOC always be low and trigger my uC interrupt!
Am also confused with the algorithm for my code. need to code it properly as i need to store each data for each sensor in one shot to stack and then display onto the LCD. Then check for the thresholds and perform control operations!
Lots of questions
sorry... my 1st proj on a uC. I thought i was good at this and now am busted!
K then waiting for u guys' expert advice... thanks a ton guys!!!!
cya
Also i felt that since OE and START can be always connected to +5V and i can just read the o/p as and when i need by changing the Address lines. But then wont my EOC always be low and trigger my uC interrupt!
Am also confused with the algorithm for my code. need to code it properly as i need to store each data for each sensor in one shot to stack and then display onto the LCD. Then check for the thresholds and perform control operations!
Lots of questions
sorry... my 1st proj on a uC. I thought i was good at this and now am busted!
K then waiting for u guys' expert advice... thanks a ton guys!!!!
cyasashijoseph
Mar 6 2008, 10:30 PM
You can follow Mazidi for programming the ADC.
And for starters you may follow these steps......
while(1)
{
get_adc(temp) x 10 => T //get 10 samples for temp and store the average in T
get_adc(hum) x 10 => H
get_adc(ldr) x 10 => L
Display(T)
Display(H)
Display(L)
if(T>Tthresh) do .....
if(H>Hthresh) do ....
if(L>Lthresh) do .....
some_delay()
}
And for starters you may follow these steps......
while(1)
{
get_adc(temp) x 10 => T //get 10 samples for temp and store the average in T
get_adc(hum) x 10 => H
get_adc(ldr) x 10 => L
Display(T)
Display(H)
Display(L)
if(T>Tthresh) do .....
if(H>Hthresh) do ....
if(L>Lthresh) do .....
some_delay()
}
Amit Radha
Mar 7 2008, 6:18 AM
Hi shashi thanks for the idea. this was basically wat i had in my mind. but i had not thought of having the avg of 10 values. as i thought il keep displaying the variations on a real time basis. I am basically foxed on the reading the data and storing into stak part. and another prob! i have not got a hold on programming the uC in C so i am stil stuck to assembly level programming only
Also i was having another doubt. how do i provide a clock to the ADC? i had thought of 2 inverters with an RC this was generating a 850kHz clock but wil i be able to synchronise the ADC with the 8051? I wil be using a 11.0592 crystal for it. In Mazidi he shows a diagram where the same crystal is tapped and a propagation delay is introduced by means of cascaded d flip flops. can i stick to the inverter buffer or the Mazidi way or do u suggest something else?
Also i was having another doubt. how do i provide a clock to the ADC? i had thought of 2 inverters with an RC this was generating a 850kHz clock but wil i be able to synchronise the ADC with the 8051? I wil be using a 11.0592 crystal for it. In Mazidi he shows a diagram where the same crystal is tapped and a propagation delay is introduced by means of cascaded d flip flops. can i stick to the inverter buffer or the Mazidi way or do u suggest something else?
sashijoseph
Mar 7 2008, 11:35 AM
and another prob! i have not got a hold on programming the uC in C so i am stil stuck to assembly level programming only
You call it a problem?Many would love to be burdened with such a problem(asm skill)
As for the clock you can directly feed it from the 8051 using timer interrupt.
Ajay
Mar 7 2008, 9:16 PM
well thats the reason my preference for newbies is to use assembly first rather to go for C. C makes you lazy
and you find things very very hard if you have to write a code in asm.
and you find things very very hard if you have to write a code in asm.Amit Radha
Mar 8 2008, 6:01 AM
Wel my skills in assembly are nothing great either... but farely decent.
Regarding the clock, using timer is a very good idea as there wil be no synchronisation problemms and ul get a clean pulse but my problem is that i am trying to reduce the no of pins of the uC. This is mainly because i am having an ADC, LCD (probably buttons for it...which i most probably will have to eliminate and use a time varying display) and also mtors, relays etc to my uC. so i need to be careful with the no of pins i use for everything.
Also later i plan to make it an sms based system so that wil again need the serial commn pins! And my stage 3 is to make it a multi processor system (hope i can achieve that b4 the deadline).
Another embarrasing problem that has tied me down is that i am stuck with making my power supply. got the +5V but in an attempt to get -5V i blew the thing up (dint refer datasheets of 7905!!!) and all subsequent boards were al screwed up (pardon the language)
i need to redo it carefully now!!!!
And i am yet to start coding
:'(
Regarding the clock, using timer is a very good idea as there wil be no synchronisation problemms and ul get a clean pulse but my problem is that i am trying to reduce the no of pins of the uC. This is mainly because i am having an ADC, LCD (probably buttons for it...which i most probably will have to eliminate and use a time varying display) and also mtors, relays etc to my uC. so i need to be careful with the no of pins i use for everything.
Also later i plan to make it an sms based system so that wil again need the serial commn pins! And my stage 3 is to make it a multi processor system (hope i can achieve that b4 the deadline).
Another embarrasing problem that has tied me down is that i am stuck with making my power supply. got the +5V but in an attempt to get -5V i blew the thing up (dint refer datasheets of 7905!!!) and all subsequent boards were al screwed up (pardon the language)
i need to redo it carefully now!!!!And i am yet to start coding
:'(sashijoseph
Mar 8 2008, 10:11 AM
Don't worry ...... we all make mistakes.I remember wiring a 78L05 like a 7805 without caring to read the datasheet and then ending up with a lighter pocket.
So make an estimate of exactly what all stuff you would be hooking up in ver1 of your project.Then calculate the total pin requirement and if it crosses whatever is available then you can start using alternate tricks to reduce pin count.
So make an estimate of exactly what all stuff you would be hooking up in ver1 of your project.Then calculate the total pin requirement and if it crosses whatever is available then you can start using alternate tricks to reduce pin count.
Amit Radha
Mar 9 2008, 3:32 AM
Hmmm il surely keep that in mind. Its been a real learning though slow experience for me. hope i can get this power supply sorted out tomorrow. I have started working on how i want the entire setup to look and work like. just been too lazy over the week end.
Also on the ADC and uC part i had a doubt, do u think there wil be synchronisation problems if i do not use a clock sourced by the crystal or the timer feature as u mentioned? also wil noise be a problem if i use a slightly longer wire for connecting the clock of the ADC from the uC?
Regarding the conncetions of sensors to the ADC. do i need to use any resistors b/w them to limit the current? My biggest concern is that the data sheet of the humidity sensor HIH4000 (my most expensive component- it costs as much as the rest of my h/w!) datasheet mentions the max i/p current as 500uA and the ideal operating current is 200uA. They would sertainly have ensured it does not draw more current than that unless at the o/p we happen to draw more current. so will the ADC cause trouble?
Also on the ADC and uC part i had a doubt, do u think there wil be synchronisation problems if i do not use a clock sourced by the crystal or the timer feature as u mentioned? also wil noise be a problem if i use a slightly longer wire for connecting the clock of the ADC from the uC?
Regarding the conncetions of sensors to the ADC. do i need to use any resistors b/w them to limit the current? My biggest concern is that the data sheet of the humidity sensor HIH4000 (my most expensive component- it costs as much as the rest of my h/w!) datasheet mentions the max i/p current as 500uA and the ideal operating current is 200uA. They would sertainly have ensured it does not draw more current than that unless at the o/p we happen to draw more current. so will the ADC cause trouble?
Amit Radha
Mar 10 2008, 7:05 AM
Hey. Hows everyone? looks like its been a busy monday for all
Mine too. I finally hav my power supply up and i am getting +5 & -5V!! Hurrah!!!
And that leads me to my next hurdle. Programming the uC. I made a small code to try testing the LCD. And also another for the ADC. and then thought il integrate them to c how it works... and to my despair i am unable to proceed beyong the build option. I somehow managed to change somesettings and generated the hex file also. but beyond that i see no option o program. how do i procced? pls help asap.
also pls go thro my previous post and let me know about that current and synchronisation doubts i had..
BTW since my doubts on the sensors have been cleared for now and i am stuck in programming part etc, should i start a new thread for that or shall i continue here??
Cya for now
Mine too. I finally hav my power supply up and i am getting +5 & -5V!! Hurrah!!!
And that leads me to my next hurdle. Programming the uC. I made a small code to try testing the LCD. And also another for the ADC. and then thought il integrate them to c how it works... and to my despair i am unable to proceed beyong the build option. I somehow managed to change somesettings and generated the hex file also. but beyond that i see no option o program. how do i procced? pls help asap.
also pls go thro my previous post and let me know about that current and synchronisation doubts i had..
BTW since my doubts on the sensors have been cleared for now and i am stuck in programming part etc, should i start a new thread for that or shall i continue here??
Cya for now

Ajay
Mar 10 2008, 7:23 AM
sure
start a new one.. coz it will be easy to have a follow-up then 
start a new one.. coz it will be easy to have a follow-up then 
Chiru
Mar 10 2008, 9:46 PM
Hi Amit, couldn't keep in touch, was busy at Mumbai
Give the blue print of your project, we shall try to help u with the code

Give the blue print of your project, we shall try to help u with the code

Ajay
Mar 11 2008, 12:38 PM
nice to see more helping people around
good work Chiru and Shashi...
good work Chiru and Shashi...
Amit Radha
Mar 22 2008, 6:12 AM
Hey am so sorry for not posting for over a week. My connection was down. Thanks to BSNL!!!! Wel it was finally set right today. Besides that i was stuck up at college too due to some accreditation work and also had to do my 1st project seminar. Which by the way was a hit. The idea was appreciated alot and the presentation too impressed the evaluators. Also i have my internal assesment tests on monday n tuesday so il be stuck til tuesday due to that.
After doing some realistic work, it feels sick to go to books!
Coming back to the project. I have made my ADC board. I used a Schmitt triggered NAND gate (4093 if am not mistaken) to generate about 700khz clock. I need to make the uC board now n tehn try the code on it.
About the blue print, I have not yet drawn the ckt, but i have it on paper. N yeah another prob is that i was planning to use the ADCs EOC as INT0 of uC but i think that cant be done right.
The following is my flow for the prog on which i have started coding:
1.Switch on
2.Display initialisation msg
3.Initialise ADC
4.Read sensor1 from ADC
5.Store in uC buffer memory
6.Read sensor2 from ADC
7.Store in uC buffer memory
8.Read sensor3 from ADC
9.Store in uC buffer memory
10.Read sensor4 from ADC
11.Store in uC buffer memory
12.Initialise LCD
13.Display al sensor data from buffer
14.Check sensor1 data wrt threshold
15.Switch on/off actuator
16.store status in buffer for actuator1
17.Check sensor2 data wrt threshold
18.Switch on/off actuator
19.Store status in buffer for actuator2
20.Check sensor3 data wrt threshold
21.Switch on/off actuator
22.Store status in buffer for actuator3
23.Check sensor4 data wrt threshold
24.Switch on/off actuator
25.Store status in buffer for actuator4
26.Go to step 2.
Also the LCD will be used with a switch. In the normal condition it will display the readings of the sensors. When the button is pressed it should display the condition of the actuators(which will be stored in the actuator buffer). When the switch is turned off it must go to step 2 and start reading the sensors again. To achieve this i think i must connect the switch to INT0 or INT1 right.
Also the ADCs EOC cannot be connectd to INT0 for the flow i have mentioned and only polling method can be used right? Else while its waiting for the 1st sensors conversion to finish i wil be latching the 2nd sensors address to teh ADC.
Pin details
P0 LCD data
P2.7 RS
2.6 R/W
2.5 E
l
P1 ADC data
P3.0 OE
P3.1 Start
P3.2 EOC
P3.3 SWITCH FOR TOGGLING LCD DISPLAY
P3.4 ADD A
P3.5 ADD B
P3.6 ADD C
P3.7 ALE
am i on the right track now?
After doing some realistic work, it feels sick to go to books!
Coming back to the project. I have made my ADC board. I used a Schmitt triggered NAND gate (4093 if am not mistaken) to generate about 700khz clock. I need to make the uC board now n tehn try the code on it.
About the blue print, I have not yet drawn the ckt, but i have it on paper. N yeah another prob is that i was planning to use the ADCs EOC as INT0 of uC but i think that cant be done right.
The following is my flow for the prog on which i have started coding:
1.Switch on
2.Display initialisation msg
3.Initialise ADC
4.Read sensor1 from ADC
5.Store in uC buffer memory
6.Read sensor2 from ADC
7.Store in uC buffer memory
8.Read sensor3 from ADC
9.Store in uC buffer memory
10.Read sensor4 from ADC
11.Store in uC buffer memory
12.Initialise LCD
13.Display al sensor data from buffer
14.Check sensor1 data wrt threshold
15.Switch on/off actuator
16.store status in buffer for actuator1
17.Check sensor2 data wrt threshold
18.Switch on/off actuator
19.Store status in buffer for actuator2
20.Check sensor3 data wrt threshold
21.Switch on/off actuator
22.Store status in buffer for actuator3
23.Check sensor4 data wrt threshold
24.Switch on/off actuator
25.Store status in buffer for actuator4
26.Go to step 2.
Also the LCD will be used with a switch. In the normal condition it will display the readings of the sensors. When the button is pressed it should display the condition of the actuators(which will be stored in the actuator buffer). When the switch is turned off it must go to step 2 and start reading the sensors again. To achieve this i think i must connect the switch to INT0 or INT1 right.
Also the ADCs EOC cannot be connectd to INT0 for the flow i have mentioned and only polling method can be used right? Else while its waiting for the 1st sensors conversion to finish i wil be latching the 2nd sensors address to teh ADC.
Pin details
P0 LCD data
P2.7 RS
2.6 R/W
2.5 E
l
P1 ADC data
P3.0 OE
P3.1 Start
P3.2 EOC
P3.3 SWITCH FOR TOGGLING LCD DISPLAY
P3.4 ADD A
P3.5 ADD B
P3.6 ADD C
P3.7 ALE
am i on the right track now?
Amit Radha
Mar 24 2008, 4:51 AM
Reply pls
am waiting..
am waiting..sashijoseph
Mar 24 2008, 10:54 AM
Step12 "initialise LCD' should be before step2.
Polling the EOC would be better and simpler since you have to wait for the adc data before moving forward.So no point using an interrupt.
For the ADC values it would be better if you took ~10 samples for each sensor and used the average value.You may use the bucket(or was it barrel?) shifting algo posted somewhere by Shyam,for averaging.This way you minimise the chance of your actuators swinging wildly with each value.
Polling the EOC would be better and simpler since you have to wait for the adc data before moving forward.So no point using an interrupt.
For the ADC values it would be better if you took ~10 samples for each sensor and used the average value.You may use the bucket(or was it barrel?) shifting algo posted somewhere by Shyam,for averaging.This way you minimise the chance of your actuators swinging wildly with each value.
Amit Radha
Mar 25 2008, 7:06 AM
Soory about Step12!! that was foolish of me!
Could u pls tel me the link or the thread where that algorithm is by shyam?
Thanks a ton
Could u pls tel me the link or the thread where that algorithm is by shyam?
Thanks a ton

sashijoseph
Mar 25 2008, 12:50 PM
This is the thread.....
http://www.8051projects.net/plugins/forum/forum_viewtopic.php?5070.40#post_7316
http://www.8051projects.net/plugins/forum/forum_viewtopic.php?5070.40#post_7316
Amit Radha
Mar 26 2008, 8:33 AM
Hey Shashijoseph,
I am unable to follow that algorithm. N my C skills for 8051 are pathetic so understanding that code is impossible for me!
Pls could u elaborate on that?
Sorry for being dumb
I am unable to follow that algorithm. N my C skills for 8051 are pathetic so understanding that code is impossible for me!
Pls could u elaborate on that?
Sorry for being dumb

Ajay
Mar 26 2008, 10:10 AM
There is nothing difficult in it..
its same like taking average of 10 values..
you add all 10 values and divide it by 10, so you get average.
Now when next time you take average, you have to consider the 10 samples taken before too..
i explain like this..
data1, data2, data3, data4, data5, data6, data7, data8, data9, data10 => avg1
data2, data3, data4, data5, data6, data7, data8, data9, data10, data11 => avg2
data3, data4, data5, data6, data7, data8, data9, data10, data11, data12 => avg3
data4, data5, data6, data7, data8, data9, data10, data11, data12, data13 => avg4
so while taking average you are considering all samples taken before too..
so only first time you are waiting for 10 samples, after that you are just waiting for one sample and then keep taking averages..
I hope you now understand the algorithm.
its same like taking average of 10 values..
you add all 10 values and divide it by 10, so you get average.
Now when next time you take average, you have to consider the 10 samples taken before too..
i explain like this..
data1, data2, data3, data4, data5, data6, data7, data8, data9, data10 => avg1
data2, data3, data4, data5, data6, data7, data8, data9, data10, data11 => avg2
data3, data4, data5, data6, data7, data8, data9, data10, data11, data12 => avg3
data4, data5, data6, data7, data8, data9, data10, data11, data12, data13 => avg4
so while taking average you are considering all samples taken before too..
so only first time you are waiting for 10 samples, after that you are just waiting for one sample and then keep taking averages..
I hope you now understand the algorithm.
Amit Radha
Mar 26 2008, 10:16 AM
oh oki got it now! i am such a dumb***
I thought it was wat u mentioned but was not sure. I am presently coding for the system using 1 sensor only. Once its done and working right, ill add the code for other sensors also. Am stuck at that LCD initialisation part also and displaying on the LCD! its very complicated. I have not completed the code yet thats y i have not yet posted it. Can i post an incoplete code for ur scrutiny?
I thought it was wat u mentioned but was not sure. I am presently coding for the system using 1 sensor only. Once its done and working right, ill add the code for other sensors also. Am stuck at that LCD initialisation part also and displaying on the LCD! its very complicated. I have not completed the code yet thats y i have not yet posted it. Can i post an incoplete code for ur scrutiny?
Ajay
Mar 26 2008, 10:27 AM
if you feel any problem using LCD, you take a look at LCD tutorial..
why would i need the code?
why would i need the code?

Amit Radha
Mar 26 2008, 10:34 AM
Wel i did go through it. So quite a few of my doubts have been cleared
am not sure on how to make those custom characters. I need to display % symbol.
Was having another doubt. Is it possible to store strings in the RAM of the 8051? i want do it to display the actuator status. els il have to store a 0 or 1 in RAM locations amd correspondingly pick up "On" or "Off" from the ROM (After putting it there ofcourse!)
I wanted u to see my code to tell me if i was on the right track.
For that ADC barrel algo, il need to use an array right? And how do i perform the averaging? And then shift all the data. Dont u think it will slow down the performance of the system because i need to read 4 sensors, display their data and then check the threshold for each n then turn on/off actuators and then display it!
am not sure on how to make those custom characters. I need to display % symbol. Was having another doubt. Is it possible to store strings in the RAM of the 8051? i want do it to display the actuator status. els il have to store a 0 or 1 in RAM locations amd correspondingly pick up "On" or "Off" from the ROM (After putting it there ofcourse!)
I wanted u to see my code to tell me if i was on the right track.
For that ADC barrel algo, il need to use an array right? And how do i perform the averaging? And then shift all the data. Dont u think it will slow down the performance of the system because i need to read 4 sensors, display their data and then check the threshold for each n then turn on/off actuators and then display it!
Ajay
Mar 26 2008, 11:29 AM
'%' symbol is there in
LCD isn't it? try..
averaging wont take much time.. yes you need array..
see shyam's code.. he did exactly what you are looking.
LCD isn't it? try..
CODE:
unsigned char string1[] = "this stored in ram";
unsigned char code string2[] = "this stored in rom";
unsigned char code string2[] = "this stored in rom";
averaging wont take much time.. yes you need array..
Amit Radha wrote ...
And how do i perform the averaging? And then shift all the data
see shyam's code.. he did exactly what you are looking.
Amit Radha
Mar 26 2008, 11:32 AM
Ajay i really dont follow the c codes! pls help me in assembly (if its not too much of a trouble)...
Ajay
Mar 26 2008, 12:13 PM
well its same as you do in C..
lets say adc_read is your routine for ADC then
;for first time
acall adc_read
mov adc1, A
acall adc_read
mov adc2, A
;and so on...
acall adc_read
mov adc10, A
;adc1 to adc10 are location in RAM
;Now is mmm.. average..
;confusing :-p
lets say adc_read is your routine for ADC then
CODE:
;for first time
acall adc_read
mov adc1, A
acall adc_read
mov adc2, A
;and so on...
acall adc_read
mov adc10, A
;adc1 to adc10 are location in RAM
;Now is mmm.. average..
;confusing :-p
shyam
Mar 26 2008, 10:51 PM
hi amit...
forget abt the barrel shifter code a the moment...
there are several other DSP algorithms that can be used...
today i m gonna start a new thread regarding it...
wait for it to come... and afterwards u shud not have any problem regarding it..!!
forget abt the barrel shifter code a the moment...
there are several other DSP algorithms that can be used...
today i m gonna start a new thread regarding it...
wait for it to come... and afterwards u shud not have any problem regarding it..!!

Amit Radha
Mar 27 2008, 6:44 AM
Hi ajay, sorry i went offline suddenly! Had a power cut due t heavy rain I suppose!
Hey Shyam thanks a million! il have a look at that thread... hope its out.. pls do it soon! I really need it. I understood the algorithm, but coding the whole thing in assembly is very tedious! I am unable to do it I admit
First of all cant use an array like in C and then averaging it is another task! Also then performing the shift! How do u do that!!!
I am having another doubt regarding the ADC. Now the o/p of ADC is not hex right, its BCD so i need to do a BCD to HEX conversion and then store it in my buffer tehn do a HEX to ASCII to display it on the LCD? I need the HEX equivalent cos i need to perform the check for threshold.
Another doubt regarding the LCD. A pot is needed b/w Vcc, Vee & Vss for controlling the contrast. But what are the 2 pins +LED and -LED for on the LCD? (ie. pin 15 and 16) is it for the backlight? so do i connect it to +Vcc & GND respectively? was making my uC board today and got stuck here. The data sheet of HD44780 dint mention anything about it...
Hey Shyam thanks a million! il have a look at that thread... hope its out.. pls do it soon! I really need it. I understood the algorithm, but coding the whole thing in assembly is very tedious! I am unable to do it I admit
First of all cant use an array like in C and then averaging it is another task! Also then performing the shift! How do u do that!!!
I am having another doubt regarding the ADC. Now the o/p of ADC is not hex right, its BCD so i need to do a BCD to HEX conversion and then store it in my buffer tehn do a HEX to ASCII to display it on the LCD? I need the HEX equivalent cos i need to perform the check for threshold.
Another doubt regarding the LCD. A pot is needed b/w Vcc, Vee & Vss for controlling the contrast. But what are the 2 pins +LED and -LED for on the LCD? (ie. pin 15 and 16) is it for the backlight? so do i connect it to +Vcc & GND respectively? was making my uC board today and got stuck here. The data sheet of HD44780 dint mention anything about it...
shyam
Mar 27 2008, 10:44 AM
regarding LCD ..
yes Amit u r right +led =>vcc -led =>gnd and they r for backlight...
yes Amit u r right +led =>vcc -led =>gnd and they r for backlight...
sashijoseph
Mar 27 2008, 11:01 AM
The o/p of the ADC is definitely binary(hex).
For eg. if the input to the ADC(configured with 0-5v full scale) is 2.5v,the output of the ADC will be 128(decimal) or 80h.This is what will be stored in your buffer....so no need to convert BCD to hex.You can use this value directly for your threshold comparison.
For displaying,you'll have to multiply this hex value with the step size and then convert he result to ASCII.
For eg. step size with a 8-bit ADC configured 0-5v full scale is 5/256=19.53mV(say 20mV)
Now suppose you get a hex value 80h from the ADC.The value to be displayed is 80hx14h=A00h.Now convert this hex value to ASCII for displaying on the LCD.
The LED+/- are for the backlight.You may leave it unconnected or connect it through a 10ohms series resistor to vcc and ground.
For eg. if the input to the ADC(configured with 0-5v full scale) is 2.5v,the output of the ADC will be 128(decimal) or 80h.This is what will be stored in your buffer....so no need to convert BCD to hex.You can use this value directly for your threshold comparison.
For displaying,you'll have to multiply this hex value with the step size and then convert he result to ASCII.
For eg. step size with a 8-bit ADC configured 0-5v full scale is 5/256=19.53mV(say 20mV)
Now suppose you get a hex value 80h from the ADC.The value to be displayed is 80hx14h=A00h.Now convert this hex value to ASCII for displaying on the LCD.
The LED+/- are for the backlight.You may leave it unconnected or connect it through a 10ohms series resistor to vcc and ground.
Amit Radha
Mar 27 2008, 11:47 AM
Hey thanks a lot!!!
That gives me some work to do for tomorrow! mu uC board was on hold cos of that +/- LED doubt of mine. My code (for 1 sensor) is almost done. il complete it tomorrow and post it pls do let me know how to improve it or incase i have made any mistakes...
Cyas for now.. gnit
That gives me some work to do for tomorrow! mu uC board was on hold cos of that +/- LED doubt of mine. My code (for 1 sensor) is almost done. il complete it tomorrow and post it pls do let me know how to improve it or incase i have made any mistakes...
Cyas for now.. gnit
Amit Radha
Mar 27 2008, 11:49 AM
Well, i forgot to ask. is there any way i can improve the sensitiviy of the temp sensor? I mean in the present set up i cannot show decimal values, right? So can that be incorporated. its not very necessary though, but it certainly will improve the set up a bit i feel..
Ajay
Mar 27 2008, 10:05 PM
which temperature sensor you are using?
when taking average values.. you can get decimal values too..
when taking average values.. you can get decimal values too..
Amit Radha
Mar 28 2008, 5:25 AM
Hi Ajay,
I am using an LM35. But not connecting it directly op the ADC, I am using an opamp as Shashi (or Chiru. dont remember) told me it wil help to smoothen and caliberate the o/p. How can i get the decimal values using it?
As Shashi mention 2 days back,
The o/p of the ADC is definitely binary(hex).
For eg. if the input to the ADC(configured with 0-5v full scale) is 2.5v,the output of the ADC will be 128(decimal) or 80h.This is what will be stored in your buffer....so no need to convert BCD to hex.You can use this value directly for your threshold comparison.
For displaying,you'll have to multiply this hex value with the step size and then convert he result to ASCII.
For eg. step size with a 8-bit ADC configured 0-5v full scale is 5/256=19.53mV(say 20mV)
Now suppose you get a hex value 80h from the ADC.The value to be displayed is 80hx14h=A00h.Now convert this hex value to ASCII for displaying on the LCD.
Now i am having a doubt regarding this. I thought instead of making the uC do the calculationsm i can create a look up table such that for a particular hex o/p of the ADC it picks up the corresponding ASCII value and stores in a buffer for display. Can this be done?
My code (for the temp sensor only is ready except for this part.)
Also i am facing a peculiar problem with my power supply circuit!
Its o/p voltage starts dropping as i start increasing the devices drawing supply from it! I am using a 6V 1A tranformer followed by a bridge rectifier then and LM7805 and LM7905 regulators (for +/-5V)
I am using an LM35. But not connecting it directly op the ADC, I am using an opamp as Shashi (or Chiru. dont remember) told me it wil help to smoothen and caliberate the o/p. How can i get the decimal values using it?
As Shashi mention 2 days back,
sashijoseph wrote ...
The o/p of the ADC is definitely binary(hex).
For eg. if the input to the ADC(configured with 0-5v full scale) is 2.5v,the output of the ADC will be 128(decimal) or 80h.This is what will be stored in your buffer....so no need to convert BCD to hex.You can use this value directly for your threshold comparison.
For displaying,you'll have to multiply this hex value with the step size and then convert he result to ASCII.
For eg. step size with a 8-bit ADC configured 0-5v full scale is 5/256=19.53mV(say 20mV)
Now suppose you get a hex value 80h from the ADC.The value to be displayed is 80hx14h=A00h.Now convert this hex value to ASCII for displaying on the LCD.
Now i am having a doubt regarding this. I thought instead of making the uC do the calculationsm i can create a look up table such that for a particular hex o/p of the ADC it picks up the corresponding ASCII value and stores in a buffer for display. Can this be done?
My code (for the temp sensor only is ready except for this part.)
Also i am facing a peculiar problem with my power supply circuit!
Its o/p voltage starts dropping as i start increasing the devices drawing supply from it! I am using a 6V 1A tranformer followed by a bridge rectifier then and LM7805 and LM7905 regulators (for +/-5V)
Amit Radha
Mar 28 2008, 9:04 AM
Okay! Now I am thoroughly confused!!!
I tried making a look up table for the LM35. But i realised I need to have 2 separate LUTs, one for the ten's place n the other for unit's place (Pls tell me if it needent be done that way) and I am unable to figure out how do u access the tables then?
Firstly I must mention I have connected the LM35 to a uA741 with a gain of 4.8 which is connected to the ADC. So at 25 deg C the o/p of my ckt will be 1.2V. The output of the ADC will be 3Dh ie 61d. How do i convert this to ASCII and display it now!
I initially though that its wiser to calculate the corresponding ASCII value and store it in a LUT n access it... but now i feel its far too complicated.
But i need to use a LUT because the formula for the Humidity sensor is far to complicated to be done in the uC so i have to manually calculate it for the range of voltages and store the corresponding value in a LUT.
Pls help
Also. How do i display degree symbol. The ASCII codes table in Mazidi doesnot list it...
I tried making a look up table for the LM35. But i realised I need to have 2 separate LUTs, one for the ten's place n the other for unit's place (Pls tell me if it needent be done that way) and I am unable to figure out how do u access the tables then?
Firstly I must mention I have connected the LM35 to a uA741 with a gain of 4.8 which is connected to the ADC. So at 25 deg C the o/p of my ckt will be 1.2V. The output of the ADC will be 3Dh ie 61d. How do i convert this to ASCII and display it now!
I initially though that its wiser to calculate the corresponding ASCII value and store it in a LUT n access it... but now i feel its far too complicated.
But i need to use a LUT because the formula for the Humidity sensor is far to complicated to be done in the uC so i have to manually calculate it for the range of voltages and store the corresponding value in a LUT.
Pls help
Also. How do i display degree symbol. The ASCII codes table in Mazidi doesnot list it...
sashijoseph
Mar 28 2008, 12:46 PM
The LM7805 needs atleast 2V for dropout,ie ~7V at it's input.A 9v xformer would be better.
Amit Radha
Mar 28 2008, 8:03 PM
Hey thanks a lot. Yup no problem take ur time... ur doing us noobs a big favor by helping out on the forum i admit.
Regarding the supply, I was told to take a higher current rating transformer (2 or prefferably 3A, 5A tranformer wil become too huge). Also i bought a 6-0-6 tranfirmer and was using onle 6-0 terminals. Itseems that could also be a reason (i mean the center tap) so using a 0-6 transformer would be better.
So to solve the problem il use a 0-9, 3A tranformer. Hope that wont bee too much for the system right?
Regaring the Look up table, i think i have thought of a solution, il try coding it and if it solves the prob then il post it here.
I am facing another design issue now. I need to know in wat all ways can the uC be RESET, besides that reset momentary push button as mentioned in Mazidi.
I need this because as mentioned in my design, i show the actuator status only when a button is pressed. This i am doing by connecting teh switch to INT0, but when the switch is turned back to original position, I need to again reset the system so that it starts rading the sensors afresh and then displays the sensor data. I cant just use a RETI at the end of my ISR as that will take the IP to where it was before, but my display will not change instantaneously, right?
Regarding the supply, I was told to take a higher current rating transformer (2 or prefferably 3A, 5A tranformer wil become too huge). Also i bought a 6-0-6 tranfirmer and was using onle 6-0 terminals. Itseems that could also be a reason (i mean the center tap) so using a 0-6 transformer would be better.
So to solve the problem il use a 0-9, 3A tranformer. Hope that wont bee too much for the system right?
Regaring the Look up table, i think i have thought of a solution, il try coding it and if it solves the prob then il post it here.
I am facing another design issue now. I need to know in wat all ways can the uC be RESET, besides that reset momentary push button as mentioned in Mazidi.
I need this because as mentioned in my design, i show the actuator status only when a button is pressed. This i am doing by connecting teh switch to INT0, but when the switch is turned back to original position, I need to again reset the system so that it starts rading the sensors afresh and then displays the sensor data. I cant just use a RETI at the end of my ISR as that will take the IP to where it was before, but my display will not change instantaneously, right?
Chiru
Mar 28 2008, 8:10 PM
A 6V AC will give over 8V DC if not heavily loaded and should work fine with 7805, still its better to use a 9V one as Sashi suggested. Moreover there should be a good heatshink on the reg so as to prevent thermal shut down (current reduced and voltage against load) 

rbk23
Mar 28 2008, 8:28 PM
Thanks...Anyway, I find this model, dunno can be used or not. It is from nemoto japan, http://www.nemoto.co.jp/en/products/sensor/manual/nhs-20.html or mec HCZ-H or HCZ-J series. May I know it can be used?
Thanks so much
Thanks so much
sashijoseph
Mar 28 2008, 9:06 PM
3A for an embedded system is OVERKILL big time.With a cap(~1000uF) on the bridge,a 6v trans. should supply ~8.4v,but if it goes below 7v under load then regulation will suffer.So use a 9v,1A transformer and you'll be fine.Also use a 10\100 uF cap on the output pin of the 7805.
As for the switch,why do you want it to reset the system...coz even after reset it will give you the same sensor readings as before reset(provided conditions don't change during reset).So for eg. if without reset(and the switch back from acuator mode to sensor mode) the temp display was 25deg,then even after reset it will display 25deg,provided temp. doesn't change to some other value during reset.
As for the switch,why do you want it to reset the system...coz even after reset it will give you the same sensor readings as before reset(provided conditions don't change during reset).So for eg. if without reset(and the switch back from acuator mode to sensor mode) the temp display was 25deg,then even after reset it will display 25deg,provided temp. doesn't change to some other value during reset.
Chiru
Mar 28 2008, 9:15 PM
Amit, employ a proper adc loop rather than reset


Amit Radha
Mar 29 2008, 7:10 AM
Hi Shashijoseph and Chiru, thanks a ton for the repeated support and prompt solutions
I checked the o/p of my bridge rectifier, was getting nearly 7.5V (was reducing a bit though at times) So i got a 9V 2A tranformer. Not tested it yet. Will do it on monday.
3A for an embedded system is OVERKILL big time.With a cap(~1000uF) on the bridge,a 6v trans. should supply ~8.4v,but if it goes below 7v under load then regulation will suffer.So use a 9v,1A transformer and you'll be fine.Also use a 10\100 uF cap on the output pin of the 7805.
Will using 2A tranformer damage the system by any chance? I will be using this to power my ADC, 4 sensors, uC, LCD, and a buzzer also. So i thought ite better to be on the safer side by sing 9V 2A.
I am using a heatsink on the 7805(used a mica sheet and heatsink paste also). But the 7905 has a complete plastic casing so i did not put a heatsink to it. Also,the regulators are followed by a 10uF and 1uF cap each.
As for the switch,why do you want it to reset the system...coz even after reset it will give you the same sensor readings as before reset(provided conditions don't change during reset).So for eg. if without reset(and the switch back from acuator mode to sensor mode) the temp display was 25deg,then even after reset it will display 25deg,provided temp. doesn't change to some other value during reset.
Wel i wanted to reset the system because the original mode of the LCD is to display the sensor data. Now, cosider a situation where the user presses the switch to see the actuator status, the interrupt occurs and the ISR changes the display, I include a delay in it so that the screen is on for say 5sec. After that on execution of RETI, the LCD must display the previous mode, ie. sensor status screen. for that it must restart from the beginning but RETI will cause it to continue where it was interrupted and there will be a delay till the uC completes what it may be doing at that time and then reach the part of the code to display the sensor status.
I thought of using the watchdog timer (using the AT89S52) which supposedly resets the system when it overflows. so I can give it a count upto 5sec and then it will overflow and consequently reset the system. But that as u mentioned and few others also should not be done. So pls tel me if its a healthy practice to reset the system like this.
Also one more doubt, to trigger INT0, i am using a push to on switch similar to the one which is used for the reset switch of the uC. now, one end is connected to the uC and the other to +5 or GND? and should i use an RC ckt also. I am thoroughly confused with wt to do about that! I hope u got my question. I have thoroughly confued my team also!!!
I have asked Lots of questions. Want to program my uC and test the system by monday!
Hope i have not started bugging u guys... Thanks a lot once again! bye for now. 
I checked the o/p of my bridge rectifier, was getting nearly 7.5V (was reducing a bit though at times) So i got a 9V 2A tranformer. Not tested it yet. Will do it on monday.
sashijoseph wrote ...
3A for an embedded system is OVERKILL big time.With a cap(~1000uF) on the bridge,a 6v trans. should supply ~8.4v,but if it goes below 7v under load then regulation will suffer.So use a 9v,1A transformer and you'll be fine.Also use a 10\100 uF cap on the output pin of the 7805.
Will using 2A tranformer damage the system by any chance? I will be using this to power my ADC, 4 sensors, uC, LCD, and a buzzer also. So i thought ite better to be on the safer side by sing 9V 2A.
I am using a heatsink on the 7805(used a mica sheet and heatsink paste also). But the 7905 has a complete plastic casing so i did not put a heatsink to it. Also,the regulators are followed by a 10uF and 1uF cap each.
sashijoseph wrote ...
As for the switch,why do you want it to reset the system...coz even after reset it will give you the same sensor readings as before reset(provided conditions don't change during reset).So for eg. if without reset(and the switch back from acuator mode to sensor mode) the temp display was 25deg,then even after reset it will display 25deg,provided temp. doesn't change to some other value during reset.
Wel i wanted to reset the system because the original mode of the LCD is to display the sensor data. Now, cosider a situation where the user presses the switch to see the actuator status, the interrupt occurs and the ISR changes the display, I include a delay in it so that the screen is on for say 5sec. After that on execution of RETI, the LCD must display the previous mode, ie. sensor status screen. for that it must restart from the beginning but RETI will cause it to continue where it was interrupted and there will be a delay till the uC completes what it may be doing at that time and then reach the part of the code to display the sensor status.
I thought of using the watchdog timer (using the AT89S52) which supposedly resets the system when it overflows. so I can give it a count upto 5sec and then it will overflow and consequently reset the system. But that as u mentioned and few others also should not be done. So pls tel me if its a healthy practice to reset the system like this.
Also one more doubt, to trigger INT0, i am using a push to on switch similar to the one which is used for the reset switch of the uC. now, one end is connected to the uC and the other to +5 or GND? and should i use an RC ckt also. I am thoroughly confused with wt to do about that! I hope u got my question. I have thoroughly confued my team also!!!
I have asked Lots of questions. Want to program my uC and test the system by monday!
Hope i have not started bugging u guys... Thanks a lot once again! bye for now. 
Amit Radha
Mar 29 2008, 11:23 AM
Just saw this in a thread "ABOUT MICROCONTROLLERS" by TPS:-
ABOUT THE Microcontrollers
A: Port 0 has open drain outputs. Ports 1, 2, and 3 have internal
pullups. What does this mean? See the next question and answer.
Q: Port 0 has open drain outputs. Ports 1, 2, and 3 have internal
pullups. What does this mean, and why should I care?
A: When used as outputs, all port pins will drive the state to which
the associated SFR latch bit has been set. Except for port 0,
which will only drive low (not high). When a 0 is written to a
bit in port 0, the pin is pulled low (0). But, when a 1 is
written to a bit in port 0, the pin goes into a high impedance
state - or in other words, "disconnected", no value. To be able
to get a 1 as output, you need an external pullup resistor to
pull up the port (to 1) when the port is in its high impedence
state. Typical values for pullups might be 470 ohm to drive a
LED, and 4.7K or higher to drive logic circuits.
C: Any port pin may be used as a general purpose input simply by
writing a 1 into the associated SFR latch bit. Since ports 1, 2,
and 3 have internal pull-up devices they will pull high and will
source current when pulled low. When a port 0 bit is programmed
for input (set to 1) it will go to a high impedance state.
I am using P0 of the uC to DB0 to DB7 of LCD. Does that mean i need to add 4.7k Resistors between the uC amd the LCD pins???
۞ TPS ۞ wrote ...
ABOUT THE Microcontrollers
A: Port 0 has open drain outputs. Ports 1, 2, and 3 have internal
pullups. What does this mean? See the next question and answer.
Q: Port 0 has open drain outputs. Ports 1, 2, and 3 have internal
pullups. What does this mean, and why should I care?
A: When used as outputs, all port pins will drive the state to which
the associated SFR latch bit has been set. Except for port 0,
which will only drive low (not high). When a 0 is written to a
bit in port 0, the pin is pulled low (0). But, when a 1 is
written to a bit in port 0, the pin goes into a high impedance
state - or in other words, "disconnected", no value. To be able
to get a 1 as output, you need an external pullup resistor to
pull up the port (to 1) when the port is in its high impedence
state. Typical values for pullups might be 470 ohm to drive a
LED, and 4.7K or higher to drive logic circuits.
C: Any port pin may be used as a general purpose input simply by
writing a 1 into the associated SFR latch bit. Since ports 1, 2,
and 3 have internal pull-up devices they will pull high and will
source current when pulled low. When a port 0 bit is programmed
for input (set to 1) it will go to a high impedance state.
I am using P0 of the uC to DB0 to DB7 of LCD. Does that mean i need to add 4.7k Resistors between the uC amd the LCD pins???
sashijoseph
Mar 29 2008, 11:54 PM
Nope......between Port and Vcc (pullup).
sashijoseph
Mar 30 2008, 12:33 AM
Also one more doubt, to trigger INT0, i am using a push to on switch similar to the one which is used for the reset switch of the uC. now, one end is connected to the uC and the other to +5 or GND? and should i use an RC ckt also. I am thoroughly confused with wt to do about that! I hope u got my question. I have thoroughly confued my team also!!!
The switch should be connected to the port pin and Gnd.....never to Vcc(atleast not directly without a resistor).
I think switch debouncing isn't necessary in your application since you'll be returning from the interrupt(5 sec delay like you said) long after the switch would have settled. So no chance of 'misfiring'.You would need to debounce if your ISR were to complete in say 5ms.
Amit Radha
Mar 30 2008, 7:15 AM
Hi shashijoseph,
Thanks a ton
Il include those 4.7k resistors b/w the port and Vcc.
I had got thoroughly confused with the switch! thanks for clearing that out too! Now in my code i make INT0 an endge trig. int. should i do it or leave it as level trig? i feel it should be edge trig. right?
U dint tell me if its safe to use the 0-9V 2A transformer? I have explained my ckt in the post just after chiru's reply.
Regarding the RESET of the system. I tried to include a proper loop as u and Chiru suggested but i have come across a peculiar situation. Hope i can explain it properly-
cosider that the uC is initialising the LCD for displaying sensor data rom the buffer or that it is displaying the sensor data from the buffer. At that instant user presses the button for viewing actuator status. this triggers the interrupt and in the ISR, the LCD is re initialised and sensor status is displayed. after 5sec delay, RETI instrn executes and uC starts from where it was interrupted ie : halfway initialising the LCD or halfway thrugh displaying the sensor data.
In both these cases, the display will now probably be garbled or only partly correct data will be displayed right?
What do i do now?
Thanks a ton
Il include those 4.7k resistors b/w the port and Vcc.
I had got thoroughly confused with the switch! thanks for clearing that out too! Now in my code i make INT0 an endge trig. int. should i do it or leave it as level trig? i feel it should be edge trig. right?
U dint tell me if its safe to use the 0-9V 2A transformer? I have explained my ckt in the post just after chiru's reply.
Regarding the RESET of the system. I tried to include a proper loop as u and Chiru suggested but i have come across a peculiar situation. Hope i can explain it properly-
cosider that the uC is initialising the LCD for displaying sensor data rom the buffer or that it is displaying the sensor data from the buffer. At that instant user presses the button for viewing actuator status. this triggers the interrupt and in the ISR, the LCD is re initialised and sensor status is displayed. after 5sec delay, RETI instrn executes and uC starts from where it was interrupted ie : halfway initialising the LCD or halfway thrugh displaying the sensor data.
In both these cases, the display will now probably be garbled or only partly correct data will be displayed right?
What do i do now?