Troubleshooting Challenge

devian_t

New Member
Troubleshooting Challenge

I got a set up here that I can't seem to see what is wrong.

Scenario: I am trying to add a rapid fire for my xbox 360 controller using picaxe 08M. The xbox 360 controller works on 2x1.2 rechargeable battery. Im trying to rapidfire Left Button. The schematic as follows



Code:
Code:
'Rapidfire 360 Controller
input 2

main:
 do while pin3 = 1
   input 1 
   pause 50
   low 1
   pause 50
   high 1
 loop
goto main
Considerations:
Left & Right Button is triggered when ground is applied.
Left & Right Trigger is triggered when +V is applied.
To trigger the Button again, ground should be removed and applied again.
To trigger the Trigger again, +V should be removed and applied again.

Result so far:
The code above works as a rapid fire for Left Button after the code download. But after a few minutes it also triggers the Right Button. Some instance it triggers Left Trigger. I have a feeling that the 2x1.2 rechargeable battery is the culprit or maybe just my code. Thanks for the help.

P.S. Cheating on the game is not my goal, its just a motivation. :)
 

hippy

Technical Support
Staff member
Welcome to the PICAXE Forum.

First question is what is your previous PICAXE and electronics experience ?

I'm not over familiar with the XBOX360 controller so it's not clear what the difference is between Left Button and Left Trigger ( and same for Right ), what you want to control and what you are using to control with. Also, what do the other ends of the two buttons connect to ?

The 2x1.2V batteries may be a problem but it may also be how you are interfacing with the controller; that may be putting strain on the electronics, drawing a lot of current and running the batteries down.
 

chigley

Senior Member
You've got the wrong idea for controlling the trigger states.

Use the low command to 'compress' the trigger, but never use the high command in an attempt to 'release' the trigger. Instead, you should always use the input command.

For example:

Code:
symbol pulse_width = 25
symbol gap_between_shots = 100

do
	low 4 ' pushes trigger down
	pause pulse_width ' wait long enough for game to realise
	input 4 ' set pin back to input, releasing trigger
	pause gap_between_shots ' wait before shooting again
loop while pin3 = 1
^ That's completely untested, but it should work. A rapid fire controller was my first project. I'm not claiming to be an expert, but from my experience the concept in the code above should achieve what you're after.

An 08M will just about manage off the AA batteries, but it'd be preferrable if you could use a wired controller, as this has a 5v power rail as opposed to 3v.

@hippy - by left/right buttons he means buttons which he's installed onto the rear of the controller. He's going to use these to shoot, where the triggers would normally be used.
 
Last edited:

lanternfish

Senior Member
Hi

A suggestion is to put comments on each line briefly describing what that line should do as this can help others better identify what each part of your code is meant to do. I have commented some of your code below:

Code:
'Rapidfire 360 Controller
input 2                             ; make pin 2 an input

main:                               ; main routine
 do while pin3 = 1               ; while pin3 is high do this loop
   input 1                          ; make pin 1 an input
   pause 50                       ; pause 50
   low 1                            ; make pin 1 low (even though it is set as an input)
   pause 50                       ; pause 50
   high 1                           ; make pin 1 high (even though it is an input)
 loop                                ; repeat this section until pin3 goes low
goto main                          ; repeat all
Have you read Part 3 pg 25 of the manual, the part about interfacing switches?

Part of the problem may be that with no pull-up/down resistors on your inputs the picaxe is reading the input falsely as noise on the inputs are read as low or high.

And search the forum (or google) to see if someone else has worked on a similar project.

Also read the part about output interfacing. Like Hippy I am not au fait with Xbox controllers but if you are trying to bridge an existing controller switch you may be inadvertently shorting a picaxe output to 0V or +V.

Hope this helps
 

chigley

Senior Member
I also meant to add that you can't use output 0 to control the trigger states, as it can't be configured as an input.
 

devian_t

New Member
@hippy. Thanks for the welcome!! I have a little of experience with microcontroller. I play with Boe-bot(Parallax BS2) before then used picaxe as a brain for my boe-bot. I have no school training on electronics and have some basic knowledge of programming. I am using the commands which are the most familiar to me.

The LEFT & RIGHT BUTTONS and LEFT & RIGHT TRIGGERS are part of a game joystick. If you press the LEFT BUTTON on the joystick (example) the character on the game will punch. For multiple punches I have to release the LEFT BUTTON and press it again. Its either train yourself to press rapidly(and have a carpal tunnel) or create another button that gives rapid "Signal-No-signal" to the joystick button.

@chigley. Oh! ok.. I can see that your code make more sense than mine. I will try that and let you know as soon as I have a free time. But another thing, If the wrong part is just my code what do you think is the cause of other buttons' (other than LEFT BUTTON) trigerring?

@lanternfish. LEFT & RIGHT BUTTONS and LEFT & RIGHT TRIGGERS are outputs here. They are like LED that I am trying to blink rapidly. The input I use is the button on pin3 to start the "Signal-No Signal" given to the (this case) LEFT BUTTON.
 

devian_t

New Member
Code:
symbol pulse_width = 25
symbol gap_between_shots = 100

