Suggestions on IR communication

I'm using a IR transmitter on a Arduino UNO board where I also connected a servo motor and a CC motor and a IR receiver on another Arduino UNO board where i connected a joystick and i'm trying to let them communicate by using IRemote library.

I'd like to receive suggestions on how realize the IR communication. In particular, i have to send just four signals in order to change the CC motor rotation and to control the servo motor.

For example, if i move the joystick UP or DOWN, then CC motor has to change its rotation while if I move the joystick on the left or on the right, then the servo motor has to rotate in different directions.

Can you give me some suggestion about the protocol to use, please?

Hi,

I don't know anything about the library you are using, but if I was trying to implement a proportional ir remote system, I would use an ir emitter driven directly from the servo library.

I would try something like three servos, on for throttle, one set at a fixed signal just to act as a separator, then the steering servo.

The servo library already implements the type of pulse width encoding used to drive servos and electronic speed controllers, so why invent something else less efficient when you can transmit this directly ?

I am about to get on a plane some will have to leave it at that for now, if your interested in this approach I can help out tomorrow

Duane B

You gave me a great idea!

I can pass the value from joypad directly to the IR emitter by using servo library in order to have a proportional signal. But, i have to receive and recognize these signals on the other side with the IR receiver and i'm not able to figure out how implements this other side of the communication. :cold_sweat:

Hi, Still not on the plane yet.

If you look on my blog there is a post on using interrupts to read a signal from an RC receiver, this will work for you, but you will be taking the interrupt from an ir receiver instead.

Prove the concept with the code from my blog and then I can give you some pointers on adding a second channel to the signal.

Rcarduino.blogspot.com look in the most popular posts.

Duane b

I've read what you wrote about the RC and the Arduino, but i cannot figure out how to implement the IR communication. It's ok the servo control part on your article, but it is important to decide what kind of signal the transmitter has to send. :~

Hi, The servo needs this type of a signal which is easily generated by the servo library -

If you generate this on a pin with an ir transmitter connected, you can send it directly. I am not sure where you see the difficulty ?

is it that you haven't sent anything through ir yet ?

Duane b

Sorry for the delay.. Thank you a lot for all your suggestions!

The difficulty I see is on the receiver side where it has to recognize if the transmitted signal has to move the servo motor (left or right) or the CC motor (front or reverse motion).

Tipically, when i send a IR signal with IRemote library, I receive a long integer string with a lots of numbers.

Hi, The approach I suggested does not involve the IRRemote library. If all you want to do is send a signal to a servo and a motor through Infra red, then just use the servo library to generate a servo signal, but connect it to an IR Emitter instead of a servo. On the other end you can read the signal and send it straight out to a servo with no additional coding or decoding on either end.

What IR Receiver are you using, if its one that expects a signal in a given frequency range, you can build a small circuit with a 555 Timer to create this signal and then switch it using a PIN driven by the servo library. I can point you to some good online resources for building this part if your receiver needs it, but let me know what type it is first.

Once you have one channel up and running its easy enough to add some more to the signal.

Duane B

rcarduino.blogspot.com

I'm using a IR TSOP2438, do you think it can work with servo library?

I'm asking this because i tried to let a LED blinking with this code:

void loop()
{
  digitalWrite( sendPin, HIGH);
  delay(100);
  digitalWrite( sendPin, LOW);
  delay(100);
  Serial.println("Invio");
}

but the receiver didn't recognise the signals.

Tomorrow, i'll try to use servo library, do you think it will work with my IR receiver?

Hi,

I suggest using the IR-Library by Ken Shirriff. It's very ease to use.

Just send a signal with   irsend.sendSony(0xa90, 12); // Sony TV power code and on the receiver-side check the signal with    if(results.value == 0xa90). You can use your own codes instead of 0x[u]a90[/u].

Common IR-Sensors like the TSOP2438 do have filters for 38 khz transmission, thats maybe why your 100ms pulse won't be recognized. (meaning its way too long for a 38khz pulse detecting range)

