# I am unable to read the Cvs



## RovDan (Feb 4, 2019)

Hello everyone,

I have built a DIY Command Station 10 years ago. It works very fine. I can send all the Cvs I want. However, I work in blind mode.

Now, I want to read to the Cvs Decoders. For that, I spent time to read the NMRA recommanded pratices RP9xxxx.

I set a 47 ohms resistor beetween my programming Track and my command station. I set then a scope to catch the ACK pulse on this resistor.

When I change a Cv, I see this ACK pulse without problem. Moreever, I noticed this pulse is only visible for the first Packet. This means that the decoder seems not ACKing if the Cv doesn't change.

Now, my next project is to read the Cvs. If I did'nt make a mistake, the NMRA norm tells the correct packet is :

Preamble 0 AD1 0 AD2 0 1110CCVV 0 VVVVVVVVV 0 DDDDDDDD 0 EEEEEEEE 1
WHERE CC=10 (manipulation bit)
V = Cv number -1
D=111 0 B PPP
where 0= verify bit
B=0 if I want to search a 0 (B=1 for a 1)
PPP=000 if I want to read the LSB bit or 111 for read the MSB bit

So, on my opinion, my packet would be : PR 0 AD1 0 AD2 0 232 0 4 0 224 0 EEEEEEEE 1 if I want to ask if the LSB bit of Cv 3 is 0

Unfortunately, I never noticed the ACK although I am sure due to my Cv, it would give me an ACK.
If somebody could tell me where my mistake is, I would be very happy.

Best regards

RovDan
www.roverch.net/modelisme/Modelisme.html


----------



## gunrunnerjohn (Nov 10, 2010)

You got stuck in moderation, I set you free.


----------



## gregc (Apr 25, 2015)

can you post a link to the NMRA spec describing how to read a CV?

and can you clarify what the procedure is. is the ack acknowledging that a packet has been received or is it in response to a query that a particular bit in a CV is set?


----------



## mopac (Feb 24, 2011)

I have a digitrax DCC. I do not know or understand your formulas. Way above my pay grade. I do know that I have to use a program booster to read some decoders. I do understand what you mean of being in the blind. What current CV value is. My booster
goes inline with wires to programming track. If you could find what the programming
booster does that might help you.

Welcome to the forum.


----------



## CTValleyRR (Jul 26, 2014)

Yeah, that's why I let the fine engineers at MRC do all the programming to read CV's for me.

Sorry I can't help.


----------



## RovDan (Feb 4, 2019)

*I am unable to read a Cv*

Hi,

For me, the Model railroad Hobby is not only running trains in a nice background. It's also to study both DIY software and hardware.

Many times in this adventure, I have been stopped by a problem. After spending hours to resolve it, every time, I finally found the solution. It's a good challenge. It's a part of the hobby.

Just a question about this forum : why does a post need hours to be posted ?

Best regards,

RovDan
www.roverch.net/modelisme/Modelisme.html


----------



## wvgca (Jan 21, 2013)

RovDan said:


> Just a question about this forum : why does a post need hours to be posted ?



