can anyone help me how to interface a thumbslide joystick with an atmega8
and also help me with the ADC code
Welcome to Cemetech, Saransh123007! I can only assume that you saw my slide joystick to TI-calculator interfacing video (namely this one)? And can we safely assume that you're using this joystick from Sparkfun? As you can tell from that page, the pinout is:

1) x-axis output
2) +5V
3) y-axis output
4) gnd

They quoted me as saying: "Just to make sure I'm clear, my pin 4 is the one closest to the two screw/mounting holes. When connected to an Arduino, I get a range of about 128 to 775 on each axis, with enough consistency to check if it's at -x, center-x, +x, and -y, center-y, and +y."

May I ask what language you're writing? AVR ASM or C?
i am using win avr . the joystick is form sparkfun . Yes, i saw your video with that calculator. Can you help me with this because it is my college project and i have never worked with adc module of atmega8 yet and the thumbslide joystick too
http://www.watterott.com/media/images/popup/09426-03.jpg

in this webpage there is a photo of the joystick so you mean to say that the pin which is lowest towards the gorund is the ground pin right ?
saransh123007 wrote:
http://www.watterott.com/media/images/popup/09426-03.jpg

in this webpage there is a photo of the joystick so you mean to say that the pin which is lowest towards the gorund is the ground pin right ?
The bottom pin in that photograph (closest to the two screw/mounting holes) is indeed GND. By the way, a point of etiquette on Cemetech: when it's less than 12 or 18 hours since your last post, edit your post instead of double-posting, please. So what is your main confusion, the hardware or the software side of things?
okay sir will not double post . And i Want help for both hardware and software as in how should i connect the joystick to the port of an atmega8 and ADC programming to read it .
saransh123007 wrote:
okay sir will not double post . And i Want help for both hardware and software as in how should i connect the joystick to the port of an atmega8 and ADC programming to read it .
Well, let's take a look at a sample Atmega8 pinout:

I see six ADC inputs, namely pins PC0 through PC5. You need two inputs for the joystick (one for the X axis, one for the Y axis), so perhaps ADC0 and ADC1, or 23 and 24, respectively. The connections for Gnd and +5V on the joystick are hopefully obvious. I found a very simple ASM example for reading an ADC, but I have a feeling you want C, not ASM:

http://avrbeginners.net/architecture/adc/m8_adc_example.html
All the relevant information can be found in the ATmega8 datasheet under "Analog-to-Digital Converter". What have you tried? What are you having difficulty with?
thanks alot for your help and time . But should i connect the joystick directly without any resistors and capacitor ?
saransh123007 wrote:
thanks alot for your help and time . But should i connect the joystick directly without any resistors and capacitor ?
Yup, no need to put anything in between. Did you examine the two links that Benryves provided? Those should help you and help us help you.
yes i am examining it currently its a helpful source thank u
saransh123007 wrote:
yes i am examining it currently its a helpful source thank u
Excellent. Let us know if you have any new questions, and of course keep us updated on your progress.
can u help me with the break of 128 to 775 ie how do i know that suppose the joystick is in forward position then what will be the rating on y-axis (+ve direction) and what will be the data on the reverse side
saransh123007 wrote:
can u help me with the break of 128 to 775 ie how do i know that suppose the joystick is in forward position then what will be the rating on y-axis (+ve direction) and what will be the data on the reverse side
Welcome back, long time no see! I suppose you're referring to the bounds that I posted on the Sparkfun page? You can either do a high water / low water mark system if you're only interested in knowing forward and back, but you probably want forward, center, and back, correct?
yes i even want right and left also . what is watermark stuff can you enlighten me with it
saransh123007 wrote:
yes i even want right and left also . what is watermark stuff can you enlighten me with it
The high watermark and low watermark concept deals with the fact that when you push to, say, +800, it only returns to, say, +500, and when you push to +100, it only returns to +400. Therefore, it's hard to tell where the center is. For forward and back, then you can say that going below +300 is foward, and the joystick remains in the forward position until it goes above +600, at which point it is in the back position. However, you want forward, back, and center, so you could say something like this, which is ripped straight from my code:


Code:
   j = analogRead(xAxis);
   if (j < 250) i = 1;      //keyleft
   if (j > 650) i = 2;      //keyright
   j = analogRead(yAxis);
   if (j < 250) i = 4;      //keyup
   if (j > 650) i = 3;      //keydown
   if (i == 0) return;
ok thank you sir but i am using atmega8 in that i get values stored in adch and adcl where l- lower and h- higher register in this how does this no. get stored do have knowledge about it ?
saransh123007 wrote:
ok thank you sir but i am using atmega8 in that i get values stored in adch and adcl where l- lower and h- higher register in this how does this no. get stored do have knowledge about it ?
Well, I would take a look at how two-byte words are stored; there's lots of documentation on that. For example, 767 is $02FF, so h=$02, and l=$FF.
If using C, it's just a simple

Code:
uint16_t value = ADC;

Otherwise, you have to bear in mind the following:
Quote:
When ADCL is read, the ADC Data Register is not updated until ADCH is read. Consequently, if the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH. Otherwise, ADCL must be read first, then ADCH.
yes thanks forgot that lol
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement