Announcement

Collapse
No announcement yet.

8243(4) timer interrupts

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

  • Randal Milota
    replied
    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

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

    Leave a comment:


  • Paul Dixon
    replied
    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.

    Leave a comment:


  • Randal Milota
    replied
    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).]

    Leave a comment:


  • Paul Dixon
    replied
    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.

    Leave a comment:


  • Lance Edmonds
    replied
    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>

    Leave a comment:


  • Randal Milota
    replied
    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).]

    Leave a comment:


  • Paul Dixon
    replied
    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.



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

    Leave a comment:


  • Randal Milota
    replied
    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).]

    Leave a comment:


  • Paul Dixon
    replied
    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.

    Leave a comment:


  • Tom Hanlin
    replied
    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

    Leave a comment:


  • Randal Milota
    replied
    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).]

    Leave a comment:


  • Lance Edmonds
    replied
    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>

    Leave a comment:


  • Randal Milota
    replied
    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

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

    Leave a comment:


  • Randal Milota
    replied
    Tom,

    Thanks for the info, but I DID break his code

    I'm using msie4 and,like Paul, have no problems pasting his code (and others on this site)
    into notepad or textpad (my editor). However, I did get the amorphous blob
    when trying to paste Mike Luther's first response in this thread.

    Glad to know you guys at PB have something to do in your FREE time
    Part of the problem "may" be the "when do I put a CR in this line" dilemma
    I encounter whenever I post to the forum. In other words, maybe they are not being stripped
    out, they are just not put in by people used to word wrapped text??

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


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

    Leave a comment:


  • Paul Dixon
    replied
    Tom,
    <<Did you test on code that was posted using the [ code ] tag? >>

    No, I don't even know what the [ code ] tag is. I tested it on the code that
    I posted in this thread. I just cut it from a source code file and pasted it
    into the "your reply" box.

    Paul.



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

    Leave a comment:


  • Tom Hanlin
    replied
    Nope, I'm using MSIE 5.0 here. As far as I know, it's a problem
    with all versions of Internet Explorer. Did you test on code
    that was posted using the [ code ] tag? That's where the problem
    comes in.

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

    Leave a comment:


  • Paul Dixon
    replied
    Tom,
    I was not aware of that...but I've just tried it and the line
    breaks are preserved in IE5, which I have here. I'm sure I never
    had trouble with it before. Perhaps it's a specific version of IE?

    Paul.



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

    Leave a comment:


  • Tom Hanlin
    replied
    Originally posted by Paul Dixon:
    Yes, you broke it. The code needed no reformatting.
    Be advised that Microsoft Internet Explorer does not treat breaks in lines properly when you copy to the clipboard. So, if you try to copy code from these forums using MSIE, all of the CR/LFs disappear, and the code is left as an amorphous blob. This is presumably why Randal needed to reformat.

    We hope to find a solution for this (in our copious free time). Suggestions (other than "don't let anyone use Internet Explorer") would be welcome.


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

    Leave a comment:


  • Paul Dixon
    replied
    Randal,
    <<Would you comment on the "don't use this in windows, only DOS" ?>>

    Timing in a DOS program never works well under Windows. In plain DOS, your code controls the entire
    machine. In Windows, your program is controlled by the operating system which will switch out your DOS program
    from time to time to do other things. During this time your code is not running so the pulse times will not
    be updated. Try it and see, it almost works on my machine but the timing is raggy.
    I'm not a Windows programmer so I have no idea how best to do it in Windows, but it will be possible.
    My preferred soloution would be external hardware to produce the pulses then the operating system wouldn't
    matter.

    <<I'm not worthy! I'm not worthy!>>

    The bill is in the post.

    <<I realize this may be a very obvious/simple thing that I should!!>>

    It is obvious, the code as posted is already passing variables back and forth between ASM and BASIC,
    just copy the method. The way I did it is not necessarily the best but it works like this:

    1) define a pointer to point to the variable (which will be a word of memory in the ASM code)
    e.g. DIM ThisPointer as dword ptr

    2) in the ASM section, reserve a few byte to act as the actual variable
    e.g. ThisVariable:
    !dd 0

    3) Point the pointer at the variable
    e.g. ThisPointer = codeptr32(ThisVariable)

    4) The variable is then accessed from BASIC using @ThisPointer
    e.g. @ThisIsThePointer = 1234
    e.g. PRINT @ThisPointer

    5) The variable is accessed in ASM using a mov instruction
    e.g. !mov ax,ThisVariable
    e.g. !mov ThisVariable,al

    Paul.


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

    Leave a comment:


  • Randal Milota
    replied
    Paul,

    Your most recent code is very close to what I need. You've given me my hardware rate timer. Thank You.
    The port bits are hard-coded in the int routine. The example uses out 128,255 (set 8 bits),out 128,0
    (clear bits). I need to change these bits on the fly. How do I pass the value (0 to 255) to
    send out the port to this int routine. i.e. At each interrupt(output to port), I need to set and clear
    various bit combinations including some bit-twiddling for the p port inversions on status and control pins.

    The twiddling I know how to do, passing an (additional) value to the ASM int routine I need help with.
    I realize this may be a very obvious/simple thing that I should!! see, but if you would indulge me one
    more time, I think i'll be on my way.



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

    Leave a comment:

Working...
X