I finally got the octocouplers and tried them in my circuit but without success. I think I have reviewed my code and circuit tens of times but I don’t see where is the issue. Even with the octocouplers connected I still have the same symptoms. Once the DC motor runs, I cannot read any signal anymore with the infrared. Weird, very weird.
Anyway, I keep looking but I am also busy with plan C :-). I have seen on Ebay that there exists an L298N with integrated optocouplers in the chip to for isolation. I have ordered it yesterday evening. I hope I can finally get it to work. In the meanwhile when I have time I keep looking into my circuit to see what could possibly be wrong. My circuit is not that complicated.
Optocoupler
I have been done a lot of research and reading the last few days to figure out how I can solve my problem. Finally I ended up at the following page about DC Motors. See DC-Motors.
There is a part about noise caused by the DC motors. To isolate both circuits (Raspberry Pi linked/Battery holder linked (l298n->DC-motor)) I have to use an opto isolator (opto coupler). I did some further investigation and yes, that’s the way I wanna go. It explains the issue that I have. So I immediately decided to buy a couple of those opto isolators(4n35 FSC Optocoupler) on EBAY. I can’t wait to get to work but I’ll have to work delivery which will take a few weeks :-(. The opto couplers are on their way from China.
IR Receiver versus DC motor
Some more about my issue. I tried an alternative calling irw direcly in my java code
p = Runtime.getRuntime().exec("irw");
And the result was exactly the same. Once the motor starts turning, the IR receiver seems hanging. When the motor stops, the IR receiver works again. Some reading and searching on the internet learned me that a possible cause could be electric noise because of the running DC motor. I tried to put a capacitor around the DC motor but without result. In other words I am stuck for the moment and thus still looking for a solution. If any of you would have any suggestions, they would be very welcome. I have no electronic background what probably explains my lack of knowledge on that.
In the meanwhile I also posted my issue on a Raspberry Pi forum. See Forum post
I will keep you posted as soon as I get around this issue.
Look for JLIRC Alternative
My first experiments with JLirc were promising but at some point I started getting issues. The idea was simple. Compile the code and put in in the classpath. That was working well but in the context of my Rasbperry Controlled Car I got weird issues. The JLirc library has a native implementation to read the infrared signals. The library has a nativeRead method to read data from the socket : /dev/lircd.
Without batteries attached to the car this is working well without any issues but with batteries inside, it hangs after the first button I click on the remote control. Weird, very weird. I have spend a lot of time trying to figure out what is the issue but I cannot find it. As I said, without batteries in the battery holder, it works, with batteries, it hangs. I can’t see nor understand the link with why it would hang.
In my search I have noticed that the JLirc library dates from 2001. And that is a little surprising. I don’t say the issue could be related to that but I prefer to have code that is more recent. I have learned out of experience at work that sometimes code running under an older JVM does not work fluently anymore under more recent versions.
I will have a look if I can read the socket via another way. When I have time I will also try to further figure out what is wrong.