Shop OBEX P1 Docs P2 Docs Learn Events
SX20 as clock/sync source for other devices? — Parallax Forums

SX20 as clock/sync source for other devices?

T ChapT Chap Posts: 4,223
edited 2008-10-15 21:01 in General Discussion
I have two devices I want to sync, once device needs to clock out of phase.

The devices requires a minimum of 150uS on time on the positive clock phase, one turns on while the other turns off simultaneously. The max on time is 150ms but the faster the better.

Considering potential variances of times using discreet components, I was thinking to use the SX20 and two pins off of it to to the clocking.

Is the SX20 capable of near 150uS on times, and would it's own internal clock be adequate to insure an On time safely above 150uS?

Considering the cost of an inverter IC and discrete components, the confidence of a known(semi known) clock rate might make sense using the SX. It would be great not to need to add the resonator, but I can't tell from the data whether these speeds could be obtained with out one.

Thanks

Comments

  • pjvpjv Posts: 1,903
    edited 2008-05-09 23:38
    Hi Originator;

    If all you want to do is simultaneous alternating phase clocking on two channels, it takes a loop of only two instructions consuming four clock cycles, and the SX family can easily do that at speeds up to 12.5 MHz (80 nano seconds on and 80 off) with a 50 mHz resonator. Using the internal 4 mHz oscillator, the best you can get is 1 MHz (1 micro second on and 1 off).

    As for slower; with a down counter you could program it to do almost any loop multiple slower.

    Cheers,

    Peter (pjv)
  • T ChapT Chap Posts: 4,223
    edited 2008-05-09 23:59
    Thanks pjv, based on the minimum ON time req'd of 150 microseconds, and what you state regarding the internal resonator's capability (1 micro second on and 1 off best case), the internal resonator would be suited to 150 microsecond on and 150 microsecond off clocking correct?

    I am not an SX expert but have used a few some years back, is the speed I need something capable with SX-B?

    I have spent a lot of time on Google looking at clock circuits and clocking IC's, and so far have not seen a simpler option than on SX20 smt with no external resonator or xtal. I wouldn't want to trust RC based discrete stuff for the life of the product.


    Thanks
  • pjvpjv Posts: 1,903
    edited 2008-05-10 03:02
    Hi Originator;

    All you need to do is configure the chip to activate the internal oscillator, and disable the interrupts. Then make the two chosen port bits outputs, an load them with opposing values, one a zero, and the other a one. Then load the w register with bits set to match the positions of the chosen port bits. Next create a loop that XORs the w register into the output register, and you're done.

    For example, using port B, bits 3 and 0;


    ··········· setb···· rb.0
    ··········· clrb····· rb.3
    ··········· mov···· w,#%0000_1001
    Loop··· · xor······ rb,w
    ··········· ········· (in-line here put some other dummy instructions or a counter·to slow things down)
    ··········· jmp····· Loop
    ············
    Now if you need to do other things such as SX/B simultaneously, things get a lot more complicated, and if you need the frequency continuously and at a steady pace, then it migt become very difficult without a real time O/S.
    Those exist of course (see my Parallax contest entry of two years ago), but depending on your needs, is very much more complicated than this simple example which answers your original question.

    Cheers,

    Peter (pjv)
  • T ChapT Chap Posts: 4,223
    edited 2008-05-10 03:34
    Thanks a bunch pjv, seems pretty simple, there needs be no other commands except to slow the thing down to get it just over 150uS ON, plus add a little time to account for internal fluctuations on it's own osc.

    Considering you estimated that @ 4mhz and 4 lines = 1uS, just add something in there to delay it till it looks right and I am set.
  • T ChapT Chap Posts: 4,223
    edited 2008-10-15 06:13
    Killing time until a new SX key arrives, thought I'd read the assembly SX tutorial. I want to toggle two pins on and off separately, with adjustable time on, and dead time between each. 150us on time miminum. Is this in the ball park or workable?

    Are unused pins OK left as is or should they be set to outputs to avoid floating as inputs?

    Thanks


                                'set internal oscillator
                                'disable the interrupts?
    
            org 0    
                                ;toggle between output ra0 and ra3 with dead time between each
                                ;ra0 = $01,  ra3 = $08
    
    start_point              mov    !ra,#0         ;make all of port a outputs
                       mov    ra, #0     ;make all of port a = %00000000
    
    
    :loop           mov    ra, #$01     ;make ra0 = 1, ra3 = 0
                      nop                     ;set ra0 On time = 1 clock cycle per nop in turbo, adjust until 150us, add nop's as needed
                      mov     ra, #0     ;set ra0 back to 0
            
                      nop                     ;set some dead time between ra0 OFF and ra3 ON nop = 1 clock in turbo
                                                             ;add nops as needed
            
                      mov    ra, #$08    ;turn ra3 on        
                      nop                    ;set ra3 On time = 1 clock cycle per nop in turbo, adjust until 150us, add nop's as needed
                      mov     ra, #0    ;set ra0 back to 0
    
                      jmp            :loop
    
    

    Post Edited (Originator) : 10/15/2008 7:34:55 AM GMT
  • BeanBean Posts: 8,129
    edited 2008-10-15 11:16
    SX/B is certainly fast enough for this.

    DEVICE SX20,OSC4MHZ,TURBO,STACKX,OPTIONX
    FREQ 4_000_000
     
    Out1    PIN RA.0 OUTPUT
    Out2    PIN RA.1 OUTPUT
     
    PROGRAM Start
     
    Start:
      Out1 = 1
      Out2 = 0
      DO
        RA = RA XOR 3
        PAUSEUS 150
      LOOP
    END
    
    


    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter

    www.iElectronicDesigns.com

    ·
  • T ChapT Chap Posts: 4,223
    edited 2008-10-15 15:34
    Thanks for that info Bean. I will experiment with both, kinda fun learning the assembly from scratch too.
  • Lord SteveLord Steve Posts: 206
    edited 2008-10-15 17:41
    I have used the SX to clock two other chips: a 6502 and a Propeller.

    http://forums.parallax.com/showthread.php?p=655817

    http://forums.parallax.com/showthread.php?p=722736
  • T ChapT Chap Posts: 4,223
    edited 2008-10-15 19:45
    Could use some advice on troubleshooting 'no key found' with both a key and blitz that used to work.

    The circuit is straight forward, 3v3 on the SX20. I used a 6volt power supply into an SK Key Ring, and the Key Ring regulator is outputting 4.59 volts. On attempting to program, I get a red light on the USB cable only if it is not plugged into anything, but get RED and green activity for a split second if it is plugged into any device.

    I can measure 3v3 on the SX20, it also has 3.3 on the Osc2 pin, and approx .2 on Osc1.

    The power is connected to the SX and metered at each pin.

    I cam meter the 4.59 volts from the Key Ring getting up into the SX Key/Blitz on Vdd, as well as 3v3 on the Osc2 pin in the Key/Blitz, so everything seems connected all the way to the chip.

    Using either device, there is the error always that says ' No Sx Key found on port 5". I have tried two computers that have formerly programmed SX's, one with serial port, and the lap top with USB serial adapter that works fine on the Propeller.

    Any suggestions would be great.

    If these programming devices are blown, then that makes 3 dead ones. One of my own, and two I Just borrowed from a friend today. I wonder what buying another one today is going to solve if I just blew these two borrowed ones? Are they really that fragile?

    In the circuit, the 3v3 on the header is not really getting to the SX KEY, as the Key Ring does not allow it to get in, rather the 4.59v from the regulator powers the SX Key or blitz.
    270 x 284 - 15K
    sx.jpg 15.2K
  • BeanBean Posts: 8,129
    edited 2008-10-15 20:10
    Pin 1 of the programming header should be GND not pin 2.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter

    www.iElectronicDesigns.com

    ·
  • T ChapT Chap Posts: 4,223
    edited 2008-10-15 20:14
    No, that header shown is my own dual row 2x2 header on a PCB for space concerns, the pinout is accurate to the chip and KeyRing.

    Everything checks out from the Key ring to the pins of the SMT SX20.

    Post Edited (Originator) : 10/15/2008 8:22:49 PM GMT
  • T ChapT Chap Posts: 4,223
    edited 2008-10-15 21:01
    Update:

    I was told in one thread when asking about the power to the SX KEY RIng to use 5 v, as well I had Googled the Key ring yesterday and read another post by Gunther that 5 volts was required on the Key Ring. I was using 6. I tried 12 just now and finally got it to program. Thanks for the suggestions guys. Now I understand it is a power issue. 5 volts may work, but it must require a hefty supply, probably 1amp and up.

    Post Edited (Originator) : 10/15/2008 9:21:04 PM GMT
Sign In or Register to comment.