Hi,

As the previous poster has suggested, then detector you are using requires a 38khz signal. there are libraries that will generate this signal, but they are generally intended for sending infra red remote codes for home entertainment systems such as tvs etc. These libraries will not give you a signal for proportional control of a servo.

One quick experiment to try it to use a 555 timer to generate the 38khz signal for the ir emitter and then use the servo library to drive an arduino pin connected to the reset pin of the 555.

This will generate the correct frequency for your detector, but pulsed in the correct way to provide proportional control of a servo.

The 555 and 556 timer chips are great little devices that can be used for all sorts of projects, so if nothing else you will increase your options for future projects by experimenting with the 555 and 556

EDIT: Alternatively you can search for code examples for generating a 38Khz signal directly from an Ardiuno PIN, there are lots. If you find one that does not use timer 1, you can use an AND gate to combine an Arduino generate servo signal with the Arduino generated 38Khz IR signal to get a proportional 38Khz Servo signal out of the AND gate. I will have a go at putting together an example this evening.

Duane B

@kduin: can i use any kind of signal? Where can i find more information on how to create customized IR signal?

@DuaneB: today, i’ll try to find a 555 timer in order to see if i’m able to use it with my arduino. I have to use two 555 or i have to use only one timer to generate the signal?

Can I try to send very fast pulses? Or arduino is not able to simulate a frequency like that? :cold_sweat:

Hi Marcus, Just to make sure I am not leading you in the wrong direction for your project, can you give a quick outline of what you want the end result to be, then we can make a better judgement on IR or any other alternatives.

Duane B

rcarduino.blogspot.com

ok :)

I'm in this situation:

1) Arduino + IR receiver + servo motor + motor

2) Arduino + IR transmitter + 2-axis joypad (it uses two potentiometers)

  • When i move forward the joypad stick i want to transmit a IR signal to the second arduino in order to move the motor.
  • When i move on the left the joypad stick i want to send a signal to turn on the left the servo
  • When i move back the joypad i want to send a signal to change the rotation direction of the motor
  • When i move on the right the joypad stick i want to send a signal to turn on the right the servo
  • Also, if i move forward and on the right the stick, then it have to send two signal in order to let the motor and the servo move

Do you think servo library can help in this task? Does i really need the NE555 timer? What about if i let the led blink more faster?

Hi, Ok, your project is as I previously understood it.

The next question is, do you want control of the servo and the motor to be proportional ? if so its more functionality and more work than simple on/off left/right.

Are you going for proportional control ?

If so, my thinking is that you can generate a 38Khz IR signal from an Arduino timer or a 555 Timer and then pulse this signal on and off using the servo library.

Are you planning to use two Arduinos ? or just one for transmitting or receiving ?

Duane B

rcarduino.blogspot.com

I'm using two Arduino, the first to receive and the second to send signals.

I'd like to try to use the proportional solution becayuse it seems to be smarter than the simple on/off control, but i'm worried about the difficulty to accomplish the proportional task.

I've bought two 555 Timer this morning but i didn't know if it's easy to use it to generate the correct signal; may be it would be easier to use Arduino timer, what do you think about it?

i also bought another IR receiver in order to see if i can use it without generate the 38Khz signal. The new IR reiceiver is: Siemens SFH 507-38 and this is its datasheet: http://www.datasheetarchive.com/dl/Datasheets-31/DSA-617620.pdf Do you think it's better than my previous IR reiceiver?

EDIT: if the reicever accept 38Khz signals, can i let a LED blink each 26 microseconds?

Hi, The 38 at the end of the part number tells you the frequency that the receiver expects, so in this case its 38Khz.

You can use code to generate the 38Khz, but the 555 timer is such a fundamental chip to so many projects that you might as well figure out how to use one, it will also allow you to drive your IR Transmitter with much more power than an Arduino PIN, this will increase your range and reliability.

