Subject : RE: Philips Microcontroller Forum Digest - Issue : 970601 at 10:57 From : Chiel de Jong > >Message 4 : > Subject : Measuring temperature with 80c535 > From : Igor Poljansek >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > Hi Igor Analog Devices have some very nice new IC's. Temperature sensor, reference voltage, ADC and serial interface built into a SMD 8 pin package. type numbers 7816,7817 and 7818. Accuracy of 1 degree Celcius. It also has an Over Temperature Indicator bit. Regards >Chiel de Jong Subject : Re: Philips Microcontroller Forum Digest - Issue : 970605 at 10:57 From : WAGNERL@ix.netcom.com On 06/06/97 03:20:00 you wrote: > >Philips Microcontroller Forum Digest - Issue : 970605 at 10:57 > > > > >Message 1 : > Subject : Telephone line voltage measurement. > From : "K. Sheker" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > >Message 1 : > Subject : Telephone line voltage measurement. > From : "K. Sheker" > > > >The requirement is to measure the voltage on the >telephone line. The points to be taken care off: > >1. The current drawn shouldnt exceed 750 micro amps else > the line will go into off hook condition. > >2. Preferably there should be isolation between the > the telephone line and the measuring circuit. > >3. The measuring circuit shouldnt be affected by the > incoming ringing voltage (125 V AC). > >Any help is highly appreciated. Please post and e-mail. > >Thanks. > >Sheker. > >Sheker > > ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > 1) You did not mention if you want to measure it digitally or what. 2) In case of digital, you need to specify what is the resolution, or how many digits. 2) Any analog to digital converter (ADC) has high impedance on input that will draw only few microamps for measurement. We are talking of MegaOhms of input impedance. 3) The best way to isolate it is using an ADC with serial communication, so you can use opto-isolators to transfer it, just (1) clock, (2) gate, (3) data, to the processor. In this case you will need an isolated power supply for the ADC, normally a 9Vdc battery is enough, or for better results you need to use a switching power supply to delivery isolated power via a small transformer to the circuits in contact with the telephone line. 4) The protection for the RING signal, is just a matter to use clamp diodes after some resistors on the input, to keep it below some safe levels for the ADC. By the way, it is safe to think that the RING AC signal can vary from 40 to 150 VRMS, with a frequency that can varies from 15.3 to 68Hz. 5) It is a good idea to use some surge protection at the input (Metal Oxide Varistor or MOV) for more than 150V, so it will not suffer with the RING signal. 6) If you supply more informations about your requirements, probably we can help you a little bit better. Subject : Re: 87C51 Port problem help pl. From : "Alistair George" > Message 1 : > Subject : 87C51 Port problem help pl. > From : "S.C.Babu" > HELP PLEASE: > ------------ > > I am using a 87C51. Port P0.0 is pulled up to 5v through a 10k resitor. > A PNP transistor (BC557) base is connected to this port (P0.0) through > a 10k resistor, the collector is grounded and the emitter is connected > to 5V through a 5v dip relay (coil dc resistance of less than 20 ma) and > a reverse diode (IN4002) is connected in parallel (not shown). Easy to make this mistake.... Take out the base resistor; it is not necessary. Put in a 12e resistor between the relay and supply, and make sure there is a tant bypass on the junction of 12e and relay to deck. That should fix the problem. Regards, Alistair George. Subject : Re: Re port problems - whoops From : "Alistair George" > > From: avm@giasmd01.vsnl.net.in > To : forum@philipsmcu.com Sorry, that should have been a bit clearer; take out the base resistor between Port & Base. Regards, Alistair George Subject : 87C51 Port problem help pl. From : WAGNERL@ix.netcom.com I agree with the friends, it must be some with the voltage filtration to the relay. By the way, you can use an BS170 (FET Transistor, channel N) instead of the PNP. You can avoid the pull up resistor and keeps only the 10k to the BS170 gate. A small capacitor tied to the BS170 gate will helps to avoid some possible spike or short pulses to drive the relay. Another suggestion: Next time, try to use a LCA110 from CP Clare, it is a 6 pin microchip, opto relay, to be used at phone line, you can drive only 4 mA to the LED and get a safe "relay" isolated contact, you also don't need to use any kind of protective diode, since you have no coil involved. It is clean, without gliches or some voltage noise. Phone line comutation also generates noise. Be sure to be using a MOV (Metal oxide varistor) and some high voltage small capacitors to filter this high spikes on the phone line. Subject : incremental encoders From : Bill.Houghton@sv.sc.philips.com (Bill Houghton) Dmitry Shabalin asked about using incremental encoders. Since these had an A & B channel, I'm assuming they are quadrature encoders (the phase difference between the encoder outputs indicates direction while the outer track indicates counts). I have written code for these for an 80c51 family part that samples the encoders, which is included below. I think that when I used this it was in another program where I call this code once every mS. The key to using these is to note that since there are two bits (A&B) there are only four possible states that the wheel can be in at any one time. (One problem with using an interrupt driven on the A channel is that you will miss low-to-high transistions of the A channel since the 80C51 is active low on its interrupt pins). Ideally, you want to look at the state changes. My code looks at the current state, compares it with the previous state, and decides whether to increment, decrement, or do nothing to the count. It was for an optical mouse so it includes left and right buttons. The stuff in the "LOOP" where the status byte was sent to bits on P1 & P3 was for debugging purposes on a demo board that didn't have a full port available. ;mouse encoder program ;WGH 07/28/95 $MOD51 ;equates list X1 EQU P3.5 X2 EQU P3.4 Y1 EQU P1.0 Y2 EQU P1.1 LSW EQU P1.2 RSW EQU P1.3 DSEG ORG 20H ENC_VAL: DS 1 ENC_STAT: DS 1 ;bits ; ;ENC_VAL = Y2OLD-Y1OLD-Y2NEW-Y1NEW-X2OLD-X1OLD-X2NEW-X1NEW ;ENC_STAT = --------- --------- RSW - LSW - DCY - INY - DCX - INX ; X1NEW BIT ENC_VAL.0 X2NEW BIT ENC_VAL.1 X1OLD BIT ENC_VAL.2 X2OLD BIT ENC_VAL.3 Y1NEW BIT ENC_VAL.4 Y2NEW BIT ENC_VAL.5 Y1OLD BIT ENC_VAL.6 Y2OLD BIT ENC_VAL.7 LSWB BIT ENC_STAT.4 RSWB BIT ENC_STAT.5 CSEG MAIN: MOV C,X1 ;read the current encoder values MOV X1OLD,C ;and save as the old values MOV C,X2 ; MOV X2OLD,C ; MOV C,Y1 ; MOV Y1OLD,C ; MOV C,Y2 ; MOV Y2OLD,C ; LOOP: CALL GET_ENC ; MOV C,ENC_STAT.0 ; MOV P1.4,C ; MOV C,ENC_STAT.1 ; MOV P1.5,C ; MOV C,ENC_STAT.2 ; MOV P1.6,C ; MOV C,ENC_STAT.3 ; MOV P1.7,C ; MOV C,LSWB ; MOV P3.2,C ; MOV C,RSWB ; MOV P3.3,C ; SJMP LOOP ;***** GET_ENC routine ***** ; ;Reads the current value of the encoder wheels for both the X and Y movements. ;Compares the new state with the previous state and decides whether the the positions ;should be incremented, decremented, or left alone. Also looks at the state of the mouse buttons. ;Parameters returned in ENC_STAT variable. ; GET_ENC: MOV C,LSW ;read the left switch CPL C ;return a "one" MOV LSWB,C ;if the switch is closed MOV C,RSW ;and do the same for the right switch CPL C ; MOV RSWB,C ; MOV C,X1 ;read the current encoder values MOV X1NEW,C ;and save as the new values MOV C,X2 ; MOV X2NEW,C ; MOV C,Y1 ; MOV Y1NEW,C ; MOV C,Y2 ; MOV Y2NEW,C ; MOV A,ENC_VAL ;get the encoder old & new values ANL A,#0FH ;save only the X values MOV DPTR,#ENC_TBL; MOVC A,@A+DPTR ;look up the state transition in the table ANL ENC_STAT,#0FCH; clear out the X inc/dec info ORL ENC_STAT,A ;and add in the new inc/dec info MOV A,ENC_VAL ;get the encoder old & new values SWAP A ;get the Y info into position ANL A,#0FH ;save only the Y values MOV DPTR,#ENC_TBL; MOVC A,@A+DPTR ;look up the state transition in the table RL A ; RL A ;get Y inc/dec info into position ANL ENC_STAT,#0F3H; clear out the Y inc/dec info ORL ENC_STAT,A ;and add in the new inc/dec info MOV A,ENC_VAL ;copy new encoder states RL A ;to RL A ;old encoder states MOV ENC_VAL ;and save them RET ;and done ENC_TBL: DB 00H ;0000 S0 goes to S0 so no change DB 01H ;0001 S4 goes to S1 so increment DB 10H ;0010 S4 goes to S3 so decrement DB 00H ;0011 S4 goes to S2 so no change DB 10H ;0100 S1 goes to S4 so decrement DB 00H ;0101 S1 goes to S1 so no change DB 00H ;0110 S1 goes to S3 so no change DB 01H ;0111 S1 goes to S2 so increment DB 01H ;1000 S3 goes to S4 so increment DB 00H ;1001 S3 goes to S1 so no change DB 00H ;1010 S3 goes to S3 so no change DB 10H ;1011 S3 goes to S2 so decrement DB 00H ;1100 S2 goes to S4 so no change DB 10H ;1101 S2 goes to S1 so decrement DB 01H ;1110 S2 goes to S3 so increment DB 00H ;1111 S2 goes to S2 so no change END Subject : RE: temperature sensors From : Chiel de Jong ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > >Message 13 : >temperature sensors > From : "Daryl E. Bruner" > > >My MicroController needs a temperature sensor >for a buddy. Can you suggest some devices? >I'm familiar with the Dallas DS1620 series and >Analog Devices TMP03/04. Do you know of others? >Accuracy to two degrees Celsius is fine. > >Thanks, >Daryl E. Bruner > > ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > >Message 4 : > Subject : Measuring temperature with 80c535 > From : Igor Poljansek >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > Hi Igor and Daryl Analog Devices have some very nice new IC's. Temperature sensor, reference voltage, ADC and serial interface built into a SMD 8 pin package. type numbers 7816,7817 and 7818. Accuracy of 1 degree Celcius. It also has an Over Temperature Indicator bit. Regards >Chiel de Jong > > > Subject : Re: Temperature Sensor From : Wayne McPherson > My MicroController needs a temperature sensor > for a buddy. Can you suggest some devices? > I'm familiar with the Dallas DS1620 series and > Analog Devices TMP03/04. Do you know of others? > Accuracy to two degrees Celsius is fine. > > Thanks, > Daryl E. Bruner > > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< We are currently using National's LM60, which depending on the flavour is accurate to 3 or 4 deg. C. It works very well and is particularly suitable to low power applications. Subject : Re: temperature sensors From : Gerhard Fiedler > From : "Daryl E. Bruner" > >My MicroController needs a temperature sensor >for a buddy. Can you suggest some devices? >I'm familiar with the Dallas DS1620 series and=20 >Analog Devices TMP03/04. Do you know of others? >Accuracy to two degrees Celsius is fine. I used the National LM35 with success. It is available in different accuracies and temp ranges (and prices, of course :-) and is calibrated in 10mV/degC. There is also a sibling available which is calibrated in deg F. Subject : Re: temperature sensors From : Scott May <<<<<<<<<<<<< My MicroController needs a temperature sensor for a buddy. Can you suggest some devices? I'm familiar with the Dallas DS1620 series and Analog Devices TMP03/04. Do you know of others? Accuracy to two degrees Celsius is fine. >>>>>>>>>>>> Crikey, I'll see if I can get it right this time!! (refer to the telephone line simulator...) Dallas make parts DS1820 and DS1821 which are 1 wire devices with temperature measurement accurate to about 0.5 deg C. Much like the DS1620 types, but in a 3 pin package, and are cheaper. You can read greater resolution from them, but not necessarily greater accuracy. Subject : Re: temperature sensors From : Ferry Toth Note that the Dallas parts are not REALLY 0.5 deg C accurate. If you check out the specs you see that this accuracy applies only in a limited range. An alternative is the SMT160 from Smartec, The Netherlands. The *accuracy* of this device better then +/- 1C from -40C to +80C. It is basically a 3 wire device, with a duty-cycle modulated 0-5 (TTL and CMOS compatible) 3kHz signal. The duty-cycle is directly related to the temperature and requires no calibration. (T =3D (DC - 0.32) / 0.0047 for deg C). There are various ways to program any mC to read out the duty-cycle (polling, interrupt, hardware timer etc.) The price should be $1 - $2 in larger quantities. For more info check out:http://ourworld.compuserve.com/homepages/SMARTECNL/tempspec.ht Subject : re 87C752 A/D Problems From : Nigel Mulvana Hi, Not really sure if this is how I reply to a single message, apologies if I mess anything up! I have had these sort of problems before whilst using the ADC on a 552. I solved it (for good!) by setting ADCI to zero after the conversion! ie ADCON = 0x2C; while(!ADCI)(); ADCI = 0; <------- PUT IN THIS LINE Subject : Re: 87C752 ADC From : Osman Erol Dear Tusek, The below cases can be an answer to your problem: *87C752 AVss must be tied to ground and AVcc, to +5.00V reference. These reference voltages can not be varied for +- %10 Vcc. One can think to adjust freely these voltages, for example to obtain 00H value for 4mA, like ADC8080, but this is not possible. Out of tolerences on those pins may result to failure of the IC. *Since you use P1.0-P1.4 for analog inputs, all of these pins must be considered as a floating input. You can not write a value to one of those pins, while in ADC mode. However, you can select the port status to digital i/o, but this time, the internal pull-ups will draw these pins to logical 1 which will result an exponentially decraising voltage when switching to ADC mode and therefore a wrong input value. *I have used this program, and it worked well: mov a,#channel_number orl a,#28h mov adcon,a adc1: mov a,adcon jnb acc.4,adc1 the adc value will be stored in adat register. Note: please not to change the acc value with interrupts! Subject : Re: 87C752 A/D problems From : Greg.Goodhue@sv.sc.philips.com (Gregory Goodhue) reply to Joe Tusek: Hello Joe, I believe that I know the cause of your problem with the A/D converter. I cannot be absolutely certain because I don't know exactly what instructions your compiler may have generated for the code you show. The clue is that inserting longer delays gives better results. This didn't make sense to me at first. When the ADCI flag is set, the conversion is complete, the result is in the ADAT register, and it DOES NOT CHANGE after that, no matter how long you wait. However, if you read ADAT early, ADCI is set, you can get partial conversion results. Some people even use this to get low resolution A/D readings faster than the full conversion time. For this to happen in your code, the "while(!ADCI){}" statement would have to be failing (i.e. falling out of the loop before ADCI is really set). So, how could that happen? First, I believe your C compiler is being very efficient and using a JNB instruction (direct bit test) to form the "while" loop. This instruction can be generated because the ADCON register address is one that would normally be bit addressable on an 8051 type device. However, the 8xC752 has a little known quirk that now becomes an issue. The ADCON register is NOT bit addressable! If you look closely at the special function register table in the data sheet, you can see that ADCON is not flagged by a "*" as being a bit addressable register (the same thing is also repeated in the text describing the A/D converter). But your compiler doesn't know this and treated it as one anyway. So, the "while" loop fails. The solution would be to write that line differently and hope that the compiler is not TOO smart and optimizes it back to a JNB. I would try writing it as: while(!(ADCON & 0x10)){} The idea is to force the compiler to generate a separate instruction to read the entire byte of ADCON before testing the ADCI flag. I think this will fix the problem. Subject : Re: 87C752 A/D problems From : clyde@htsoft.com (Clyde Smith-Stubbs) Greg.Goodhue@sv.sc.philips.com (Gregory Goodhue) wrote: > normally be bit addressable on an 8051 type device. However, the 8xC752 has > a little known quirk that now becomes an issue. The ADCON register is NOT > bit addressable! If you look closely at the special function register table > in the data sheet, you can see that ADCON is not flagged by a "*" as being > a bit addressable register (the same thing is also repeated in the text > describing the A/D converter). But your compiler doesn't know this and The data sheet I have DOES have a * in the SFR listing against ADCON; but it says in the text that it is not bit addressable! (this is the 1994 data book). Assuming Greg is right (and he should be in a position to know) I'll pass over they question of why ADCON is not bit addressable (since it's at an address that SHOULD be bit addressable) - as far as fixing the problem, I believe Joe is using our C compiler, and the following should get around the problem: while((ADCON & 0x30) != 0x30); This tests the ADCI and the ENADC flag. The ENADC flag must be set if the ADC is operating, so when ADCI is set, the loop will terminate. This will prevent the compiler using a bit instruction. Subject : Re: 87C752 A/D problems From : Greg.Goodhue@sv.sc.philips.com (Gregory Goodhue) reply to Clyde Smith-Stubbs: Hello Clyde, Thanks for the tip on how to force the compiler to not use bit instructions. I hadn't thought of that technique. FYI, the 8xC752 data sheet was corrected (the "*" removed from the ADCON listing) in all of the Philips microcontroller data books starting from 1995. It got that way because someone here naively thought that it would be bit addressable just because it was at a bit addressable location. That would be very logical, but things don't always work that way! I don't know the details of how ADCON got that way in the first place, so I can't explain it either.