newbie help : subsumption


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2007
    Posts
    12

    Default newbie help : subsumption

    i'm new to pic basic and i'm trying to setup a simple subsumption architecture...
    can anyone help with this code :

    start:

    go_command = command_none
    stop_command = empty


    if go_command <> command_none then motor_output = go_command
    if stop_command <> command_none then motor_output = stop_command

    select case motor_output
    case stop_command
    portb = %00001100
    case go_command
    portb = %00000011
    end select

    goto start



    basicly i'm just trying to select the correct state based on when go/stop_command(s) are not command_none.

    I can't seem to select the second case, go_command, it always just assigns 00001100 to port b

    can anyone help

    thanks

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hi,
    If you're using MELABS PicBasicPro then you can't have the IF statement like:
    Code:
    if go_command <> command_none then motor_output = go_command
    You'll have to do:
    Code:
    if go_command <> command_none then 
         motor_output = go_command
    Endif
    HTH

    /Henrik Olsson.

  3. #3
    Join Date
    Apr 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    thanks for the help i've now got it working
    i have one last issue..

    the code as it stands :

    'manually select
    Seek_output = backward '1
    Evade_output = idle '2
    Panic_output = idle '3
    settle_output = idle '4

    start:

    'subsumption
    'if x is not in idle mode assign the output from that layer
    'if the layer is idle then move to the next..

    if Seek_output <> idle then
    motor_actuator = Seek_output 'state 1

    elseif Evade_output <> idle then
    motor_actuator = Evade_output 'state 2

    elseif Panic_output <> idle then
    motor_actuator = Panic_output 'state 3

    elseif settle_output <> idle then
    motor_actuator = settle_output 'state 4
    end if

    ' motor case statement only selects with numbers
    ' need to use text for clarity

    gosub motor_control

    goto start

    motor_control:

    select case motor_actuator
    case left
    portb = %00000001
    case right
    portb = %00000010
    case forward
    portb = %00000011
    case backward
    portb = %00000100
    end select
    return
    now the motor control case statement selects ok when i use numbers but i would much prefer to use text, can anyone help..

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


    Did you find this post helpful? Yes | No

    Default

    Hi,
    now the motor control case statement selects ok when i use numbers but i would much prefer to use text, can anyone help..
    I'm not sure I understand that correctly but let's say that this work
    Code:
    motor_control:
    
    select case motor_actuator
      case 1
        portb = %00000001 
      case 2
       portb = %00000010
    end select
    return
    Then set up some constants matching those numbers, like:
    Code:
    Left CON 1
    Right CON2
    Forward CON 4
    Reverse CON 8
    
    select case motor_actuator
      case Left
        portb = %00000001 
      case Right
       portb = %00000010
    'and so on.....
    end select
    return
    Sorry if I misunderstood.
    /Henrik Olsson.
    Last edited by HenrikOlsson; - 7th April 2007 at 16:10.

  5. #5
    Join Date
    Apr 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    that works !

    thanks for you help

Similar Threads

  1. Newbie making an ignition timer
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 5th August 2012, 17:45
  2. Newbie 74hc595 question
    By manjero in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 22nd January 2008, 22:22
  3. Newbie: Temperature measurements
    By Budda in forum General
    Replies: 10
    Last Post: - 30th March 2007, 09:56
  4. PIC Newbie
    By azmax100 in forum Schematics
    Replies: 7
    Last Post: - 23rd February 2007, 04:52
  5. request for a newbie forum
    By nimonia in forum Forum Requests
    Replies: 1
    Last Post: - 20th May 2006, 09:01

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