Debug, readadc problems

unigamer

Member
I am using the 28/40 proto board with a 40X1 chip. I am trying to use a Playstation joystick and the readadc command. However when using the debug command I always have a fluctuating reading of around 65 even if there is nothing even plugged into the pin!

I have tested that I'm using the right pin with a digital on/off switch and it works perfectly.

I am at a loss as to what to do?

My code is
main:
readadc 0,b1
debug b1
pause 100
goto main

:)

 
 

pcfixit

New Member
Have you remembered to put a pull-down or pull-up resistor on the input ( i cant remember which you are meant to use) because a floating input may be causing the fluctuating reading of 65. This might or might not work, it worked for me last time i attached a pot to a picaxe, but i cant remember the values, Sorry.
I am also trying to get a joystick to work with a picaxe, one of the old Tiny PC ones, i got it working after about an hour of messing around.
Good luck with your project :)
Alex

Edited by - pcfixit on 24/06/2007 11:32:45
 

unigamer

Member
An hour?!?!?! ;)

It works fine on my voltmeter, that is the voltage increase and decreases as it should. Connecting directly to the pin also shows the voltage is changing there as it should. I am using 1k resistor and using the diagram from the PICAXE book page 129.

Hmmm...

 
 

hippy

Ex-Staff (retired)
What voltages are your meter showing - Does the voltage range from 0V to 5V ( or whatever you are powering the PICAXE at ) ?

When using the switch, does the Debug display show values of 0 and 255 being read ?

You can remove the PS joystick, connect a 1K / 4K7 / 10K pot between 0V and PICAXE supply and feed the wiper to your 1K resistor. That should show Debug readings ranging between 0 and 255.

Also check you have the joystick wired to the correct 40X1 leg; connecting to the wrong leg often appears to work but doesn't give accurate and consistent readings.

You can try reading the joystick ( and trying the above tests ) on a different analogue input to see if that gives any better results.
 

hippy

Ex-Staff (retired)
<i>I am using 1k resistor and using the diagram from the PICAXE book page 129 </i>

Which PICAXE book is that; The David Lincoln one ?

Don't forget that not all of us have the same books as you do so do not know what the circuit there may look like.
 

unigamer

Member
OK, now I feel like a bit of an idiot. I had it attached to a normal input pin, not an ADC pin. Whooops. It is all working perfectly now and I thank everyone for their help. :)

For anyone reading this having a similar problem:

Check you are using an ADC input NOT a regular input.

Thanks again!

Edit: Hippy, I did not realise there was more than one. It is the David Lincoln one - Programming and Customizing the Picaxe Microcontroller

weenip: The title of the book is above.

http://194.201.138.187/epages/Store.storefront/?ObjectPath=/Shops/Store.TechSupplies/Products/PUB127

At about &#163;15 it is fairly expensive when all the information can be found online and in the PICAXE manuals fairly easily. However, I like having something I can just read through and it is clearly written with good example projects.

Edited by - unigamer on 24/06/2007 14:36:56
 
Top