confused new user help needed
staffshome
Posts: 28
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
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 Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
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.
·
·
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 Adrian
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
· 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
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
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
· 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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 9/16/2009 3:19:13 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·