Instruction cycle measurement


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Instruction cycle measurement

    Hi,
    Windows isn't known for being good at high resolution timing, atleast not with the "standard" tools. Why not do one of two things:
    1) Just stream the data from the PIC to the PC. The serial port control in VB buffers the data behind the scenes.
    2) If you do need to have the PC poll the PIC then buffer the data in a circular buffer with enough size and send it off in bursts.

    /Henrik.

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: Instruction cycle measurement

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Windows isn't known for being good at high resolution timing, atleast not with the "standard" tools. Why not do one of two things:
    1) Just stream the data from the PIC to the PC. The serial port control in VB buffers the data behind the scenes.
    2) If you do need to have the PC poll the PIC then buffer the data in a circular buffer with enough size and send it off in bursts.

    /Henrik.
    It's above my level of knowledge. But, I'm willing to learn. It's actually a USB VB program but I'm guessing the same ideas apply. I'll play around with it and see what I can do. Thanks for the help.

  3. #3
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: Instruction cycle measurement

    After some searching, it appears as though there's no way to get below a 1mS timer with VB6. The problem, as you mentioned, is windows.

    Now how to solve it?

    I can miss up to 30 packets per revolution of code (mainloop -> Goto mainloop) so what is the easiest way to get every single piece of data? My preference would be for the PIC to store the data and then when the PC gets around to it, that packet will be sent.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Instruction cycle measurement

    Hi,
    USB, OK, never played with that myself. But anyway, are you sending one single measurment from the PIC to the PC each time the PIC is polled? If you reliably can get a poll rate of say 20Hz and you need 500 measurments per second you need a buffer in the PIC of atleast 500/20=25 measurements (bytes or words?) but I'd probably add some margin to that.

    Now, depending on how the rest of the code is set up, ie. if interrupts are used etc using the local buffer can be more or less complicated. Assuming that no interrupts are used to put data INTO the buffer all your main program has to do keep track of where in the buffer to put the next byte using a pointer variable
    Code:
    BufferSize CON 25
    LocalBuffer VAR BYTE[BufferSize]
    Ptr VAR BYTE
    Ptr = 0
    Each time you get a new measurment to put in the buffer you do something like
    Code:
    LocalBuffer[Ptr] = NewMeasurment
    Ptr = Ptr + 1
    If Ptr = BufferSize THEN GOTO BufferOverFlow   ' Buffer not emptied in time.....
    The routine that sends the data to the PC when polled then just have to send any data that's in the buffer. I'm using HSEROUT here since I don't know how you're doing it with USB
    Code:
    If Ptr > 0   'Only do this of there's any new data in the buffer
      For i = 0 to (Ptr - 1)
        HSEROUT [LocalBuffer[i], 10,13]
      NEXT
      Ptr = 0    ' Reset pointer
    ENDIF
    Something like that, perhaps.

    If you're not using interrupts then obviosuly the PIC can't read data and put into the buffer at the same time that it's sending data but I don't know exactly how that works when using USB. If you're using interrupts to fill the buffer, ie. the routine that sends data to the PC can be interrupted by the routine putting data into the buffer you'll need to resort to a circular buffer.

    /Henrik.

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