Need help with Counter/Timer application


Closed Thread
Results 1 to 22 of 22
  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263

    Default Need help with Counter/Timer application

    I'm working with PBPro and the 16F877.

    I don't need an RTC.

    What I need is a simple, compact, dependable way to clock from 0 to 6000 or more in increments of 100 milliseconds.

    Russ
    Last edited by RussMartin; - 29th August 2006 at 23:14.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Can you be more specific... i'm not sure of what you want to do.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    I need an interrupt every 100 ms, but very much as a background operation. On each, the program must check an array of stored values. When one matches the number of 100 ms intervals that have occurred, additional functions must happen.

    Example: Stored in the array are the values 123 and 456. Each is a value in tenths of a second (12.3 and 45.6 seconds, respectively). The clock begins running from 0 when an input is recognized. When the clock hits 123, a small set of instructions will execute. When it hits 456, another small set of instructions will execute. When the last (highest) value has been matched, the clock resets to 0 and waits until the next input to begin the process again.

    The values may change, and there will be more than two, of course, but I need to look at the array every 100 ms.

    Is that clearer?

    I've done this with the 8051 family but I'm very new to PIC architecture and don't know my way around it yet. I'm working my way through a couple of books on it right now. I also have the data sheet and, after I pick up a couple of extra reams of paper, I'm going to print the family reference manual.

    Russ
    Last edited by RussMartin; - 30th August 2006 at 06:34.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi Russ,

    Something like below could work for you but it is just an example to show the idea.

    Same concept could be applied to a Timer module of the PIC.



    Code:
    DEFINE OSC 20
    
    TRISB = %00000000
    PORTB = 0
    
    Relay1     VAR PORTB.0  'A relay is driven through PORTB.0
    Relay2     VAR PORTB.1
    Relay3     VAR PORTB.2
    
    RUSS_Timer var word     'A timer variable 
    RUSS_Match var word     'A variable to match timer with stored variables in Lookdown Table.
    
    
    Begin:
    
       Russ_Timer = 0
       RUSS_Match = 0
    
    
    Start:
    
       PAUSE 100   'You need 100ms of time intervals.
       RUSS_Timer = Russ_Timer + 1
       
       LOOKDOWN RUSS_Timer ,[34,46,49,112,119,122,123,124,156,189,205,235],RUSS_Match     'Get an index value from the timer. Ad d more...
    
       BRANCHL  RUSS_Match, [Run_RED, Run_Green, Run_Blue, Run_last]     'Go run the matching set of instructions. Add more....
       
    
       goto start
    
    
    Run_Red:
    
       high relay1
       goto start
       
    Run_Green:
    
       high relay2
       low  relay1
       goto start
    
    Run_Blue:
    
       TOGGLE relay3
       low relay2
       goto start
       
    Run_Last:
    
       PORTB = 0
       goto begin  'Reset All.
       
    
    
    END
    Last edited by sayzer; - 30th August 2006 at 11:27.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Thanks. I wanted to try something like that, but the problem is the processor may have to do other things while the time is ticking away. Let me show it this way:

    time 0.0 seconds -> We have an input, so we start counting.

    time 0.1 seconds -> Is test1, test2, or test3 equal to 1? No? Let's keep counting.

    . . .

    time 12.3 seconds -> Is test1, test2, or test3 equal to 123? YES, test2 is! Let's quickly perform operation A while counting continues in the background. Is there any test value greater than 123? YES, test3 is, so let's just keep counting

    . . .

    time 45.6 seconds -> Is test1, test2, or test3 equal to 456? YES, test3 is! Let's quickly perform operation B while counting continues in the background. Is there any test value greater than 456? NO!--let's reset the counter to 0 and wait for another input.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  6. #6
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Russ,
    Have a look at Darrel Taylor's Instant Interrupts. http://darreltaylor.com/DT_INTS-14/intro.html


    From this (and Darrel's elapsed timer) you can get an interrupt driven timer to count out your .1sec intervals.

    Then you can put the conditional tests and assosiated code either:
    a) In the interrupt handler itself (OK if the code is short, but not very good for lots of code)
    b) In your main loop, and poll the timer value for changes.

    This should get you started in the right direction. There are otherways to do this, but Darrel Talyor has generously done all the hard work for you getting the interrupts working.

    HTH,
    Steve

  7. #7
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default A true Multitasking Processor

    BTW - Since you are playing with time (which passes always and so quick and causes us to get older physically), how will you handle an incoming operation say B while the previous operation say A is still in progress?

    Is there a possibility like that?

    Here is another wish I should post to Wish list : A true Multitasking Processor – say four separate operations simultaneously.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    A PIC already multi-tasks...

    It runs multiple Timers all independantly from each other or anything else that's happening...

    It runs Multiple Comparators and Op-Amps (if fitted) all independantly from anything else...

    It can Transmit and Receive on it's USART (if fitted) independantly from anything else...

    It can do ADC conversion independantly from anything else...

    It can do PWM Output independantly from anything else...

    That's because it's got the HARDWARE to do it. However, until we get multi-core PICs, it can only execute one software instruction at a time. Even your desktop PC only executes one instruction at a time (ignoring the new dual-core CPU's), but it time-slices, so it appears like you are running multiple tasks. Time-Slicing is a kernel function of an OS which sits below any higher-level application program. PICs can time-slice too, but because until recently their Program Memory has been limited to only a few Kb, by the time you've added a true multi-tasking kernel, there's not been much room for anything else layered on top.

    So until someone markets an embedded multitasking OS for the PICs, you're limited to writing clever programs that perform seemingly 'simultaneous' functions yourself.

  9. #9
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie
    A PIC already multi-tasks...
    That's because it's got the HARDWARE to do it. However, until we get multi-core PICs, it can only execute one software instruction at a time. ....

    That is what I meant.

    For example:

    Code:
    While PORTB.0 = 0 
      do a kind of loop here...
    wend
    
    While PORTA.0 = 1
      do another kind of loop here...
    wend

    These two while statements can not execute et the same time. This is just an example.

    BTW; humans also multi-task albeit most of us do not even realize that we do.


    ---------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  10. #10
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    That is what I meant.

    For example:

    Code:
    While PORTB.0 = 0 
      do a kind of loop here...
    wend
    
    While PORTA.0 = 1
      do another kind of loop here...
    wend

    These two while statements can not execute et the same time.

    ---------------
    True... because of the way the program is written it will repeatedly service the PortB loop until such time as PORTB.0 = 1

    If you want BOTH loops to be serviced then there is a way of doing that. Admittedly they wont be serviced simultaneously but each will be repeatedly serviced

    Code:
    ExampleLoop:
    
    If PORTB.0 = 0 then
      do a kind of loop here...
    Endif
    
    If PORTA.0 = 1
      do another kind of loop here...
    Endif
    
    Goto ExampleLoop
    I have a project where a PIC is decoding IR signals and also receiving short commands over a serial port. The main loop is basically

    Code:
    Main:
    Gosub CheckForIR
    Gosub CheckForSerial
    Goto Main
    The IR check takes the most time but that is the main activity that the PIC has to do. Serial data is received by the USART so will buffer upto two characters. Servicing the Serial data normally takes only 1ms so that it returns more or less immediately unless serial data is received at which point it waits in the serial loop a bit longer to receive any extra data as that now becomes the priority.

    Its not true multi tasking but everything does get done OK
    Keith

    www.diyha.co.uk
    www.kat5.tv

  11. #11
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    true Multitasking Processor – say four separate operations simultaneously.
    Which is fine until you want to do six things simultaneously.

    As Melanie said
    Even your desktop PC only executes one instruction at a time (ignoring the new dual-core CPU's), but it time-slices, so it appears like you are running multiple tasks.
    My laptop is currently running many programs in the background and appears to be a speedy machine but when I first boot it up it takes forever due to the heavy processor demands for each of the applications starting up.

    To achieve the appearance of effective multitasking you must prioritise each task and ensure that a routine to service that task is performed often enough for the program to work.

    eg. Task levels "Critical", "Important", "Menial"

    Code:
    Main:
    
    For MenialTasks = 0 to 5
       For ImportantTasks = 0 to 3
          Gosub CriticalTask
          Select Case ImportantTasks
              Case 0 
                  Gosub MostImportantTask
              Case 1 
                  Gosub LessImportantTask1
              Case 2 
                  Gosub MostImportantTask
              Case 3 
                  Gosub LessImportantTask2
          End Select
       Next ImportantTasks
       Select Case MenialTasks
              Case 0 
                  Gosub MenialTask1
              Case 1 
                  Gosub MenialTask2
              Case 2 
                  Gosub MenialTask3
              Case 3 
                  Gosub MenialTask4
              Case 4 
                  Gosub MenialTask5
              Case 5 
                  Gosub MenialTask6
          End Select
    Next MenialTasks
    
    Goto Main
    To complete both the nested loops takes 24 circuits.
    (6 MenialTasks * 4 ImportantTasks).

    If you look you will see that the subroutines called are...

    CriticalTask - 24 times (once every loop of the ImportantTasks)
    MostImportantTask - 12 times (every other loop of ImportantTasks)
    LessImportantTask 1 & 2 - 6 times each (once per ImportantTasks loop)

    Each MenialTask gets called once for every complete cycle of both loops.

    You just need to figure out the most important things to do and how to keep track of what you are doing
    Keith

    www.diyha.co.uk
    www.kat5.tv

  12. #12
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    BTW - Since you are playing with time (which passes always and so quick and causes us to get older physically), how will you handle an incoming operation say B while the previous operation say A is still in progress?

    Is there a possibility like that?
    Sad to say, yes there is. That's why I'm having one PIC handling the user interface, inputs, and master timing, and other PICs performing the requisite operations.

    Here is another wish I should post to Wish list : A true Multitasking Processor – say four separate operations simultaneously.
    As you can see, I'm kind of approaching that with primitive "distributed (or parallel) processing".

    All of my prior work over the years has involved the Z80, the 8051 family, and the 68HCxx line, always with "glue" in the form of support chips (RAM, PROM, EEPROM, SPIs and/or PPIs--you know), so it's kind of fun to look at "doing it all with PICs large and small".

    PS: A lot of my practical PIC education is coming from reading Melanie's posts in this forum (and in the archives). Melanie, I'd like to nominate you for goddess.
    Last edited by RussMartin; - 1st September 2006 at 05:29.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  13. #13
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by keithdoxey
    .....

    True... because of the way the program is written it will repeatedly service the PortB loop until such time as PORTB.0 = 1

    If you want BOTH loops to be serviced then there is a way of doing that. Admittedly they wont be serviced simultaneously but each will be repeatedly serviced.....

    I wanted to indicate that when a continious loop is in progress and you need that progress as long as your circuit is in operation, you will not be able to do other things.

    In my example above, "While" statements have loops inside.
    They are not a single line of instructions, they are loops.

    One must be completed so that other can run. But, if you need an infinite loop, it will never exit that loop.

    However, if we had a dual core PIC as Melanie mentioned or quad core, then you can do a simple thing as below. Say CORE1, CORE2, CORE3 etc. are new commands of PBP's 2010 version.


    Code:
    CORE1    'Separate Job Handler.
    
    While PORTB.0 = 0 
       Do a loop here....
    Wend
    
    END CORE1
    
    CORE2     'Separate Job Handler.
    
    While PORTB.A = 1 
       Do a loop here....
    Wend
    
    END CORE2
    
    
    CORE3      'Separate Job Handler.
    ...
    END CORE3
    
    ..
    ...
    ....
    
    etc...
    they all work simultaneously.


    Am I being too much imaginery here?
    Last edited by sayzer; - 1st September 2006 at 10:24.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  14. #14
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    OK. Multi-core MCU I think is expensive. Using more than one chip also.

    So why not use a bigger PIC with more memory to do the job of all others smaller PIC's?

    How? Well I have never done it but for a long time I was thinking to do it like that:

    1. All tasks even loops should execute only for a fraction of time, a slot.
    2. An interrupt handler would share time slots to all loops or subs.
    3. The interrupt handler might also grab the serial characters and buffer them as long as the serial transmission is slower than the handler execution time.
    4. If a loop has to execute 10 times, then a counter and a flag could be used so that every time that loop is given time, it knows where it was and what to do.

    In general I think these are the main rules to make an RTOS on a PIC. May be if we work together we can built an RTOS of our own for control applications. One man is difficult to accomplish this task.

    Ioannis

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink Think simple ...

    Hi,Sayzer

    You're a bit complicated in your thoughts ...

    just need to send keywords to other " slave" PICs to have them running or waiting ... WHILE your main program ( and CORE ...) is running. as you can write a full port at a time, that make 8 perfectly synchronized "slaves" ... for an 8 bits device.


    Now, if TRUE multitasking is really needed, nothing keeps you away from two processors running on the same clock ... and sharing some of their inputs, even a full 8 bits bus.

    BUT, a good analysis of the problem greatly simplifies the hardware ... say 999 times upon 1000... Humour.

    A good peripheral use is also something to think at ... as we always overuse our CPU's ... for little stupid things ( i.e. translate in physical units instead of "counts" !!! )

    assembler is a really good programming teacher ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  16. #16
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics
    You're a bit complicated in your thoughts ...
    When I was 13 yrs old, in 1989, I was telling about my thoughts to some electronic engineers around me.

    One thought was about having a wireless network card (1989 !).
    I was playing with FM transmitters and was thinking how can I get rid of the wires of the LAN cards (old ones with BNC); could it be possible to adapt an FM transmitter to a LAN card etc.

    The engineers that I mentioned this to told me "You're a bit complicated in your thoughts ..."

    They said it would be useless, who would need a wireless LAN ? !!!!

    Well...no comment there today!

    A few yrs later, I was telling about having wireless earphones for cell phones.
    Guess what? who would need it? Just put the phone on your ear!!!

    Well, Bluetooth is kind of thing that people tend to use!

    Alain, pls do not take it personal, it is not about you. I am sure you understand my point.

    This is why my signature is like that.

    But,

    Quote Originally Posted by Acetronics
    Now, if TRUE multitasking is really needed, nothing keeps you away from two processors running on the same clock ... and sharing some of their inputs, even a full 8 bits bus.
    This is a good idea and I have seen some similar examples of it albeit not really true multi tasking.

    Having say 12F508, cheap ones, as slaves to do small jobs etc. could be nice. I will have a drawing to see what I can do. But, ONE PIC with TRUE multitasking is not that.



    -------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  17. #17
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default Thanks, everyone . . .

    SteveB put me on the right track. I reviewed Darrel's posts on the subject, then sent him a PM. He responded with a link to a new page on his web site:

    http://darreltaylor.com/DT_INTS-14/TimerTemplate.html

    It appears to answer my question!
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  18. #18
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Smile

    Hi Russ,
    From your first mail it seems you have already done your project using the 8051 core. Let me tell you my experience.
    I know only Programming in BASIC. I work with both the PIC BASIC and the BASCOM 8051 compilers. PIC basic does not support nesting of interrupts. To say all interrupts will vector to only one address location and you can not find which interrupt had called the ISR. Unlike PIC BASIC, BASCOM can have multiple interrupts, and you can determine its priority. Say for example you are using int0 and timer0...

    The code in BASCOM goes like this..
    ON TIMER0 tim0 ' on timer0 interrupt go to ISR tim0
    ON INT0 int_0 ' on external interrupt go to ISR int_0
    PRIORITY SET INT0

    This sort of feature is not there in PIC BASIC. Some call it software interrupt.
    THe command is ON INTERRUPT. The PIC BASIC also has tremendous amount of interrupt latency, ie the time taken between when the interrupt had occured and when it actually enters the ISR.
    BASCOM has a wonderful simulator, with which you can see all the SFR and the variables change. From the timer counter you can find out exactly how much time it take to enter into your ISR from the instant interrupt occured. All this can be viewed in the simulator.
    Time critical projects certainly require a simulator. The external interrupts can also be software generated in the bascom simulator.

    I certainly would love to have such a simulator in PBP. Which will verymuch reduce our development time. Without a simulator you are like blind man searching for a screw in a maze.
    If you are serious about using interrupts and all the hardware features of the PIC i suggest you start learning assembly language. Thats the best way to go untill they come out with a more enhanced way of interrupt handling in basic.
    I would like to have the comments of other participants in this thread.
    Thanks
    Raghunathan

  19. #19
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Raghunathan,

    Thats the best way to go untill they come out with a more enhanced way of interrupt handling in basic.
    They didn't, but I did.

    You may want to take a look at my Instant Interrupts (DT_INTS).
    http://www.darreltaylor.com/DT_INTS-14/intro.html

    It solves all the problems you just mentioned.


    For the simulator, you can do that with MPLAB.
    Or debug the real thing with Microcode Studio Plus.
    <br>
    DT

  20. #20
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Exclamation Yes!

    Raghunathan,

    Thanks for your comment. All of my work with the MCS-51 family has been in assembler, C, or Small C (Small C also with the 68HC11); I have no experience with BASCOM.

    As I mentioned before, I was referred by SteveB to Darrel's work and inquired by PM (thanks, Darrel!). He has got this issue nailed. Check the web site!

    http://www.darreltaylor.com/DT_INTS-14/intro.html

    I also downloaded DT_INTS-14.bas and ReEnterPBP.bas, printed them out, and walked myself through how he does it. This is a worthwhile exercise.

    See especially http://darreltaylor.com/DT_INTS-14/layers.html.
    Last edited by RussMartin; - 4th September 2006 at 21:33.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  21. #21
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Raghunathan,

    Your explaination of using the PICs interrupts is not quite fair. The limitations you mention are mostly a function of PIC BASIC Pro, not the PIC. Darrel touched on it, but here's a little more.

    Quote Originally Posted by ra68gi
    To say all interrupts will vector to only one address location and you can not find which interrupt had called the ISR. Unlike PIC BASIC, BASCOM can have multiple interrupts, and you can determine its priority.
    You can actually "find which interrupt had called the ISR" quite easly by tesing the Interrupt Flag in the ISR for the interrupts you expect. Additionally, the 16-bit PICs (18Fxxxx) have high and low priority interupts (which are usable by PBP). These vector to different locations, and as would be expected, a High Priority event can interrupt a Low Priority Interrupt, but no the other way around.

    Quote Originally Posted by ra68gi
    This sort of feature is not there in PIC BASIC. Some call it software interrupt. THe command is ON INTERRUPT. The PIC BASIC also has tremendous amount of interrupt latency, ie the time taken between when the interrupt had occured and when it actually enters the ISR.
    Yes, this is quite true. And the reason for this is that PIC BASIC Pro will finish executing the BASIC command before going to the ISR. And since each PIC BASIC Pro commands are made up of many ASM commands, there could be quite a large delay (especially if you had something like PAUSE 5000). The advantage though is that you can write your ISR entirely in PIC BASIC Pro, and don't have to worry about what's going on under the hood. But, if you can't afford any delays in your interrupts, you need to work the interrupts in ASM. Or use Darrel's Instant Interrupts.

    As Russ mentioned, he "....walked [himself] through how [Darrel Taylor] does it. This is a worthwhile exercise". If you take the time, it's a great way to learn how to handle PIC interrupts (as well as the other neat tricks Darrel uses ).


    Steve
    Last edited by SteveB; - 5th September 2006 at 05:19.

  22. #22
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Smile

    Thanks Darrel,
    I have down loaded all the files associated with instant interrupts. It will take me a few days to learn them and use it in my projects.

    Hi SteveB,
    Thanks for your reply.

    "And since each PIC BASIC Pro commands are made up of many ASM commands, there could be quite a large delay (especially if you had something like PAUSE 5000). The advantage though is that you can write your ISR entirely in PIC BASIC Pro, and don't have to worry about what's going on under the hood. But, if you can't afford any delays in your interrupts, you need to work the interrupts in ASM. Or use Darrel's Instant Interrupts."

    I know that PBP commands are non re-entrant, but that is not the case with Bascom. What happens in bascom is the waitms can be interrupted and the only draw back is that the duration of the wait gets extended.
    You have a free demo version Bascom in which you can write upto 2k. You also have an extensive user manual, which will get you started immediately. Just have a try. To get started in timers, counters and interrupts in basic it is the easiest. Hmmm... can't say until i have worked with Darrel's instant interrupts.

    I will be working on a 50 hz line-interactive UPS design using a micro controller. The heart of the program will be to generate two 50hz out of Phase pulses whose duty cycle depends on a feed back from the output voltage of the UPS. I intend to use two timers for it. Timer0 to generate a constant 10ms(not exactly 10ms but say 9.5ms or so providing a dead band of 1ms between two pulses) and timer1 to measure time until my A/d value of the feed back(from the output transformer) reaches a preset value(which translates to 230v output).
    There are 2 transistor banks. You first switch on one bank and check the a/d value. If the a/d value reaches the preset value, stop timer1 and switch of that bank. Now switch on the other bank exactly for the the same timer1 value. Each of the bank will be switched on only for the timer1 duration.If the banks are switched on for unequal time value, then there will be what we call a flux imbalance in the transformer core we switch onto. This would lead to huge amount of current drawn onto one bank of transistors and resulting in their failure. During the dead band period i have to make other measurements like battery voltage, mains incoming voltage etc.and control a few relays, leds and buzzer for incoming mains voltage regulation and annunciations.
    There is already a thread on powersupply/ inverter in this forum.

    Since i was interested in this project, i just thought it right to tell you because this is a project whic will have to use many of the hardware featue of the PIC.
    Let me figure out a way to write the code with Darel's instant interrupts.

    Thanks Guys, for your response.
    Raghunathan

Similar Threads

  1. Simple TMR1 application example needed
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th February 2010, 09:52
  2. Unusual Interrupts Application Problem
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th May 2009, 11:55
  3. PIC16F877A for application in mobile robot...
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th January 2009, 14:47
  4. DS1307 automotive application
    By DynamoBen in forum Schematics
    Replies: 10
    Last Post: - 31st August 2006, 00:33
  5. Timer Application
    By charudatt in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th February 2004, 06:05

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts