Announcement

Collapse
No announcement yet.

8243(4) timer interrupts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Paul,

    Thank you for the step by step on passing variables to ASM in PB.
    I often seem to understand concepts more readily than the nuts and bolts
    to implement them. You have helped me a lot.

    Randal

    ------------------

    Comment


    • #22
      To copy text from a message for pasting into another app (ie, the PowerBASIC IDE, Notepad, etc) and you are using Internet Explorer, then choose Edit Message (the middle icon above the pertinent message), and then copy the desired text from the Edit window. This should preserve CR/LF formatting for pasting.

      Netscape users don't appear to require this step - they can just hightlight & copy direct from the message proper.


      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #23
        Paul,

        I found mdelay. On my own hard drive! I had pulled it from the main powerbasic
        site about two weeks ago. No wonder you knew it was on the site somewhere. Its your routine!
        I didn't understand it then but filed it away for when I had someone to ask.
        Now it makes more sense. Since the init for both routines is the same, can they be used concurrently? More below.

        One question: If I want to vary the length (time on vs. time off) of individual pulses while maintaining
        the pulse rate we've been talking about all along (which is speeding up and slowing down),would you suggest
        using mdelay inside of the routine in this thread, or just use this threads latest routine and send it TIMEONvalue, then TIMEOFFvalue?

        Wait, that may not be clear. In other words, use two timing routines(one a delay, the other a timer), with one called for timeon
        (which stays constant) and the other called for timeoff(which is always varying).Or just use one timer with
        appropriate values?

        Does your answer change if both timeon and timeoff are changing. This would be the case with PWM (pulse width modulation).

        So in the first case we have a varying pulse train whose tops(or bottoms) are some fixed size to suit the external
        hardware they are connected to.(this is my current need)
        The second case is a fixed overall rate within which the top and bottom percentage of the pulses are varied within the
        available pulse time(PWM). (I can see a future need for this, so I am asking now.)

        What are your thoughts? (besides maybe, I wish I'd never gotten into this thread!

        BTW, What sort of programming do you do?


        Lance,
        Thanks for the cut/paste info.
        What about this window I am typing in right now (to post). How do I know when to
        press <enter>? It is very frustrating to have to edit each post so it looks right.

        ------------------




        [This message has been edited by Randal Milota (edited August 15, 2000).]

        Comment


        • #24
          Paul:
          When posting code on the Forums, you should use [ code ] to indicate the start of the code, and [ /code ] to indicate the end of the code (the brackets are used, but there are no spaces). This changes the font to something more appropriate for code, makes sure that the lines don't get wrapped inappropriately, and so forth.

          For example:
          Code:
             rem This text is using the [ code ] tag.
          Lance:
          MSIE 5 doesn't appear to have an "Edit Message".

          ------------------
          Tom Hanlin
          PowerBASIC Staff

          Comment


          • #25
            Randal,
            <<can they be used concurrently?>>

            No, but you'd never need to anyway.

            <<..or just use this threads latest routine and send it TIMEONvalue, then TIMEOFFvalue?>>

            That's how to do it. Instead of pulsing your output, you should invert it. Then instead of sending "time to wait for next pulse" as the NextValue, you would send pairs of times ie. TIMEONvalue, then TIMEOFFvalue.

            <<Does your answer change if both timeon and timeoff are changing.>>

            No, the routine as written handles this well for pulse high/low durations of 20usecs to 55msecs. In fact, while I was writing this routine I found it easier to test by pulsing the speaker instead of the external port and oscilloscope and I did exactly what you are suggesting. i.e. I sent PWM pulses to the speaker as the 1usec pulse of the original routine is too short and is filtered out by the speaker ciruitry so can't be heard. If you need >55ms then it's not too difficult..but I'll leave you to do it. If you need <20us then a faster machine will help a little. My K6-III/400 appears to be good for 10us between pulses, a 486 might not manage better than 50us. Any faster than 10us and a PC on its own is no good.

            <<BTW, What sort of programming do you do?>>

            I seem to do be doing a lot of timer/PWM/interrupt routines recently! I'm an electronics engineer, not a programmer. However, there is a lot of overlap between electronics and software and I've seen too many times where a person of one profession or the other makes a stupid, costly decision out of ignorance that I think it's a good idea to at least understand both fields well enough to know when to stop and ask for advice from the other side.

            Paul.

            Comment


            • #26
              Paul,

              I thought you might be electronics oriented. Seems the people working at hardware level are either that or game programmers. I also came into this via electronics. I fully agree that knowledge of the other side is sorely missing from many endeavors. Grew up with a father (Union electrician) talking at dinner about those D**m engineer/ architects and "didn't they know anything re: real world". Now I listen to engineers wondering why the electricians can't/won't do what they've asked!


              If you've still got the test code you mentioned, could you post it. I think that would be a great way to tie up this thread!

              I had an uncle and cousin, both EE's, that I used to ask the kinds of questions I've been asking here, but both died last year. In the middle of a (this)project we were working on together. Been afraid to get on this forum and be too needy/greedy. I've been a coach for many years (track and field) so I understand letting someone "get it themselves", but I've also seen the MAJOR strides made sometimes when the sticky bits are laid out in their entirety by someone who already knows...

              I've said it before, but its worth repeating, Thank You!

              Randal

              ------------------
              Lance,

              I used no CR in this post, except for paragraphs, as you said. Works for the output, thanks!
              BUT it really makes it hard to proof, or compose thoughts (scroll to the left, scroll to the right, now come on everybody, scroll all night) Its been a long couple of days



              [This message has been edited by Randal Milota (edited August 15, 2000).]

              Comment


              • #27
                Randal,
                <<If you've still got the test code you mentioned, could you post it.>>

                Test code? It doesn't deserve to be called that. All I did was replace the following lines (which pulsed the output port):

                Code:
                !mov al,255             ;pulse the output, use your own port number
                !out 128,al             ;my ouput port is at 128
                !mov al,0
                !out 128,al
                ..with these lines which drive the speaker instead:


                Code:
                !in al,&h61             ;get current speaker state into al
                !and al,&hfe            ;make sure it's enabled by clearing bit0
                !xor al,2               ;invert speaker bit (bit 1)
                !out &h61,al            ;write it back to the speaker
                This puts a PWM signal on the speaker line which can be heard. Consecutive values sent to the routine determine the high and low times of the pulses.

                Paul.



                ------------------

                Comment


                • #28
                  Paul,

                  Thanks for the quick reply, I was hoping you would put it all together with the calling routine which calcs the timeon/timeoff values.
                  Is the xor what you meant when you said invert it rather than pulse it? I can see that, and I understand the concept of consequetive shortwaitVal/longwaitVal to set the pulse top width(length),and bottom width(rate).

                  I just want to be shown how the calling routine interacts with the delay routine, and how you'd implement the variable pulse width. Doesn't the last post just set the bit, then immediately flip it(with xor)? Please show me how to change the "time until flip".

                  I really hope this hasn't become too frustrating for you. I'm really close to getting it.

                  Randal

                  ------------------
                  Looked again and think I see that EACH int flips the bit! So if the ints are coming short/long (or whatever) the pulse out will reflect that! Did I get it?

                  I still would like to see the interaction described above. I think this falls into what we talked about earlier. I have been looking at all the pieces of the problem for some time, and have come to understand many of the parts, but how they should be put together is when its probably time to go look/ask someone.Kind of like banging a program together from a lot of 3rd party libs, each has its own methodology and conventions, and getting them to respect and work with each other is sometimes as much work as stating from scratch! You are helping me understand it, not just use it. I appreciate that.

                  I am sending out bit combos(values 0-255) to the p port dataport (i.e. 378). the bits are used for step/dir control of motors(4). There is a master rate (with accel and decel),which the motor going farthest uses, the rest are slaved (submultiples) of its rate.
                  So I calc which bits need to be set (step or no/dir + or -) and use this as bits of outport,bits. Then, after a suitable delay for the motor drivers, clear only the bits just set.(some drivers also need the dir bits set before the stepbits are issued, but this is such a small delay that almost anything the pc does will slow it enough to allow for it. Then I wait til your routine says, "its time to output the next bits,sir!" and repeat the process til done.


                  I thought since you have put so much time into helping me you ought to know more how I'm trying to use it.



                  [This message has been edited by Randal Milota (edited August 15, 2000).]

                  Comment


                  • #29
                    Originally posted by Tom Hanlin:
                    Lance:
                    MSIE 5 doesn't appear to have an "Edit Message".
                    The Edit Message icon appears above each message in the thread, so it a function of the BBS software rather than the particular browser being used.

                    I use both NE (3?) and IE5, and the Edit Message icon appears above each message for me, and I'm sure Admin privileges have nothing to do with their appearance. I use the Edit Message technique (almost) daily with MSIE5.



                    ------------------
                    Lance
                    PowerBASIC Support
                    mailto:[email protected][email protected]</A>
                    Lance
                    mailto:[email protected]

                    Comment


                    • #30
                      Randal,
                      <<I was hoping you would put it all together with the calling routine which calcs the timeon/timeoff values.>>

                      It is all there, the calculation of time on and time off is trivial in my case because I'm just sweeping the pulses up and down. I can't do it for your case because I don't know how your pulses need to be varied for your task. You just replace the "@NextVal=..." line with the calculation of your next interval.

                      <<Is the xor what you meant when you said invert it rather than pulse it?>>

                      Yes.

                      <<I just want to be shown how the calling routine interacts with the delay routine,>>

                      But it's already there:

                      "@NextVal=.." sets the time of the next high or low interval and ..

                      Code:
                            DO
                            LOOP UNTIL @done
                            @done=0
                      ..synchronises the BASIC code with the real pulse train being produced.


                      Perhaps you'd understand it more easily in the following form:

                      Code:
                           DO
                      
                           @NextVal=100:REM I want this pulse to be HIGH for 100 timer ticks
                      
                           DO
                           LOOP UNTIL @done  :REM do the handshaking between BASIC and interrupt routines
                           @done=0
                      
                           @NextVal=200:REM I want this pulse to be LOW for 200 timer ticks
                      
                           DO
                           LOOP UNTIL @done  :REM do the handshaking between BASIC and interrupt routines
                           @done=0
                      
                           REM loop back to do the next pulse
                           LOOP

                      It's up to you to set the "@NextVal=.. " to give the timing you require.


                      <<Doesn't the last post just set the bit, then immediately flip it(with xor)?>>

                      No, it works as advertised. You're confusing bit numbers. Bits are numbered from 0 (Least significant) to 31 (most significant). BIT 0 is cleared to enable the speaker. Bit 1 is toggled to produce the pulse.

                      If you still have trouble with this then I suggest you set the port address to your real output port and stick an oscilloscope on it. Then run the code and experiment with changing the values. It'll soon become so obvious what's happening that you'll not believe that you ever had trouble understanding it.

                      Paul.

                      Comment


                      • #31
                        Paul,

                        Thanks for your patience with me.

                        Re: <no, it works as advertised> Did you see my ahha! below (in that post)?

                        I think it all makes sense now. I can do other things (set up bits,etc.) while waiting for the done flag, correct??
                        That done flag is my hook to the int? I have to be sure what I am doing is done before the int (done flag),yes?? If your answers match mine, then we're done with this.

                        My O-scope(s) are still packed from a recent move. I will be able to get to one this week, and will do as you suggest. Thanks for all your help. Can't help wondering, Are you from/in the UK? Some of your verbage reminds me of friends there.

                        ------------------


                        [This message has been edited by Randal Milota (edited August 18, 2000).]

                        Comment


                        • #32
                          Randal,
                          <<Did you see my ahha! below (in that post)?>>

                          Yes, but it appeared after I'd read the post and composed my reply.

                          <<If your answers match mine, then we're done with this.>>

                          My answers all match!

                          <<Can't help wondering, Are you from/in the UK?>>

                          Yes to both.
                          I've just looked up "verbage" in my dictionary, we spell it "verbiage" over here and it says "The excessive and often meaningless use of words". Thanks. I'll try to be more concise in future!

                          Paul.
                          P.S.the alternative meaning is also listed but the dictionary says its rarely used that way.

                          Comment


                          • #33
                            Paul,

                            On this side of the pond, verbiage(I often spell it that way,too) just means using certain word combinations. But really, I think you've already got concise pretty well understood.
                            No nd 2 chng.

                            Randal

                            ------------------

                            Comment

                            Working...
                            X