Page 5 of 5

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Mon Jan 09, 2017 9:25 pm
by rperkins
Glad you got it working for you

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Tue Jan 10, 2017 12:10 am
by jhsa
He was just lucky he got it to work :mrgreen: He should be blinking LEDs instead :mrgreen: Now he thinks he is a programmer :mrgreen:

Joking :) ;) Have a beer :D

João

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Tue Jan 10, 2017 12:12 am
by MikeB
Just a note, the declaration:
static byte throttleWatchdog;
almost certainly is defining an unsigned quantity, in this case a byte of 8 bits that stores a value from 0 to 255.
The declaration:
static long throttleWatchdog;
defines a signed quantity, in this case likely 32 bits long that stores a value from -2147483648 to +2147483647.
You might find you want:
static unsigned long throttleWatchdog;
to declare an unsigned, 32-bit value that stores values from 0 to 4294967295.

If the 8-bit value is a problem after 30 seconds, a 16-bit (unsigned) value would overflow in a little over 2 hours.
The 32-bit value (signed) would overflow after 7.5 years, 15 years if unsigned!

Mike.

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Tue Jan 10, 2017 3:21 pm
by andrewju
Amazing!!! Thanks a lot, Mike!
I believe an "unsigned int" (16-bit) should be pretty much sufficient. Though, 15 years sounds tempting! :) There's no harm in using an unsigned long, right? The code is really small, and there's still more than enough of free memory...

jhsa wrote:He was just lucky he got it to work :mrgreen: He should be blinking LEDs instead :mrgreen: Now he thinks he is a programmer :mrgreen:
Ha-ha-ha! I was kicked out from my C++ course at the university. :roll: So I'm not even close to be a programmer, that's for sure! :mrgreen:

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Tue Jan 10, 2017 3:30 pm
by jhsa
Ahhh, that explains why you know a bit more than blinking a couple LEDs :) :D
I need to get myself kicked out from some course to see if I learn something as well Ha ha ha :mrgreen: :mrgreen:

João

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Thu Jan 12, 2017 10:58 am
by andrewju
Just in case someone will want to build this IR module, here is the Arduino sketch with my corrections:

- Fixed unwanted IR pulses when throttle = 0 for 30 seconds or more
- Improved robustness of IR channel selection (now it works properly with AR9x and ersky9x)
- Incoming PPM channels sequence is changed to RETA (because all of my models are setup this way). Though, is easy to change this according to your specific needs. Comments in the code are very informative!

This is based on David Frank's version modified for an S107C, so camera controls should also work (not tested as I don't have an S107C).


There's one issue (coming from the original v09) I didn't find a fix for. If there is no PPM signal during power on, the IR module will behave strangely. It seem to lose synchronization and doesn't properly decode incoming PPM stream (whenever it will arrive). This happens if you power your radio ON with some switches in a wrong position, or throttle not idle, etc. In this case, the radio alerts you and won't transmit anything over the PPM line until the alerts are confirmed. So even when you pass through the startup checks (correct the switches, put throttle to 0, etc.), the IR module still won't control your helicopter until reset.

I still don't understand why this happens. I probably will look into it a bit later, although I don't have any ideas so far. For now I made a hardware fix for that by placing a reset button on the module itself. So I just clear all the alerts on my radio and then reset the IR module - it always works good then!

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Thu Jan 12, 2017 1:39 pm
by jhsa
You need my RF module soft power switch circuit. :) It will only power the module ON if a signal is being sent to it by the radio ;)

I know this is just a workaround to the problem, but I think it would work.. And you would be able to turn the module ON or OFF via the firmware :D Only for Ersky9x though ;) :)

João

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Thu Jan 12, 2017 4:30 pm
by andrewju
I really do think about your power switch circuit, BTW! Ideally, I could have installed the IR module internally (to PPM2) and keep XJT as my main external module. But this will make the IR module permanently mounted in my main radio. Given that this SYMA helicopter is a toy for home, I don't think I want to do it this way...

Adding your circuit to control power on demand is still an option to consider, even for an external IR module!

Re: Continued-Infrared module for JR compatible TX, including 9x

Posted: Thu Jan 12, 2017 8:31 pm
by jhsa
You can even build it inside the module itself ;)

But you can control both modules with only one Soft Power board.. External and Internal..

João