Jump to content

Byte Array help with Control Box Communication

So I currently have a Sit-stand desk which uses a control box to control the linear actuators to make the desk move up and down. The manufacturer gave me a key on how to communicate with the control box. Here it is:

 

picture2.PNG.af243978f894553a73f2e3a81ffadcc7.PNG

 

1. What do I do with Byte 4 to make the desk go up? Look at key to the right for that Byte Description

 

2. Would I build a byte array with this?:

 

Byte 1: 0xD8

Byte 2: 0xD8

Byte 3: 0xff (This is the device ID)

Byte 4: What do I do for this to make the desk go up? Would I make bit 7, 6, 5, 4, 3, 2, and 0 a binary 0? Then would I keep the S+ a binary 1 because the key to the right says if S+ = 1 then it will move the desk up?

Byte 5: Needs to be the same as Byte 4

 

Once I'm finished with Byte 4, would I convert all those one's and zero's to hexadecimal? 

 

Thanks!

Tech enthusiast and CS Student

 

 

 

 

 

Link to post
Share on other sites

On 1/10/2018 at 2:04 AM, CmzPlusHardware said:

Byte 4: What do I do for this to make the desk go up?

Byte 4 bit 1 has to be set to true.

On 1/10/2018 at 2:04 AM, CmzPlusHardware said:

Would I make bit 7, 6, 5, 4, 3, 2, and 0 a binary 0? Then would I keep the S+ a binary 1 because the key to the right says if S+ = 1 then it will move the desk up?

Yes. 1 means function is enabled, 0 means it is disabled.

On 1/10/2018 at 2:04 AM, CmzPlusHardware said:

Once I'm finished with Byte 4, would I convert all those one's and zero's to hexadecimal? 

That's not how numbers work...

 

Some code to make your life easier :

#define _DESK_BIT7_  0x80
#define _DESK_BIT6_  0x40
#define _DESK_BIT5_  0x20
#define _DESK_BIT4_  0x10
#define _DESK_BIT3_  0x08
#define _DESK_BIT2_  0x04
#define _DESK_BIT1_  0x02
#define _DESK_BIT0_  0x01

To enable function bit you have to bitwise or them :

int8_t Byte4 = _DESK_BIT1_ | _DESK_BIT2_ | _DESK_BIT5_;

If you only want to enable bit one :

int8_t Byte4 = _DESK_BIT1_;

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×