BigCat41121
New Member
Hello, this is my first project with a PICAXE microcontroller. I am tapping into my Xbox 360 wireless racing wheel and trying to add a gated 6 speed plus reverse shifter. There is a switch at each gate that switches on when the shifter is put into that gear. These switches are connected to the PICAXE28X1, and then the microcontroller determines how many ‘up’ or ‘down’ shifts to send to the paddle shifters.
I’ve attached the code that I’m using. When I run the simulation in the programming editor, the code appears to function correctly. However, when I flash the code to the microcontroller and use it for the shifter, two things happen.
1. The microcontroller does not shift properly. Instead, the two output pins alternate switching high and low infinitely.
2. However, when a gear is engaged (a switch is on), the output pins stop alternating high and low, but nothing else happens.
I’ve tested the whole system with a multimeter and no wires are crossed or anything. So I believe that it is the PICAXE that isn’t working. Anybody know what’s going on with my code?
I’ve attached the code that I’m using. When I run the simulation in the programming editor, the code appears to function correctly. However, when I flash the code to the microcontroller and use it for the shifter, two things happen.
1. The microcontroller does not shift properly. Instead, the two output pins alternate switching high and low infinitely.
2. However, when a gear is engaged (a switch is on), the output pins stop alternating high and low, but nothing else happens.
I’ve tested the whole system with a multimeter and no wires are crossed or anything. So I believe that it is the PICAXE that isn’t working. Anybody know what’s going on with my code?
Code:
symbol current = b0
symbol new = b1
symbol change = b2
init: let current = 1
main: if pin0 = 1 then
goto setR
elseif pin1 = 1 then
goto set1
elseif pin2 = 1 then
goto set2
elseif pin3 = 1 then
goto set3
elseif pin4 = 1 then
goto set4
elseif pin5 = 1 then
goto set5
elseif pin6 = 1 then
goto set6
else
goto main
endif
setR: let new = 0
if new = current then main
goto calc
set1: let new = 1
if new = current then main
goto calc
set2: let new = 2
if new = current then main
goto calc
set3: let new = 3
if new = current then main
goto calc
set4: let new = 4
if new = current then main
goto calc
set5: let new = 5
if new = current then main
goto calc
set6: let new = 6
if new = current then main
goto calc
calc: if current<new then up
if current>new then down
up: let change = new-current
for b3 = 1 to change
high 1
wait 1
low 1
next b3
let current = new
goto main
down: let change = current-new
for b3 = 1 to change
high 0
wait 1
low 0
next b3
let current = new
goto main