variable modifiers / aliases...


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default variable modifiers / aliases...

    ok, first off... i'm now the proud owner of PBP2.60a... u2 programmer is also on it's way...

    i'm driving a stepper motor driver IC from a pic.
    the driver IC has several inputs for it's settings...

    For example, torque setting is two bits (4 settings), 25%(00), 50%(01) 75%(10) and 100% (11).
    PBP doesn't support doing the following...

    Code:
    Torque var byte
    torque.0 var PORTD.6
    Torque.1 var PORTD.5
    The torque setting is changed from the menu (to be writen) so it would be easier to just increase the variable by 1 up to 4 rarther than having to mess around with torque1 and torque2 separate vars.

    is their a better way?
    Thanks

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I can suggest the following solution:

    Code:
    Torque   Var Byte
    
    Select Case Torque
    
    Case Torque = 25 
    PortD.6 = 0: PortD.5 = 0
    
    Case Torque = 50
    PortD.6 = 0: PortD.5 = 1
    
    Case Torque = 75
    PortD.6 = 1: PortD.5 = 0
    
    Case Torque = 100
    PortD.6 = 1: PortD.5 = 1
    
    End Select
    Cheers

    Al.
    All progress began with an idea

  3. #3


    Did you find this post helpful? Yes | No

    Default

    hmmm, never used select... I'll look it up in the manual for some bedtime reading...

    Thanks for that aratti.

    Edit: i looked in the manual, it doesn't specify if select case is used once or is 'ran' whenever you want to update?

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Edit: i looked in the manual, it doesn't specify if select case is used once or is 'ran' whenever you want to update?
    I suggest you to place the snippet in a subroutine and call it, with a GOSUB, all the times you need to change your torque setting.

    Al.
    All progress began with an idea

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Thats what i thought...

    I think i'll put all three in an 'update' subroutine since at the moment it's only called twice, one at initialisation and once when you hit the 'go' button. however, a later revision may decide that you can change these settings while it's running...

    thanks again aratti

  6. #6
    Join Date
    Mar 2005
    Location
    Cocoa, Florida
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Torque - jumpers

    If you really need soft then Arrati has it.

    Personally, I would start a project like that with torque select jumpers on the board and save precious pins for the feature creep you know is coming.

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