Magic IR and Variable help
HI,
I am trying to use Magic IR to play a code form a variable that i have stored in my DAT section, but i seem not to be able to get it to work. Also does Magic IR require a decimal or a binary number in order to work.
Here is a very simple example of what i already have.
Thank you,
CameronM
I am trying to use Magic IR to play a code form a variable that i have stored in my DAT section, but i seem not to be able to get it to work. Also does Magic IR require a decimal or a binary number in order to work.
Here is a very simple example of what i already have.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ magicir : "magicir_010" PUB main repeat magicir.playcode(1,@p,@pl) waitcnt(clkfreq + cnt) DAT p long 714867 pl long 108
Thank you,
CameronM
Comments
Here's my project that's still in progress.
http://www.savagecircuits.com/forums/showthread.php?169-Networked-Universal-Remote&p=1793&viewfull=1#post1793
It records low-high-transitions and stores them.
Then you can play back these transitions.
This means it is NOT possible to send just a byte or some bytes.
For this you need information about the signal-standard Sony RC5 or something else
Even on a wired serial link you have to define baudrate, number of databits, stopbits and parity
It's the same with IR-remote signals. You have to define to which standard they belong.
If you want to use magic IR you have to record your ir-signal first and then you can playback this signal.
best regards
Stefan
Thank you very much,
CameronM
I've modified Magic IR to output the data to a terminal. I then cut and paste the data into a DAT section to use in another program that only plays the data. I'll find it and post it here some time today.
Duane
Edit: I just reread the thread (often a good idea for me). It looks like my program wont help you much. I'll still find and post it in case it's useful to someone else. (I'll probably start a different thread.)
It's Magic IR with the ability to save 32 buttons worth of IR codes. The IR codes are displayed in an easy to copy format so you can include it in a different object easliy. The IR codes are saved to EEPROM so the power doesn't have to stay on. My version of Propeller EEPROM is a little different than the original. I added a method to make it behave better with other cogs that may want to use the EEPROM.
I used this code to record a few camera controls so my robot can control a camera with an IR LED.
I have a Panasonic camera and I couldn't get any of the IR Kit's codes to work with it. Thanks to Nick, this works.
Let me know if anyone needs help using the play back feature using variables in a DAT section.
Duane
magicIrDemo101211b - Archive [Date 2010.12.11 Time 20.37].zip
Stephan is right - it's meant for when you don't know the signal format, parity, etc. It just records transition timing & you need to use the object to capture the code. If you only have a few codes, Duane's code will work perfectly, just capture the code, copy & paste into the propeller tool. One tip, push the Remote control button briefly when capturing the code - it seems to work better that way.
If you want to just send data, take a look at this object in the obex, it might help you.
Thank you,
CameronM
You are welcome.
Saving code to a SD card shouldn't be a problem. You'd want to remove the formatting I added to make it easier to cut and paste into a DAT section. You'd probably want to save the data as a comma delimited file (just write a comma in between data entries). I had the code print in hexadecimal since it's easy to see how many bytes it takes up that way. You might want to output the code in decimal to the file (it shouldn't really matter, as long as you read it back the same way you wrote it).
The EEPROM space could be a limiting factor if you had lots of codes to record. The remote I was using had 32 buttons so I made 32 sections in my storage buffer. I mainly wanted the print out of the code to use with a different program I was working on.
It might help if you let us know what you're trying to do. As Nick mentioned, if you want to send data with an IR link then a different object would probably work better for you. IR Magic is great if you need to record an IR remote that wont work with IR Kit.
If you have limited memory, it might be possible to "compress" the codes given by IR magic. I started working on a program that would find a common divisor to all the intervals. I think this method could work to reduce the size of each datum from a long to a word. The intervals would need to be lengthened (at play back) by the same factor used to reduce them. I found if I took the smallest interval and divided it by 21 the other intervals where within 2% of being a multiple of this number. I stopped working on this approach since I didn't really need it.
If you're interested in my "compression" code, I'll post what I wrote before deciding I didn't need it. If you do try to compress your data make sure and exclude the first interval from your calculations since there is a bit of set up time required when IR Magic sees it's first pulse of light.
I have a Panasonic camcorder that I've mounted under my RC helicopter. Thanks to Nick's IR Magic (and some tweaks by me) I can control the camera with a second RC radio system. Pretty cool.
Duane
Thank you,
CameronM
Thank you,
CameronM
You would have to add code that saves the recorded high-low-sequences into the EEPROM and can read it in later from the EEPROM.
Recording the highs and lows is possible without knowing something about the IR-code-standards.
This kind of recording is on the lowest level.
If you step up one level then this lowest level of creating, the right high-low-pattern with the right frequency, has to be programmed and not recorded. For the Sony RC5 IR-code standard there exists
an object in the obex.
If you want to save memory (HUB-RAM in the prop) and if you don't want to record every single button of your remotecontrols you need to have all the code already defined in software and then call
sendroutines through variables
Of course you could try something inbetween by recording all the buttons and defining
constants that refer to each button.
best regards
Stefan
@CameronM, The code I posted needs a lot of work to turn it into a useable universal remote. One improvement would be to have the codes record to upper EEPROM so the reserved memory for codes doesn't limit your code size. As it stands now the intervals of up to 32 codes may be saved in RAM. The codes are also written to EEPROM at the same address as they are located in RAM so they remain useable after the Propeller it turned off.
The printout in hexadecimal doesn't do much for you as is. It needs to be cut and pasted into a DAT section of a separate program. This way a program can use the codes without needing to be able to record them directly. I'm afraid I don't have much time this week to make a better example object of this technique. I am attaching the program I'm working on now that uses this technique. This code is very messy. I should have time either next week, or the week after to make a better universal remote. (It is on my todo list). I think your idea of using a SD card to hold the data is probably the best option. I take it this isn't an urgent project for you? If it is (say as a Christmas present), I could probably make time next week to help (or maybe the weekend). I'm hoping to make a universal remote for my in-laws so I think we have a shared goal.
I was just looking at the Object I'm uploading. I remember I have the "playcode" method started in a different cog. This was because I had counters interfering with each other. (I'm using a method to measure pulse widths which also requires a counter.) I'd suggest looking at the "playcode" method and how it is called. The IR codes are at the bottom in the DAT section. I have tested this code. I can control the zoom of my camera using my RC transmitter.
Sorry, I don't have a nice clean example for you. I will work on this again within the next two weeks.
Duane
AX12WithIrControl101209a - Archive [Date 2010.12.15 Time 11.46].zip
Thank you,
CameronM
I am new to propeller programming and looking for some help on my first program. I was wondering if there was any further progress on this project as I too am looking to store the IR codes on a SD card. Would this best be done with a fsrw object? I would be using the code provided by Duane Degn as my network connection is currently MIA and I am left with terminal for now. Could this be modified to write to an SD card I am confused as to what values would need to be written to the txt file, just the value of codeptr and codelength? Is this easily done?
Thanks for everyone help with this!
Dylan
no it's not enough to store codepointer and length. AFTER the codepointer all the details of how the signal looks like are stored.
IR-magic records all the low-high-transistions of the recorded signal.
This means you have to store all the memory starting at the codepointer and the amount of bytes (or longs) is the codelength.
I think the FAT engine from Kye is a bit easier to use than fsrw this object offers commands on a higher level than fsrw.
But I'm no expert about SD-cards.
I would divide the project in several steps.
- getting IR-recording to work and play back
- getting an SD-card mounted (logically) to the propeller-chip
-writing and reading dummy-data to the SD-card
after these steps putting together IR magic and the SD-card FAT-enginge
best regards
Stefan
1. When the propeller receives a IR signal it looks to see if that IR blast is stored and if it is send out the IR blast or multiple blast I have set for that IR blast
2. If the propeller received a blast that is not in memory just send it out of the IR LED then clear the buffer.
This way if using option #1 you can have it setup to say when the DVD button is hit it will turn on every piece of equipment that i want to view a DVD with.
Also if using option #2 I only need to operate something that is programmed into my remote it will just pass it along to the unit being controlled.
Thanks for the Code examples Duane and Nick by the way.
I also believe this way of doing things for me will cut down on the amount of stored codes needed.
Also if anybody has any code relating to this project that I could take a look at, it would be greatly appreciated. Just trying to learn as much as I can from the great people on this forum. Thanks again for your help
I think I have some time to work on the universal remote code.
One of the things I need to decide on is what kind of interface to use. The code I posted earlier uses the Parallax Serial Terminal for user input. I'm thinking I'll stick with the PST for user input as I make a generic version of the program. Hopefully it wont be hard to adapt the program to use a keypad interface or whatever interface any of you'd like to use.
Another decision is which SD object to use. Do you want time stamps on your files? I usually use a DS1307 as my RTC. Is this okay with all of you (or some of you?). Do we want folders on the SD card? I'll probably do which every way I think would be most useful to me (or the easiest way) and let other modify it to meet their own needs/wants.
@Dan, Have you started working on trying to match IR codes? I think this is easier said than done. I can think of several uses for such code. I might try to do this if you don't beat me to it.
@DylanS, One of the first things to try if your device doesn't respond appropriately to an IR code is to re-record the intervals. You might also want to modify the Spin code (look in the "Play" method in magicIrDemo101211b) to repeat the code a greater number of times. (I think it repeats 10 times. You might want to try having it repeat 20 times.)
Your xbox DVD remote might use a different modulation frequency. IR Magic uses 38KHz. I think the IR receivers are usually "tuned" to around 38KHz as well. If you have access to an oscilloscope and can take apart your remote, you could "scope" the IR LED to find out its modulation frequency. There are probably better ways of doing this. Someone else might have a better suggestion on figuring out how to record the IR codes from your xbox DVD remote. Wikipedia lists the different frequency in its "Consumer IR" article.
One change to the code I hope I can make without too much pain is to record the length of each interval individually. Right now the code keeps a running total or the number of clock cycles from the first transition. I think changing it to record the clock cycles of individual transition should make Dan's attempt of recognizing previously recorded IR codes easier (but not easy).
Hopefully I'll have something to share in a day or two. It depends on how busy my day job keeps me (always unpredictable).
Feel free to make requests of what you'd like included in an updated IR Magic and I'll feel free not to include it. (That's not meant to sound as rude as it came out. If your request is within my programming abilities and doesn't take to much time, I'll probably try to add it.)
I'm still pretty new to the PASM side of programming the Propeller but I don't think the features I'm planning on adding should require much PASM.
Thanks again Nick for getting this started.
Duane
I have been looking through the code you have posted and the IR Magic code and I see one problem is that the time the button on the IR remote is pressed might be the main reason why it would be hard to match the codes that are stored with the button pressed.
What I might do to just get most of the features I want for now from the remote I want to control everything with is setup my remote to send the Sony protocol and then capture the buttons from the remote then use the IR Magic to record my other remotes and when I press a button on my remote the Propeller will send out the IR blast I want.
I am not too sure what to do about the ir codes not working, but the fact you said it repeats the code a number of times makes me wonder if it could send the code multiple times causing the TV to turn on and off with one push. Occasionally when re-recording and playing back, it would turn the TV off then turning it on I could hear it doing something such as turn on and off at the same time. Does that make sense in this application?
Thanks again for all your help!
There is a good chance that this is what is happening. If so you would have to analyse the bytesequence
that is recorded where does the pattern repeat?
You could also try to code something for this. Therefore you would have to compare
byte1..4 with byte5..8
byte1..5 with byte5..10
byte1..6 with byte7..12
etc.
Where all bytes are equal you catched the sequence that is repeating.
Maybe creating a graph would make it easier to detect where the pattern repeats.
If I remember right there exists some code in the obex that works as a logic graphic analyser
best regards
Stefan
The line "repeat 10 '3" repeats the recorded code ten times. Nick's original demo had the recorded cord playback in an endless loop. I was trying to pick a number of repeats that worked best for my application. The commented out "3" makes me think three repeats weren't enough for me. DylanS, you might what to change it back to "3" and see if that works better for you. You could also change it to "1" and see it that works better. I"ll have to figure out a way of making the repeats user configurable.
DylanS, sorry, I don't think I'll be adding a web server.
For those of you wanting to use a this an IR repeater, have you thought about going the RF route? Your Propeller powered universal remote could send a radio signal to the IR controller located inside you entertainment center. You could use a couple of XBees or other transmitter/transceiver. I've used these Nordic modules a lot myself. I think there are also less expensive transceivers you could use.
Dan, your right about a delay in measuring the first interval. It seems to be small enough that the code still plays back in a reconizable way but it would probably mess up any attempt to find a pattern in the code. In my early attempts at finding a pattern, I'd always leave the first interval out of the calculations.
Off to program a SD card universal remote.
Duane
If you want to control your Audio/Video gear in a closet from a web browser then you need to look at the project that Nick posted in the projects section. It has a web interface and stores plenty of codes he even has a little video of him using it from his smart phone. I plan to use Nicks project with the web browser with my Droid tablet but my wife does not like using the tablet for tv control and also the Kids need to operate the TV and they are not very nice to dads new tablet...so this is why I am building it into a IR repeater. Here is the link to Nicks Web Clicker.
http://forums.parallax.com/showthread.php?125494-Web-Clicker-Internet-Remote-Control
Duane,
Yes the RF route is one good option for the gear in the closet but the TV that is in the same room will need some type of IR signal going to it so the RF route makes a nice custom remote but not really needed unless you plan to some type of A/V gear in the closet that is going to a TV in a different part of the house. I have looked into using some of the 4.3inch touch screens that Rayman has for sale to make a custom remote then you could use RF, IR or any other form of communication but the only problem is a nice enclosure to house the project in might be expensive.
Dan
The MagicIR recorder also stores all the time values as deltas from the moment of the first transition. I changed it to store them as deltas from the previous transition, which made it much easier to see the bit patterns in the code.
Once you're storing deltas, the values remain relatively small, so it's quite possible to store the codes in 16 bits (or even as low as 8) since most remotes operate with fixed transition times, around 600 or 700 us. I set my "code recorder" to take the resulting array of time deltas and round them all to the nearest multiple of 350, and then just do the multiply again during playback. You can store many more codes this way, but it also makes it more likely that you'll experience problems, since some remotes have crappy timing, and some simply don't adhere to any standard at all. For the remotes I'm replacing, this doesn't look like it'll be an issue.
I'm actually hoping to allow the code to store either a "transition times" code or a "bit pattern + encoding method" code. Since JVC and Sony use standard encoding methods, if you can figure out what the bit length time base is, you should be able to store a code as:
Time multiplier (in microsecs), Coding scheme (JVC / other), bit count, bits
(It's a lot like the Pronto remote encoding, shown here: http://www.hifi-remote.com/sony/Sony_pronto.htm)
I'm going to try to make a post-processing routine that's smart enough to convert the time intervals into this representation, since it'd be MUCH more compact.
I haven't had a lot of time to work on this yet, but I'll post updates as I make progress.
Do you mind sharing the code you have for decoding the IR transitions from the previous transitions this would help with obtaining the bit pattern a lot.
Dan
Not at all. I'm at work for a while, but the code is basically this:
That will convert the codes from being absolute time values into being "amount of time since the last transition". Note that you have to make the playback code keep a running time value (or just use the return result of the waitcnt command, since that's what it's for).
Once you've converted the array into deltas, divide the value by (clkfreq / 1_000_000) to get microseconds, like this:
From there it's pretty easy to see what the time base for the codes is. All the transitions after the first two (start bits) should be close to an even multiple of a common value. Beware that most remotes will repeat the codes as long as the button is pressed, or just fire a few in a burst to make sure they're "heard". You'll see a normal code, followed by a long transition time, followed by a code pattern identical to the first, another long transition, and so on.
I'll try to remember to post what I've got tonight when I get home.
Jason
http://www.celadon.com/infrared_protocol/infrared_protocols_samples.pdf
So, from the doc, using the length and "style" of the sync pulse at the beginning, you should be able to work out which kind of encoding it is (assuming it falls into one of them) and from there, work out the actual bit pattern relatively easily.
Thanks Dan, I had looked at that and am looking at using it with a html web gui but I am currently without a way to network to my prop, so I am left with serial terminal for now. I would also like to add the SD functionality so that the codes are stored on the card, but this will be the end goal.
Does anyone know if you can have the html code stored on the SD card instead of embedded in the firmware? I have seen reference that it can be done but can't seem to find anyone who has done it.
Thanks Duane, I changed it back to three and that solved the problem. Thanks for the advice.
Thanks again everyone for the help!
Yes you can store the HTML data onto a card their are a few examples of that in this forum on the SpinneretWeb parallax sells. Its uses the wiznet 5100 chip to interface the propeller
Also the Spinneret has a micro SD card slot on it and a Propeller so its like everything you need in ONE...
http://forums.parallax.com/forumdisplay.php?82-Spinneret-Web-Server
I like the examples on these threads also..
http://forums.parallax.com/showthread.php?127107-DHCP-working!-(code-now-attached)
http://forums.parallax.com/showthread.php?127181-Timothy-Swieter-s-TCP-and-web-server-demo
http://forums.parallax.com/showthread.php?128139-Playing-led-with-HTTP-demo-mod
http://forums.parallax.com/showthread.php?127499-Contest-Entry-Real-Time-Energy-Price-HVAC-Controller
Hope these help the Spinneret is next on my list of TOYS
Dan Bennett
I was just wondering if you had made any progress in the SD version of the Magic IR code. Also, were there any improvements made to Nicks Code in making your EEPROM code? I am trying to merge the two projects and was wondering what portions you would recommend improving on in Nicks Code.
Thanks for all your help
Dylan