Here I am with the 8th update on my smart life challenge project, and I would first want to thank everyone who commented or emailed me about my previous update messages. Seeing that someone is out there watching my progress (and struggle with various issues) gives me a wonderful feeling and energy to work on this project.
This weekend I spent some time finalizing the front-end amplifier PCB design and I submitted it for fabrication. I have designed this PCB to be plugged into J2 connector of the PSoC4 Pioneer kit, and below I am showing a picture of a printout of the PCB layout next to J2 connector:
I expect to receive the bare board before the end of the week and some parts on back order are also due this week, so if everything goes right next weekend I will assemble the board the test the entire brainwave appliance control system.
After submitting this PCB for fabrication, I went back to IR remote control protocols and after a few hours of experimenting I've got the TV on/off function to work. The main issue I struggled with was the pulse length of modulated infrared signals that I generate with a function implemented in the PSoC4 CPU. After poking around and scrambling my mind to figure out why the code was not recognized by the TV, I found out that the pulse length of “1” and “0” bits is critical to the infrared receiver inside the TV. So first I have recorded the ON/OFF binary sequence of bits using the infrared receiver I talked about last week; the sequence is:
The main issue with this sequence of bits is that there are 33 of them; if they were 32 it would have been easy because I could store it into a uint32 type variable, but being 33 I couldn't fit in. I then went back to my old C and C++ books and I tried to define a 64 bit variable as long long and unsigned long long, but the compiler didn't like that and complained that the length does not fit into the variable type that I have chosen. It looked to me that the compiler ignored the first “long” term in the definition and thought that I define a variable as only “long” type (I think it happened like this from the error message that I received).
What really helped me was to notice that all codes of the various functions on my TV remote have the LSB bit equal to “1”. So I then modified the serial bit transmission function so that I send a “1” bit at the end of the 32-bit sequence, thus making possible the transmission of 33 bits while storing the code in a 32-bit variable.
Trying to solve this issue I then figured out that the sequence of serial bits that I showed above was actually sent starting with the MSB bit not with the LSB, which made me store this code value “backwards” in a hex type variable (since otherwise the leading zeroes would have been ignored and lost from serial transmission).
Another small challenge was the insertion of delay segments in the CPU code; previously I used the command CyDelay(…) but I had issues getting fine resolution of delay periods. After some search on the Internet I found out that I can use the command CyDelayUs(…) which then gave me higher resolution and this way I could “fine” adjust the infrared pulse widths to be recognized by the TV receiver.
Here is a section of the code showing the use of CyDelayUs() function and also showing the trick of sending an additional “1” pulse at the end of the serial bit sequence.
And here is a short video showing how I turned on the TV using this infrared transmission function implemented in the CPU of PSoC4 in the Pioneer kit. In this experiment I am using an emulator for the eyes movement (two push-buttons on the breadboard) since the experimental amplifier that I have previously shown in a video is now broken (I accidentally broke one pin of an integrated circuit on one of those “hanging” breadboards for who remembers that video). I didn’t want to spend time fixing it since the PCB board that will hold this front end amplifier is scheduled to be fabricated this week.
In this video I will first press one of the emulator buttons 4 times (representing the eyes movement toward left four times). The PSoC4 CPU then decodes this sequence and selects the serial bit code to be sent to the TV from a look-up table, after which it forms the signal and sends it to the infrared LED (hanging on some wires in the center of the screen). Then the oscilloscope captures this sequence of serial data and we can see the TV red indicator LED becoming green. The image comes after some (long) delay from the moment the TV receives the command and activates the display.
After the TV turns ON I then clear the waveform on the oscilloscope and then I press again four times the push-button of the emulator. After the fourth push the CPU inside the PSoC4 transmits the serial signal to the infrared LED and the oscilloscope captures and displays that signal. The TV turns OFF immediately, a lot faster than when it turned ON.
So this is where I am now; next weekend I am planning to assemble the PCB and put together the entire brainwave appliance controller system.
Until next update, all the best wishes to all contestants of this smart life challenge. I really enjoy working on this project.