MyOutput = %00011100_00110101

SXleeSXlee Posts: 47
edited 2011-01-07 - 06:28:31 in Microcontrollers
Hi all,
I have:
Leds 		PIN 	RBC OUTPUT		' LEDs on RB/RC

Setup into 6 groups leds, 2 lots of 2 leds and 4 lots of 3 leds.

I calculate the val of each group, i.e:
_
01 'group1
_---101-- 'group2
_001
'group3
00_
'group4
---111--_
'group5
000
_
'group6

How do I add them up to get:

MyOutput = %00011100_00110101
RBC = MyOutput

Lee

Comments

  • SXleeSXlee Posts: 47
    edited 2011-01-04 - 13:16:01
    Is it like this:
    ' -------------------------------------------------------------------------
    ' IO Pins
    ' -------------------------------------------------------------------------
    Leds 		PIN 	RBC OUTPUT		' LEDs on RB/RC
    
    ' -------------------------------------------------------------------------
    ' Variables
    ' -------------------------------------------------------------------------
    group1            VAR     Word  ' 2 leds
    group2            VAR     Word  ' 3 leds
    group3            VAR     Word  ' 3 leds
    group4            VAR     Word  ' 2 leds
    group5            VAR     Word  ' 3 leds
    group6            VAR     Word  ' 3 leds
    MyOutput        VAR     Word
    
    ' -------------------------------------------------------------------------
    ' Subroutine Declarations
    ' -------------------------------------------------------------------------
    
    Check_Inputs         SUB 0 
    Calculate_Groups     SUB 0
    Update_Output         SUB 0 
    
    ' -------------------------------------------------------------------------
    ' Program Code
    ' -------------------------------------------------------------------------
    
    Start:
    
    Main:
      DO
        Check_Inputs
        Calculate_Groups
        Update_Output
      LOOP
    
    SUB Update_Output
        MyOutput = group1
        MyOutput = group2 + MyOutput
        MyOutput = group3 + MyOutput
        MyOutput = group4 + MyOutput
        MyOutput = group5 + MyOutput
        MyOutput = group6 + MyOutput 
    
       RBC = MyOutput
    ENDSUB
    
    ' =========================================================================
    ' User Data
    ' =========================================================================
    
    Pgm_ID:
      DATA "SX/B 1.50 Template", 0
    
    MaskTable:
      WDATA %00000000_00000011
      WDATA %00000000_00011100
      WDATA %00000000_11100000
      WDATA %00000011_00000000
      WDATA %00011100_00000000
      WDATA %11100000_00000000
    

    or is there a better way?
  • SXleeSXlee Posts: 47
    edited 2011-01-05 - 04:34:11
    The 'Update_Output' should be:
    SUB Update_Output
        MyOutput = group1
        MyOutput = group2 | MyOutput
        MyOutput = group3 | MyOutput
        MyOutput = group4 | MyOutput
        MyOutput = group5 | MyOutput
        MyOutput = group6 | MyOutput 
    
       RBC = MyOutput
    ENDSUB
    
    Yes?
    or is there a better way?
  • ZootZoot Posts: 2,227
    edited 2011-01-05 - 18:31:50
    I don't see where you set the groupX set variables to be anything.

    It would help if you post a schematic of what you have the SX wired up to.

    Would also help if you post the whole program.
    When the going gets weird, the weird turn pro. -- HST

    my site: 1uffakind.com
    create bitmap data tool: 1uffakind.com/robots/povBitMapBuilder.php
    resistor ladder tool: 1uffakind.com/robots/resistorLadder.php
    convert images to ascii art: 1uffakind.com/apptoys/convtoascii/
    MC6808/Hero-1 assembler: 1uffakind.com/apptoys/onlinecompilers/MC6800/
  • SXleeSXlee Posts: 47
    edited 2011-01-07 - 02:59:27
    Hi Zoot,
    thank you for your time.
    I have the SX wired up to 2 ULN2803As "Darlington transistor arrays",
    that is one ULN2803A for RB0 - RB7 and one ULN2803A for RC0 - RC7.

    I posted a schematic hoping for some input
    THERE
    but no input, so didn't bother posting the finished schematic with the ULN2803As in it.

    That is the whole program so-far.

    Regards SXlee.
  • ZootZoot Posts: 2,227
    edited 2011-01-07 - 03:50:49
    Is that really the whole program? I don't see how it would compile and download to your SX. At the very least you declare subs that are undefined (and are called in the main part of the program).
    When the going gets weird, the weird turn pro. -- HST

    my site: 1uffakind.com
    create bitmap data tool: 1uffakind.com/robots/povBitMapBuilder.php
    resistor ladder tool: 1uffakind.com/robots/resistorLadder.php
    convert images to ascii art: 1uffakind.com/apptoys/convtoascii/
    MC6808/Hero-1 assembler: 1uffakind.com/apptoys/onlinecompilers/MC6800/
  • SXleeSXlee Posts: 47
    edited 2011-01-07 - 06:28:31
    Yes, sorry Zoot.
    My model in my head was:

    Check_Inputs
    Calculate_Groups
    Update_Output

    Now I think I only need:
    Check_Input
    Update_Output

    I had a good idea of what I need for dealing with the input,
    but couldn't see how to put info together for Updating the Outputs.

    I think post #3 is OK
    I need to do some moor on my SX28 Circuit.

    Thanks for your time.

    Regards SXlee.
Sign In or Register to comment.