go_away

Author Topic: IR transmission  (Read 12115 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
IR transmission
« on: August 01, 2008, 10:42:50 AM »
Hi guys :)

i want to ask you a few questions about IR transmission. (haven't found answers to those in the tutorials or with the search tool above)
what i am trying to do is something like this guy has already done: http://www.lasertagparts.com/mtformat.htm
he basically has a very precise protocol, each binary series corresponds to a specific action. I don't really know how to achieve something like this though. I believe, but i'm not sure, that for the transmission of binary signals you can simply use PAUSEs and HIGH <IR_led_pin>.
 example:
 i want to transmit 110011.
 could i write something like this on my microcontroller? :
high 1 (suppose 1 is the ir led pin)
pause 20
low 1
pause 20
high 1
pause 20
low 1

------

also i do not really know how these signals can be read by an IR receiver. As far is it is a single signal it shouldn't be too hard (as for range finders for example, or the thing shown in the IR tutorial on this site) but when it comes to multiple, very close to each other signals i don't know how to proceed

could you help?
:)

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #1 on: August 01, 2008, 12:11:00 PM »
well, first you will need a fast frequency (carrier) which will pe used to modulate your message.
due to all the infrared sources around us, you can't simply hook a led to an UART pin and expect the message to correctly end up at the decoder.

then you'll probably want a protocol, maybe with addresses, maybe with a checksum.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #2 on: August 01, 2008, 08:58:51 PM »
ok, i'll start by documenting myself on fast frequency carriers. But what about the receiver? does it also need something?

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #3 on: August 02, 2008, 12:18:22 AM »
ok guys! this is what i found so far: (i'll post them here so someone else can also benefit from these infromations)

http://www.rentron.com/Infrared_Communication.htm
http://www.scienceprog.com/ir-remote-control-signal-receiver-using-avr-microcontroller/

these are not complete walkthroughs or anything similar, but i think they are a good point to start from. I still need some time to understand how the whole thing works as i just go into robotics/electronics.

As for the receiver: i found that TSOP17xx have built in demodulators, that sounds great, even if i still need some more knowledge on how to make my bot (microcontroller , that is) interact with these (even if demodulated) signals.

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #4 on: August 02, 2008, 01:17:09 AM »
I wrote a small tutorial on decoding RC5 from remote controls with a TSOP sensor. Check it out on my website.

Basically, with a TSOP you get a signal you can feed your UART. But noise may still appear. From the other end, you can get an astable oscillator a tuned frequency, when the TX pins goes high, it enables this oscillator, thus creating modulated light. When the TX goes low, oscillator is disabled. By this method you effectively superimpose the carrier with the original data.

you can also get a pwm pin at your frequency and feed it to an AND gate, along with your TX. this way, you don't have to build an oscillator, and the signal will be more precise.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #5 on: August 02, 2008, 06:32:03 AM »
i am sorry i am a bit slow understanding these things (just started :) )
it appears i have a pwm (actually 2) pins on my microcontroller. so what i basically do is use it together with and AND gate, but when i get to the coding part, do i still need to use "high/low" (on/off) commands in conjunction with PAUSEs right?

as for the receiver, i'll just stick to the tutorial, it's GREAT! :)

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: IR transmission
« Reply #6 on: August 02, 2008, 08:04:24 AM »
hi,
i would recommend playing with your microcontroller's UART.
the UART is a hardware module built into most microcontrollers for passing serial information.

once you have mastered passing information between 2 microcontroller's UARTs over wires it is fairly easy to swap the wires for a modulated IR circuit at one end and a TSOP17xx at the other.

dunk.

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #7 on: August 02, 2008, 11:47:45 AM »
No, I was saying to use the pwm to obtain a constant carrier (for example, constant 38khz).
Then, you will AND the output from this pwm pin with the output of TX (uart transmitter). This will create a stream of 38khz when TX is high, and nothing when TX is 0. In other words, it will modulate your data at 38khz. At the other end you can simply put a TSOP sensor

This implies you are familiar with your uc's UART hardware, and, as dunk said, you can send serial data over the wire between two ucs (or at least an uc an your computer).

Thanks for the appreciation. There's also a serial (RS232 type) tutorial on my site, if you never worked with it before (although it still needs some corrections)
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: IR transmission
« Reply #8 on: August 02, 2008, 02:56:12 PM »
Quote
No, I was saying to use the pwm to obtain a constant carrier (for example, constant 38khz).
Then, you will AND the output from this pwm pin with the output of TX (uart transmitter). This will create a stream of 38khz when TX is high, and nothing when TX is 0. In other words, it will modulate your data at 38khz. At the other end you can simply put a TSOP sensor
sure, that is one way of generating your 38kHz carrier.
but i would still recommend experimenting with the microcontroller's UART using wires first.

once he has the UART worked out he can go on to the next stage.

