Extraction int16 to bit

Hello
I'm looking for a function to extract the bits one by one from an int16 and and then work with conditionals.
for expemple : if (M%12.1 & M%12.4){ var etat = "degivrage";} then { var etat = "marche";}

I had with a "for" function and var bit1 = {payload: bitraw[1]}; as soon as I work on the "bitx" variables I am confronted with "msg.payload: undefined /
undefined"

On industrial automatons I will directly look for this variable. For example M%1260.6

Is there a function in java or pyton?

Blockquote
//my existing code
// init bit
var bitbrut = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

for (i = 0; i < 16; i++) {
bitbrut[i] = (msg.payload >> i) & 0x1;
}

var bit0 = { payload: bitbrut[0] };
var bit1 = { payload: bitbrut[1] };

if (bit0 = 1){
var etatcaisson = "arret";
}else {var etatcaisson = "marche";
}

return [etat, bit0, bit1 ];

//Ma_At %.0
//Demande_froid %.1
//Demande_ventilation %.2
//En_Degivrage %.5
//En_Egouttage %.6
//En_Glacage %.7
//En_Defaut %.8
//En_Vidange %.9
//Fermeture_volet %.10
//Ouverture_volet %.11
//Phase_froid %.12
//Rdm_Vent_degi %.14
//Rdm_Vent_froid %.13

I tried bit-simple-sixteen but it becomes too complicated with boolean blocks. I would like a function block that is easier to handle and more repeatable

Cordially

Or you can do it the low-code / no-code way using node-red-contrib-buffer-parser...

Setup...

Output...

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.