Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Syntax for DCC Packet for reverse light and airhorn

2399 views
6 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    October 2015
  • 188 posts
Syntax for DCC Packet for reverse light and airhorn
Posted by passenger1955 on Saturday, August 6, 2016 1:20 AM

I'm trying to learn about how to write DCC packet syntax. I would like to know the syntax for turning the reverse headlight on and off, and the F1 on and off. If I assume an address of 3, I believe the syntax for turning the headlight on is:

111111111111 0 00000011 0 10010000 0 10010011

and turning the light off is:

111111111111 0 00000011 0 10000000 0 10000011

Is there anyone who could help me with reverse light and airhorn. I am trying to educate myself on learning this syntax. Thanks.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Saturday, August 6, 2016 4:51 AM

have you looked at the NMRA S-9 DCC communication standards ?

it's odd that you describe the DCC packet in terms of binary bits and not in terms of the packet format and the fields in the packet.

From the standard, the DCC packet is composed of 4 parts: preamble, address, instruction and error detection -- 12-bit preamble followed by three 8-bit bytes preceded by 0s.

The 2nd byte is the instruction where it looks like the upper 3 bits are the instruction type and the remaining 5 bits the instruction data: CCCD DDDD. 

The error detection byte value will depend on the value of the address and instruction bytes.

in the packet you show, the 1st byte is value 3, the default address which will depend on the decoder address.   The CCC field in the 2nd byte is 100 and the DDDDD field 10000.

The instruction byte has two function group types.  It looks like function group 1, CCC = 100, is the one your interested in, but while the standard indicates this group controls headlights, it isn't specific about the data values for specific headlight.

if you have firmware that generates a binary packet based on address, CCC and DDDDD and generates the corresponding error detection value, you can easily generate any command you want.  Read through the standard.

greg - Philadelphia & Reading / Reading

  • Member since
    February 2007
  • From: Christiana, TN
  • 2,134 posts
Posted by CSX Robert on Saturday, August 6, 2016 7:24 AM

The horn is generally on F2, which is controlled by bit 1 of the instruction byte, so

111111111111 0 00000011 0 10000010 0 10000001

will turn the horn on and

111111111111 0 00000011 0 10000000 0 10000011

will turn the horn off.  Remember, however, that you have to OR the bits of the functions that you want on, so if have the headlight on and want to blow the horn you have to use 

111111111111 0 00000011 0 10010010 0 10010001 (F0 on and F2 on)

or the headlight will turn off when you blow the horn.

The reverse light will depend on how the decoder is programmed.  If it is set for directional lighting (the usual default), then when you send a reverse speed/direction command the headlight command will control the reverse light.  If it is not set for directional lighting, then it depends on the function that the rear llight is programmed for. 

  • Member since
    October 2015
  • 188 posts
Posted by passenger1955 on Saturday, August 6, 2016 12:46 PM

Thanks so much Robert. Is there a list of which bit in the instruction byte controls which F(0,1,2...)?

The decoder I am driving for test purposes is a SoundTraxx. They describe the lights as F0f for front light and F0r for rearlight.Maybe that means they have directional lighting turned on?

Thanks so much for your help.

  • Member since
    February 2007
  • From: Christiana, TN
  • 2,134 posts
Posted by CSX Robert on Saturday, August 6, 2016 2:11 PM

It's in the NMRA Standards and Recommended Practices (http://www.nmra.org/index-nmra-standards-and-recommended-practices) under "S-9.2.1 DCC Extended Packet Formats".

F0 (also called FL) is controlled by bit 4 and F1 - F4 are controlled by bits 0-3.

Yes, F0f and F0r refer to F0 when setup to be directional.

  • Member since
    October 2015
  • 188 posts
Posted by passenger1955 on Saturday, August 6, 2016 2:49 PM

Excellent. You've been so helpful. I think I have the basics.

One question. If I want to turn F5 off, do I send:

111111111111 0 00000011 0 10000000 0 10000011

or

111111111111 0 00000011 0 10110000 0 10110011

Appreciate it.

  • Member since
    February 2007
  • From: Christiana, TN
  • 2,134 posts
Posted by CSX Robert on Saturday, August 6, 2016 6:01 PM

111111111111 0 00000011 0 10110000 0 10110011

 

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!