Replies: 3 comments
-
The investigations were continued. A setup with a TSAL6200 IR emitting diode and an NPN transistor was not satisfactory. The loose wiring on the breadboard also resulted in poor signal quality, so I now soldered this circuit onto a hole pattern board. The control of the diodes now works well, but I found that the 200µs burst was sometimes too long, and the pauses were also not consistent. Further attempts were made by replacing the one-shot-timer mimic with delayMicroseconds() pauses. I also blocked the interrupts using critical sections for the duration of the transmission. And last but not least, I found an error when extracting the data bits. Of course, they have to be read out in the opposite direction. Code-Snippet from beo4_tx_task() showing the for(;;) { // wait until beoCodes arrive at queue
if(pdTRUE != xQueueReceive(beo4->m_beo4_tx_queue,&beoCode,portMAX_DELAY)) {
ets_printf("TaskBeoTx().xQueueReceive() failed ");
continue;
}
// generate carrier pulses and pauses according to beoCode
taskENTER_CRITICAL(&my_spinlock);
beo4->tx_pc(bZero); // send start sequence: 1,1,5
beo4->tx_pc(bZero);
beo4->tx_pc(bStart);
beo4->tx_pc(bZero); // send beoLink (always bZero)
curBit=preBit=0; // init current and previous Bit
for(jc=15,ic=0;ic<16;ic++,jc--) { // generate 16 data bits of BeoCode
uint8_t pulseCode=0;
curBit=(beoCode>>jc) & 1;
if(curBit==preBit) pulseCode=bSame;
else if(1==curBit) pulseCode=bOne;
else pulseCode=bZero;
preBit=curBit;
beo4->tx_pc(pulseCode); // send pulsecode for current Bit
}
beo4->tx_pc(bStop); // send stop code
beo4->tx_pc(0); // finish frame with final carrier pulse
taskEXIT_CRITICAL(&my_spinlock);
} unsing delayMicroseconds() instead of one-shot-timers inline void tx_pc(uint8_t pulsecode) {
uint32_t pulse_width=(uint32_t)(((uint64_t)pulsecode*t_pc)-t_low_pulse);
ledcWrite(m_tx_pin,8); // turn carrier on
delayMicroseconds(200);
ledcWrite(m_tx_pin,0); // turn carrier off
if(0 < pulsecode) { // no timer for the final carrier-pulse
delayMicroseconds(pulse_width);
}
} --> See commit ec979dc I was able to successfully send from one ESP32 + TSAL6200 and receive with a second ESP32+TSO7000. I will provide the sources for the two main.cpp. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Here I would like to share ideas for testing the transmit routine.
The frame consists of 455kHz bursts (about 200µs) followed by pauses. The length of the pause is determined by the pulse code, e.g. 3125µs for a
BEO_ZERO
. For the burst the ESP32 must generate a PWM signal with a 50% pulse/pause ratio and a frequency of 455kHz. During the pauses, the ratio is set to 0, then the output signal remains low.The platformio IDE somehow does not support the newer Version. It's a shame that the espressif people let platformio down like this. To use the newer boards like ESP32-C6 and so on you have to switch to the pioarduino repository. The platformio.ini must explicitly refer to this platform, like so:
I will therefore rely on this platform and adapt the functions affected by the migration, e.g. ledcSetup() does not exist anymore and is included within ledcAttach(). And the channel is selected automatically.
old
new
example of BEO_SRC_AUDIO - BEO_CMD_RADIO frame
detail of 455kHz burst
Beta Was this translation helpful? Give feedback.
All reactions