How fast can can I transfer 4096 bytes between two PICAXEs using IR ?

Buzby

Senior Member
Hi All,

I'm trying to determine the feasibility of sending 4096 bytes between two PICAXEs, using just IR.

From Manual 2, for the Sony protocol, a Logic level 1 is transmitted as a 1.2 ms pulse, logic 0 as a 0.6ms pulse. Each bit is separated by a 0.6ms silence period.

Using the above figures, the maximum length of a bit is 1.8mS including the inter-bit silence.

4096 bytes = 32768 bits, which gives a maximum time of 32768 * 1.8mS, which is 58.98 seconds.

I am intending to use PWM to fake the Sony protocol, so I can use the full byte instead of just 7 bits.

Then I will then use PULSIN on the second PICAXE to decode the pulses from the IR receiver.

Both PICAXES will be 28X2-5's.

Does this seem feasible ?

Or better still, is there a solution in the forum somewhere ?

Cheers,

Buzby
 

Dippy

Moderator
Why not just try simple serial modulating the IR ? - assuming you are using off-the-shelf receiver modules.
If you make your own hardware you could run it faster.
Depends on the hardware you plan to use and your own design ability.
 

erco

Senior Member
+1 Dippy! I have often wondered how well a simple serial IR data link would work. The throughput of the IR receiver module is likely the limiter. BTW, there are many different variations of IR receivers. Waitrony has ~two dozen variants, each one specialized for a given set of conditions, like high sunlight conditions, continuous signal acceptable, etc. There's probably a few for higher data rates as well.
 

Buzby

Senior Member
Hi Dippy,

The IR receiver needs to see a 38KHz carrier, so if I was to use serout or similar I would need to add hardware to modulate a carrier.

(( Idea ! ?. Connect the Tx LED between the PWM pin and the SEROUT pin, with a resistor of course.
When SEROUT pin is low LED will flash at PWM rate. When SEROUT is high LED will not light.))

I looked at the Sony spec, and assumed the timings were the best you could get.
After all, Sony would have had a much bigger research team than me when they designed it.

Also, the normal IROUT/IRIN will still be needed, so I can't stray too far from the normal hardware.

I will be able to try these ideas shortly, when I receive some new IR receivers, ones which still have their magic smoke inside.

Cheers,

Buzby
 

Paix

Senior Member
I have a related question that is close to my heart.

My context is a variant of R Burnett's TDMS (Telegraph Distortion Measuring Set) standard serial tester. Taking the serial output at a suitably low baud rate from the 08M2, and feeding it into a second 08M2 operating as an AFSK/Morse Tone Modulator state machine.

My application would be selected to operate Tone Modulation or AFSK (Audio Frequency Shift Keying) modes depending on a mode input being high or low and a logic signal input to represent either a Morse or relatively low baud speed Telegraph signal. The modulator would be receiving debounced data levels (debouncing for mechanical inputs to be looked at once the initial work is proven). On change of signalling input level, the Modulator would select or turn off the appropriate PWM signal for the desired frequency of output. In my case 800Hz or so for Morse and 2125Hz and one of 2195Hz, 2250Hz or 2795Hz for telegraph (170Hz shift, Narrow shift 450Hz or Standard shift 850Hz). I'm not sure that I can get the PWM with a 1:1 duty cycle low enough for my needs. Program Editor is on a Windows Laptop upstairs, so haven't looked yet, but I am certain that similar principles could be used to modulate/manipulate a 1:1 PWM signal at around 38kHz in order to radiate a form of FSK signal which might be discriminated to recover mark or space signalling conditions.

Some info might be had in the "Handbook of Optical Through the Air Communications" from http://www.imagineeringezine.com/files/air-bk2.html
 

hippy

Technical Support
Staff member
Using more trickery with the on-chip Data Signal Modulator hardware of the M2 the modulator and carrier can be combined onto a single pin, inverted if needs be, allowing simpler IR LED driving, especially if via transistor or FET.

Serial IR worked at 2400 baud but not exhaustively tested. 4800 baud did not seem to work but I did not investigate further.

An IR LED+R across PWMOUT and SEROUT pins should also work as suggested.

Code:
#Picaxe 08M2

' IR modulated output on Out 0, to LED+R to 0V

Low 1

PwmOut 2, 27, 56       ; 36kHz

PokeSfr $FC, %11000000 ; SFR $39C MDCON
PokeSfr $FD, %00000001 ; SFR $39D MDSRC
PokeSfr $FE, %00000000 ; SFR $39E MDCARL
PokeSfr $FF, %10000100 ; SFR $39F MDCARH

Do
  SerOut 1, N2400, ( "U" )
  SerOut 1, N2400, ( b0  )
  b0 = b0 + 1
  Pause 1000
