Controlsystem for compact sporting (clay shooting)


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187

    Default Controlsystem for compact sporting (clay shooting)

    Hi

    I´m trying to to make a control system for 8 clay throwers for compact sporting.

    This is how a compact sporting place can look like.


    Exampel taken from this PDF http://www.fitasc.com/public/regleme...g230908_UK.pdf
    (We do not shoot whit 6 shooters as in the example)




    4.4 Shooting sequence for a round
    Shooters position (See Annex 3):
    The shooters in the squad go to on the stands in the order set out on the score sheet.
    The shooter waits behind stand # 1, is ready to take the shooter’s place, once the
    shooter at stand 5 has finished shooting the clays on his/her menu.
    The shotgun position is free at the time of calling for the target (at the shoulder or
    not).
    All the targets must be fired at with the gun at the shoulder.
    The shooters fire in turns at each single and double target in the order on the menu.
    A time lapse of 10 seconds at most is allowed for each shooter to call for his target
    or targets after the shooter at the previous stand has finished firing.
    The Referee must announce to the shooter at the station # 1 when it has to shoot.
    When the shooter at stand # 5 has finished firing at the targets on his menu:
    • He moves to stand # 1 and waits behind it
    • The other shooters move to the next stand on their right
    • The shooter who was waiting previously takes his place on stand # 1.
    It is always the shooter on stand # 1 who starts the round of five targets
    The control system I want to make is a box with 2 buttons THROW and REVERSE.
    Now we have a big box whit 8 buttons for each thrower and manual push the different combinations for each stand, I want to make this by steep throw a program whit just one button.

    I tried to make this whit 20 loops and wait for the throw button to be pressed and just jump to the next loop or back to the previous loop if REVERSE button what pressed.

    This works for 5 shooters but I also want to tell the program if the number of shooters for example is only 1, 2, 3, or 4, I will store number of shooters in a variable that is set by the user via a LCD before the game starts (1 to 5 shooters)

    If three shooters they will start on stand 1, 2, 3 and after the menu move to 2, 3 and 4 and then to 3, 4, 5 and then to 4, 5, 1 and that last shooting on stand 5, 1, 2.

    How do i do that, should I still use 20 different loops and write a lot of IF THEN ELSE within them to decide witch loop that should be the next to jump to?

    Or how do I do it in a good way?

    My English is not perfect so I hope you understand what I trying to do here.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    If three shooters they will start on stand 1, 2, 3 and after the menu move to 2, 3 and 4 and then to 3, 4, 5 and then to 4, 5, 1 and that last shooting on stand 5, 1, 2.
    Do I understand correctly . . . You want to DeSelect the unused stands from automatically throwing the clay? So you would throw in sequence 123, 234, 345, 451, 512 for 3 shooters . . . 1234, 2345, 3451, 4512, 5123 for four shooters . . . ? You should be able to do that using an array and shift the bits over.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yes that´s correct.
    How do i do an Array and shift bits, do you have an short example?

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    Yes that´s correct.
    How do i do an Array and shift bits, do you have an short example?
    Got 1 ready now, incomplete but it serves as example, change the shooters var to change lights lit
    Code:
    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON  
    @MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF 
    @ __config  MyConfig 
    include "modedefs.bas"
    DEFINE OSC 4
    PortA = 0
    PortB = 0
    PortC = 0
    TRISA = 1
    TRISB = 0
    TRISC = %00000000
    i var word 'locks up @ 255 with byte
    ANSEL = 0
    ANSELH = 0
    CM1CON0 = 0
    CM2CON0 = 0
    shooters var byte
    total var byte
    serout PortA.2,t9600,["enter shooters"]
    ' too lazy to do input routine
    shooters = 2
    
    lookup shooters -1,[1,3,7,15,31],total
    main:
    portc = 0
    'pause 200
    for i = total  to 255
    portC = i
    i=i  << 1-1
    pause 500
    next i
    i=0
    portC = i
    pause 500
    
    goto main
    end
    not a typical array as we normally see them, but it works using pickit2 & lowpin demo board
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Sorry... but I don´t understand how to do the program with the lookup function.

    Where comes the numbers [1,3,7,15,31] from and what does it do?

    How to i use the lookup to point the program to the right loop that contains the right clay combination?

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    Sorry... but I don´t understand how to do the program with the lookup function.

    Where comes the numbers [1,3,7,15,31] from and what does it do?

    How to i use the lookup to point the program to the right loop that contains the right clay combination?
    What does it do . . . It tells your program how many shooters are there, from the input I was too lazy to code for you. You get that input from a key routine or waste 5 ports as inputs, either way you answer the question, how many shooters. I answered it by coding shooters = 2, you I expect will want to select 1 to 5 at will.
    The numbers in the lookup table are decimal representations of their binary equivalent. Think of PortC as a 8 digit binary display, 1 would light just bit 0, 3 would light bits.0:1, 7 lights bits 1:3 . . . I urge you to try this code snippet and alter the numbers and see what it does. The lookup table just makes the counter count read differently, when it sees 1 it reports 1, 2 it reports 3, 3 it reports 7 . . . in binary. The -1 in the lookup just makes 0 invalid as you would never have 0 shooters.
    Last edited by Archangel; - 27th July 2009 at 07:47.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Ok now I understand the function of LOOKUP but i don´t know how to use it to jump to the right loops when the number of shooter changes.

    This is how the shooting sequence look like


    When there are five shooters, one on each stand they shoot as in the diagram above. and then they move one steep right and the guy on stand 5 move to the stand 1 and the shooting sequence starts from STAND 1 again and so on.... until all shooters have shoot from all 5 stands.

    But if there are 3 shooters the shooting sequence will look like this.
    1st run
    LOOP 1
    LOOP 2
    LOOP 3

    LOOP 6
    LOOP 7
    LOOP 8

    LOOP 11
    LOOP 12
    LOOP 13

    2:e run

    LOOP 2
    LOOP 3
    LOOP 4

    LOOP 7
    LOOP 8
    LOOP 9

    LOOP 12
    LOOP 13
    LOOP 14

    3: run
    LOOP 3
    LOOP 4
    LOOP 5

    LOOP 8
    LOOP 9
    LOOP 10

    LOOP 13
    LOOP 14
    LOOP 15

    4:run
    LOOP 4
    LOOP 5
    LOOP 1

    LOOP 9
    LOOP 10
    LOOP 6

    LOOP 14
    LOOP 15
    LOOP 11

    5:e and last run
    LOOP 5
    LOOP 1
    LOOP 2

    LOOP 10
    LOOP 6
    LOOP 7

    LOOP 15
    LOOP 11
    LOOP 12

  8. #8
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    The LOOKUP code will only work for the first 3 loops if there are 3 shooters.. or?

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Can you post your whole code so we can see where you are at.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Here try this:
    Code:
    '****************************************************************
    '*  Name    : 16F690Shooter.BAS                                   *
    '*  Author  : Joe S.                                                  *
    '*  Notice  : Copyright (c) 2009 []                             *
    '*          : No Rights Reserved                               *
    '*  Date    : 7/29/09                                           *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON  
    @MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF 
    @ __config  MyConfig 
    include "modedefs.bas"
        DEFINE OSC 4
        PortA = 0
        PortB = 0
        PortC = 0
        TRISA = 1
        TRISB = 0
        TRISC = %00000000
        i Var Word 'locks up @ 255 with byte
        ANSEL = 0
        ANSELH = 0
        CM1CON0 = 0
        CM2CON0 = 0
        shooters var byte
        total    var byte
        sub      var byte
        dummy    var byte
        serout PortA.2,t9600,["enter shooters"]
    ' too lazy to do input routine
    start:
        shooters = 2
    
    
    main:
        if portA.0 = 0 then goto main  
    
        select case shooters
            case  1
            gosub one
            case  2
            gosub two
            case  3
            gosub three
            case  4
            gosub four
            case  5
            gosub five
            case else
            goto start
        end select
    
    goto main
    end
    one:
        for i = 0 to 4
          lookup i,[1,2,4,8,16],total
          portc = total
          pause 1000
        next i
    return
    
    two:
          for i = 0 to 4
          lookup i,[3,6,12,24,49],total
          portc = total
          pause 1000
        next i
    return
    
    three:
          for i = 0 to 4
          lookup i,[7,14,28,25,19],total
          portc = total
          pause 1000
        next i
    return
    
    four:
          for i = 0 to 4
          lookup i,[15,30,29,27,23],total
          portc = total
          pause 1000
        next i
    return
    
    five:
          portc = total
    return
    For now change the number of shooters and recompile, or put in a routine to select # of shooters, PortA.0 high will start cycle
    Last edited by Archangel; - 29th July 2009 at 22:31.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  11. #11
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Thanks Joe
    No it works!


    My code for 2 shooters

    Code:
    for i = 0 to 29
    lookup i,[1,2,6,7,11,12,2,3,7,8,12,13,3,4,8,9,13,14,4,5,9,10,14,15,5,1,10,6,15,11],total
     
    if total = 1 then gosub clay1 
    if total = 2 then gosub clay2
    if total = 3 then gosub clay3
    if total = 4 then gosub clay4
    if total = 5 then gosub clay5
    if total = 6 then gosub clay6
    if total = 7 then gosub clay7
    if total = 8 then gosub clay8
    if total = 9 then gosub clay9
    if total = 10 then gosub clay10
    if total = 11 then gosub clay11
    if total = 12 then gosub clay12
    if total = 13 then gosub clay13
    if total = 14 then gosub clay14
    if total = 15 then gosub clay15
    pause 3000
    next i

  12. #12
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Glad you got it working . . . Cheers.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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