![]() | ![]() | ![]() |
| | |||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I am working on a project to interface a mouse and keyboard with an xbox 360 controller. I am still learning but I do understand PICs so much better after 2 weeks of learning. I believe I have figured out how to connect all of the buttons from the 360 controller to a PIC(lets assume I am using a PIC16F737) using 4x4066IC analog switches. So here are the questions that I have:
Thank you in advance for your replies, I am learning a ton from them. | |
| |
| | (permalink) |
| hi chem I need to attach 6 analog signals (coming from potentiometers) to my PIC16F737. Do I need to attach reference voltages to the + or - Vref spots to be able to use the analog (DAC) pins? NO, Use the PIC's internal +5Vref. [look at ADCON1 reg on the datasheet, if VCFG0 and 1, are set to logic 0, then internal Vref] Since I am attaching 6 analog signals to my PIC do I need a different Vref connection for each of the 6 signals? NO, Use the PIC's internal +5Vref What exactly is a Vref for? If +Vref is say +5v then an ADn, input voltage of 0v thru to +5V would give you a ADC value of,,, 0 to 1023 [its a 10bit ADC, 0x3FF] If +Vref was say, +2.5V then an ADn, input voltage of 0 thru +2.5V would give you an ADC value of 0 to 1023. If +Vref set to +5V and -Vref set to say, +2V, then an ADn, input voltage of +2v thru +5V would give you an ADC value of 0 to 1023 Caution: there are min/max limits on +/-Vref The best way for me to learn about the analog pings on PICs is if someone could please draw a schematic for connecting analog signals to the analog pins of a PIC16F737 with a little explanation. You must say what the voltage ranges are you that you want to connect, as it effects the answer I can give you. This should help with ADC part of the post.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 19th April 2007 at 02:47 PM. | |
| |
| | (permalink) |
| I did the programming for this guy's project a few years back, which involves interfacing a PS/2 mouse: http://imakeprojects.com/projects/seeing-eye-mouse/ There are some schematics/connection diagrams on there, though not to the level of drawing an exact picture with a real connector. But really, a PS/2 connector only has 4 pins - +5v, ground, data and clock. Hooking up +5v and ground is a no-brainer, and then you hook up data and clock to whatever PIC IO pins you want to use - there's not much need for a diagram, other than perhaps a diagram of which pin is which on the particular PS/2 connector you are using, which you can surely find by searching the web.
__________________ EEgeek.net | |
| |
| | (permalink) | |
| In case anyone who is replying is interested the xbox 360 controller uses a +5v power so from what I understand that will work great with PICs since I think most if not all run on 5v. Eric you said: Quote:
So 1.61v is the max and 0v is the minimum voltage I would deal with in my particular case. So let me get this straight.
evandude, From looking at the circuit from your webpage it seems very straight forward. Very nice article it's very useful.
My guess is the Vcc is not at 5v, so that is the reason for the resistors. Am I right? Thank you for your replies! They have been really helpful. | ||
| |
| | (permalink) |
| hi chem, > To give a good example of what I am dealing with imagine a 1 dimensional axis of a joystick; if the joystick is pushed up all the way then that would equal 1.61v and if it is pushed down all the way that is equal to 0v. So if it is left idle in the center it should read 0.805v. >> So 1.61v is the max and 0v is the minimum voltage I would deal with in my particular case. Using these voltage inputs with a +Vref [internal] of +5V.... ADNin = 0V, ADC value = 000 ADNin = 0.805V, ADC value = (0.805/5) * 1023 = 164 [ 0xA4] ADNin = 1.61V, ADC value =(1.61/5)*1023 = 329 [0x149] IF, you wanted to increase the resolution, [get a bigger count range], you could set the +Vref to +2.5V, this would have the effect of doubling the above count values. You would have to connect a +2.5Vref voltage source to +Vref, this would change ALL the ADCin's to the new scale factor. [You should not use a +Vref of less than +2.5V, else you would be out of spec for the PIC] >> So let me get this straight. If I have 6 analog signals (6 different potentiometers) to attach to my PIC all I would need to attach is the +5v, ground and the 6 wires from the potentiometers? The spec sheet for the PIC, states that the source impedance of the analog voltage source should not exceed 10K0. All this means is, the resistance value of the joystick pots should not be more than 10K0... If this is not possible, then there are ways around it, a little more circuitry. Or is there more I would need to connect to get this to work? No, providing the joystick pots are less than 10K. Hope this is clear, ask if not. Regards
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | |
| |
| | (permalink) |
| ericgibbs, Thank you for your help I really appricate it. There are a few things that I would like to make sure that I understand. Please bare with me I am still learning.
Thanks. evandude, After looking at that project you had made with connecting the PS2 port to a PIC I made my own diagram.
| |
| |
| | (permalink) |
| hi chem, The minimum Vref for a PIC is 2.5v? From the data sheets I use, yes. Am I correct to say that +Vref and -Vref set the upper and lower limits for voltage range of analog pins? Yes, BUT again there a limits to -Vref and +Vref, settings, they are descibed in the datasheet, IMO, not very well!. EDIT: A more accurate description of the +/-Vref action, would be: the +/-Vref values set the 'span' or 'slope' of the ADC. Since the range that I am interested in is 0v to 1.61v do I need to attach a Vref? If the range was 0v to 5v then I guess I would not need to attach anything to the Vref? No, just program the PIC to use the defaults, ADCON1, reg. Could I just set the internal Vref to 2.5v, if not why? There is no way to do that. You can buy 2.50V ref devices, to connect to the +Vref input, they are powered from the +5Vsupply line. I think the resistance value between the pots is 10k, so its not under 10k is that ok? Thats just at the recommended limit, no damage will be done if you connected a higher value resistance pot, it would just effect the ADC response/acquisition time. When you ask about the resistance between the pots are you talking about the resistance between the upper voltage and lower voltage? Yes. I have included a drawing of how I was planning to attach the pots to my pic could you please take a look at it and make any changes if see something wrong? Will reply asap.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 21st April 2007 at 10:49 AM. | |
| |
| | (permalink) |
| hi chem, ref your dwg of the PS2 connector, are you reading the pin numbers in reverse order.? my kbd datasheet says. 1. kbd clk 2. gnd 3. kbd data 4. n/c 5. +5V 6. n/c On the Xbox dwg, remember the 0V connection from the Xbox to PIC pcb. As a side point,, are you aware that the kbd data and clock lines are bi-directional? and open-collector. Have you had a look at the keyboard 'key' coding requirements?
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 7th July 2008 at 12:19 PM. | |
| |
| | (permalink) | |
| Quote:
http://www.computer-engineering.org/...board_Protocol There are a number of external components that "should" be used in general, however on a PIC you can basically get away without them. The idea is that the PIC needs to be able to put the line in two states: pulled low (with an output drive) or pulled high with a weak pull-up resistor, so that the keyboard/mouse can pull it low to send data. The PIC can do the former of course with a pin set as an output, and it can do the latter by setting the pin as an input with the internal weak pull-ups enabled. If the I/O pins you choose to use for the data/clock lines do not have internal weak pull-ups available, you would need to add pull-up resistors externally. Check the datasheet. I don't see anything immediately wrong with your schematic at first glance, however I didn't verify the pinouts of the PS/2 connectors, and you of course need to check the pull-up thing I mentioned above.
__________________ EEgeek.net | ||
| |
| | (permalink) | |
| Quote:
The truth is the mouse and keyboard pinouts are exactly the same. At work, I have a PIC with one PS/2 connector with only four wires attached. It has been used to test both keyboards and mice. Last edited by tkbits; 23rd April 2007 at 03:53 AM. | ||
| |
| | (permalink) |
| hi tk, I dont quiet follow what you are saying? As stated the PS connectors for mouse and keyboard are identical and there are only 4 active pins, hence only 4 wires? If you check the OP's original drawing the mouse and kbd are labelled as a mirror image. Regards
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | |
| |
| | (permalink) |
| Not sure if this helps or not, but http://www.lynxmotion.com/images/html/build074.htm That webpage has some information on using a PS2 controller to control a hexapod robot (pinouts, etc). They are using a ABB for the micro, but the PIC is very similar. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| PIC PS/2 Keyboard Circuit and Code - 5 Keys Only | ejp | Micro Controllers | 2 | 14th November 2003 03:03 PM |
| Circuit functioning very strange. Why? | Cyclone | Electronic Projects Design/Ideas/Reviews | 12 | 4th November 2003 01:31 AM |
| Designing a circuit to convert game port to serial port | Diluka Moratuwage | General Electronics Chat | 1 | 29th July 2003 05:40 PM |
| Basic Serial Port Circuit | grudge | Electronic Projects Design/Ideas/Reviews | 4 | 18th April 2003 01:04 PM |
| help I need a circuit layout designing | leon | Electronic Projects Design/Ideas/Reviews | 8 | 22nd February 2003 04:45 AM |