Something quick to try is to build a 38Khz circuit with the 555 Timer, then use your Arduino to drive a servo signal which will enable/disable the 555 timer using the reset pin. On the receiver side, you 'might' be able to drive a servo with just a 5v power supply and the IR Receiver.

If you want to get away from the requirement for a 38Khz signal, you can try an infra red detector instead of a receiver, but its so easy to generate the 38Khz signal with a timer (Arduino or 555) and it makes for a much more reliable system.

Here is a quick update on one of my own projects where I am using an infrared detector the same as yours to detect my RC Car lapping. The RC Car has a simple 555 timer circuit (no arduino) outputting a 1 millisecond pulse of 38Khz IR signal.

http://rcarduino.blogspot.com/2012/03/punk-consoles-and-ir-transmitters-555.html

One limitation of this is that if I want to use the system in bright sunlight I need to enclose the detector in a shade, this is no problem for me as I need the detection zone to be very tight anyway but If you plan on using your control system outside, IR might not be practical for you. If you decide not to go this way, build a 555 punk console, I have been dying to but haven't found the time.

If do you want to take the IR route, I would suggest that you do so in stages, and as a first stage I would suggest that you build the battery driven detector circuit from the Lady Ada link and build a 555 IR circuit. If you can activate the LED in the detector circuit with your 555 circuit, the next step would be to connect the 555 to the Arduino, let us know when you are ready to do that, you will need to add some decoupling capacitors first but we can get into that when we need to. After the decoupling capacitors it should all be simple enough.

EDIT: I have a nagging idea that its would possible to build the entire transmitter and receiver from a few timers, I have never tried it, but logically I can see how it could work.

Duane B

rcarduino.blogspot.com

At the moment, i did the IR sender and receiver with the on-off system without the proportional system and it seems to work well. For each joy-pad position, I send a sony signal which the receiver recognise and is able to move the servo and the motor.

Now, i'd like to do the proportional one, but the problem is this: if i generate a pulse proportional to the potentiometer position and then i send it with the IR LED, how can i let the receiver to recognise it? And how the receiver will be able to recognise if the proportional signal is for the servo motion or for the motor?

Can you send number codes, like for TV channels? If it's less than Y (100?) then it's for the motor, if it's greater than Y then it's for the servo.

Hi, To tell which channel a pulse is for I would suggest an approach similar to radio based RC Systems. They use a fixed frame which contains all of the channels as consecutive pulse widths. If you use the servo library you can cheat a bit and get it to do most of the work for you.

The servo library automatically generates pulses using a 20ms frame, the pulses for each channel within the frame are between 1 and 2ms long.

See here for background -

http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.html

The problem is that the Arduino Servo library doesn't quite do this in exactly the same way as an RC transmitter, but by using one dummy servo we can fake it so that its close to an RC Transmitter signal and will allow us to get two channels in and out of the signal.

Heres how -

1) Create a throttle servo and attach it to a throttle pin 2) Create a dummy servo and attach it to an unused pin 3) Create a steering servo and attach it to a steering pin

We use the dummy servo to create a 1.5 ms space in the signal between the throttle and steering pulses.

Note: 1.5ms is the default pulse width we could change it.

In our receiver code we can work on the basis that -

1) If we haven't seen a pulse for over 10ms the pulse we are looking at now is the throttle 2) If we saw a pulse less than 2ms ago, that was the throttle and the current pulse is the steering.

The dummy servo is not used, but because of the way the Arduino Servo Library is written, we need this to create a gap between the end of the throttle and the start of the steering pulses within our single IR Channel.

You will need a small circuit to allow the throttle and the steering pins to activate your IR Emitter, or you can cheat and do a quick test with two IR Emitters if you have them - just for testing ;-)

Some IR Detectors have rules about the types and sequences of pulses that they will process, if that is the case with yours I am sure we can work around it.

Duane B

rcarduino.blogspot.com