Triggering 5 TTL clocks simultaneously


Closed Thread
Results 1 to 40 of 84

Hybrid View

  1. #1
    TurboLS's Avatar
    TurboLS Guest

    Default Triggering 5 TTL clocks simultaneously

    OK, this code is written to wait for an interrupt, then clock out 784x512 bytes of data. The only chunk of the code shown is that which controls the clocking scheme. My question is if there is any way to execute time sensitive commands faster than the 1 usec instruction time. Thanks for all the help.

    horizpulse var byte
    vertpulse var byte

    horizpulse = 1
    vertpulse = 1
    PORTB.0 = 0 ‘portb.0 is the Vphase1 clock
    PORTB.1 = 0 ‘portb.1 is the Vphase2 clock
    PORTB.2 = 1 ‘portb.2 is the Hphase1 clock
    PORTB.3 = 0 ‘portb.3 is the Hphase2 clock
    PORTB.4 = ‘portb.4 is the reset clock

    buttonloop:
    IF PushButtonOnPORTABIT2 = 1
    THEN GOTO vertloop ‘waits for 5V that signals shutter is closed
    ELSE GOTO buttonloop
    vertloop:
    horizpulse = 1
    PORTB.0 = 1
    PAUSEUS 139
    PORTB.0 = 0
    PORTB.1 = 1
    PAUSEUS 139
    PORTB.0 = 1
    PORTB.1 = 0
    PAUSEUS 139
    PORTB.0 = 0
    PAUSEUS 270
    vertpulse = vertpulse + 1
    IF vertpulse < 512
    THEN GOTO horizloop
    ELSE GOTO buttonloop
    horizloop:
    PORTB.2 = 0
    PORTB.3 = 1
    PAUSEUS 139
    PORTB.3 = 0
    PORTB.2 = 1
    PAUSEUS 139
    horizpulse = horizpulse + 1
    IF horizpulse < 784
    THEN GOTO horizloop
    ELSE GOTO vertloop
    END

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


    Did you find this post helpful? Yes | No

    Default

    My question is if there is any way to execute time sensitive commands faster than the 1 usec instruction time
    use a faster crystal.. depending of your PIC... some can run up to 40MHZ.

    so in this case... 0.1 usec by SOME ASSEMBLER instruction
    Steve

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

  3. #3
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    I was also toying with the idea of just setting the registers in one line, like

    PORTA = %11001010

    or something to that effect, but I have no idea how I would loop that.

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


    Did you find this post helpful? Yes | No

    Default

    if you want to send 8 bits of data to PORTA in one shot... yes PORTA=MydataToSend will be what you need. Be sure that you have set the TRISA register before that
    TRISA=255
    Steve

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

  5. #5
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, here is my updated code, now I just have a few questions:

    1.) Is there a way to split PORTA into analog and digital inputs?
    2.) PORTB.4 is the reset clock and basically it has to be pulsing as soon as the microcontroller powers up. The problem is that once i start the other clocks, the time at which the reset goes high has to be in synch with H1 going low and H2 going high. In addition, it's high duration is 1/4 of the high time of the horizontal clocks. I will post up a timing diagram to explain what i mean later today. So basically I can't just put it in one of my loops, I have to start it pulsing at like a 25% duty cycle and when the other clocks are going, it has to be in synch with the horiztonals like i said earlier.

    any help is appreciated.

    ' Connect analog input to (RA0)
    ' Connect clocks to PORTB
    ' PORTB.0 is the Vphase1 clock
    ' PORTB.1 is the Vphase2 clock
    ' PORTB.2 is the Hphase1 clock
    ' PORTB.3 is the Hphase2 clock
    ' PORTB.4 is the reset clock
    ' Connect pin 2 from the DB9 connector to PORTC.6
    ' Have a +5V source ready to touch PORTA.2 to trigger clocking process

    include "modedefs.bas"

    ' Define ADCIN parameters
    Define ADC_BITS 8 ' Set number of bits in result
    DEFINE OSC 20 ' Sets clock speed to 20Mhz
    Define ADC_CLOCK 4 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000010 ' Set PORTA analog
    TRISB = %00000000 ' Set PORTB to all output
    Pause 500 ' Wait .5 second

    Pause 500 ' Wait .5 second

    horizpulse var byte
    vertpulse var byte
    adval var byte ' Create adval to store result

    horizpulse = 1 ' Initialize counters, initial states
    vertpulse = 1
    PORTB.0 = 0
    PORTB.1 = 0
    PORTB.2 = 1
    PORTB.3 = 0
    PORTB.4 = 0

    buttonloop:
    IF PushButtonOnPORTABIT2 = 1
    THEN GOTO vertloop ' Waits for 5V that signals shutter is closed
    ELSE GOTO buttonloop
    vertloop:
    horizpulse = 1
    PORTB.0 = 1
    PAUSEUS 139
    PORTB.0 = 0
    PORTB.1 = 1
    PAUSEUS 139
    PORTB.0 = 1
    PORTB.1 = 0
    PAUSEUS 139
    PORTB.0 = 0
    PAUSEUS 270
    vertpulse = vertpulse + 1
    IF vertpulse < 512
    THEN GOTO horizloop
    ELSE GOTO buttonloop
    horizloop:
    PORTB.2 = 0
    PORTB.3 = 1
    PAUSEUS 139
    PORTB.3 = 0
    PORTB.2 = 1
    PAUSEUS 50
    ADCIN 0, adval ' A/D 8 bit value from PORTA.0 into adval
    SEROUT2 PORTC.6,16416,[BIN8 adval,13,10] ' Output 8 bit word serially to PC from C.6
    PAUSE 87
    horizpulse = horizpulse + 1
    IF horizpulse < 784
    THEN GOTO horizloop
    ELSE GOTO vertloop
    END
    Last edited by TurboLS; - 21st February 2005 at 21:37. Reason: incomplete

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


    Did you find this post helpful? Yes | No

    Default

    1.) Is there a way to split PORTA into analog and digital inputs?
    for sure... see datasheet in the A/D section.. ADCON1 TABLE 19-2

    will be interesting to have kind of flowchart and schematic for the other problems you have.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    TurboLS,

    What version of PBP are you using? I've never seen this work in any versions I've had.

    IF vertpulse < 512
    THEN GOTO horizloop
    ELSE GOTO buttonloop

    I've wanted to use that type of syntax before, but I get nothing but errors. Did I miss an update or something. I have 2.45

    Darrel
    DT

  8. #8
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    I am using 2.46 and I will have a pic up soon that has the timing scheme. thanks for the replies.

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. How do I set GPIO 0-2 and 5 simultaneously?
    By cstack in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th August 2009, 09:32
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26

Members who have read this thread : 0

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