(Notice: this walkthrough is going to be updated as i don't have time ATM to make videos and photos, so stay tuned!)
INTRODUCTION:
Hi guys, here's what i learned about comunicating with Serial ports on my picaxe.
First of all, what can i do with this walktrough? Well, with serial comunication you will be able to transmit data from an mcu (picaxe) to another one. This could be useful if, for example, you want to make a remote with different buttons and want it to send different variables to the receiver, according to the button pressed.
But first i'd like to start with comunication with wires. The setup is pretty simple, all you need is a couple of wires.
SERIAL COMMUNICATION WITH WIRES:
What you have to do in this case is connect an output (any one) of the sender to the input(digital) of the receiver. You also have to make sure these two thing happen: (1) both grounds (of the two MCUs i mean) must be connected. This is because if electrons get sent from an MCU to another, they need to have a return path, in other words the circuit must be closed for the electrons to flow. (2) the input of the receiver must be connected to the ground in series with a 10k resistor, else it will act as an antenna (won't say anything else about this since i don't know much).
Now to the coding!
SENDER:
serout <outputpin>, <baudmode>, (<variable>)
That's it? yes... The output pin you are using goes into <outputpin> (wow i didn't know that!) the baudmode specifies the baud rate (i'd be glad if somebody more experienced than me could explain what it exactly is) and the polarity of the signal. For our type of connection we will be using iNverted (N) signals, while True outputs are used in conjunction with, say, a max232 chip. Just remember that not all speeds are available on every picaxe chip.
RECEIVER:
serin <inputpin>, <baudmode>, <variable>
where <variable> is where the variable received will be stored. (i will add some more infos about the other features of the SERIN command later on)
Remember that once the receiver bumps on the SERIN command, it will stop everything until it receives a variable, whereas when a program bumps on the SEROUT command, it will simply send out the code and get on with the program, even if that variable hasn't been received.
NOW IT'S INFRARED TIME!
well...it's quite the same. Only thing is that, of course, the two grounds won't have to be connected, as electrons won't be transmitted "over the air", they'll just enter the LED and get grounded, and that closes the circuit (simplified explanation)
The receiver will have the IR detector and demodulator connected to one of its inputs (connection depends on the type of receiver, however i'll be adding some schematics for a bunch of common TSOP sensors). The sender will have an IR led with its anode connected to a PWM port and its cathode to the ouput pin (which corresponds to the <outputpin>)
Coding:
the receiver has the same code as written before.
SENDER:
pwmout a,b,c
serout <outputpin>, <baudmode>, (<variable>)
where a, b and c are the fields which specify the pin used, the frequency and the duty cycle. This is needed because your IR sensors will work at a specific frequency, in other words they will only be detecting IR with a particular frequency (this of course depends on the receiver you are using. (for TSOPs the last two digits tell you the frequency in kHz they work at)
To make everything easier, just use PICAXE > Wizards > pwmout... your compiler. I am currently using 50% of duty cycle and it works fine for me.
And this ends the walkthrough! Hope you found it useful.