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


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,096


    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

  2. #2
    Join Date
    Feb 2013
    Posts
    1,096


    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

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


    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.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,096


    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

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


    Did you find this post helpful? Yes | No

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

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

    Almost there

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,935


    Did you find this post helpful? Yes | No

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

    Truly amazing!

    Ioannis

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


    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

  8. #8
    Join Date
    Feb 2013
    Posts
    1,096


    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, 22:38
  2. large & efficient electro magnet
    By therian in forum Off Topic
    Replies: 13
    Last Post: - 19th October 2012, 06:53
  3. Making code more efficient, any ideas please?
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th July 2011, 13:28
  4. Efficient comparison on data (iButton)
    By enigma in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th August 2010, 13:37
  5. Is there a more efficient way?
    By markedwards in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2005, 23:38

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