DCC transmitter

robertc

New Member
I need to send a packet string with bits as short as 58 microsends to compy with the NMRA DCC protocol for model railway command control systems. Is it possible to send a string of ones and zeros that fast using the picaxe or does the onboard basic interpreter slow it down too much?
regards
Bob Comerford
Australia
 

manuka

Senior Member
Even with a 08M the <b>PULSOUT </b> command is able to specify pulse durations down to 10 &#181;S at 4MHz &amp; 5&#181;S at 8MHz.With a 16MHz 18 etc you're good to 2&#189; &#181;S. How picky is timing on your data string? Yeah- guess I could Google NMRA specs., but the acronym rather reminded me of NRA...

Hippy is the forum bit banging champ, so I'll leave him to take over from here- Stan



Edited by - manuka on 20/04/2007 07:06:47
 

robertc

New Member
Thanks Stan, I'll look at the specs for puls out. I was originally thinking I might be much too slow if I had to generate the pulsetrain from a string of basic commands. I don't have the specs in front of me at the moment but I think there is a leeway of 55-61uS for the half cycle. If it is possible I will happily put my programmer and 3 pic chips that seem to have each decided not to be reprogrammable after a few goes and buy some piaxe chips and forget all about assembler code. Basic will do this part time user these days.
regards
Bob Comerford
 

manuka

Senior Member
Bob- you may not even need Pulsout as a quick forum search shows NMRA DCC (+ Picaxe prospects) was pretty well thrashed out last year. See =&gt; <A href='http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=4906&amp;forum_id=27&amp;Topic_Title=Please%2Bhelp%252C%2Btrain%2Bcontrol%2Bproblem&amp;forum_title=No+new+posts+please!+19 ' Target=_Blank>External Web Link</a>
 

robertc

New Member
Hi Stan, I have read through that thread and while it starts discussing DCC it moves off into their own system and dicusses Mark Csele's DCC system that uses a pic not a picaxe. I need something different to Marks design. However I still need to do the same basic thing. I need to toggle an output high for 58uS then low for 58uS to generate a logic one. Logic 0 is essentially twice as long. Will the interpreted basic instructions be processed fast enough in a picaxe to send a string of ones and zeros?
e.g
how long would it take to process something that would effectively do this (send a 1 and 0)
pulsout pin 1, 58uS
pause 58 uS
pulsout pin1 ,116uS
pause 116uS
regards
Bob Comerford
 

BeanieBots

Moderator
To help answer your question, have at look at this thread and the other threads it points to:-
<A href='http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=2521&amp;forum_id=16&amp;Topic_Title=PICAXE%2BCommand%2BTimings&amp;forum_title=No+new+posts+please%21+10' Target=_Blank>External Web Link</a>

Essentially, a 'typical' command takes 250uS to execute. Thus, at 4Mhz, I don't think it will ever do what you want. At faster clock speeds some possibility but will need a lot of care.

The soon to arrive 28X1 supports pause in uS as well as mS. With its higher clock rates it may well offer a solution.

Edited by - beaniebots on 20/04/2007 13:41:23
 

hippy

Ex-Staff (retired)
I checked the DCC protocol, and although it is essentially 5V 'RS232' serial it has each bit encoded as a variable pulse-width data stream ( any DCC experts are welcome to correct me if I've misunderstood ).

Getting that out of a PICAXE at the required rate could prove hard and probably impossible, but as always I'd liked to be proved wrong.

Before discovering the 18X could do high-speed serial, I had suggested using a long shift-register filled with desired bit levels which could be filled by bit-banging what would be the PWMOUT pin as the clock, then turning on PWMOUT ( or enabling another clocking source ) at the right rate to churn the data out. That would work but is complex hardware-wise.

One solution to bit-banging non-standard formats for the X1's / X2's ( a bit late to suggest it, I know ) would be to have a BITBANG command which interprets at high speed a sequence of commands which can be pre-loaded into SFR, Scratchpad, Table, Data Eeprom or somewhere. The stored commands could each be a byte -<code><pre><font size=2 face='Courier'> 0nnn nnnn : Wait N cycles
1000 -ppp : Clear Pin P
1001 -ppp : Set Pin P
1010 -ppp : Toggle Pin P
1100 -iii : Wait for In Pin I = 0
1101 -iii : Wait for In Pin I = 1
1111 ---- : Finished </font></pre></code> Plenty of scope there for a better thought out design, more complex or simpler.

I had primarily envisaged this as being useful for bit-banging out non Sony IR streams, but I guess there are other uses.

An alternative would be a block of bytes with the bit-stream in them, then simply spool them out at the desired rate.
 

robertc

New Member
250us instruction time! It cetainly will have trouble keeping up. That has saved me wading through the published literature to find out. Thats what these forums are very good at.Thanks one and all !!!
I guess I will have to struggle on with the pic and assembler. If only they wouldn't keep dying on me. If anyone reading this has experience with JDM type programmers and pic 16F84A's they might like to let me know if they have a habit of stopping the pic from being programmed after 2 or 3 goes.
regards
Bob Comerford


Edited by - bobcom on 21/04/2007 00:14:36
 
Top