dunk.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #9 on: August 03, 2008, 12:02:49 AM »
i just discovered my picaxe has infra-red interfacing made simple! anyway guys, thanks for all your feedback, as soon as i have time and as soon as i find my components i'll try making some circuits with uart. Meanwhile i'll read thoroughly your tutorial, izua.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #10 on: August 03, 2008, 03:55:15 AM »
i've also found this:
http://www.world-educational-services.net/PICAXE%20Infra-Red%20Interfacing.htm
looks like picaxe 08 has transmitting and receiving made simple, and it costs around 2 US$.
posted it in case someone else may found it useful

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #11 on: August 03, 2008, 08:09:08 AM »
oh i got another question for you guys! :)
say i wanna have 4 tsop sensors on my bot (for a better coverage), but want to use the least input pins as possible. Can i just place them in parallel so they only go to one input pin? If yes, what would happen if the same IR signal hit two sensor (connected to the same input pit) simultaneously?

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: IR transmission
« Reply #12 on: August 03, 2008, 10:09:33 AM »
you'll need multiple input pins , unless you make the inputs digital and use a demultiplexer(the opposite of a multiplexer , lol )  that gives you the status of the sensors in TTL serial format on one pin.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #13 on: August 03, 2008, 10:54:41 AM »
wait, aren't demultiplexers used when there are multiple outputs? in this case the output (in case i wanna use a single input) will only be one. So maybe i would need a multiplexer, am i right?
« Last Edit: August 03, 2008, 11:11:03 AM by Captain_Tuna »

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: IR transmission
« Reply #14 on: August 03, 2008, 11:16:49 AM »
wait, aren't demultiplexers used when there are multiple outputs? in this case the output (in case i wanna use a single input) will only be one. So maybe i would need a multiplexer, am i right?

u need the following

a microcontroller to translate multiple inputs on its multiple input pins ( the slave microcontroller) . Then the main microcontroller will "ask" the slave microcontroller for the status of the pins which the slave will give to the main via serial output.

an easier approach is to just sacrifice those pins on your main microcontroller


also , you might want each sensor to have different frequencies to look for , in order to differentiate between signals

Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #15 on: August 03, 2008, 02:55:19 PM »
multiplexers are a different thing. you need shift registers for multiple inputs, similar to the multiple output thing (you have checked my site, i'm impressed :P)

you'll need to decide in software what happens when two sensors receive the same signal. it should be received in the same time, though.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #16 on: August 03, 2008, 08:13:40 PM »
it should be received in the same time, though.
yea that's my probelm... anyway, i'll document myself on shift register and on using a slave microcontroller with many inputs.
thank you for your help given so far :)

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #17 on: August 03, 2008, 09:32:10 PM »
basically, you hope that there are not two opposing sources that will be catched by two opposite sensors.
so, the first one which triggers (sees the sample) gets priority.
simplest method would be to check only that one.
more complex - sample all of them, in four variables, but time them all according to the first one which triggered.
even more complex - use four timers to time them individually.

