(Solved) RMT driver for software UART with 22 bit data possible?

User avatar
ok-home
Posts: 98
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: RMT driver for software UART with 22 bit data possible?

Postby ok-home » Sat Nov 30, 2024 2:03 am

Hi
you can try
the code works with packet data

Code: Select all

 #define MAX_HBS_PACKET_SIZE 26 
 typedef struct { 
 hbs_packet_hdr_t packet_hdr;// hbs packet header 
 hbs_item16_t packet_data[MAX_HBS_PACKET_SIZE];// hbs packet data
  } hbs_packet_t;

encoding/decoding inside
timings are configurable in code
at least 25 bytes encoded in 22 bits it accepts in one packet
https://github.com/ok-home/hbs_rmt_serial/

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Sat Nov 30, 2024 3:49 am

ok-home wrote:
Sat Nov 30, 2024 2:03 am
Hi
you can try
the code works with packet data

Code: Select all

 #define MAX_HBS_PACKET_SIZE 26 
 typedef struct { 
 hbs_packet_hdr_t packet_hdr;// hbs packet header 
 hbs_item16_t packet_data[MAX_HBS_PACKET_SIZE];// hbs packet data
  } hbs_packet_t;

encoding/decoding inside
timings are configurable in code
at least 25 bytes encoded in 22 bits it accepts in one packet
https://github.com/ok-home/hbs_rmt_serial/
Great, it work at lease with RX data, I just tested with RX code only. Thank you for the code.

I see the code you are using the 16 bit item from the ring buffer (rmt_item16_t), it is not mention in any documents, it is rmt_item32_t 32 bit. Why not using standard 32?
I just using the code and it work, but I want to understands more about RMT

User avatar
ok-home
Posts: 98
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: RMT driver for software UART with 22 bit data possible?

Postby ok-home » Sat Nov 30, 2024 4:27 am

I see the code you are using the 16 bit item from the ring buffer (rmt_item16_t), it is not mention in any documents, it is rmt_item32_t 32 bit. Why not using standard 32?
I just using the code and it work, but I want to understands more about RMT
the type is defined in the code, it's local, I just feel more comfortable with it.

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Sat Nov 30, 2024 4:41 am

ok-home wrote:
Sat Nov 30, 2024 4:27 am
I see the code you are using the 16 bit item from the ring buffer (rmt_item16_t), it is not mention in any documents, it is rmt_item32_t 32 bit. Why not using standard 32?
I just using the code and it work, but I want to understands more about RMT
the type is defined in the code, it's local, I just feel more comfortable with it.
Yes, it is OK, your code running very stable, I never see data error in 1 hour.

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Sat Nov 30, 2024 2:32 pm

ok-home wrote:
Sat Nov 30, 2024 2:03 am
Hi
you can try
the code works with packet data

Code: Select all

 #define MAX_HBS_PACKET_SIZE 26 
 typedef struct { 
 hbs_packet_hdr_t packet_hdr;// hbs packet header 
 hbs_item16_t packet_data[MAX_HBS_PACKET_SIZE];// hbs packet data
  } hbs_packet_t;

encoding/decoding inside
timings are configurable in code
at least 25 bytes encoded in 22 bits it accepts in one packet
https://github.com/ok-home/hbs_rmt_serial/
In test it not show any error, but in the real like it show error, device from manufacturer from Japan.
Do you give me hint to improve the decode?

Code: Select all

E (69947) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (70365) P1P2 RCV: 241130 21:22:24.066 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (70416) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (70416) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=106
E (70637) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (70638) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=106
W (71105) P1P2 RCV: 241130 21:22:24.806 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (71156) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (71156) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (71765) P1P2 RCV: 241130 21:22:25.466 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (71816) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (71816) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=106
W (72285) P1P2 RCV: 241130 21:22:25.986 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (72336) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (72336) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (72605) P1P2 RCV: 241130 21:22:26.306 : 00 f0 30: 20 2b b0 00 20 10 20 10 02 82 00 6c da 70 0d 00 52 cc 28 22 
I (72622) HBS RMT: Sent Data at: 241130 21:22:26.323  for 30
W (73145) P1P2 RCV: 241130 21:22:26.846 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (73196) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (73196) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
E (73417) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (73417) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (73885) P1P2 RCV: 241130 21:22:27.586 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (73935) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (73936) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (74545) P1P2 RCV: 241130 21:22:28.246 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (74595) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (74596) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (75065) P1P2 RCV: 241130 21:22:28.766 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (75115) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (75116) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=106
W (75379) P1P2 RCV: 241130 21:22:29.079 : 00 00 11: 00 00 00 00 00 18 e4 00 00 00 00 40 00 00 a0 
I (75380) HBS RMT: Main controller temperature: 24.89 Count: 13
E (75426) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (75427) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=103
W (75845) P1P2 RCV: 241130 21:22:29.546 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (75895) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (75896) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
E (76117) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (76118) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (76585) P1P2 RCV: 241130 21:22:30.286 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (76635) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (76636) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
W (77225) P1P2 RCV: 241130 21:22:30.926 : 00 00 10: 00 62 02 19 00 51 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (77275) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (77276) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105
And if running both TX and RX in real time, send data after receive 30ms, the data receive on other side wrong, It is ok if send slow without receive and send only.

