Once i get it up and rinning right, I will definitely send you pics. This is a final project for my Bachelor’s Degree in Electronics.
I am having technical difficulties in programming subroutines when using the RIOS code that has been converted to Basic. What I did was program two simple sequences using the RIOS program. I want to use each of these sequences as a seperate subroutine with the Stamp. This way, depending on what the input signal to the Stamp is, a different subroutine can be called and in any order.
What I think is happening is that the DATA variables are getting mixed from the different movements and it’s causing some spurious results. individually, the two different arm programs work great, but when combined, they conflict a bit.
Here’s the combined code:
' FuctionalTest2.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
'This program tests the functionality of using subroutines to control the arm
'----------- Main Program ------------
Main:
GOSUB Num1
PAUSE 500
GOSUB Num2
PAUSE 500
END
'----------- Subroutines --------------
Num1:
DATA 155, 195, 210, 164, 142, 144, Word 1000, Word 0
DATA 155, 195, 210, 164, 142, 144, Word 30, Word 0
DATA 155, 171, 202, 164, 142, 144, Word 330, Word 0
DATA 155, 171, 169, 148, 142, 144, Word 660, Word 0
DATA 155, 188, 188, 148, 142, 144, Word 300, Word 0
DATA 155, 195, 210, 162, 142, 144, Word 300, Word 0
idxa VAR Word
time1a VAR Word
pause1a VAR Word
pos1a VAR Byte
pos2a VAR Byte
pos3a VAR Byte
pos4a VAR Byte
pos5a VAR Byte
pos6a VAR Byte
SSC32a CON 15
PAUSE 500
FOR idxa = 0 TO 5
READ idxa * 10, pos1a
READ idxa * 10 + 1, pos2a
READ idxa * 10 + 2, pos3a
READ idxa * 10 + 3, pos4a
READ idxa * 10 + 4, pos5a
READ idxa * 10 + 5, Pos6a
READ idxa * 10 + 6, Word time1a
READ idxa * 10 + 8, Word pause1a
SEROUT SSC32a, 6, "#0P", DEC pos1a * 10, " #1P", DEC pos2a * 10, " #2P", DEC pos3a * 10,
" #3P", DEC pos4a * 10," #4P", DEC pos5a * 10, " #5P", DEC pos6a * 10," T", DEC time1a, 13]
PAUSE time1a + pause1a
NEXT
RETURN
Num2:
DATA 156, 195, 209, 161, 142, 144, Word 1000, Word 0
DATA 156, 170, 171, 149, 142, 144, Word 540, Word 0
DATA 141, 170, 171, 149, 142, 144, Word 120, Word 0
DATA 172, 170, 171, 149, 142, 144, Word 240, Word 0
DATA 172, 165, 187, 154, 142, 144, Word 450, Word 0
DATA 145, 165, 187, 154, 142, 144, Word 300, Word 0
DATA 145, 173, 204, 163, 142, 144, Word 210, Word 0
DATA 183, 173, 204, 163, 142, 144, Word 360, Word 0
DATA 156, 173, 204, 163, 142, 144, Word 240, Word 0
DATA 156, 195, 210, 163, 142, 144, Word 330, Word 0
DATA 156, 195, 210, 157, 142, 144, Word 90, Word 0
idx VAR Word
time1 VAR Word
pause1 VAR Word
pos1 VAR Byte
pos2 VAR Byte
pos3 VAR Byte
pos4 VAR Byte
pos5 VAR Byte
pos6 VAR Byte
SSC32 CON 15
PAUSE 500
FOR idx = 0 TO 10
READ idx * 10, pos1
READ idx * 10 + 1, pos2
READ idx * 10 + 2, pos3
READ idx * 10 + 3, pos4
READ idx * 10 + 4, pos5
READ idx * 10 + 5, Pos6
READ idx * 10 + 6, Word time1
READ idx * 10 + 8, Word pause1
SEROUT SSC32, 6, "#0P", DEC pos1 * 10, " #1P", DEC pos2 * 10, " #2P", DEC pos3 * 10,
" #3P", DEC pos4 * 10," #4P", DEC pos5 * 10, " #5P", DEC pos6 * 10," T", DEC time1, 13]
PAUSE time1 + pause1
NEXT
RETURN
I have it set up to simply run one subroutine followed by the other in a loop. What it actually does is run the first subroutine twice, then it only does half of the second routine and locks up (or stops moving).
I added an “a” at the end of the variables for the first subroutine so that the program doesn’t get confused.
Any ideas you have will be greatly appreciated! Thanks,
Jerald