Serin and serout o8M to 08M

wlie

Member
I bought a wireless receivers and transmitters from Hongkong, just want to play with them. Now I tried to transmit data between two 08M. After one day of struggling I gave up. I never got the same data on the receive side as send from the transmit side. Only nonsense.
Then I put a wire between the two 08 with the same dismal result. What I thought was a simple task looks like learning to fly a jet. I have search the forum and tried the most (I think). Also tried to replace the two 08 with som brand new one.The distance between the two are about 25cm and using the same power supply.
Tried with N2400, T2400, N1200, T1200. Also tried with "pulsout 1,200" instead of "SerOut 1, T2400, (85,85,85,85,85,85,85,85,85,85)".
The code is very simple.

;Transmit code:
#PICAXE 08M
#terminal off

Transmit:
Do
;pulsout 1,200
high 1
SerOut 1, T2400, (85,85,85,85,85,85,85,85,85,85)
Pause 5
SerOut 1, T2400, ("ABCDEF")
Pause 1000
Loop

;Receive code:
#PICAXE 08M
#terminal 4800

Receive:
Do
SerIn 2, T2400, b0
If b0 > $20 And b0 < $7F Then
SerTxd( b0 )
End If
Loop
 

Jamster

Senior Member
When connecting picaxe together by wire you need resistors on the pins and a resistor to ground between them. I cant remember the values of the top of my head though, e?

Code:
Tx--\/\/\/\/----+----\/\/\/\/----Rx
                |
0v---\/\/\/\/---+
Asci art not good sorry

Please post a datasheet to the Rf links to.

EDIT: on the receiving end try
Code:
;Receive code:
#PICAXE 08M
#terminal 4800

Receive:
Do
SerIn 2, T2400, b0
SerTxd( b0 )
Loop
 
Last edited:

hippy

Ex-Staff (retired)
Hardware ...

Connect the SEROUT pin to the SERIN pin, join the 0V together.

Software ...

Transmitter:
Do
Pause 1000
SerOut pin, N2400, ( b0 )
b0 = b0 + 1
Loop

Receiver:
Do
SerIn pin, N2400, b0
SerTxd( #b0, " " )
Loop
 
Last edited:

wlie

Member
Hippy
That worked fine - b0 is now counting up on the receive side. Next - how can I for example send "Hello World" or any other characters? I would think that the code as I described in my post #1 should work.

Jamster.
It should not be necessary to use resistor as long I use the same power supply.
I have done as Hippy suggest "Connect the SEROUT pin to the SERIN pin, join the 0V together".
 

hippy

Ex-Staff (retired)
The problem with the first code is that you are sending too quickly for the receiver to keep up. Try this ...

Transmitter:
Do
Pause 1000
LookUp b0, ( "Hello World" ), b1
SerOut pin, N2400, ( b1 )
b0 = b0 + 1 // 11
Loop
 
;Transmit code:
#PICAXE 08M
#terminal off

Transmit:
Do
;pulsout 1,200
high 1
SerOut 1, T2400, (85,85,85,85,85,85,85,85,85,85)
Pause 5
SerOut 1, T2400, ("ABCDEF")
Pause 1000
Loop

;Receive code:
#PICAXE 08M
#terminal 4800

Receive:
Do
SerIn 2, T2400, b0
If b0 > $20 And b0 < $7F Then
SerTxd( b0 )
End If
Loop
You are sending the 'ABCDEF' on the Tx side as a qualifier without sending any actual data, and then not checking for the qualifier at the receiver. Take the quotes out from your second serout and your code ought to work.
 

wlie

Member
hippy
Yes, this also works (except I only see 72 101 108 108.. which represents the ascii value), but isn't there a way to send these characters a little faster, it works very slowly.

calvinsykes
Maybe my English is a little rusty. I don't realy understand what you mean by "qualifier" and also I can't see how to remove the quotes as the program will not accept this. Ascii character should be in quotes - or? Please write the code line for me.
 
Yeah, sorry. I'm wrong. Forgot that quotes were needed for ascii strings. What I mean by qualifier is you can tell the transmitter to send something that the receiver then 'listens' for. The receiver will only accept the incoming byte if it is preceded by the qualifier byte, otherwise the picAXE will just pick up on interference and treat it as if it were real data - so you would get the 'nonsense'. The code I used when trying to get radio communication to work is:

Tx:

Code:
main:	for b0 = 0 to 100 'loop
	serout 5, T600, (0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55) 'preamble
	pause 15
	serout 5, T600, ("data", b0) 'send qualifier (I called it "data") then send variable
	pause 200
	next
	goto main
Rx:

Code:
main:	serin T2400, 0, ("data"), b0 'only accept the byte if it is preceded by the qualifier
	debug b0 'send value to PC
	goto main
 
i'm going to have to sign off for the night (exam tommorow:( ) so see if that helps at all, and I'll have a proper go tomorrow.
 

westaust55

Moderator
Jamster.
It should not be necessary to use resistor as long I use the same power supply.
I have done as Hippy suggest "Connect the SEROUT pin to the SERIN pin, join the 0V together".
Directly connecting two PICAXE pins together will definitely work as you have found.

However there can be problems and catastrophe on a PICAXE scale IF something goes wrong.
The 08M and all X2 and M2 parts can have most of the IO pins set as inputs or outputs. If all goes right and your programs do the right “thing” then no problem exists.

But if a command wrongly sets the input pin of the receiving end as an output then the smoke begins.

Consider that one output is set high (ie near 5 Volts) and the other is set low (ie near 0V) then you have virtually a short circuit across the power supply through the PICAXE chips which will have an extremely high probability of damaging the PICAXE chips.

For this reason, if you want to take precautions, it is often recommended to insert a single resistor between the two PICAXE pins. Any value from 220 Ohms and above can be used as 220 Ohms is sufficient to limit the current to 20 mA which is within the capabilities of the PICAXE chip.

In summary – use of a resistor is not mandatory, but is recommended.


Note: 220 Ohms comes from (5.0 Volts – 0.3 Volts) – 0.3 Volts / 0.020 Amps = 220 Ohms
 

wlie

Member
westaust55
I agree, despite the fact that a PICAXE 08m is cheap, so is a resistance much cheaper. Now I have sacrificed a 220 ohm resistor. Thanks for your advice.

For everyone else, thanks for the help. All problems solved - your help and reading the manual did it. Actually, it was all in the manual!
And now I will try to transmit wireless, which was my original project.
 
Top