Jump to content

CV 29 Check Bit 4


Pete172

Recommended Posts

Hi All,

I wish to check if CV29 bit 4 is set , within a LokSound V4 sound decoder.

From the Loksound manual, if bit 4 is set, then a detailed speed curve may be set/ already exist in CV's 67 - 94.

I am using Railmaster& Elite to read CV's, but when I read Cv 29, it only returned a value of 002, and a status /string 99 20 29 2 104, no info about Bits at all.

So - how can I read what Bits are set at when I read CV29 ? (I need to check if Bit 4 is set)

Also - what does the status /string 99 20 29 2 104 actually mean ?, I cant find any detail on this in the Railmaster manual.

Once I know if a complex speed curve (or simple 3 step speed curve CV2, 5 & 6) has been previously set within this decoder, then I can start to make adjustments- once I know what I'm dealing with ...

Any explanation or insight about this & how to proceed would be very welcome.

Many thanks,

Peter

Link to comment
Share on other sites

Pete, you can ignore the reference to "status /string 99 20 29 2 104" the penultimate 2 in that string is the decimal value of CV29, but knowing that will only confuse you more. Just concentrate on the decimal value reading the CV returns. In your case you have stated that this 2.

.

Have a look at this web Hyperlink. CV29 is explained far better here than in the Hornby manual. There is also an on-line calculator on that link that will convert your decimal 2 value into what actual settings have been set. In your case, decimal two is '128 Speed Steps' (needed for directional lighting to work).

.

Once you have grasped the concepts of 'bits' all should become clear, it really isn't difficult once someone explains it properly.

.

Also, in RM. If you click (or it might be a double click) the CV29 value box. A popup should appear with a simple 'check box' list. This feature is very similar to the calculator located on the linked page given above. I've just had a quick look at the online calculator and can see that to retain your '128 speed steps' ( CV29 value 2 [bit 1] ) and add 'Speed Curves ( CV29 value 16 [bit 4] ), you would add these two decimal numbers together and write decimal 18 to CV29. You will see how I arrived at this figure by looking at the linked page.

.

EDIT: Poliss got in with basically the same info and web link, whilst I was busy typing my longer reply.

Link to comment
Share on other sites

So that's all three of us then concurring and coming to the same conclusion to write 18 to CV29.

.

That in itself is absolutely fine, but I believe Pete would like to have a better understanding of the theory and mechanics of CV29, else he wouldn't have wrote:

.

"Any explanation or insight about this & how to proceed would be very welcome."

.

The fact that he is delving into the depths of the Loksound V4 decoder manual, not an easy read. Also, means that he is up for a more indepth explanation of CV29.

Link to comment
Share on other sites

 Hi,

I still need to digest what you have all said, just to understand it all...but many thanks.

The Loksound manual is full of statements like..set bit 4 to 1 in CV 124, .........etc etc..

How can I read bits ? How do I write bits (if needed ) ???

Thanks,

Peter...

Link to comment
Share on other sites

Pete,

Bit late in the day now, but I will try and put together a bits and bytes tutorial in a PDF document and upload it to my cloud service and post a link to it in this thread. Look for it tomorrow, probably afternoon (UK time).

Link to comment
Share on other sites

Pete............Bits are either on or off...that is # 0 meaning 'off'  and # 1 meaning 'on'.   Bit0 has a value of 1; B2 = 2; B3 = 4; B3 = 8; B4 = 16; B5 = 32.....If you want a Bit to be 'on' note it's value and add that value to any other Bit value to give the required number to type into the CV.........So in the case you mentioned, CV29, you want 128 speed steps 'on' that is value '2' in Bit2 and then you want Speed Curve 'on' Bit4 value= 16, so simply add the two values together.

.Where Loksound says set Bit4 to 1 it means turn it 'on' by adding the value 16 to any other 'on' value you have selected in that CV...........So you don't actually write Bits, just add their values together and write the CV.  HB.

Link to comment
Share on other sites

