Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 4th February 2007, 12:23 AM   (permalink)
Default Serial Clock/Latch/Strobe/etc. on PIC

Does anyone know how how to do the aforementioned serial communications to do things like communicate with game console controllers that have Data/Clock/Latch lines? I'd be greatful if someone could point me in the right direction.

Thanks.
ArtemisGoldfish is offline  
Old 4th February 2007, 04:11 AM   (permalink)
Default

Google. There are plenty of descriptions of how most game controllers work. Ps1/Ps2 controllers are particularly useful and easily found on the net.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 4th February 2007, 04:52 AM   (permalink)
Default

Well, many PIC's have an SPI module. It may not be completely compatable, depends on how many bits are sent. Also is the 'latch' a simple strobe line, that goes low then high after each 'byte' sent, or is it more like a clock select where its held low during the transfer?

Failing that, even though I PIC should handle it easily, a serial shift register, something like the 4094 (CMOS) or the 74HC595 would do. They'll convert the stream to parallel, and the 'latch' line would load the byte to the output. A PIC could simply use the 'latch' as an interupt to read the byte on its port. I think almost all logic shiftregisters have an 'output enable' line, which means youu can use the PIC'sd port for something else as well. When the 'latch' goes high (or low, whatever) the PIC could change the port to inputs, enable the output of the SR, then read it in. Then just disable the SR's output and switch back to outputs.

I'm sure theres a timing diagram of the exact console controller you're talking about somewhere on the web. I think its pretty 'doable' anyway.

Blueteeth
__________________
Inconsistency is the key to flexibility!
Blueteeth is offline  
Old 4th February 2007, 05:02 PM   (permalink)
Default

It's not only doable, it's been done to death =) Especially with the Ps1 and Ps2 controllers. You can actually buy commerical products that let you use a PS1 controller on your computer as a PC joystick. The protocol is not overly difficult to convert.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 4th February 2007, 11:58 PM   (permalink)
Default

Quote:
Originally Posted by Sceadwian
It's not only doable, it's been done to death =) Especially with the Ps1 and Ps2 controllers. You can actually buy commerical products that let you use a PS1 controller on your computer as a PC joystick. The protocol is not overly difficult to convert.
Well, yes, but that isn't quite what I'm trying to do. I'm trying to get the data so I can do something like control a stepper motor attached to a PIC with buttons on the controller.

Edit, in place of a superfluous double-post:

My datasheet describes the MSSP module (Master Synchronous Serial Port). Would this happen to be what I'm looking for?

Last edited by ArtemisGoldfish; 5th February 2007 at 12:05 AM.
ArtemisGoldfish is offline  
Old 5th February 2007, 01:44 AM   (permalink)
Default

Yep, thats the one. It can be configured either as 'SPI' or I2C'. You'll want it as SPI, and its configurable for clock phase, datarate, and a few other gubbins that might be useful. YOu coudl just experiment with those settings to find the one that works for your controller. Its in fact a very handy module, I've used it for I/O expansion using cheap (really cheap) logic shiftregisters, and the code in the PIC is about 16 lines long (which is why I brought up the shift register thing). But its not great at being a slave, although it does work. I think your controller will be the master, that is, it provides the clock source for the transfers, all the PIC does it read in the data.

Theres plenty of info on google. It's probably easier to just read the data from it and light up some led's or whatever, rather than converting it to another format. If you want a 'test' routine, what I usually do with devices that output unknown data is, write a little prog that displays the data on a generic character LCD, in hex. Because usually it'll send a set character for whatever button/analogue stick you're pushing, and then the value of that input. So if you just display the first 3 placeholders as the first character, then a space, then the second etc.... any rapid changes in the data (btw, it sends data very quickly) will appear on the LCD to quick for you read, but the set characters won't change. Analogue sticks are just two potentiometers, whose position is converted to digital inside the controller, so expect a 'stationary' analogue stick to have a set value, somewhere in the middle, like 77h(x) 77h(y) or something.

I know that probably sounds complicated but its handy for debugging things. You could always just sent the bytes it gets from the controller to a UART and send to a PC with hyper terminal to see the output, although because of the speed differences of the two interfaces, you'll probably have to set up a buffer, and then things get a little tricky.

I'm sure google has the answers, and I've seen some code for exactly what you want, but I don't have the link.

Goodluck, and sorry for the rant.

Blueteeth
__________________
Inconsistency is the key to flexibility!
Blueteeth is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
serial port cud u extend it?????? jam_mafia Electronic Projects Design/Ideas/Reviews 5 15th February 2006 07:52 AM
interfacing the MC serial port Julia Micro Controllers 50 25th June 2005 08:41 PM
Serial to Parallel mstechca Electronic Projects Design/Ideas/Reviews 6 30th March 2005 05:40 AM
pic16f877 serial recieve acting screwy masconejos Micro Controllers 6 9th April 2004 11:09 AM
Can a Basic Stamp support 2 serial ports? Scruit Electronic Projects Design/Ideas/Reviews 13 15th August 2003 03:07 PM



All times are GMT. The time now is 07:36 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker