View Full Version : new to this, need help......

11-24-2009, 12:33 PM
Hi everyone, I'm pretty new to this but am picking things up pretty quick. On to my problem.....

I have a BS2 on the home work board and PBASIC 2.5. I am trying to read data bits from a device that uses a method of timed serial output.
This device has a 11.58ms synchronization period where the output is high. At the end of the synch period is a high to low transition. 251.77us after the start of the transition I need to know the state of the pin, high or low (the first bit should be a high level for start). The pin will then go high again for a short time, to provide the high to low transition so the next bit can be read at 251.77us.

I have 32 bits I need read, then the unit can pause for approx 16ms, before the 11ms synch period starts.

Essentially, the device I am trying to read the data from has:
32 data bits including the start bit, these will be either high or low depending on what it is trying to say
4 fill bits, these will be a low state
38 synch bits (according to the devices output protocol), these will be in a low state and I'm not concerned with these
66 bits of idle time, these are in a high state and immediately precede the start bit.

total the device is outputting 140 bits in 48ms with 11.58ms of idle time
the first 32 bits come in 16.11ms and these are the important ones, the remaining time will be needed for outputs I imagine.

So far I have tried everything I can think of to get this to work for me, SERIN does not work since there are no stop bits until bit 33 and the BS2 can only handle 16.....also I have know way to know what baud mode this would be, parity, ect.....

SHIFTIN does nothing for me since this is a single wire data line......

I've also tried experimenting with PULSIN to measure the length of the low and debug "0" if it is longer than x amount of time or "1" if it is shorter.

So far all my efforts have been futile........any suggestions on how I may be able to get this to work?

Mike Green
11-24-2009, 12:50 PM
The Stamp just isn't fast enough to do this. The simplest statements in PBasic take 140us or more to execute. You don't even have time for two such statements to handle a bit.

You will either have to do all of the decoding in external hardware or use a faster microcontroller like the SX or Propeller (which could easily do the job).

11-24-2009, 02:31 PM
Hi Mike,

Thanks for the reply, I had gotten to the point of thinking that this was not possible with this chip/board. This is a project that I have had in the back of my head for a while now and just finally got up the ambition to figure out how to make it work. Having absolutely no experience with micro chips previously, I bought the Home work board kit to learn on.....figured I might as well give it a shot with this before buying something else!

You say an SX or Propeller, huh? I haven't looked at them yet but I'm guessing there are various versions of them......can you recommend one that will collect the info that I need from my external device and during its down time, provide a LCD display with the pertinent info and output to a audio device? Preferably something still using PBASIC.

Much thanks!!

Mike Green
11-24-2009, 02:49 PM
I'm partial to the Propeller. Look at the Propeller Demo Board. It's programmed in Spin rather than PBasic. The Demo Board has a built-in stereo audio output and can drive either a video display or a VGA display (or both). It can also handle an LCD display, but the sockets for video and VGA are already there.