Hello everybody,
I'm looking for help. My intention is writing python code for a MooVee Revell micro helicopter using a pc with USB-serial and the IR Toy from Dangerous Prototypes (V2.2) I want to use it in my classroom for educational purposes. I am a teacher in computer science. My learners learn to programm with python 2.7 using among others serial.py.
I managed (trial and error) to read the packages from the remote control delivered with the micro heli using the IR Toy:
Here I only list the Least significant byte of the 16 bitsvalue read by the IR Toy because the most significant byte is 0 for every reading except for byte 34:
byte 1: startbyte (always 1)
byte 2: throttle on/off (1=off 0=on)
byte 3 to 9: throttle values (0b0000000 to 0b1111110)
byte 10 to 14: left/right value (default 0b1000)
byte 14 to 18: forward/backward value (default 0b1000)
byte 18 and 19: channel A=0b01,B=0b10,C=0b11
byte 20: ?
byte 21: toggle video on/off
byte 22 and 23: ?
byte 24: trim left
byte 25: trim right
byte 26: toggle light
byte 27: toggle turbo
byte 28: take photo
byte 29: demo
byte 30 to 34: checksum (sum all bytes==1) %(mod) 16
byte 34 : total packetlength in microsec = sum(all byte-lengths of byte 1 to 34, bin(ord(least significant readbyte))*21.3333)
Hopefully I have not made to many errors so far.
For the reverse action, that is, to program code for letting the heli exercise some nice movements, I like to get some help from someone who knows how to write python. Some example code would be very nice but any advice is appreciated
gr,
Frank Westland
I'm making some progress. here is my output from my commandline when I send the ir toy some chars in python 2.7
Please, respond if you have any suggestions to overcome the buffer underrun after sending the last string (with length = 8 chars) in the package:
#run selftest
written hex(ord(byte)) : 1 0x56
respons byte no 1 chr(ord()): V
respons byte no 2 chr(ord()): 2
respons byte no 3 chr(ord()): 2
respons byte no 4 chr(ord()): 2
written hex(ord(byte)) : 1 0x54
respons byte no 1 chr(ord()): F
respons byte no 2 chr(ord()): A
respons byte no 3 chr(ord()): 2
respons byte no 4 chr(ord()): 0
written hex(ord(byte)) : 1 0x53
respons byte no 1 chr(ord()): S
respons byte no 2 chr(ord()): 0
respons byte no 3 chr(ord()): 1
written hex(ord(byte)) : 1 0x24
written hex(ord(byte)) : 1 0x25
written hex(ord(byte)) : 1 0x26
set the modulation frequency
written hex(ord(byte)) : 1 0x6
written hex(ord(byte)) : 1 0x4e
written hex(ord(byte)) : 1 0x0
==========================
The Packet to be send:
Amount of strings
(with length 62 chrs (except the last one is shorter and ends with 0xFF 0xFF))
to be sent: 2
Iterative part with:
written hex(ord(byte)) : 1 0x3
respons byte no 1 hex(ord()): 0x3e
send string - 0 with length: 62
respons byte no 1 hex(ord()): 0x3e
send string - 1 with length: 8
respons byte no 1 hex(ord()): 0x3e
#'t' = 0x74 for the amount of bytes send
respons byte no 1 hex(ord()): 0x74
respons byte no 2 hex(ord()): 0x0
respons byte no 3 hex(ord()): 0x46
#Here we seem to have and 'F' (for buffer underrun) instead of 'C' for succes
respons byte no 4 hex(ord()): 0x46
respons byte no 5 hex(ord()): 0xff
respons byte no 6 hex(ord()): 0xff
respons byte no 7 hex(ord()): 0xff
respons byte no 8 hex(ord()): 0xff
respons byte no 9 hex(ord()): 0xff
respons byte no 10 hex(ord()): 0xff
==========next packet===============
resetting:
written hex(ord(byte)) : 1 0x0
written hex(ord(byte)) : 1 0x0
written hex(ord(byte)) : 1 0x0
written hex(ord(byte)) : 1 0x0
written hex(ord(byte)) : 1 0x0
end
------------------
(program exited with code: 0)
Press return to continue
send string - 0 with length: 62
respons byte no 1 hex(ord()): 0x3e
send string - 1 with length: 8
respons byte no 1 hex(ord()): 0x3e
Did you include the 2 'FF' terminating bytes (in the 70 you sent) to signal end of transmission?
If not this would explain an under-run!
[quote author="Hybrid02"]How do I put the IRToy into a mode where I can detect / display the frequency of the incoming signal?
thanks.[/quote]
It is described on the following page: http://http://dangerousprototypes.com/docs/USB_IR_Toy:_Sampling_mode
look for 0x04 Frequency report
It is essentially a command issued when in sampling mode. You issue the command only after a signal is received (or the command provides the info for the last received signal)
2 values are returned. There is a bug with the second value & unfortunately, the firmware hasnt been updated with the fix.
The first value is usually ok, as long as the remote is held close to the IRToy. (cms)