Loop
Code:
#Picaxe 28X2
#Terminal 9600
Do
  SerIn C.0, T2400, ("U"), b0
  SerTxd( #b0, " " )
Loop
 

Buzby

Senior Member
Hi Westie,

I knew someone had done it before, your document is first class !.

Putting the IR LED between two pins will limit the current, but on my breadboard I'm not worried.
If this idea turns into a full blown project then the IR will be output from multiple LEDs with transistors.

Did you do any checks for the highest baud rate using the PWM+Serial method ?.

Cheers,

Buzby
 

Buzby

Senior Member
Using more trickery with the on-chip Data Signal Modulator hardware of the M2 the modulator and carrier can be combined onto a single pin
I drooled over that !.

The DSM was my first idea, but they don't have DSM's in X2's.

Serial IR worked at 2400 baud but not exhaustively tested. 4800 baud did not seem to work but I did not investigate further.
There will be a maximum baud rate, probably related to how many cycles of 38KHz 'fit in' to one serial bit time.
I suspect if the number is too low the IR receiver won't 'lock on'.

My hardware should arrive today, and I'll be back home, so I'll try the various options tonight.

Cheers,

Buzby
 

Buzby

Senior Member
Hi hippy,

Even though I've not got an M2, I tried to follow how you set the DSM control registers :
Code:
PokeSfr $FC, %11000000 ; SFR $39C MDCON  =  Enable DSM and DSM output, I get that OK
PokeSfr $FD, %00000001 ; SFR $39D MDSRC  =  Source from MDMIN pin, I don't see how this works, I expected EUSART ( 1010 )
PokeSfr $FE, %00000000 ; SFR $39E MDCARL =  CarrierLo set to Vss, I think
PokeSfr $FF, %10000100 ; SFR $39F MDCARH =  CarrierHi set to PWM CCP1, I think
I get the first, not the second, and the last two the enable/disable bits seem reversed.

Where have I gone wrong ?

Cheers,

Buzby
 

hippy

Technical Support
Staff member
I get the first, not the second, and the last two the enable/disable bits seem reversed.
The second is MDMIN pin, which is pin 1, and that's driven by SEROUT 1 so used as an output and an input - not recommended but works in this case.

The last two are set so when SEROUT idles low and MDMIN input is low, 0V (Vss) is output (MDCARL), when high the PWMOUT is selected (MDCARH). The msb of the last set disconnects the PWMOUT from pin 2 so it can be used as a normal output pin if required ( ie a TOGGLE 2 could be added to see the looping taking place )
 

Buzby

Senior Member
It's getting clearer !.

However, I must do some paid work, so I'll have get of the forum now !.

Cheers,

Buzby
 

Buzby

Senior Member
Serial IR worked at 2400 baud but not exhaustively tested. 4800 baud did not seem to work but I did not investigate further.
I got my setup working, PWM+SEROUT with the IR LED across the two pins.

2400 baud works fine, I sent many 100's Kbits with no problem.

4800 baud was useless, until I increased the PWM rate.
Setting it to 70KHz allowed transfers at 4800 with less than 0.5% error.

Going over 70KHz nothing worked, I think the frequency is too high for the IR receiver.
I think the only way to get high speeds is to use an IR receiver tuned for a higher frequency.
I've seen 60KHz ones, there may be even higher.

Tomorrow I'll try to optimise, - run at 32MHz, use hser, prune the code, etc.

As it is, I'd be quite happy with the performance at 2400 or 1200 baud for most applications.
It's easy to code, you just use serin and serout as normal.
And it's cheap. What other wire free communications link can you make for less than £1 ?.

Cheers,

Buzby
 

inglewoodpete

Senior Member
I got my setup working, PWM+SEROUT with the IR LED across the two pins.

2400 baud works fine, I sent many 100's Kbits with no problem.
Out of interest, how long did the 4k data transfer take, compared with the theoretical 4kB/minute you calculated for IR protocol?
 

Buzby

Senior Member
It takes about 35 seconds at 2400 baud.

The theoretical value ( from http://www.calctool.org/CALC/prof/computing/transfer_time ) is less than 14 seconds.

My experimental code is very ragged, it needs a good tidy up, and it's only running at 8 MHz.

I'll try at 32MHz and report back.

EDIT : I forgot, can't run at 32 till I work out how to get slow baud rates. ( There is no T2400_32 constant )

EDIT : hserout !
 
Last edited:

Buzby

Senior Member
Progress !.

Using hser and running at 32 MHz the transfer time for 4096 bytes is now 20 seconds.

This is quite good, but I think it could be made better.

More experiments later !.

Cheers,

Buzby
 

inglewoodpete

Senior Member
You probably won't get much faster. The IR receiver module requires a minimum number of (38*)kHz pulses to recognise a transition. Send too fast and there are not enough carrier pulses to trigger an output.
 

Buzby

Senior Member
Yes, I suspected that at post #10.

But I did yet improvements in speed by setting PWM higher than 38KHz, upto 70 KHz before it stopped working.

The higher PWM means more cycles per bit, but the IR receiver is tuned to 38, so it's response drops off dramatically either side.

There are IR receivers with frequencies of 60KHz, and maybe others are higher.
Using these it should be possible to go much faster.

Anyway, I'm happy with 20sec, it's plenty fast enough for what I need.

Cheers,

Buzby
 

hippy

Technical Support
Staff member
As inglewoodpete says; 38kHz is ~26us, at 4800 that's 206us per bit so at best 9/10 pulses of IR per bit. It can require 6+ pulses to be considered IR detection, and even if the pulses are seen, the serial signal and its timing out of the receiver will be quite different from the serial in to the IR LED. The mid serial bit sampling may be borderline or not work at all.

Code:
           |   S   |   0   |   1   |   2   |   3   |

OUT : _____|||||||||_______|||||||||_______|||||||||_______

       _________    ____________    ____________    _______
IN  :           |__|            |__|            |__|
                :   :       :       :       :       :
                :   :       :       :       :       :
                |   S   |   0   |   1   |   2   |   3   |
 

hippy

Technical Support
Staff member
Interesting reading in there which I've seen before but never paid too much attention to ...

• Enhanced data rate up to 4000 bit/s

• Burst length should be 6 cycles/burst or longer.

• After each burst which is between 6 cycles and 70 cycles a gap time of at least 10 cycles is necessary.

• For each burst which is longer than 1.8 ms a corresponding gap time is necessary at some time in the data stream. This gap time should have at least same length as the burst.

• Up to 2200 short bursts per second can be received continuously.

I suspect most of that is dictated by the AGC and detection algorithms in the chip so it would be interesting to compare other manufacturer's devices.

IrDA allows up to 115200 baud so maybe look at non-modulation mechanisms if you want higher baud rates because demodulation requirements are probably the limiting factor.
 
Top