Example when send only the other side can receive the data

Code: Select all

00 f0 38: 01 00 62 02 1b 00 17 02 1b 00 14 01 00 08 10 c0 38 18 c7
But after active both send and receive the other side only receive:

Code: Select all

 fd fd ff: fc f8 fb f0 e3 80 f1 e0 e3 80 0a 01 00 08 10 c0 38 18 c7 
 or
 37 fe f8: f0 f6 e0 e3 80 f1 e0 e3 80 0a 01 00 08 10 c0 38 18 c7 
 81 1b 00: 17 02 1b 00 14 01 00 08 10 c0 38 18 c7
 
And random with other wrong data.

User avatar
ok-home
Posts: 98
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: RMT driver for software UART with 22 bit data possible?

Postby ok-home » Sat Nov 30, 2024 10:13 pm

E (72336) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (72336) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105

Code: Select all

#define RX_PULSE_LOW_LVL_DELAY_COMPENSATION (5)
#define TX_BIT_DIVIDER (102) // 1042 // esp32_hbs=100

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Mon Dec 02, 2024 10:15 am

ok-home wrote:
Sat Nov 30, 2024 10:13 pm
E (72336) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=98
E (72336) HBS RMT: receive frame err START bit 1 lvl=1, bit_in=1,dur=105

Code: Select all

#define RX_PULSE_LOW_LVL_DELAY_COMPENSATION (5)
#define TX_BIT_DIVIDER (102) // 1042 // esp32_hbs=100
But it is not working with other value than the original. Can we accept more value like 93 to 107 (I see in the real signal) than fixed value in your code? I try with RX_PULSE_LOW_LVL_DELAY_COMPENSATION from 1 to 10 but none of them work with the real signal, both for RX_PULSE_LOW_LVL_DELAY_COMPENSATION and RX_PULSE_HIGH_LVL_DELAY_COMPENSATION

User avatar
ok-home
Posts: 98
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: RMT driver for software UART with 22 bit data possible?

Postby ok-home » Mon Dec 02, 2024 12:06 pm

#define RX_BIT_DIVIDER (100)
// min duration on log ( dur_of_0 = 93 ) compensation = 100-(10 оr 15) ---- RX_BIT_DIVIDER - RX_PULSE_LOW_LVL_DELAY_COMPENSATION must be less than the minimum dur_of_0
#define RX_PULSE_LOW_LVL_DELAY_COMPENSATION (15)

// min duration on log ( dur_of_1 = 103 ) compensation = 100+0 ---- RX_BIT_DIVIDER - RX_PULSE_HI_LVL_DELAY_COMPENSATION must be less than the minimum dur_of_1
#define RX_PULSE_HI_LVL_DELAY_COMPENSATION (0)

i see
low lewel = 98 hi level 106 98+106 = 204/2 ( middle ) 102 - RX_BIT_DIVIDER = (100)

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Mon Dec 02, 2024 12:24 pm

ok-home wrote:
Mon Dec 02, 2024 12:06 pm
#define RX_BIT_DIVIDER (100)
// min duration on log ( dur_of_0 = 93 ) compensation = 100-(10 оr 15) ---- RX_BIT_DIVIDER - RX_PULSE_LOW_LVL_DELAY_COMPENSATION must be less than the minimum dur_of_0
#define RX_PULSE_LOW_LVL_DELAY_COMPENSATION (15)

// min duration on log ( dur_of_1 = 103 ) compensation = 100+0 ---- RX_BIT_DIVIDER - RX_PULSE_HI_LVL_DELAY_COMPENSATION must be less than the minimum dur_of_1
#define RX_PULSE_HI_LVL_DELAY_COMPENSATION (0)

i see
low lewel = 98 hi level 106 98+106 = 204/2 ( middle ) 102 - RX_BIT_DIVIDER = (100)
3% the time it show error, I mean cover how to cover 3% off that or reduce it, whatever value I set it worse than value set by RX_BIT_DIVIDER only, two other set 0

Code: Select all

E (4866296) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (4866297) HBS RMT: receive frame err START bit 0 lvl=1, bit_in=1,dur=106
E (4866301) HBS RMT: data len: 222, cnt_byte: 24, error_cnt: 2
E (4866395) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=96
E (4866396) HBS RMT: receive frame err START bit 0 lvl=1, bit_in=1,dur=106
E (4866400) HBS RMT: data len: 24, cnt_byte: 3, error_cnt: 2
W (4866471) P1P2 RCV: 241202 18:28:45.739 : 00 00 10: 00 62 02 1b 00 31 00 00 00 00 00 00 00 80 40 01 00 00 00 00 
E (4866521) HBS RMT: receive frame err START bit 0 lvl=0, bit_in=0,dur=99
E (4866522) HBS RMT: receive frame err START bit 0 lvl=1, bit_in=1,dur=105

User avatar
ok-home
Posts: 98
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: RMT driver for software UART with 22 bit data possible?

Postby ok-home » Mon Dec 02, 2024 12:50 pm

try
https://github.com/ok-home/hbs_rmt_ser ... al.c#L121
and
#define RMT_RX_IDLE_THRES (5000) // from 2400 to 10000

Who is online

Users browsing this forum: Majestic-12 [Bot] and 107 guests