XRF. What am I doing wrong?

peatatnaples

New Member
I have been using a 14M chip to control "use" of power generated by photo-voltaics. As these are 70metres from the house I'ved used a small pv connected to the system to feed in light data. I thought to update using a current sensing transformer on the pv's and wireless transmit the data to the house. XRF seemed quick and easy for the job but I must be doing something wrong. I have been trying to read adc on an 08M2 and transmit this variable to another 08M2 to control an LED. See transmit and receive programmes and attached diagram.
Thanks in anticipation Peat
Code:
'TRANSMITTER This should read a voltage and send it by XRF

symbol varA = b0
let dirsC = %00010101   'sets inputs & outputs
high C.4 'sets serout pin3  high for XRF

main:
	readadc C.1, varA' reads voltage on C.1 (pin6)
	serout C.4,T2400_4,(varA)'send voltage out of pin 3 @9600baud
	pause 2000' wait a bit

	goto main

Code:
'RECEIVER This should get voltage from XRF and use it
	symbol varA = b0
	let dirsC= %00010101  'sets inputs & outputs
rmain:	
	serin C.3,T2400_4,varA'receives voltage on pin4 @9600b
	if b1 >200 then high C.2 else low C.2 endif 'light diode pin5 if high voltage
	pause 2000
	goto rmain
 

Attachments

geoff07

Senior Member
So what are the symptoms?

You might want to consider using a qualifier. That is a string that is sent to allow the receiver to separate the wanted signal from noise. See the manual.

Why the pause in the receiver program?

What baud rate is it operating at? 2400 or 9600?
 

Haku

Senior Member
One of the first important things to do with XRF's is to pull pin 3 (its RX line) high as leaving it floating through not connecting it to anything or connecting it to the pin of a Picaxe which is set to input can introduce the problem of 0's being randomly transmitted through the antenna as the XRF thinks it's receiving data through its RX pin.

Either connect that pin to the +3v line or issue "high b.3" (or whatever pin you're using) at the beginning of the code.

If you haven't set the XRF baud rate it'll be defaulted to 9600.
 

westaust55

Moderator
It can also be worth trying a test with the XRF modules disconnected and run a wire between the Serout and SerIn pins to prove that the rest of the project is in fact working correctly (don't forget to link the ground (0 V) side of the supply rails together as well.
Once the rest is proven, then add the XRF modules.
 

peatatnaples

New Member
Thanks all for response. Symptom was high adc input on transmitting chip failed to light diode on receiving chip. i have since read that C.3 as serin input needs external diode so I have swapped pins and used a wire to connect chips and it works OK. but still fails to work wirelessly. Do all the component parts need to be at same baud rate? to get 08M2 to do 9600baud I will need to setfreq m8 as 2400baud is max at 4mHz or can the XRF be slowed to 2400? The pauses were in the program to help my slow old brain keep up with it on simulator.
 

westaust55

Moderator
Yes, whether wired or wireless comms, it is essential for both the sending and receiving modules on ANY project to be set to the same baudrate otherwise the receiving end will only detect "garbage".

With the PE in simulation mode, as well as single step mode to slow the process down, there is also an option to slow the speed down - have a look in the Options window.
 

Haku

Senior Member
As far as I'm aware you can have one Picaxe connected to an XRF at 2400 and another Picaxe connected to another XRF at 9600, and they will communicate with each other so long as the XRF's radio data rate (ATDR setting) is the same on both modules, and so long as you don't try to continually stream data at a higher rate than the radio data rate or lowest baud rate.
 

peatatnaples

New Member
Sorted. Setting the 08 to 9600baud and putting a debug line in the code allowed me to see some odd values caused by a faulty switch which effectively left the input floating when the switch was not pressed. So onwards to the next problem to stimulate the brain. Thanks all
 
Top