View Single Post
Old January 27th, 2010, 06:39 PM   #30
ninja250
You are sleeping
 
ninja250's Avatar
 
Name: Casey
Location: LMFAO!!!
Join Date: Nov 2009

Motorcycle(s): 2

Posts: A lot.
Here's the weak code I wrote for the BS2 module.
It's basically a simplified version of programming. If you could even call it that. haha

This whole thing would have to be redesigned with an atmel controller anyways for a production unit and rewritten in C. Not a problem at all, This way is just quicker/funner/easier for prototypes.

All that is missing from the program below is the gear increment and decrement algorithms. Would look something similar to the lean angle routine.
The 7 segment display outputs are already referenced and the delays can be adjusted to suit. Ah yes, the potentiometer variables are missing still too. The part that makes the whole thing adjust to fit on any bike.

Probably not the most efficient way to do things though. I'm not a good programmer. lol
It will start to get more twisted as the features pack on.

Quote:
' {$STAMP BS2}
' {$PBASIC 2.5}

x VAR Word
y VAR Word

main:
IF (IN7 = 0) THEN shift
GOSUB lean
GOTO main

lean:

PULSIN 8, 1, x
DEBUG CLS, ?x
IF (x < 2300) THEN L3
IF (x < 2400) THEN l2
IF (x < 2500) THEN l1
IF (x < 2550) THEN middle
IF (x < 2600) THEN r1
IF (x < 2700) THEN r2
IF (x < 2800) THEN r3
RETURN

middle:
LOW 0
LOW 1
LOW 2
HIGH 3
LOW 4
LOW 5
LOW 6
RETURN

r1:
LOW 0
LOW 1
HIGH 2
HIGH 3
LOW 4
LOW 5
LOW 6
RETURN

r2:
LOW 0
HIGH 1
HIGH 2
HIGH 3
LOW 4
LOW 5
LOW 6
RETURN

r3:
HIGH 0
HIGH 1
HIGH 2
LOW 3
LOW 4
LOW 5
LOW 6
GOSUB rrr
RETURN

l1:
LOW 0
LOW 1
LOW 2
HIGH 3
HIGH 4
LOW 5
LOW 6
RETURN

l2:
LOW 0
LOW 1
LOW 2
HIGH 3
HIGH 4
HIGH 5
LOW 6
RETURN

l3:
LOW 0
LOW 1
LOW 2
LOW 3
HIGH 4
HIGH 5
HIGH 6
GOSUB lll
RETURN

shift:
LOW 3
GOSUB first
IF (IN7 = 0) THEN buttonbreak
GOSUB neutral
IF (IN7 = 0) THEN buttonbreak
GOSUB second
IF (IN7 = 0) THEN buttonbreak
GOSUB third
IF (IN7 = 0) THEN buttonbreak
GOSUB fourth
IF (IN7 = 0) THEN buttonbreak
GOSUB fifth
IF (IN7 = 0) THEN buttonbreak
GOSUB sixth
IF (IN7 = 0) THEN buttonbreak
GOSUB fifth
IF (IN7 = 0) THEN buttonbreak
GOSUB fourth
IF (IN7 = 0) THEN buttonbreak
GOSUB third
IF (IN7 = 0) THEN buttonbreak
GOSUB second
IF (IN7 = 0) THEN buttonbreak
GOSUB neutral
IF (IN7 = 0) THEN buttonbreak
GOTO shift

buttonbreak:
PAUSE 500
IF (IN7 = 0) THEN main
RETURN

first:
HIGH 0
HIGH 11
HIGH 9
HIGH 15
HIGH 10
HIGH 12
LOW 14
LOW 13
PAUSE 1000
LOW 0
HIGH 11
HIGH 9
HIGH 15
HIGH 10
HIGH 12
HIGH 14
HIGH 13
PAUSE 500
RETURN

neutral:
HIGH 1
LOW 9
LOW 10
LOW 14
HIGH 15
HIGH 11
HIGH 13
HIGH 12
PAUSE 1000
LOW 1
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 500
RETURN

second:
HIGH 2
LOW 12
LOW 13
LOW 10
LOW 9
LOW 15
HIGH 14
HIGH 11
PAUSE 1000
LOW 2
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 500
RETURN

third:
HIGH 3
LOW 12
LOW 13
LOW 10
LOW 14
LOW 15
HIGH 9
HIGH 11
PAUSE 1000
LOW 3
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 500
RETURN

fourth:
HIGH 4
LOW 11
LOW 10
LOW 13
LOW 14
HIGH 15
HIGH 9
HIGH 12
PAUSE 1000
LOW 4
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 500
RETURN

fifth:
HIGH 5
LOW 12
LOW 11
LOW 10
LOW 14
LOW 15
HIGH 9
HIGH 13
PAUSE 1000
LOW 5
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 500
RETURN

sixth:
HIGH 6
LOW 12
LOW 11
LOW 10
LOW 14
LOW 15
LOW 9
HIGH 13
PAUSE 1000
LOW 6
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 500
RETURN

lll:
LOW 11
LOW 9
LOW 10
HIGH 14
HIGH 13
HIGH 15
HIGH 12
PAUSE 50
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 50
RETURN

rrr:
LOW 13
LOW 10
LOW 14
HIGH 15
HIGH 9
HIGH 12
HIGH 11
PAUSE 50
HIGH 9
HIGH 10
HIGH 11
HIGH 12
HIGH 13
HIGH 14
HIGH 15
PAUSE 50
RETURN
__________________________________________________
http://www.ninjette.org/forums/signaturepics/sigpic2121_4.gif <Yeah, it's a 250.
LMFAO!
Weaksauce
ninja250 is offline   Reply With Quote