Controlling OG-4 Decathron with PBP in an efficient way.


Closed Thread
Results 1 to 40 of 40
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Controlling OG-4 Decathron with PBP in an efficient way.

    Hello, I'm adding an OG-4 decathron tube to my open source nixie clock project. It being run by separate PIC and own power supply. The tube has following pins, which are being driven by MPSA42 transistors, controlled via PIC12F683. These pins are


    Z - reset pin,also lights up, let's call it "zero"
    A,B,C - enable pins


    So sequence is as follows:


    do
    pulse Z, then pulse A, B, C in repeating loop, 9 times, after that
    pulse A and then pulse B, to lit up remaining dots
    loop


    This code provides the spinning in clockwise direction (there are also PAUSE statements, to adjust the speed). To reverse the direction, sequence after Z should be C, B, A


    So what I want to achieve. It does 1 complete run and comes back to zero. Then starts at 1st dot at right to zero and again makes 1 complete run and comes back to 1st dot. After that, it starts from 2nd dot and makes turn till it reaches 2 again, then starts at 3 and goes to 3 and so on, including 29th dot. Then starts over


    I've developed very crude and inefficient code for that, which runs on 12F683. I only have made animation till 10th dot and it already using 1k of available chip memory. Of course, I can switch to say 12F1840, but code is still not that good - any attempt to add say 2 times making the same rotation needs complete code rewrite. So is there a way that my code can be optimized? or I have another idea, Decathron tube can be considered as a kind of shift register, so maybe there is another, more efficient approach of doing the above task?

    Here is my code

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 15.05.2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    ANSEL = %00000000    
    CMCON0 = 7 
    TRISIO=%00001000
    OSCCON = %01110111
    'Include "Modedefs.bas"
    Define	OSC	8		' Set Xtal Frequency
    
    
    '	Clk     Var	GPIO.5		' Data is clocked on rising edge of this pin            kviteli
    '	Dta  	Var	GPIO.4		' Bits are shifted out of this pin          stafilosferi
    
    
    ZERO    var     GPIO.0
    ONE     VAR     GPIO.4
    TWO     VAR     GPIO.1
    TRE   VAR      GPIO.2
    cik var word  'loop variable
    x   var word   'delay variable
    increment var word 'incremental variable
    lop var word  'also variable
    increment=0  'temp
    sub var word 'intracounter variable
    sub=9
    x=30
    
    
    'INIT tube and reset to 0
    inika:
    LOW ONE
    LOW TWO
    LOW TRE
    HIGH ZERO
    PAUSE x
    LOW ZERO
    
    
    tavi:         
    
    
    'stage 1______________________________________________
    sub=9
    gosub sub9
    high one  'proper finish?  one and two
    pause x
    low one
    high two
    pause x
    low two
    high zero
    pause 1000'delay for display
    low zero
    
    
    
    
    'stage 2 ______________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    pause 1000
    low one
    
    
    'stage 3____________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause 1000
    high tre
    low two
    pause x
    low tre
    
    
    'stage 4____________________________________________
    sub=8
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause 1000
    low tre
    
    
    'stage 5____________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause 1000
    low one
    
    
    'stage 6____________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause 1000
    high tre
    low two
    
    
    'stage 7____________________________________________
    pause x
    low tre
    sub=7
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause 1000
    low tre
    
    
    'stage 8____________________________________________
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause 1000
    low one
    
    
    'stage 9____________________________________________
    'X=100
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause 1000
    high tre
    low two
    pause x
    
    
    'stage 10____________________________________________
    low tre
    sub=6
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause 1000
    low tre
    
    
    
    
    goto tavi
    
    
    sub9 'subroutine for spinning
    
    
    for cik=1 to sub 'amount needed for full loop
    high one
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    low tre
    next
    
    
    return
    
    
    
    
    subzero:
    
    
    high one  'proper finish?  one and two
    pause x
    high two
    low one
    pause x
    high zero
    low two
    pause x'delay for display
    high one
    low zero 'subzero here
    
    
    return

  2. #2
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    One simple thing you can do is to combine commonly occurring sequences into a sub, for example
    Code:
    hl2:
        pause x
        high two
        low one
    return
    doing that (and making variables 'byte' instead of 'word') drops it down from 1K to 330
    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 15.05.2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    'device=PIC12F683
    
    'Include "Modedefs.bas"
    Define  OSC 8       ' Set Xtal Frequency
    
    cik var byte       'loop variable
    x   var byte        'delay variable
    sub var byte        'intracounter variable
    
    ZERO    var     GPIO.0
    ONE     VAR     GPIO.4
    TWO     VAR     GPIO.1
    TRE     VAR     GPIO.2
    
    ANSEL = %00000000    
    CMCON0 = 7 
    TRISIO = %00001000
    OSCCON = %01110111
    
    
    sub=9
    x=30
    
    'INIT tube and reset to 0
    inika:
    LOW ONE
    LOW TWO
    LOW TRE
    HIGH ZERO
    PAUSE x
    LOW ZERO
    
    tavi:         
    
    'stage 1______________________________________________
    sub=9
    gosub sub9
    
    high one  'proper finish?  one and two
    gosub hl2
    gosub hl0
    pause 1000  'delay for display
    low zero
    
    'stage 2 ______________________________________________
    gosub sub9
    gosub subzero
    pause 1000
    low one
    
    'stage 3____________________________________________
    gosub sub9
    gosub subzero
    gosub hl2
    pause 1000
    gosub hl3
    low tre
    
    'stage 4____________________________________________
    sub=8
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    pause 1000
    low tre
    
    'stage 5____________________________________________
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    gosub hl1
    pause 1000
    low one
    
    'stage 6____________________________________________
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    gosub hl1
    gosub hl2
    pause 1000
    high tre
    low two
    
    
    'stage 7____________________________________________
    pause x
    low tre
    sub=7
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    gosub hl1
    high two
    low one
    gosub hl3
    pause 1000
    low tre
    
    'stage 8____________________________________________
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    gosub hl1
    gosub hl2
    gosub hl3
    gosub hl1
    pause 1000
    low one
    
    
    'stage 9____________________________________________
    'X=100
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    gosub hl1
    gosub hl2
    gosub hl3
    gosub hl1
    gosub hl2
    pause 1000
    high tre
    low two
    pause x
    
    'stage 10____________________________________________
    low tre
    sub=6
    gosub sub9
    gosub subzero
    gosub hl2
    gosub hl3
    gosub hl1
    gosub hl2
    gosub hl3
    gosub hl1
    gosub hl2
    gosub hl3
    pause 1000
    low tre
    
    goto tavi
    
    hl0:
        pause x'delay for display
        high zero
        low two
    return
        
    hl1:
        pause x
        high one
        low tre
    return
    
    hl2:
        pause x
        high two
        low one
    return
    
    hl3:
        pause x
        high tre
        low two
    return
    
    sub9: 'subroutine for spinning
        for cik=1 to sub 'amount needed for full loop
            gosub hl1
            gosub hl2
            gosub hl3
        next
        low tre
    return
    
    
    subzero:
        high one  'proper finish?  one and two
        gosub hl2
        high zero
        low two
        pause x'delay for display
        high one
        low zero 'subzero here
    return
    I've bound to have goofed that up somewhere so it's up to you to fix whatever I screwed up, but you get the idea.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Yeah I already started that, but had no idea, going from word to byte will save that much space
    I'm still thinking, decathron is a ring counter/shift register, so maybe there is some other ways of controlling it....

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


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    And stop using HIGH/LOW, those waste both time and space.

    The animation can most likely be done with two FOR loops. An outer that steps thru the starting position from 1 to 29 and an inner that "sweeps the circle" one revolution starting/stopping at the dot pointed to by the outer loop.

    If I'm not mistaken the effect you're after is similar to the the common "please wait the computer is busy" circle thingy you see on Windows systems?

    /Henrik.

  5. #5
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    You can't do it with two FOR loops, because you have to consider the reset pin and fact that number of dots is even, but number of control pins is odd. So it is always required to add an extra step out of loop, depending on even/odd current position.

    The effect I'm making is as follows. Rotation starts from dot 1 and comes again to dot 1, stops there for a second, then quickly rotates one full loop, but stops at dot #1. Waits for a second, full spin and stop at dot #2 and so on, till it makes full turn.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    If you say so :-)
    Do you have a datasheet describing the driving signals, I'm having some difficulties understanding how it works based on your description.

    /Henrik.

  7. #7
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    I have only Russian book about it. But principle of operation is nicely shown in animation here:

    https://threeneurons.wordpress.com/dekatron-stuff/

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Quote Originally Posted by HenrikOlsson View Post
    And stop using HIGH/LOW, those waste both time and space....
    /Henrik.
    Well, I have some doubts about this. If it relates to output port registers I think it is necessary to use High/Low commands. Or at least this used to be the case with older versions of PBB.

    Direct control of port registers like this portb.0=1 may cause problems when the program is long because of memory page issues. I may be wrong here. Anyone?

    Ioannis

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    If it relates to output port registers I think it is necessary to use High/Low commands.
    the only problem with high/low is that they waste time and code space setting/clearing the tris register ,every time they are invoked.


    Direct control of port registers like this portb.0=1 may cause problems when the program is long because of memory page issues.
    the only issue with direct port writes once you have the tris reg set appropriately is the potential for rmw issues , especially at high clock speeds.
    always use lat regs if possible and a shadow reg otherwise if rapid sequential port manipulation of individual pins will be employed
    Warning I'm not a teacher

  10. #10
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Most everything PIC made in the past decade features LATx Registers;
    LATB.0 = 1
    (Of course you could also insert a bit of ASM if FOSC cycles are important
    @ BANKSEL LATB
    @ BSF LATB,0

  11. #11
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    For this particular case, speed is not an issue, since these tubes have couple of KHz max operating frequency, and in my case there are Pause 30 and Pause 1000 statements

  12. #12
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Run into strange problem - setting GPIO.5 as input messes with GPIO.4 - it becomes high when GPIO.5 is read, so disrupts complete code routine. I'm using TRISIO=%00100000 to make GPIO.5 as input. If I disable it as input, then other code works fine.

  13. #13
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    In your code at the top of the page you list TRISIO=%00001000. Of course GPIO.3 is MCLR and is Input only. In the previous post you state you are having problems with TRISIO=%00100000. It's probably not your issue, but try TRISIO=%00101000.

  14. #14
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    It does not helps. And I'm not using MCLR pin for anything except programming. Tried TRISIO=%00101000 but that does not helps. Tried disabling MCLR from config, also no change. Making a pin input creates issues with others being output.

  15. #15
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    I tried to replace HIGH/LOW statements with TRISIO.X=1 or 0, it does not helps. In fact, say TRISIO.0=1 does not make GPIO.0 pin high.

  16. #16
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Did you try a new PIC? I've never seen what you're describing. Thinking something internal might be whacked.

  17. #17
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    its a classic rmw problem.
    can also be caused by excessive load on output pin (capacitive or resitive) causing pin to not achieve proper logic level.
    Warning I'm not a teacher

  18. #18
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Yes tried new chip. Output pins are connected to MPSA42 transistor via 10K resistor.

  19. #19
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    If I swap chip with 12F1840, will problem still exist?

  20. #20
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    I decided to put it aside, to give my mind some rest, and back to DS3231.
    I found that it does not return seconds properly.

    Have two different example codes, they work fine for minutes and hours, but does not work for seconds - seconds increase like 02 04 08 10 12 14 16 till 28, then 29 and again increase in 2 and so on.

    Code:
    SecondsMSB=BCDSeconds & $70 
    SecondsMSB=SecondsMSB>>4              
    SecondsLSB=BCDSeconds & $0F              '
    Seconds=(SecondsMSB*10)+SecondsLSB 'combines DECMinutes MSB and LSB
    
    
    x=RTCSEC >> 4
    Y=RTCseC // 16
    z=X*10+Y

  21. #21
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    If I swap chip with 12F1840, will problem still exist?
    more than likely , you need to understand and remedy the situation.

    http://www.picbasic.co.uk/forum/showthread.php?t=15843&highlight=shadow
    http://www.picbasic.co.uk/forum/showthread.php?t=15013&highlight=shadow

    a
    nd post your code and a schematic so we don't just keep guessing
    Warning I'm not a teacher

  22. #22
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Code is posted above.

    Schematic is simple, there are 4 MPSA42 transistors, each of which is connected via 10K resistor to corresponding ports (ZERO, ONE, TWO, TRE) as shown in code. GPIO.5 is tied via 10K resistor to VDD, and button pulls it to zero.

    Only addition to code above is

    Code:
    koka:
    
    if GPIO.5=0 THEN 'if pin pressed
    goto tavi 'launch rotation
    ENDIF
    pause 1
    GOTO KOKA

  23. #23
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    and post your code and a schematic so we don't just keep guessing
    i mean post the code you are using now!
    i'm likely to make mistakes going back through several pages of add infested forum to try and patch together what i think you may be using.
    and even a hand drawn schematic makes things clearer
    Warning I'm not a teacher

  24. #24
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    OK one moment, let me finish this first, figured DS3231 error reason now, it was due to re-using variable. I need rest, serious rest

  25. #25
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Here it is:

    if I change TRISIO config so port 5 is no longer input and directly launch the code, it works properly.

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 15.05.2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    ANSEL = %00000000  'disable analog  
    CMCON0 = 7 'disable comparators
    TRISIO=%00101000 'input config
    OSCCON = %01110111
    'Include "Modedefs.bas"
    Define OSC 8  ' Set Xtal Frequency
    ' Clk     Var GPIO.5  ' Data is clocked on rising edge of this pin            kviteli
    ' Dta   Var GPIO.4  ' Bits are shifted out of this pin          stafilosferi
    
    ZERO    var     GPIO.0
    ONE     VAR     GPIO.4
    TWO     VAR     GPIO.1
    TRE   VAR      GPIO.2
    cik var byte  'loop variable
    x   var byte   'delay variable
    increment var byte 'incremental variable
    lop var byte  'also variable
    increment=0  'temp
    sub var byte 'intracounter variable
    sub=9
    x=44                   '22 x and 295 y for 30 second loop
    y var word 'showdelay   44 and 590 for 1 minute loop
    y=590
    'INIT tube and reset to 0
    inika:
    LOW ONE
    LOW TWO
    LOW TRE
    HIGH ZERO
    PAUSE x
    high one
    LOW ZERO
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high zero
    low tre
    pause x
    low zero
    koka:
    if GPIO.5=0 THEN
    goto tavi
    ENDIF
    pause 1
    GOTO KOKA
    tavi: 
          
    'stage 1______________________________________________
    sub=9
    gosub sub9
    high one  'proper finish?  one and two
    pause x
    low one
    high two
    pause x
    low two
    high zero
    Pause Y'delay for display
    low zero
    sta2:
    'stage 2 ______________________________________________
    gosub sub9
    gosub subzero
    Pause Y
    low one
    'stage 3____________________________________________
    gosub sub9
    gosub subzero
    pause x
    high two
    low one
    Pause Y
    high tre
    low two
    pause x
    low tre
    'stage 4____________________________________________
    sub=8
    gosub sub9
    gosub subzero
    gosub sub2
    Pause Y
    low tre
    'stage 5____________________________________________
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    Pause Y
    low one
    'stage 6____________________________________________
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    high tre
    low two
    'stage 7____________________________________________
    pause x
    low tre
    sub=7
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    'stage 8____________________________________________
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    'stage 9____________________________________________
    'X=100
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    high tre
    low two
    pause x
    'stage 10____________________________________________
    low tre
    sub=6
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    'stage 11____________________________________________
    low tre
    sub=6
    gosub sub9
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    gosub sub1
    high one
    low tre
    Pause Y
    low ONE
    'stage 12____________________________________________
    low tre
    sub=6
    gosub sub9
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    gosub sub1
    high one
    low tre
    pause x
    high two
    low ONE
    Pause Y
    low two
    'stage 13____________________________________________
    high tre
    pause x
    low tre
    sub=5
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    pause x
    high two
    low ONE
    pause x
    high tre
    low two
    Pause Y
    low tre
    'stage 14____________________________________________
    sub=5
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    pause x
    high two
    low ONE
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    'stage 15____________________________________________
    sub=5
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    low two
    'stage 16____________________________________________
    high tre
    pause x
    low tre
    sub=4
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    'stage 17____________________________________________
    sub=4
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    'stage 18____________________________________________
    sub=4
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    low two
    'stage 19____________________________________________
    high tre
    pause x
    low tre
    sub=3
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    'stage 20____________________________________________
    sub=3
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    
    'stage 21____________________________________________
    sub=3
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    high one
    low tre
    pause X
    high two
    low one
    Pause Y
    low two
    'stage 22____________________________________________
    high tre
    pause x
    low tre
    sub=2
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    high one
    low tre
    pause X
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    'stage 23____________________________________________
    sub=2
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    high one
    low tre
    gosub sub2
    pause X
    high one
    low tre
    Pause Y
    low one
    'stage 24____________________________________________
    sub=2
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    high one
    low tre
    gosub sub2
    pause X
    high one
    low tre
    pause X
    high two
    low one
    Pause Y
    low two
    'stage 25____________________________________________
    high tre
    pause x
    low tre
    sub=1
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    high one
    low tre
    gosub sub2
    pause X
    high one
    low tre
    pause X
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    'stage 26____________________________________________
    sub=1
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    gosub sub1
    high one
    low tre
    Pause Y
    low one
    'stage 27____________________________________________
    sub=1
    gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    gosub sub1
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    low two
    'stage 28____________________________________________
    high tre
    pause x
    low tre
    'sub=1
    'gosub sub9
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    gosub sub1
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    'x=400
    'stage 29____________________________________________
    high one
    pause x
    high two
    low one
    pause x
    high zero
    low two
    pause x
    low zero
    sub=9
    gosub sub9
    high one
    Pause Y
    low one
    'x=400
    'stage 30____________________________________________
    high two
    pause x
    high zero
    low two
    pause x
    low zero
    sub=9
    gosub sub9
    high one
    pause x
    high two
    low one
    Pause Y
    low two
    
    'stage 31____________________________________________
    high zero
    pause x
    low zero
    sub=9
    gosub sub9
    high one  'proper finish?  one and two
    pause x
    low one
    high two
    pause x
    low two
    high zero
    Pause Y
    low zero
    goto koka
    sub9 'subroutine for spinning
    for cik=1 to sub 'amount needed for full loop
    high one
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    low tre
    next
    return
    
    subzero:
    high one  'proper finish?  one and two
    pause x
    high two
    low one
    pause x
    high zero
    low two
    pause x'delay for display
    high one
    low zero 'subzero here
    return
    sub1: 'smaller sub
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    return
    sub2: 'even smaller sub
    pause x
    high two
    low one
    pause x
    high tre
    low two
    return
    


  26. #26
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    the code compiles and runs flawlessly in proteus, thats not the issue , check your circuit

    Name:  curio.jpg
Views: 1618
Size:  196.5 KB
    Warning I'm not a teacher

  27. #27
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Check for what?

    If I replace TRISIO=%00101000 with TRISIO=%00001000, it will also work fine (but without a button).

  28. #28
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    put an oscilloscope/logic analyser on gpio.4 and see what the signal looks like or if you don't have one
    put a led on gpio.4 in lieu of whats there now if it does not change state when gpio.5 is read then whatever is on gpio.4 is loading pin excessively.
    or else your description of the problem maybe unclear or inaccurate

    there are several of these
    gosub sub9

    i cant see a sub9 anywhere in your code
    Warning I'm not a teacher

  29. #29
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    sub9 'subroutine for spinning - it is there

    The whole circuit is assembled into box and potted with epoxy, so have no access to pins, except GPIO.5, I can check it with scope if needed.

  30. #30
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    sub9 'subroutine for spinning - it is there
    only by mcs's good grace to call anything unknown a label, the colon is missing

    The whole circuit is assembled into box and potted with epoxy,
    that would be me out .
    Warning I'm not a teacher

  31. #31
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    I potted it because it worked very fine, until I added that input parsing code
    I can build another one, that is not an issue...

  32. #32
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.


    low
    tre
    next
    return
    subzero:
    What is "next" doing? Is that a forgotten relic from previous versions?

  33. #33
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Look a bit above: for cik=1 to sub 'amount needed for full loop

  34. #34
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Here is the main code, from which all this started. This is simple spinner, pausing at certain position after whole loop.

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 15.05.2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    ANSEL = %00000000    
    CMCON0 = 7 
    TRISIO=%00001000
    OSCCON = %01110111
    'Include "Modedefs.bas"
    Define	OSC	8		' Set Xtal Frequency
    
    
    '	Clk     Var	GPIO.5		' Data is clocked on rising edge of this pin            kviteli
    '	Dta  	Var	GPIO.4		' Bits are shifted out of this pin          stafilosferi
    
    
    ZERO    var     GPIO.0
    ONE     VAR     GPIO.4
    TWO     VAR     GPIO.1
    TRE   VAR      GPIO.2
    cik var word
    x   var word
    cok var word
    lop var word
    
    
    x=50
    
    
    'INIT 
    LOW ONE
    LOW TWO
    LOW TRE
    HIGH ZERO
    PAUSE x
    LOW ZERO
    
    
    'this loop does smooth full turn
    
    
    xoxi:
    for cik=1 to 9
    high one
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    low tre
    next
    
    
    high one  'proper finish?  one and two
    pause x
    low one
    high two
    pause x
    low two
    high zero
    pause 1000
    low zero
    goto xoxi
    It works fine, provides smooth looped animation.

    Now let's add something. Changed TRISIO=%00101000. Code works fine. Added button check loop, and it becomes messed - triggering of certain pin no longer works.

    Code:
    kuku:
    if gpio.5=0 then goto xoxi
    pause 1
    goto kuku

  35. #35
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Tried to change control pin to GPIO.3 (MCLR). No change, as long as reading of port occurs in software, the glitches come on.

  36. #36
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    I think I've nailed it, and it appears to be both software and hardware issue. If input is activated, at startup, there is small pulse on random pin, which is short enough for not to be noticeable by eye, but enough to trigger dekathron (traced using scope). Solved by pulling down outputs via 10K to GND. S

  37. #37
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Name:  don1.jpg
Views: 1485
Size:  488.9 KB

    Almost there

  38. #38
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Truly amazing!

    Ioannis

  39. #39
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Thanks, this is so called "deluxe" version, with OG-4. I'm also developing simple version, with less brass and using simpler tubes. Will also make it's design plans public

  40. #40
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Controlling OG-4 Decathron with PBP in an efficient way.

    Here's fixed code. Besides code, you need also 10k pulldown resistors from transistor bases to GND.

    Code:
    ;----[12F683 Hardware Configuration]--------------------------------------------
    #IF __PROCESSOR__ = "12F683"
      #DEFINE MCU_FOUND 1
    #CONFIG
    cfg = _INTOSCIO               ; INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN
    cfg&= _WDT_OFF                ; WDT disabled
    cfg&= _PWRTE_OFF              ; PWRT disabled
    cfg&= _MCLRE_OFF             ; MCLR pin function is digital input, MCLR internally tied to VDD
    cfg&= _CP_OFF                 ; Program memory code protection is disabled
    cfg&= _CPD_OFF                ; Data memory code protection is disabled
    cfg&= _BOD_OFF                ; BOR disabled
    cfg&= _IESO_ON                ; Internal External Switchover mode is enabled
    cfg&= _FCMEN_ON               ; Fail-Safe Clock Monitor is enabled
      __CONFIG cfg
    
    
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    ANSEL = %00000000  'disable analog  
    CMCON0 = 7 'disable comparators
    TRISIO=%00001000 'input config
    OSCCON = %01110111
    'Include "Modedefs.bas"
    Define	OSC	8		' Set Xtal Frequency
    
    
    '	Clk     Var	GPIO.5		' Data is clocked on rising edge of this pin            kviteli
    '	Dta  	Var	GPIO.4		' Bits are shifted out of this pin          stafilosferi
    
    
    
    
    ZERO    var     GPIO.0
    ONE     VAR     GPIO.4
    TWO     VAR     GPIO.1
    TRE   VAR      GPIO.2
    cik var byte  'loop variable
    x   var byte   'delay variable
    increment var byte 'incremental variable
    lop var byte  'also variable
    increment=0  'temp
    sub var byte 'intracounter variable
    sub=9
    x=22                   '22 x and 295 y for 30 second loop
    y var word 'showdelay   44 and 590 for 1 minute loop
    y=295
    pause 500
    'INIT tube and reset to 0
    'x=2000
    
    
    inika:
    LOW ONE
    LOW TWO
    LOW TRE
    HIGH ZERO
    PAUSE x
    high one
    LOW ZERO
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high zero
    low tre
    pause x
    low zero
    
    
    koka:
    
    
    if GPIO.3=0 THEN
    low tre
    low two
    low one
    high zero
    pause x
    low zero
    goto tavi
    ENDIF
    pause 1
    GOTO KOKA
    
    
    tavi: 
          
    
    
    'stage 1______________________________________________
    'high zero
    'pause x
    'low zero
    sub=9
    gosub sub9
    high one  'proper finish?  one and two
    pause x
    low one
    high two
    pause x
    low two
    high zero
    Pause Y'delay for display
    low zero
    
    
    sta2:
    'stage 2 ______________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    Pause Y
    low one
    
    
    'stage 3____________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    Pause Y
    high tre
    low two
    pause x
    low tre
    
    
    'stage 4____________________________________________
    sub=8
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    Pause Y
    low tre
    
    
    'stage 5____________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    Pause Y
    low one
    
    
    'stage 6____________________________________________
    
    
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    high tre
    low two
    
    
    'stage 7____________________________________________
    pause x
    low tre
    sub=7
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'stage 8____________________________________________
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    
    
    'stage 9____________________________________________
    'X=100
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    high tre
    low two
    pause x
    
    
    'stage 10____________________________________________
    low tre
    sub=6
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'stage 11____________________________________________
    low tre
    sub=6
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    
    
    gosub sub1
    
    
    high one
    low tre
    Pause Y
    low ONE
    
    
    'stage 12____________________________________________
    low tre
    sub=6
    gosub sub9
    
    
    gosub subzero
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    
    
    gosub sub1
    
    
    high one
    low tre
    pause x
    high two
    low ONE
    Pause Y
    low two
    
    
    'stage 13____________________________________________
    high tre
    pause x
    low tre
    sub=5
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    pause x
    high two
    low ONE
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'stage 14____________________________________________
    sub=5
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    pause x
    high two
    low ONE
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    
    
    'stage 15____________________________________________
    sub=5
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    low two
    
    
    'stage 16____________________________________________
    high tre
    pause x
    low tre
    sub=4
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'stage 17____________________________________________
    sub=4
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    
    
    'stage 18____________________________________________
    sub=4
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    low two
    
    
    'stage 19____________________________________________
    high tre
    pause x
    low tre
    sub=3
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'stage 20____________________________________________
    sub=3
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    Pause Y
    low one
    
    
    
    
    
    
    'stage 21____________________________________________
    sub=3
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    
    
    high one
    low tre
    pause X
    high two
    low one
    Pause Y
    low two
    
    
    'stage 22____________________________________________
    high tre
    pause x
    low tre
    sub=2
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    
    
    high one
    low tre
    pause X
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    
    
    'stage 23____________________________________________
    sub=2
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    
    
    high one
    low tre
    gosub sub2
    pause X
    high one
    low tre
    Pause Y
    low one
    
    
    'stage 24____________________________________________
    sub=2
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    
    
    high one
    low tre
    gosub sub2
    pause X
    high one
    low tre
    pause X
    high two
    low one
    Pause Y
    low two
    
    
    'stage 25____________________________________________
    high tre
    pause x
    low tre
    sub=1
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    high one
    low tre
    gosub sub2
    pause X
    high one
    low tre
    pause X
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'stage 26____________________________________________
    sub=1
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    gosub sub1
    high one
    low tre
    Pause Y
    low one
    
    
    'stage 27____________________________________________
    sub=1
    gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    gosub sub1
    high one
    low tre
    pause x
    high two
    low one
    Pause Y
    low two
    
    
    'stage 28____________________________________________
    high tre
    pause x
    low tre
    'sub=1
    'gosub sub9
    
    
    gosub subzero
    gosub sub2
    pause x
    '-----
    gosub sub1
    '------
    high one
    low tre
    gosub sub2
    pause x
    gosub sub1
    gosub sub1
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    Pause Y
    low tre
    
    
    'x=400
    'stage 29____________________________________________
    high one
    pause x
    high two
    low one
    pause x
    high zero
    low two
    pause x
    low zero
    sub=9
    gosub sub9
    high one
    Pause Y
    low one
    
    
    'x=400
    'stage 30____________________________________________
    high two
    pause x
    high zero
    low two
    pause x
    low zero
    sub=9
    gosub sub9
    high one
    pause x
    high two
    low one
    Pause Y
    low two
    
    
    
    
    'stage 31____________________________________________
    high zero
    pause x
    low zero
    sub=9
    gosub sub9
    
    
    high one  'proper finish?  one and two
    pause x
    low one
    high two
    pause x
    low two
    high zero
    Pause Y
    'low zero
    
    
    goto koka
    
    
    sub9: 'subroutine for spinning
    
    
    for cik=1 to sub 'amount needed for full loop
    high one
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    low tre
    next
    
    
    return
    
    
    
    
    subzero:
    
    
    high one  'proper finish?  one and two
    pause x
    high two
    low one
    pause x
    high zero
    low two
    pause x'delay for display
    high one
    low zero 'subzero here
    
    
    return
    
    
    sub1: 'smaller sub
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    high one
    low tre
    pause x
    high two
    low one
    pause x
    high tre
    low two
    pause x
    return
    
    
    sub2: 'even smaller sub
    pause x
    high two
    low one
    pause x
    high tre
    low two
    return

Similar Threads

  1. Subroutine or repeated code, which is more memory efficient?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th June 2014, 23:38
  2. large & efficient electro magnet
    By therian in forum Off Topic
    Replies: 13
    Last Post: - 19th October 2012, 07:53
  3. Making code more efficient, any ideas please?
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th July 2011, 14:28
  4. Efficient comparison on data (iButton)
    By enigma in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th August 2010, 14:37
  5. Is there a more efficient way?
    By markedwards in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 26th July 2005, 00:38

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