PDA

View Full Version : State PID Question



Black02SS
March 14th, 2006, 01:22 PM
I have tried to read but I can't find this information. How would I create a calculated PID from STATE02:

Description Status=0 Status=1
Unused - -
Extended Travel Brake Pedal Switch Released Applied
Unused - -
Reverse Inhibit No Yes
Cruise Brake Pedal Switch Released Applied
Clutch Pedal Switch Released Applied
VAT Fuel Disable Inactive Active
Traction Control Status Inactive Active

I see that a value of 0 is Released and 1 is Applied. I am trying to make it so I can see the values on the chart display and in a map.

Thanks

joecar
March 14th, 2006, 02:20 PM
Edit: the red one above was thought to be bit 5, but it turns out to be bit 2.


The red one is bit 2 (bits are numbered starting from 0, starting from the bottom).

2^2 = 4

So you could use either of these in your calc pid:

iff({GM.STATE02} & 4, 1, 0)
{GM.STATE02} / 4 & 1
{GM.STATE02} >> 2 & 1

The first one says: if the bit with value 4 is on, return 1, else return 0.

The second one says: divide by 4 (i.e. shift right 2 bits), and then keep the lowest bit (throw away other bits).

The third one says: shift right 2 bits and then keep the lowest bit.

Edit: Paul says below that the raw value of the pid is required before it is operated on, so the above become:

iff(raw({GM.STATE02}) & 4, 1, 0)
raw({GM.STATE02}) / 4 & 1
raw({GM.STATE02}) >> 2 & 1

Black02SS
March 14th, 2006, 04:43 PM
I have tried this here and still can't get it to show the right values. Anymore ideas? What are you using for the "units" in the pid file? I am trying to understand where you got 32 from in this equation and Paul got 128 for the other DFCO one.

Black02SS
March 14th, 2006, 08:38 PM
Ok I did some more testing on this and I can't get it to work at all. I keep returning a constant value. Anymore ideas on this?

Blacky
March 14th, 2006, 09:27 PM
There may be a problem working with bitfields in calculated PIDs. It is still being tracked down.
Paul

Blacky
March 14th, 2006, 09:53 PM
The red one is bit 5 (bits are numbered starting from 0).

2^5 = 32

So you could use either of these in your calc pid:

iff({GM.STATE02} & 32,1,0)
{GM.STATE02} / 32 & 1

The first one says: if the bit with value 32 is on, return 1, else return 0.

The second one says: divide by 32 (i.e. shift right 5 bits), and then keep the lowest bit.
Ok, the problem is that you need the "raw" value of the STATE PIDs before you can apply bit-logic, like this:

iff(RAW({GM.STATE02})&32,1,0)
RAW({GM.STATE02}) / 32 & 1

The values (32 and 128) are used so that they match the value of a bit positionin the PID's value. 32 is bit 5, 128 is bit 7.

Bit position 7 = 128
Bit position 6 = 64
Bit position 5 = 32
Bit position 4 = 16
Bit position 3 = 8
Bit position 2 = 4
Bit position 1 = 2
Bit position 0 = 1

The above order is the order that the bit values are listed when you select "More info..." to display the STATE value bit flags.

Regards
Paul

Black02SS
March 14th, 2006, 09:59 PM
Ok, the problem is that you need the "raw" value of the STATE PIDs before you can apply bit-logic, like this:

iff(RAW({GM.STATE02})&32,1,0)
RAW({GM.STATE02}) / 32 & 1

The values (32 and 128) are used so that they match the value of a bit positionin the PID's value. 32 is bit 5, 128 is bit 7.

Bit position 7 = 128
Bit position 6 = 64
Bit position 5 = 32
Bit position 4 = 16
Bit position 3 = 8
Bit position 2 = 4
Bit position 1 = 2
Bit position 0 = 1

The above order is the order that the bit values are listed when you select "More info..." to display the STATE value bit flags.

Regards
Paul
Thanks. Here is something. I used your pid and it didn't work, but I started thinking about the values you have and the More info in the pid. I calculated down and it said that Clutch Pedal Switch Release was at BIT position 2, so I used 4 and BINGO, it works. Did I do something wrong? Thanks Paul!

joecar
March 15th, 2006, 03:36 AM
Chad,

Sorry, I had the order of the bits reversed (I counted from the top instead of from the bottom)... :doh2:

see my edit to post #2.