Shop OBEX P1 Docs P2 Docs Learn Events
confused new user help needed — Parallax Forums

confused new user help needed

staffshomestaffshome Posts: 28
edited 2009-09-18 04:06 in BASIC Stamp
Hello all
i need some help again i'm afraid

Can someone please look at the attached· file & tell me if it's good or not.
i 2nd hand friend (read as friend of a friend) has tried this for me on proteus vsm & says it ony runs start sequence buttons do not work.Unfortunately that's about all the help he gave.

want to run on bs2p40.

regards Adrian

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-09-14 16:51
    Hello, your subject doesn't seem to indicate what you're trying to do. Perhaps you should use the pencil icon to the top right of the message to edit and provide a detailed subject line. Or better yet, it looks as though you already have a thread on this subject. Perhaps this should really be followed up there so the existing people helping will know where you're at. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-09-14 18:16
    Have to agree with Chris – multiple posts do not help you.
    The file is good – it compiles , the coding style is bad.
    With exception of block of comments in beginning there are no relevant comments in the code whatsoever.
    It may not be possible to avoid GOTO in your application but your style used to be called “spaghetti code”. It is hard to follow especially without comments.
    You are asking the forum to evaluate your file (and I deliberately use file instead of code) but did not bother to add a single DEBUG in it thus indicating that you have never actually run it.
    It is not the easiest part of coding to evaluate and debug someone else’s program. Maybe you should build you own instead using 2nd·hand program.
    ·
    Please give us some better clue where you need help.
    ·
    ·
  • staffshomestaffshome Posts: 28
    edited 2009-09-14 21:35
    Hi Chris etc,
    point taken re: postings & info provided.
    If i was good at this i wouldn't need the forums help or other peoples code!
    the previosly posted code was my 1st effort at altering original & No it does not run despite any comments as to being good.
    Project is a automotive Paddle shift controller for an auto transmission.
    The File attached does run as marked in comments but some issues ???
    operates ok except
    how do i get SELECT to keep checking ? Superb bit of help from Dev null on here.
    also 2 bit orders give transposed results from select output ???

    Regards Adrianblush.gif
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-09-15 00:00
    Here are some code snippets to get you started your debugging process.
    I have not look thru the whole code but it seems that some of your subroutines perform same processing.


    Main:
    DO
    DEBUG ? mynib,CR
    'PAUSE 1000
    DEBUGIN· DEC1 mynib
    SELECT mynib
    · CASE %0110 : GOTO P:
    · CASE %0011 : GOTO R:
    · CASE %1010 : GOTO N: 'this case & case L are transposed,bit order correct wrong action
    · CASE %1001 : GOTO D:
    · CASE %0000 : GOTO Three:
    · CASE %0101 : GOTO L: 'this case & case N are transposed,bit order correct wrong action
    ENDSELECT
    LOOP


    P:·· 'works ok
    DEBUG CR, "P ",CR
    LOW 14 'Lockup
    HIGH 12 'Sol1
    LOW 13 'Sol2
    'STOP
    GOTO Main· 'how do i get from here to keep checking mynib status
    'GoTo Main non functional


    Just an adendum - include the BUTTON commands in the Main loop. I think your code would be cleaner if you used ON..GOSUB instead of BRANCH. Keep in mind it was written for BS1.
    If you keep BRANCH command don't forget to add GOTO Main on each branch.
    When you get more experience coding try to rewrite this using POLL.. set of commands.
    I can't do that on BS2e, sorry.

    ·.....
    ·ChkUpBtn:
    BUTTON 1,0,255,0,UpBtnWrk,1,UpShift
    ChkDwnBtn:
    BUTTON 2,0,255,0,DwnBtnWrk,1,DownShift
    LOOP

    UpShift:
    Gear = Gear + 1
    GOTO SetGear
    DownShift:
    Gear = Gear - 1
    GOTO SetGear







    Post Edited (vaclav_sal) : 9/15/2009 12:38:14 AM GMT
  • staffshomestaffshome Posts: 28
    edited 2009-09-15 06:51
    Hi

    thanks for the code,yes you are correct that some subroutines currently do same function,this is because they are short of some commands ie: lcd outputs & P15 outputs as an example.

    Can you see any reason for the output result error from mynib.???

    as i further note,i have modified my file with your suggested changes to Main: section & added GOTO Main on all Branch section's.I am still unable to update the pnp inputs without stopping & restarting program,i really need this to update within the program ???

    I did look at the POLL section in the manual but i am unsure as to how to apply

    Regards Adrian
  • staffshomestaffshome Posts: 28
    edited 2009-09-15 11:56
    confused.gif

    Hello All,
    can anyone help with POLLIN ,what i want to do is check 4 inputs from a multiplex switch & use the result to
    operate 6 routines.i currently am using SELECT (Help from Dev/Null).But I cannot seem to get this to run other than at start of program tried DO-LOOP /GOTO at relevent points but cannot get switch input status to update whilst in program,if i end program & restart new status is logged by SELECT.
    I Have read manual pages & searched on forum posts but i am at a loss.
    File section shown below


    mynib VAR Nib
    mynib.BIT0 = IN3
    mynib.BIT1 = IN4
    mynib.BIT2 = IN5
    mynib.BIT3 = IN6

    Gear VAR Byte 'current gear
    UpBtnWrk VAR Byte
    DwnBtnWrk VAR Byte

    UpBtnWrk = 0
    DwnBtnWrk = 0

    Main:
    SELECT mynib
    · CASE %0110 : GOTO P:
    · CASE %0011 : GOTO R:
    · CASE %1010 : GOTO N: 'this case & case L are transposed,bit order correct wrong action
    · CASE %1001 : GOTO D:
    · CASE %0000 : GOTO Three:
    · CASE %0101 : GOTO L:
    ENDSELECT
    'Select mynib works ok on initial start up but it needs to be constantly
    '······················· updated as per UpBtn & DwnBtn
    '······················· i'm unable to resolve this
    '
    This Table is for Multiplex switch for mynib inputs---
    ' PNP Table:
    ' gear A B C PA
    '··· P· 0 1 1 0
    '··· R· 0 0 1 1
    '··· N· 1 0 1 0
    '··· D· 1 0 0 1
    '··· 3· 0 0 0 0
    '··· L· 0 1 0 1

    regards Adrian
  • FranklinFranklin Posts: 4,747
    edited 2009-09-15 21:35
    I guess the next question is what parts of your program work and what parts don't. Also if you change your code and have other questions on it please re-attach the complete new code so we can play along with the latest version.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-09-16 03:02
    Try this demo

    Where the HIGH and LOW is where you would put you code
    Just remember to use GOSUB and RETURN in all of your subroutines



    IF xBtns = %0100 THEN
    GOSUB P
    ELSE

    ·' and so on


    P:
    ' your code
    return

    or

    P:
    DO
    ' your code
    LOOP
    RETURN

    Example


    Main:
    DO
    GOSUB Get_Buttons············· ' get debounced inputs
    DEBUG HOME,
    "Inputs = ", IBIN4 xbtns······· ' display in binary mode
    PAUSE 5

    IF xBtns = %0000 THEN
    LOW 0
    ENDIF

    IF xBtns = %0001 THEN
    HIGH 0
    ELSE
    IF xBtns = %0010 THEN
    HIGH 0
    ELSE
    IF xBtns = %0100 THEN
    HIGH 0
    ELSE
    IF xBtns = %1000 THEN
    HIGH 0


    ENDIF
    ENDIF
    ENDIF
    ENDIF

    LOOP

    I hope this helps

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 9/16/2009 3:19:13 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-09-18 04:06
    I still recommend adding a useful/descriptive subject if you're looking for help. Many people who may be able to help will pass over messages that don't have a subject indicating what they're about.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
Sign In or Register to comment.