View Single Post
Old 03-23-2005, 08:07 PM   #5
Dexter
Variable Bitrate
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 284
Quote: Originally Posted by rando
The interrupt based approach seems easier to me. Also, if your pic has a PWM, I belive it can be used to trigger on an edge and capture the clock all in one shot -- to improve the stability of your measurements a little.

In looking at the code, there are really only 4 bits needed to detect which button is pressed. Isn't there a 1111 (or 0000 for the inverted 4 bits) code that you receive for when the button is released; or does the bit pattern repeated continuously while the button is down? Or is this the sequence for a button press and release?

Knowing that only 4 bits are needed, you could optimize the detection routine to only save 4 bits. Whenever those bits are 0111, the next 4 bits are the ones you need -- of course this assumes that the patterns you've shown are all that will ever be on the bus; I dunno if that's true or not.

Good luck!

My PIC I will be doing testing with is a 16F628 or 16F877. Eventually I'd like to get it onto a USB PIC (not sure which one yet).

And yeah, I did notice I would only need to really save those 4 bits, as it will uniquely idenify the action. This will be the only device on the bus. I'm not planning on interfacing with any other OEM harware. But in order to perhaps make the code reusable for other hardware, I think I will process and save all bits.

This pattern is generated for a button press and release. If the button is held down, the pattern repeats itself after a pause of roughly 25ms. So after a stream is collected, I can just to back to my "wait if bus is low, wait 9ms..." routine.

Do you by chance have any more info on this PWM method? I searched for awhile but all I came up with was info on programming FPGAs. Right now, I'm trying to figure out how to implement OdysseyPC's code. I've never used timers before so I'm trying to pick that up and figure it out.

Much thanks for the response, this really helps alot!
__________________
Mazdaspeed Car Computer
gotta redo it all
Dexter is offline   Reply With Quote