Digital and PWM input : Jumping Byte information ?? in the recieved string
retlaw
Posts: 2
2 Xbee programmed for
Base station
D0 4 = digtal output default LOW
P1 2 = PWM Output
D2 4 = digtal output default LOW
Remote station:
D0 = digital input
D1 = Analog input
D2 = digital input
When I read the recieved string with a program on PC.
I can see that the first byte after the channel indicator ( character 8 ) (counting from the startbyte (0x7E) as 1st byte )
1. Byte 9 disappears when when D0 and D2 are both = zero
when one of the two digital inputs are 1 the byte is available again
2. When the PWM reading ( max reading 0x3FF ) drops below 255 the first byte disappears also until the the value goes a litlle bit higher
and the two bytes are available again.
This change in total number of bytes makes it very difficult ( practicly impossible ) to incorperate it in a program because the bytes
containig the information i want to read changes in position depending on the value ( 0 = byte not avalable, 0 > byte avalable.
A possible solution would be :
take a third Digital input kept ( e.g. D3 ) constant on 1
take care that the Analog input doesn't reach a value below 0x10
Are there other posibilities to avoid the "Byte shifting ??
Base station
D0 4 = digtal output default LOW
P1 2 = PWM Output
D2 4 = digtal output default LOW
Remote station:
D0 = digital input
D1 = Analog input
D2 = digital input
When I read the recieved string with a program on PC.
I can see that the first byte after the channel indicator ( character 8 ) (counting from the startbyte (0x7E) as 1st byte )
1. Byte 9 disappears when when D0 and D2 are both = zero
when one of the two digital inputs are 1 the byte is available again
2. When the PWM reading ( max reading 0x3FF ) drops below 255 the first byte disappears also until the the value goes a litlle bit higher
and the two bytes are available again.
This change in total number of bytes makes it very difficult ( practicly impossible ) to incorperate it in a program because the bytes
containig the information i want to read changes in position depending on the value ( 0 = byte not avalable, 0 > byte avalable.
A possible solution would be :
take a third Digital input kept ( e.g. D3 ) constant on 1
take care that the Analog input doesn't reach a value below 0x10
Are there other posibilities to avoid the "Byte shifting ??
Comments
The short answer: yes there are ways to deal with your "byte shift"; probably by using the formating options in the SERIN,SEROUT commands to ensure all numbers are 2 characters, or 3 characters or whatever.
But, we can't do it without seeing your code, and preferably a schematic of what your circuit looks like.
Cheers,
Test schematic :
It is not a question of coding but the jumping bytes : How could I know wich byte is disappearing
the byte with digital IN info ( when D0 & D2 equal zero ) or the analog value with a value smaller than 255
the analog value with a value smaller than 255 = 1 Byte (0xFF) , 256 > 2 Byte ( 0x100 )
D0 = 1 & D2 = 0 ANALOG in > 255
D0 = 0 & D2 = 0 ANALOG in > 255
D0 = 0 & D2 = 0 ANALOG in < 255
Char
Hex
VALUE
Byte pos
Char
Hex
VALUE
Byte pos
Char
Hex
VALUE
Byte pos
Start Delimiter
~
7E
126
1
~
7E
126
1
~
7E
126
1
Length Bytes
C
12
2
C
12
2
C
12
2
API Identifier
83
131
3
83
131
3
83
131
3
Source Address Bytes
2
2
4
2
2
4
2
2
4
RSSI Value Bytes
27
39
5
27
39
5
27
39
5
Option Byte
1
1
6
1
1
6
1
1
6
Sample Quantity Byte
4
4
7
4
4
7
4
4
7
Channel Indicator *
5
5
8
5
5
8
5
5
8
PWM value HIGH byte
1
1
9
2
2
9
w
F7
247
10
PWM value LOW byte
2
2
10
w
77
119
10
**
**
**
11
Check Sum
w
77
119
11
**
**
**
11
**
**
**
12