Error, Wireless Comms between PIC's

manutdfan2004

New Member
I have built two circuits both with PICAXE 18X chips, now I am trying to get them to communicate using an AM transmitter/receiver pair from maplin.

http://www.maplin.co.uk/Media/PDFs/vy48.pdf

However it isn't working as expected, I have the transmitter connected to an output pin (0) on the first PIC, and the receiver connected to the input pin (0) on the other PIC. Both are powered correctly as the programs run, the problem is that the output value of b0 that is transmitted to the PC does not increment from 0 to 100 it seems to hold a random value, I have included both the programs below in case there is something stupid I have done.

Any help would be gratefully received, otherwise its a case of me just messing around and hoping I can get it to work.

EDIT: Also after the transmitter is turned off the receiver carries on receiving data, I have check the grounding and it seems ok.

Code:
main:
	goto reading	'call code to send data to Transmitter


reading:		'reads data from sensors into registers

	goto send	'once registers updated send data


send:		'sends data from registers to Transmitter
	for b0 = 0 to 100
		high 3
		serout 0,N4800,(85,85,85,85,b0)
		pause 500
		low 3
		pause 500
	next b0
Code:
main:
	goto receive  'calls code to receive data from external device

receive:
	b0 = -1
	high 0
	serin 0,N4800,b0	
      pause 500
	low 0
	goto send 		'after data has been received call send to transfer
				'data onto computer