While Chris is writing his tutorial, let me give you the short version and correct HB's error as we go.  First, if we just think decimal, numbers are made up of units, 10s, 100s etc, as in the number 123 consisting of 3 units, 2 tens and 1 hundred.  Each of the units, 10s etc can have 10 values (0-9) hence the system is decimal.

 

In a binary system, you can have only 2 values, 0 and 1.  All numbers will be strings of 0s and 1s which are known as bits and for CVs and many other applications, we use 8 bits to make up a byte, or also known as a word, and from left to right they are bits 0-7.  The decimal values of each of these bits reading from left to right are powers of 2, bit 0 being 2 to the power 0=1, bit 1 is 2 to the power 1=2, bit 2 is 2 to the power 2=4 up to bit 7 is 2 to the power 7=128.  So each bit when set to 1 has a value of 2 to the power of its bit number (if it is set to 0, it's decimal value is also 0). And with our 8 bits we can have numbers with the decimal equivalent of 0-255.  If we write our 123 in binary, we will get 11011110.

 

So if we now go back to CV29, we can see what setting bits means and setting bit 1, speed steps, and bit 4, complex speed curves, means in decimal it has a value of 2 to the power 1 plus 2 to the power 4 = 2 + 16 = 18.

 

if you now understand that and go back to HB's post, you will see he has become slightly confused on his bit numbers in two places.  We are not setting bits 2 and 4, but bits 1 and 4.

 

Finally, when we need to set bits in CV29, we write into the CV the addition of the decimal values of those bit numbers.  QED.

 

I hope that helps and doesn't confuse.  And let's wait to see how Chris does it in his tutorial.

Link to comment
Share on other sites

 Wow.....this is verging on Bletchley Park / Alan Turing stuff....now it's really becoming complicated, specially after few beers in the pub !

Let me read this above again tomorrow with a clearer head...

N.B from what I quickly read above , I take it I don't actually read the "bits",  I should only calculate what they are /must be,  from the CV value ?

 

Thanks again for your time & effort taken to explain this.

Peter..

Link to comment
Share on other sites

Spurred on by posted expectations I got my finger out and wrote my tutorial tonight. Click the link to view and download.

.

Link deleted - new link posted in later post further below

.

Note: when the linked page opens, you should see a great big red square, click the red square. The PDF should open on screen, initially as a ‘thumb’ and then after a few seconds as a ‘full page’. There is a download link on the page to obtain an electronic copy.

.

PS - In essence, the tutorial says what Fishy has posted, but being a PDF it has the benefit of tables and graphics to explain it (hopefully) better. Any questions and points of clarification please come back and ask. If what I have written needs further work to aid clarity, more than happy to amend and update link.

Link to comment
Share on other sites

Loksound have already created an easy to understand table............just tick the value you select in each Bit, either a '0' or the number then add them together.....then change the CV to that result.......make sure you note on the page what you have done for future reference.  HB.

Link to comment
Share on other sites

Good one Chris, very clear.  Hopefully not only as I knew what you were talking about in the first place.

.

See tutorial issue 2 - new link in later post. The orignal link posted last night will no longer work. Added some extra clarity to Table 2 and added a new section on page 2. A few minor tweaks elsewhere.

.

For other's to note.......My tutorial is not meant as a replacement for any manufacturers decoder manual. I've written it to provide a 'first principles' understanding of Bits & Bytes technology (for those who want to know or have specifically asked for the detail), so that hopefully it will make the manufacturer manuals easier to read, understand and implement.

Link to comment
Share on other sites

Before someone tells me the previous link to my CV Tutorial doesn't work any more....I know. I have replaced it with an 'issue 2' document. The new link is below:

.

CV Bits Tutorial.PDF

.

13/11/2015 - issue 2

Hi Chris,

Different way of converting decimal to binary. We used to repeatedly divide by two, each time noting the remainder which would be 0 or 1. No need to know the powers of two - 64 32 16 8 etc.

Ray

Link to comment
Share on other sites

Thanks for the heads up and feedback Ray,

.

Based on your comment, I had a look at this

that explains the divide by 2 method. Yes it works, but to me looks a little bit more complicated for a novice to get their head around. Quite easy to demonstrate by video, but I think a lot more difficult to document a 'how to' in a purely text based document, else I would happily add it in as an additional alternative method on page 2

.

My reason for including the 'working back decimal to binary' example in my document on page 2 was to reinforce the contents of the tables on page 1. That is to show again the relationship between the 8 binary bits of the byte and their corresponding decimal values. I feel that by going off at a tangent into divide by 2 methodology might cause confusion.

Link to comment
Share on other sites

  • A more relevant calculation is where you have a CV value and from it you need to determine which Bits are on.
  •  Bit values.... Bit0=1   Bit1=2   Bit2=4   Bit3=8   Bit4=16   Bit5=32    
  • Say for example, a CV reads 19 and you want to see which features are 'on'.
  • The largest value that is less than 19 is 16....note Bit4 and deduct 16 from 19 = 3
  • The next value to subtract is 2, note Bit1.  The remainder is 1 so note Bit0
  • Therefore it is apparent that Bits 0, 1 and 4 are 'on' so the features they refer are active.

In reverse, if one wanted the features in Bits 0, 1 and 4 to be active then add the values. ie  1, 2 and 16...total 19 to be written to that CV

  • I hope this helps with understanding what, at the outset, looks a daunting task.   HB
Link to comment
Share on other sites

Much simpler to just go and look at the CV29 calculator poliss gave a link to on page 1 of this thread with the 2mm organisation. It does conversions both ways for you, binary to decimal and decimal to binary.  Especially if you've read and understand either my post or Chris's PDF. 

Link to comment
Share on other sites

  • A more relevant calculation is where you have a CV value and from it you need to determine which Bits are on.

.

That's precisely why I added a new page 2 section in my 'issue 2' document that explains that very process. What I would add, in agreement with Fishy's last repy, is that if ALL someone is interested in is CV29, then just use the online calculator or double click the CV29 value entry in RM. Going into my tutorial is purely for somebody who wants to understand the theory behind the Byte construction.

Link to comment
Share on other sites

Never that HB, your posts are always valued by me. Many a time we have both been on the same wavelength and singing from the same hymn sheet as I am sure you have noticed. Believe me, no offence intended at all. My intention in my reply was just to point out that I agreed with your suggestion that working back from decimal to binary was just as important as working the other way and that I had addressed that shortcoming in my version 2 tutorial document. That important aspect had been overlooked in my original version 1 doc. I'm currently working on a version 3 to address other shortcomings, but I'll be keeping that version in my 'back pocket' for posting another time. Don't want to upset Admin by keep asking him to make post amendments, I've already asked Admin to delete the original PDF link.

.

My comment about the online calculator was aimed at the casual forum reader who might be scared off by this extended indepth and highly technical set of posts in this thread. Not at you in any way shape or form.

.

Mind you all this is purely academic if Pete172 doesn't come back and read the posts. I'm sure he will at some stage, based on previous replies sounds like he is just time poor.

Link to comment
Share on other sites

 Chris,

Many thanks for writing up your tutorial, must have taken you a while..

I can now count in Binary ...yey!

What I didn't find clear at the start though, is what is a Byte ? is it just a group of 8 Bits ? is it always 8 or can it be another number.Maybe this could be made clear at the top of table 1...it may be but I wasn't seeing it at first.

Judging from your table 1, Bits 0 to 7 inclusive = 8 Bits ..correct ?..I studied table 1 for ages but didn't understand it well. I think table 2 is easier to understand, I even started to write out single decimal numbers & converting them into binary, I think this helps to understand it.

 

However, in view of the horrors happening in Paris at the moment, I don't feel like contemplating binary/ or trains just now, so I will collect my thoughts tomorrow, maybe still have one or two questions though.

Many thanks again,

Peter.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...