Serial Clock/Latch/Strobe/etc. on PIC

Status
Not open for further replies.
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.
 
Google. There are plenty of descriptions of how most game controllers work. Ps1/Ps2 controllers are particularly useful and easily found on the net.
 
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
 
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:
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
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…