# CANBUS Output multiple switch states to a single byte

**URL:** https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186
**Category:** ADU
**Created:** [August 30, 2024, 11:33am UTC](https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186 "2024-08-30T11:33:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jimster](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ecumaster.com/jimster/32/1922_2.png) [@Jimster](https://community.ecumaster.com/u/Jimster)
#### Post date: [August 30, 2024, 11:33am UTC](https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186/1 "2024-08-30T11:33:40Z")

</div>

I’m trying to output switch states to an emerald k6 ECU. Here is the info for the Ecu :

 ![IMG_1392](https://europe1.discourse-cdn.com/flex013/uploads/ecumaster/original/2X/a/a0b1b21c4616c1a17a615da6aa6cc798ad8951c8.jpeg)

I don’t see an easy way to combine multiple switch states into a single byte, certainly not on the CANbus Export page – it seems to be x1 value per channel.

Is there way around this? Any help would be mega!  
[Emerald CAN protocol5.pdf](https://community.ecumaster.com/uploads/short-url/2t0dFcbwEQLwlmTpEwYN0pR7JVK.pdf) (41.3 KB)

---

<div class="post-metadata">

### Author: ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://community.ecumaster.com/u/Greg)
#### Post date: [August 30, 2024, 12:38pm UTC](https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186/2 "2024-08-30T12:38:44Z")

</div>

you need to use number function and multiply status by value corresponding to bit number  
so bit 0 is 1, bit 1 is 2, bit 2 is 4, bit 3 is 8, bit 4 is 16, bit … bit 7 is 128

---

<div class="post-metadata">

### Author: ![Jimster](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ecumaster.com/jimster/32/1922_2.png) [@Jimster](https://community.ecumaster.com/u/Jimster)
#### Post date: [August 30, 2024, 2:50pm UTC](https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186/3 "2024-08-30T14:50:06Z")

</div>

Thanks Greg, I’m not sure I follow, is there any possibility of you please showing me an example ??

---

<div class="post-metadata">

### Author: ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://community.ecumaster.com/u/Greg)
#### Post date: [August 30, 2024, 3:29pm UTC](https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186/4 "2024-08-30T15:29:42Z")

</div>

like below please note status need to be 0 or 1 no other value  
on the picture missed status 4 will be multiplied by 8

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/ecumaster/original/2X/9/988cb8b0181c750e32ef522fc8c55d11253a1a2a.png)

---

<div class="post-metadata">

### Author: ![Jimster](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ecumaster.com/jimster/32/1922_2.png) [@Jimster](https://community.ecumaster.com/u/Jimster)
#### Post date: [September 3, 2024, 8:30am UTC](https://community.ecumaster.com/t/canbus-output-multiple-switch-states-to-a-single-byte/2186/5 "2024-09-03T08:30:00Z")

</div>

Thanks Greg, I’ll try and have a play, I’ll let you know how I get on.
