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.
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
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
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.
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.
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.
Excellent. You've been so helpful. I think I have the basics.
One question. If I want to turn F5 off, do I send:
or
111111111111 0 00000011 0 10110000 0 10110011
Appreciate it.