best - use a single timer and four interrupt pins. capture the timer value when transition on the interrupt pins occur.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #18 on: August 04, 2008, 05:40:56 AM »
a very noob question: my picaxe has a RS-232 serial connection (serial in and serial out pins are on the microcontroller). Does that mean i can use it as a UART? (UART is not mentioned on picaxe manuals, but i've seen it in the UART tutorial on this site, that's why i'm asking)
« Last Edit: August 04, 2008, 06:23:01 AM by Captain_Tuna »

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: IR transmission
« Reply #19 on: August 04, 2008, 05:11:24 PM »
RS-232 is a set of specifications for serial data transmission. for example between a PC and modem or printer.
what this means to you in this instance is that a microcontrollers UART runs at the same voltage as the microcontroller.
RS-232 on the other hand operates at a higher voltage than a UART allowing greater cable length.

since your microcontroller board does RS-232 it must have a buffer chip built in (probably a MAX232 or similar) which allows it to send and receive at the higher voltage of RS-232.
this will allow you to connect it directly to a PC serial port for example.

if you have a component that needs connected directly to a microcontrollers UART you have 2 choices:
1. identify the RX and TX lines between the microcontroller and the buffer chip and make your connection there.
2. use a 2nd buffer chip to convert back from RS-232 to TTL level voltages.


dunk.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #20 on: August 05, 2008, 04:58:31 AM »
wait i don't get it... so the RS 232 is not a UART (i thought uart had various moduels including this one). Basically i can use my rs 232 to make connection (such as the ones listed above) instead of an UART right? (of course i do need to implement the adjustments you just told me)

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #21 on: August 05, 2008, 05:22:11 AM »
UART uses TTL voltage levels, RS232 uses 0-26V with split rail (+-13).
My site also has a tutorial on setting up UART.

I'm also experimenting with IR transmission, and reception via TSOP sensors.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline dsheller

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 0
Re: IR transmission
« Reply #22 on: August 05, 2008, 05:26:49 AM »
You are correct, RS-232 is not a UART, it is a serial standard used to define what voltages correspond to a logic 1 and which correspond to a logic 0. Just from a quick scan of dunks post, rather than reading the whole thread, it looks like this is your situation:

+ You have a uC board that has a RS-232 shifter built in
+ You are attempting to contact something which uses TTL voltages for communication

So your question is "Basically i can use my rs 232 to make connection (such as the ones listed above) instead of an UART right?" What exactly are you referring to as your "rs 232" ? Furthermore, we already established that a UART != RS-232, it therefore follows that they are not interchangeable. Now, as dunk said you're going to need to do one of two things, if you go the route of shifting the RS-232 levels down then

http://www.sparkfun.com/commerce/product_info.php?products_id=133

does that. You don't necessarily need to buy the kit, as they provide the schematic.

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #23 on: August 05, 2008, 05:36:08 AM »
Actually, I think he wants UART transmission over IR (which I also want :P)
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #24 on: August 05, 2008, 05:52:58 AM »
dsheller is right, i basically want to use an uart connection but i only have a serial one. But... after all, do i really need a UART? i mean, maybe having a serial connection would be fine too, right? (I realize the 'implementation' might be different though)

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #25 on: August 05, 2008, 08:38:21 AM »
Welll yes. But then a wire would be sticking out of.. whatever it's linked to, you haven't mentioned if it's for a robotic application.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: IR transmission
« Reply #26 on: August 05, 2008, 09:18:29 AM »
it's worth pointing out that the buffer between a UART ans an RS-232 port not only changes the voltage level but also inverts the signal.

Quote
after all, do i really need a UART? i mean, maybe having a serial connection would be fine too, right?

the problem you will run into trying to connect delicate electronics to an RS-232 port is the voltages are too large so will damage your components.
that's what the buffer between a UART and an RS-232 port is doing. making the voltages larger to increase the distance you can send RS-232 down a wire.

one question before we go off on a tangent: do you want to connect 2 microcontrollers or do you want to connect your microcontroller to another RS-232 device (eg. a PC serial port)?
i suppose if you are connecting 2 of your picaxe microcontrollers the answer would be "both"....

anyway, some more suggestions in no paticular order:

- you can emulate a UART in software using regulat I/O pins. it takes a bit of programming (or being lucky enough to find the code pre written) but it is possible to do the job with regular I/O pins. (the technique is called "bit banging".)
i don't know if i'd recomend this for a beginner though.

- the internet has loads of schematics for I/R receivers for PC serial ports and a few transmitters as well. http://www.google.com/search?q=pc+serial+port+IR
as PC serial ports are RS-232 you could use one of those. (this is the same approach as using buffer chip to convert back to TTL voltage i suggested earlier.)

- use a different microcontroller.

- don't use an UART to transmit and receive. use regular I/O pins. design and program your own simple transmission system. (not as complicated as it sounds.)


dunk.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #27 on: August 05, 2008, 10:20:00 AM »
ok guys you made my mind clear now. i got the differences between them (my problem was that seeing the rs 232 under the UART tutorial made me think they were some way strictly related).

"- don't use an UART to transmit and receive. use regular I/O pins. design and program your own simple transmission system. (not as complicated as it sounds.)"
yeah you are right, i don't really know why i have to make it with the uart! actually there's a cheap chip for 3 dollars or so which makes everything simpler (the one i posted before). my only problem is that the chip only has serial (no uart ...) and that might make it hard to make him communicate with other things (see my other post "external memory reader")

So, to reply to your question, i don't really know what i'm gonna connect the serial to. if there are no cheap memory cards/thingys out there i might just go for that option (connecting 2 uCs). But i was also considering the IR serial receiver/transmitter. (I'll check the schematics for them)

but i know that now or then i'll have to use my uart so all these informations you gave me come in very handy.

Offline Captain_TunaTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: IR transmission
« Reply #28 on: August 25, 2008, 04:53:45 AM »
today i got some receivers demodulators from a nearby store. I got a problem though, i don't know the frequency the work at. I know ordering a tsop with known frequency is way better, but i can't order them now as i'll soon be changing city (i am gonna order them in a month or so), so i just bought 2 of these (mainly because they were cheap) and decided to play a bit with them while waiting for TSOP. When i asked the guy about their frequency he said "up to 40 kHz".... hmm? Does that make sense to you? I thought receivers worked at precise frequencies.

Anyways, do you know if there's a way to understand what frequency they work at? I could in fact pwm my infrared led at the most common frequencies and see what happens, but do you know if there is a better method?

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: IR transmission
« Reply #29 on: August 25, 2008, 09:21:33 AM »
They do work over a range over frequencies, 36-44 is most common. However, they are the most sensible at one given point. This happens because bandpass filters are not sensible over only one frequency, but over a range :P

Running outside the main frequency will decrease maximum distance and may cause some errors. Try looking on the sensors and see if anything is written somewhere.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

 


Get Your Ad Here