main:
do while pin3 = 1                              'program will enter the loop when pin3 is on
	low 1                                       ' pushes trigger down
	pause pulse_width                    ' wait long enough for game to realise
	input 1                                    ' set pin back to input, releasing trigger
	pause gap_between_shots        ' wait before shooting again
loop                                                'repeat the loop
goto main
I tried this but it did not work. However, I tried the do-loop without condition to check if the code works and it does, it triggers the LEFT BUTTON rapidly. What is the cutoff voltage that 08m considers an ON-input and Off input? Is it a fix value or it change depending on the power supply (ex. greater than 20% of the power supply is considered ON by 08M)?
 

boriz

Senior Member
It’s a ratio. A percentage of Vcc.

Does this work?
Code:
symbol pulse_width = 25
symbol gap_between_shots = 100

do
	if pin3=1 then
		low 1                                ' pushes trigger down
		pause pulse_width       	' wait long enough for game to realise
		input 1                 	' set pin back to input, releasing trigger
	endif
	pause gap_between_shots        	' wait before shooting again
loop                                			 ' repeat the loop
 

westaust55

Moderator
Also, the PICAXE 08M serial input pin (physical pin 2) must be pulled low. Can be wired direct by suggest a 10 kOhm resistor to ground (0Volts) before the 08M program will work.
 

devian_t

New Member


Code:
symbol pulse_width = 25
symbol gap_between_shots = 100

main
	low 4                                        ' pushes trigger down
	pause pulse_width                      ' wait long enough for game to realise
	input 4                                     ' set pin back to input, releasing trigger
	pause gap_between_shots           ' wait before shooting again
goto main
This worked. I noticed that when I use pin3 as an input to signal 08M to do a loop it shuts down for 5 sec then restart again. Maybe the power supply can't provide power to 08M when a switch is used. Here when the rapid button is pressed 08M will run the loop that shoots rapidly without waiting for anything. I also add 4-socket thingy so I can change the program for other games or if I want to have a less rapid fire(?). I use 4 so I can use physical pin7 for output.

@boriz. What percentage is it?

@westaust55. Why do we need 10K resistor on pin 2(serial input)? Maybe your talking about when downloading the program to the picaxe. I made a small programming circuit that has the 10K & 22K resistor with the stereo jack receiver(thingy) for the AXE027(USB to Serial).

@moderators. Can I link this thread from other websites? I would like to add this as a tutorial on another forum that deals with Xbox 360 stuff.
 
Last edited:

centrex

Senior Member
I would suggest that you should have the 10k/22k resistors permanently in the circuit, not something thats perhaps gets disconnected.
The manuals are quite adament about the requirement.
centrex
 

devian_t

New Member
I would suggest that you should have the 10k/22k resistors permanently in the circuit, not something thats perhaps gets disconnected.
The manuals are quite adament about the requirement.
centrex
I don't think I read that. Which manual was it?



I have this as my programing thingy together with my AXE027(USB to Serial) programing cable. I think the 10k resistor was used only when downloading the program so I don't include it on the circuit and created separate one for prolong use.
 

devian_t

New Member
I would suggest that you should have the 10k/22k resistors permanently in the circuit, not something thats perhaps gets disconnected.
The manuals are quite adament about the requirement.
centrex
Oh wait!! I see what your talking about!! "The 10k/22k resistors must be included for reliable operation. DO NOT leave the serial in pin floating as THE PROGRAM WILL NOT RUN!" Holy! in Cap letters :eek:. Your right. Maybe the reason why pin3 is not working as an input is because of that. I will try it next time I open the controller. It seems working great for now.:D

Oh yeah, why do we need a resistor there??
 

westaust55

Moderator
All PICAXE chips expect the Serial In pin to be held low when the program is being executed.
If the pin goes high, this is an indication to the PICAXE firmware within the chip that a new program is going to be downloaded.

If you do not pull the SI pin low then it is floating and when it drifts to a high ("1") level then the PICAXE will expect a new program to be downloaded and as a minimum will keep reseting.

Please read the manuals


From PICAXE Manual 1 Pages 25, 26, 28 and others
Notes:
1) The 10k/22k resistors must be included for reliable operation.
DO NOT leave the serial in pin floating as THE PROGRAM WILL NOT RUN!
 
Last edited:

lbenson

Senior Member
A longer answer is that if you are not programming the chip in-circuit, you don't need the 22K resistor. But for the sake of one additional resistor and a little wiring, you lose convenience and functionality by leaving it out.
 

Andrew Cowan

Senior Member
If you never need to program in circuit, you can connect the SI pin straight to 0V. However, it's better to include a 22K and 10K - then you can use sertxd and program the chip.

A
 

devian_t

New Member
Thanks guys!! Its working great now!! I add the 22k-10k-ground on Serial In(pin2) and pin3 as the rapidfire button. It works without any problem so far. The power supply of 1.2Vx2 doesn't seem to matter even with 360 headset. It is one thing to know your rules and another to know the consequences. Thanks for the help!
 

westaust55

Moderator
Great to read that you have your project working.

The PIC 12F683 chip (upon which the 08M is based) can operate down to 2.0 Volts with the clock at 4MHz or 8MHz.
The minimum is 3 Volts if the clock is 10MHz.
 
Top