send:
	readadc 0,b0
						'to send data onto PC
	sertxd("The Value of b0 is: ",#b0,13,10)		'sertxd("The Value of b1 is: ",#b1,13,10)

	goto main
 
Last edited:

Andrew Cowan

Senior Member
There is a lot of noise over unfiltered links. It is nothing to worry about, and easy to sort. Try:

serout 0,N4800,(85,85,85,85,"data",b0)

with

serin 0,N4800,("data"),b0

You should find all the random values stop appearing.

A
 

russbow

Senior Member
Manutdfan, be very interested in your results as I bought a pair of these over the weekend. At under a tenner for the pair, just had to get them to play with.

Andrew, have you used FM versions of 433mHZ, if so any noticable difference in performance?

Russ.
 

manuka

Senior Member
Suggest you borrow a UHF scanner & tune the 433 MHz band as well. Failing that, test things in a quiet rural area. Many urban regions are so stuffed full of 433 MHz "noise" that sensible decoding is difficult. One approach is to go to FM TX/RX types rather than these ASK cheapies, as FM of course is immune to the impulse noises that may cripple AM receivers.

Of course start simply with PICAXE wireless too! Check some of my insights => www.picaxe.orconhosting.net.nz Stan
 

womai

Senior Member
You may also want to have a thorough reading through this recent thread:

http://www.picaxeforum.co.uk/showthread.php?t=11531&highlight=wireless+link

It gives some additional info about how to get a reliable link with those modules.

Some receivers will need a longer preamble (the 85's in your send string) than what you use; e.g. the ones I have want at least 5 for reliable communication across my lab. I'd suggest you start out with maybe ten preamble bytes, and once you get it to work you can always reduce that number and find out when it stops working.

Wolfgang
 
Last edited:

Hooter

Senior Member
I may have missed something here but after receiving data and putting the value in to b0, aren't you overwriting b0 with the readADC data command?
Hooter
 

manutdfan2004

New Member
Nice Spot Hooter, I had stuck that in there to test something else and forgot to get rid of it. However i've got another problem now, I can't seem to get the damn thing to send anything now, have connected an LED up to the same pin as the data connection for the transmitter and it never lights.

I did get it to transmit and receive for a very short time, although I still had that stupid readadc command in so it didn't work properly.

Its probably something very stupid so will have a look in the morning and hopefully it will have fixed itself. Fingers crossed anyway, thanks for all the help has been much appreciated.
 

womai

Senior Member
Since you have a transmitter and a receiver, I assume only one of them is connected to the PC through the download cable at any time? In this case, are you sure you have the serial download (receive) pin of the other Picaxe tied to ground with the 10 kOhm resistor? Forgetting that can indeed result in random resets and/or unreliable operation.
 

hippy

Ex-Staff (retired)
You might want to check the following thread and also do a forum search for the numerous other posts on wireless communications -

http://www.picaxeforum.co.uk/showthread.php?t=12203

Wireless comms has challenges because it doesn't work properly until you have it working properly and it is hard to see what exactly is going wrong when it doesn't. Don't over complicate the initial code as that just makes it harder to to achieve. Start simple, get that working, then build up from there. Otherwise it can be a case of "I'm going to learn to swim, and my first attempt will be swimming acoss the Atlantic" which may have disappointing results.

As I wrote in the linked thred -

For 433MHz interfacing the moral seems to be -

* Get the baud rate and polarity right for the modules being used

* Use receiving code along the lines of -

Do
SerIn rxPin, baud, ("XY"), b0
Loop

* Use transmitting code along the lines of -

b0 = "Z"
Do
SerOut txPin, baud, ("UUUUUUUUUUUUUUUUUUUUU")
Pause time
SerOut txPin, baud, ("XY", b0 )
Pause 1000
Loop

Then it's really a matter of finding an appropriate time and how many U's need to be sent, finally reducing the transmitting loop time, sending and receiving the actual data desired and altering qualifiers as necessary.

The U's are there as a pre-amble to kick the RF receiver into a state it is ready for receiving subsequent data without corruption. Sending too many shouldn't be a problem.

The PAUSE between the U's and the qualifier is there because the receiver's SERIN may have started to synchronise to one of the U's received part way through and without it the first part of the qualifier may be taken as the last part of a previous byte so SERIN never sees valid qualifiers. The PAUSE ensures the U's have all gone by and, regardless of what SERIN has seen, it will be ready and waiting for the start of the qualifier when those are sent. The length of PAUSE should be at least the length of time it takes to send a single byte at the specified baud rate.

The qualifiers are used so SERIN doesn't accept any data from the RF receiver until it is in a steady and stable state for receiving, ignoring any corrupt data which may arrive when it isn't.

The process is akin to ringing a bell in a crowded room before a speaker says what they have to. The bell silences the chatter, the pause lets the ringing in one's ears fade away. After that whatever is said can be heard clearly, the qualifier letting you decide if it's someone you want to hear from or not.
 

manutdfan2004

New Member
Since you have a transmitter and a receiver, I assume only one of them is connected to the PC through the download cable at any time? In this case, are you sure you have the serial download (receive) pin of the other Picaxe tied to ground with the 10 kOhm resistor? Forgetting that can indeed result in random resets and/or unreliable operation.
Yeh the transmitter circuit has no serial connection, which may be my problem as I have not got a 10kOhm resistor fitted, would this go between the serial in pin (3 in the case of an 18X) and ground?

Thanks for the advice Hippy, will simplify the code and give it another run, with this and the 10kOhm in place hopefully I should get it working.

Cheers again for all the help, without this I would still be having a fit on my own and the circuit would probably have been launched out the window.
 

manutdfan2004

New Member
Good News, Finally got it working properly this morning data transmission seems fine and not even losing any packets.

Just wondering if anyone has experience with interfacing analog multiplexors using PIC's, mainly if its possible to determine which port on the multiplexor the transmission is from?

If not no worries will just mean a bit of playing around tonight to see what happens.
 

eclectic

Moderator
Good News, Finally got it working properly this morning data transmission seems fine and not even losing any packets.

Just wondering if anyone has experience with interfacing analog multiplexors using PIC's, mainly if its possible to determine which port on the multiplexor the transmission is from?

If not no worries will just mean a bit of playing around tonight to see what happens.
Which Analog multiplexer?

Can you post a link please?
e
 

QuIcK

Senior Member
Good News, Finally got it working properly this morning data transmission seems fine and not even losing any packets.

Just wondering if anyone has experience with interfacing analog multiplexors using PIC's, mainly if its possible to determine which port on the multiplexor the transmission is from?

If not no worries will just mean a bit of playing around tonight to see what happens.
presumabley you tell the multiplexor which channel to select? could you not just send that before the value?
SerOut txPin, baud, ('XY', ChSel, ADCVal)
 

manutdfan2004

New Member
Cheers QuIcK, after re-reading the manual I think I understand how they work now, there are three logic gates A, B and C. Which by sending high can give all the eight possible inputs.

Just soldering it up now so hopefully should be working soon and I can start on the fun bit working out why it has broken.
 
Top