if you are a new user .posts are moderated to help reduce spam ..once you hit 5 or 10 posts [don't know which], that restriction is removed


----------



## RovDan (Feb 4, 2019)

Many thanks Wvgca for your reply

RovDan


----------



## gregc (Apr 25, 2015)

RovDan

i'm curious about your problem and how decoders report the values of CVs. Can you provide a link to the spec you referenced in your original post?


----------



## wvgca (Jan 21, 2013)

gregc said:


> RovDan
> 
> i'm curious about your problem and how decoders report the values of CVs. Can you provide a link to the spec you referenced in your original post?



rough idea is under nmra recommended practices, section 9, electrical ..
not sure which sub section


----------



## RovDan (Feb 4, 2019)

A previous post explained my Cv's calcul. Unfortunately, it's still in moderation, not the Cv but the post....

Here's the link to the recommanded pratices for the DCC messages

https://nmra.org/sites/default/files/s-9.2.1_2012_07.pdf

Best regards,

RovDan
www.roverch.net/modelisme/Modelisme.html


----------



## gregc (Apr 25, 2015)

where is the spec describing how to recognize the acknowledgement with a 47 ohm resistor?


----------



## RovDan (Feb 4, 2019)

The specs about ACK are here :

https://nmra.org/sites/default/files/s-9.2.3_2012_07.pdf

To see the increasing current, you need a 47 ohm resistor (value used by most modelers) beetween CS and programming track

Best regards

RovDan
www.roverch.net/modelisme/Modelisme.html


----------



## gregc (Apr 25, 2015)

thanks


----------



## gregc (Apr 25, 2015)

RovDan said:


> So, on my opinion, my packet would be : PR 0 AD1 0 AD2 0 232 0 4 0 224 0 EEEEEEEE 1 if I want to ask if the LSB bit of Cv 3 is 0


i'm not sure how to interpret the above value because it seems to be a mix of binary, hex and symbols

i believe the packet should be

pre 0 01111000 0 00000011 0 11100000 0 EEEEEEEE 1
..........CCAA...AAAAAAAA......KDBBB

CC is bit manipulation, 10
AA is addr, 3
K is bit verify, 0
D is bit value, 0
BBB is bit position, 0


----------



## RovDan (Feb 4, 2019)

*Still unable to read a Cv*

Hi Gregc ... and the others.

Your packet seems wrong because you doesn't tell to te decoder wich Cv you ask for :

So, except if I make a mistake

- Pre
- 0
- Byte 1 : Decoder adress dec=3 (short address)
- 0
- Byte 2 : CV Access Instruction : bin1110CCVV
where CC=bin 10=dec8 : Bit manipulation
and VV=00 MSB Cv=bin00
so Byte 2= bin11101000 = dec232
- 0
- byte 3 LSB CV address
for Cv29 byte3 = dec28 (Cv-1)
- 0
- byte 4 =Datas = 111CDBBB
where C=bin0 (verifyBit)
D=0 we search a 0 value 
BBB=0 position bit (we search the first bit)
so byte 4= dec 224
- 0
- byte 5 is the Xor control byte = dec23 (if no error)

I think the DCC Msg should be : Pre 3 0 232 0 28 0 224 0 23 

Do you agree this calculation ?

Best regards and thanks for your patience ...

RovDan
www.roverch.net/modelisme/Modelisme.html


----------



## gregc (Apr 25, 2015)

RovDan said:


> I think the DCC Msg should be : Pre 3 0 232 0 28 0 224 0 23
> 
> Do you agree this calculation ?


i don't know how to read this. can you express binary?

page 2 of the spec describes AAA as the configuration variable address


----------



## RovDan (Feb 4, 2019)

*Still unable to read a Cv*

GregC

I think you make a mistake about the address. In page 2, line 62, we can read :
{preamble} 0 [ AAAAAAAA ] 0 {instruction-bytes} 0 EEEEEEEE 1 

- The first byte is the Locomotive decoder adress [not the CV address] so, 3 in our case. In binary it's 00000011

The three next bits are for instruction bytes : 
Line 376, we can read :
1110CCVV 0 VVVVVVVV 0 DDDDDDDD 

- second byte :
1110CCVV
CC = 10 (binary) for manipulation bit
VV are the most significant bits for the CV ADDRESS ( for Cv >255). So here, VV=00 (binary
So the second byte is : 11101000 (binary) or 232 (decimal) 

- third byte
VVVVVVVV (the CV address-1 as we can read in lines 379/380)
So we have Cv29-1=28 (decimal) - or 00011100 (binary)

- fourth byte
DDDDDDDD the detail of this byte is on line 385 :
111CDBBB
C=0 (binary) as we veriify a bit 
D=0 (binary) as we search a 0 value bit
BBB=000 (binary as the bit I search is the Low significant bit)

So the fourth byte should be 11100000 (binary) or 224 (decimal)

- fifth byte is the XOR of the four previous bytes My calculator says :

3 XOR 232 XOR 28 XOR 224 = 23 (decimal) or 00010111 (binary)

The binary packet should be Pre 0 00000011 0 11101000 0 00011100 0 11100000 0 00010111

The decimal packet should be : Pre 0 3 0 232 0 28 0 224 0 23

However, this packet seems doesn't satisfy two different decoders. The question : where do I make a mistake ?

It's frustrating because I can see the ACK pulse when I modify a Cv.... but not when I ask the decoder.

Sorry for my English, Many thanks

RovDan


----------



## gregc (Apr 25, 2015)

RovDan said:


> CC = 10 (binary) for manipulation bit


i think the bit manipulation command is described on line 130 and has a unique format


----------



## RovDan (Feb 4, 2019)

*Reading Cvs value*

Hi GregC, Hi everybody,

Thanks, GregC for your reply. I think, you are right. I will try to send this kind of packets in Service Mode rather than in Operation mode.

I benefit this post for ask to everybody who owns a Command station :

When you ask your Command station to display the Cv Value of a Locomotive decoder, you do it on the main track or on the programming track ?

Best regards

RovDan
http://www.roverch.net/modelisme/Modelisme.html


----------



## gregc (Apr 25, 2015)

RovDan said:


> When you ask your Command station to display the Cv Value of a Locomotive decoder, you do it on the main track or on the programming track ?


line 12 of the Service Mode spec says "on an isolated section of track".

since current is being used to communicate, only one decoder should be active.


----------



## wvgca (Jan 21, 2013)

RovDan said:


> When you ask your Command station to display the Cv Value of a Locomotive decoder, you do it on the main track or on the programming track ?



i have a MRC Prodigy 2, and i know the read works on the programing track... write will also work on the main track, but i haven't tried the read


----------



## J.Albert1949 (Feb 3, 2018)

With the Roco z21 system, I just "program on the main". Seems to work just fine. The Roco software makes this "child's play" simple.

I _-DO-_ make sure that all other engines are either:
- in isolated sidings that are "power routing" (i.e., they can't receive power/program code)
_or_
- off the track.

But once done, the z21 doesn't care. I _don't_ select "program on the main" (although there is a choice for this). I just treat the entire main as "my programming track". The layout is compact enough for this to work without problems.


----------



## gregc (Apr 25, 2015)

i don't think there's any reason you cannot program a CV on a particular decoder using its address either on the main with other decoders present or on the programming track.

but when reading a CV, which relies on a momentary increase in current being drawn, you want just a single decoder on the programming track. the decoder pulses the motor to draw the increased current.


----------

