Is this possible?


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jan 2010
    Posts
    88

    Default Is this possible?

    Hello Everyone,

    Having a little trouble with some coding. I have a manufacturer's product that I decided to reprogram. It is a 16F687 chip that connects its outputs to some MOSfets. They are all arranged in a row from 1-10, but the pins used are not. I wanted to be able to use coding like this:

    Code:
    ZigZag          DATA    Word %0000000001, 2
                    DATA    Word %0000000010, 2
                    DATA    Word %0000000100, 2
                    DATA    Word %0000001000, 2
                    DATA    Word %0000010000, 2
                    DATA    Word %0000100000, 2
                    DATA    Word %0001000000, 2
                    DATA    Word %0010000000, 2
                    DATA    Word %0100000000, 2
                    DATA    Word %1000000000, 2
                    DATA    Word %0100000000, 2
                    DATA    Word %0010000000, 2
                    DATA    Word %0001000000, 2
                    DATA    Word %0000100000, 2
                    DATA    Word %0000010000, 2
                    DATA    Word %0000001000, 2
                    DATA    Word %0000000100, 2
                    DATA    Word %0000000010, 2
                    DATA    Word %0000000001, 2
                    DATA    Word %0000000000, 0
    This style makes it easy to see which MOSfets are turning on and in essence is easy on the eyes, but the pins are arranged like this:

    RC5, RC0, RC4, RC1, RC3, RC2, RC6, RB4, RC7, RB6

    As you can see, they are not in order, so if I used the above format, the outputs won't zigzag like the layout, but rather be randomly jumping around.

    So my question is this, is there a way to reassign the bits after reading the zigzag code above? In plain english, I want it to say:

    read pin 0 (from zigzag) and display it on RC5
    read pin 1 (from zigzag) and display it on RC0
    etc....

    Is there a way to do this? The obvious thing would be to set up the traces in the correct order, but this is the manufacturer's board and I'm reprogramming it to do something else. I was told to use something like translating the bits, but the sample code did not work and I can't find anything else anywhere.

    The rest of my code reads each line from above and displays them one line at a time. But with this board, you can imagine how it's going to jump around.

    Thanks for your help in advance,
    Tony

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


    Did you find this post helpful? Yes | No

    Default

    If all you are wanting to do is make the code readable
    Code:
    ZIG1 VAR PORTC.5
    ZIG2 VAR PORTC.0
    ZIG3 VAR PORTC.4
    You get the picture.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Of course it's possible.
    You're using PicBasic Pro.

    Code:
    Pattern   VAR WORD
    Idx       VAR BYTE
    ;---------------------------------------------------------------------------
    INCLUDE "VirtualPort.bas";
    ASM  
    MyPortPins  macro               ; these define which bits go with which pins
    Vpin   0, PORTC,5
    Vpin   1, PORTC,0
    Vpin   2, PORTC,4
    Vpin   3, PORTC,1
    Vpin   4, PORTC,3
    Vpin   5, PORTC,2
    Vpin   6, PORTC,6
    Vpin   7, PORTB,4
    Vpin   8, PORTC,7
    Vpin   9, PORTB,6
    endm
    ENDASM
    ;---------------------------------------------------------------------------
    Init:
    @   OutputPort  MyPortPins             ; Set Pins to Output
     
    Main:
        FOR Idx = 0 to 38 STEP 2
    READ Idx, WORD Pattern             ; get pattern from EEPROM
    @       WritePort  _Pattern, MyPortPins    ; write pattern to Virtual Port
    PAUSE 100
    NEXT Idx
    GOTO Main
    Attached Files Attached Files
    Last edited by ScaleRobotics; - 1st September 2011 at 23:56. Reason: Removed B2 pin, wasn't specified originally
    DT

  4. #4
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel.
    Last edited by ERMEGM; - 16th January 2010 at 19:30. Reason: Darrel posted a reply answering my questions.

  5. #5
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default

    OK, having a little difficulty, and can't seem to sort it out. I'm getting a bad expression and an output parameter must be a variable Error on this line:

    READ Idx, WORD Pattern ; get pattern from EEPROM

    Can't figure it out. What am I doing wrong? This is going on a 16f687 chip.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You have PBP 2.60? Right?
    <br>
    DT

  7. #7
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default

    Aha. 2.50b. Is 2.60 available online to download?

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