Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/11/05 20:54
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#105058 - Classic Problem
Responding to: ???'s previous message
Mehdi said:
All things are OK, but there is a bit problem in my timing, when reading adc I disabled interrupts, This task destroys interrupts like zero cross detection on p3.2 And 135 seconds generating, when reading adc If i don't disable interrupts ,The returned value is damaged? If i use reading ADC in interrupts routine then generating 135 seconds is damaged!

This is the classic shared data problem. You need to read data (an ADC) in an interrupt routine and share it with another routine. If you do not make the ADC read operation atomic e.g by disabling interrupts, you can get corrupt data. However, disabling interrupts can cause other operations not to function correctly.

You have several options:

1. Read the ADC in the zero crossing routine. Do the zero crsooing stuff first then, if the ADC is ready, read it. The danger with this approach is if the zero crossing input stops you cannot read the ADC. However, loss of zero crossing is an arror anyway so you should be detecting it anyway.

2. You only need zero crossing when turning the heater on and off. Read the ADC when this is not happening

3. Consider synchronising everything to a single interval. As others have mentioned, you probably do not need to read the ADC more than one per second. As the ADC result is used to set the heater you don't need the zero cross untill after each ADC reading. You can also count 135 secs with this method and flash lamps at one second intervals too.

HTH

Ian




List of 39 messages in thread
TopicAuthorDate
Amenic Temp Controller,            01/01/70 00:00      
   how do you read the ADC?            01/01/70 00:00      
      By Polling DRDY!            01/01/70 00:00      
         can't DRDY be connected to an int?            01/01/70 00:00      
   Sample rate.            01/01/70 00:00      
   16 bit ADC            01/01/70 00:00      
   Safety!!!!!            01/01/70 00:00      
   Classic Problem            01/01/70 00:00      
      Why not spend $0.82 and add a cheap micr            01/01/70 00:00      
         As I suggested            01/01/70 00:00      
            If it were me.            01/01/70 00:00      
               More!            01/01/70 00:00      
                  you MUST have a double security. I woul            01/01/70 00:00      
                     Life support            01/01/70 00:00      
                        Ameni            01/01/70 00:00      
                           Thanks Steve            01/01/70 00:00      
                  Overkill            01/01/70 00:00      
                     Kai,Steve,Erik,Farshid            01/01/70 00:00      
                        What kind of temp sensor?            01/01/70 00:00      
                           Sensor            01/01/70 00:00      
                              Some questions            01/01/70 00:00      
                                 Damned good idea.            01/01/70 00:00      
                                 Answers.            01/01/70 00:00      
                                    The heater heats up and heats up and ...            01/01/70 00:00      
                        Tehran 2001            01/01/70 00:00      
                           I Am Sorry Steve!            01/01/70 00:00      
                              Mehdi, you have evaded all posts re safe            01/01/70 00:00      
                                 I want...            01/01/70 00:00      
                                    In either of these cases I fear for your            01/01/70 00:00      
                                       Safety            01/01/70 00:00      
                                          Re: safety            01/01/70 00:00      
                  Again safety            01/01/70 00:00      
                     Incentive scheme            01/01/70 00:00      
                        No pursuing available            01/01/70 00:00      
                           Thanks Farshid            01/01/70 00:00      
      Thank You All            01/01/70 00:00      
         Mail            01/01/70 00:00      
            Hi Farshid            01/01/70 00:00      
         Please post solution            01/01/70 00:00      

Back to Subject List