Cannot create a 50us Pulse
MR8-BIT
Posts: 4
Greetings all,
·
I am new to the world of STAMPS but·I am working on a project which requires the STAMP (I have the BS2) to create a 50uS "hi" followed with a 50us "lo". I have used the PULSOUT out but always seem to have about a 400us "lo" delay no matter what I attempt
·
Any insight/assistance would be greatly appreciated so I can return to finishing the task that my wife has assigned me for this weekend (the Christmas tree still isn't decorated yet)!
·
Thanks-Brian
·
I am new to the world of STAMPS but·I am working on a project which requires the STAMP (I have the BS2) to create a 50uS "hi" followed with a 50us "lo". I have used the PULSOUT out but always seem to have about a 400us "lo" delay no matter what I attempt
·
Any insight/assistance would be greatly appreciated so I can return to finishing the task that my wife has assigned me for this weekend (the Christmas tree still isn't decorated yet)!
·
Thanks-Brian
Comments
If you can afford an unused I/O pin, you might try a SHIFTOUT. With a BS2, you can have a 15us high pulse, then a 30us low period and you can repeat this clock for a specified number of bits (by attempting to clock out a specified number of bits of data which are ignored).
You didn't specify what's supposed to happen after the 50us low. Another 50us/50us high/low cycle? If so, how many? It would also help to know what your application is, in case there's another way to accomplish your ultimate goal.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 12/2/2007 7:10:36 AM GMT
Thanks for the assistance! The waveform that I am trying to generate will be used to send address and control data (in a rough 18-bit serial format) to another PIC controller device.·The signals that I am trying to generate have the following meaning:·a 50/50us pulse represents a "hi" while a 100/100us pulse represents a "lo"; yes, they will repeat.
Just to insure that I am not endangering national security in any manner my project will be used to control my model railroad layout using a system call DCC (Digital Command Control). The following link has a general layout of the waveform I am trying to create: http://www.loystoys.com/info/how-dcc-works.html
Thanks-Brian
You have confirmed what I had discovered through the o'scope. I would really like to keep the number of un-needed external electronic circuits/parts to a minimum (I had thought of this idea also).
With that said I haven't dealt with assemblers since my 6809 days in the late 80s; I must admit that I'm alittle afraid of using the SX just for that reason (I D/L the manual for a quick overview). I know I'm off this forum’s topic (STAMP Basic) but just how much code is needed for the SX to accomplish my project (general estimate); any comments (good or bad) would be welcomed.
Thanks again for the assistance; it has been fun tinkering with my STAMP over the past few weeks!
Thanks-Brian
I was holding out hope that this could be done with SEROUT. By setting the baud rate to 20K, each bit period is 50µs. Nominally, each byte is 10 bits, including start and stop bits. Since the DCC protocol allows stretching "0" bits, it seemed reasonable to assume that one could somehow crowbar a command sequence into an array and send it via SEROUT using the STR modifier. But, alas, the BS2's minimum time between the end of a stop bit and the beginning of the next start bit is 100µs. This precludes being able to send a proper preamble (10 consecutive "1" bits) or more than even five "1" bits in a row.
In the BS2p, the minimum inter-byte interval is 40µs. By setting the baud rate to 100K, the bit time is 10µs, and 40µs + 10µs = 50µs. But that's too fast a baud rate to be able to produce the 100µs "0" bit periods.
The SHIFTOUT command fares even worse — even in the BS2p, where the inter-word "recovery time" is 70µs, and the "baud" rate is 40K (25µs/bit); so the maximum number of consecutive "1" bits you could send is four. This, again, would preclude sending a proper preamble.
What you want is just on the cusp of possibility with a BASIC Stamp, but yet, so far away...
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 12/3/2007 4:07:36 AM GMT
That is easy to do with the SX/chip and SX/B
SX/B takes a bit to get use to but the SX chip can generate frequencies and pulses.
I am using encoders to set my delays or my pulse on time..
this is just a little bit of the code I used to send pulses with the SX.
DO
PULSOUT RC.0, delay ' pulses from 10 to 1000 µs The delay sets my pulse out time
PAUSEUS 2 ' 2us delay in between
PULSOUT RC.1, delay
PAUSEUS 2
LOOP
"I am running a 50Mhz resonator
SUB Setdelay
IF __PARAMCNT = 1 THEN
DELAY = __PARAM1
ELSE
DELAY = __WPARAM12
ENDIF
endsub
If you can't do it with the BS2 then go to the SX chip. I had too for almost the same reason..
I hope this helps... Have fun with the tree ......
One nagging question for me is, Just where have all the hobos gone? ...
Tonight as I lay on the boxcar,
Just waiting for a train to pass by,
what will become of the hobo,
whenever his time comes to die?
Ahh the old Merle Haggard album with those old Jimmy Rodgers tunes, I think I will pull out my old guitar and listen to that old whistle blow!
You just gotta love those old trains.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Here is a link to the details for DCC.· You'll want to look at S-9.1, DCC Electrical Standard and S-9.2, DCC Communications Standard....and maybe Recommended Practice 9.2.1 to 9.3.1.· You'll find the RPs toward the middle of the page on the link below.
http://www.nmra.org/standards/consist.html#standards
Hope this helps!
Post Edited (Desy2820) : 12/3/2007 9:55:59 AM GMT
datacps: thanks for the code example...now I have something to "reverse engineer" (I may have future questions that I may pass your way if that is OK seeming you have done this already; I'll see what I can find in past posts in the forums if I go the SX route).
metron9 & Desy2820: I know...the NMRA DCC information has abit to be desired...but I also think that somewhere in my DCC folder I have an actual programming guide provides a brief overview to program a decoder using 4-digit addressing; if nothing else this is half the fun (ok, I may have a twisted sense of what fun "is" but as I tell my wife...it keeps me out of the bars). If nothing else I can purchase the SPROGII and use DecoderPro to control my train (and look at the signals it sends out). For you train buffs out there “Long live the Chicago Northwestern”!
Thanks-Brian