wireless signal

mas11

Member
Is there a way to check and see if a signal is coming in from the receiver on a 433mhz system. I would like to know if the transmitter is sending a signal or not sending a signal. If not, then I would like to have a message displayed on the lcd stating that there is no signal. I finally got the picture on sending the code to PHanderson's 117lcd so I think I can figure out that part. I just need a little help in how to start. Can I just have the program look to see if a variable is present and if not then have a sub routine run until a variable is present? Would that work?

Thank you,
mas11
 

Dippy

Moderator
Which receiver?
There are many, many varieties.
On receivers with RSSI you could possibly ADC the level.
On others you might have a general transmission and sniff for that.
If you are detecting a sent byte you'll have to have some clever method if using a blocking command.
If you provide more info then people can/may provide you with a nice slick solution.
 

davehouston

New Member
It depends on the receiver and on the protocol used. Most standard protocols use some type of preamble to set the AGC/ATC levels in the receiver. You can use pulsin to detect it and trigger your receive routine. Even with RS232 via RF a preamble is a great help.

Also, some ASK receivers have a linear (analog) output pin. You can use it as an RSSI indicator with some simple circuitry and an ADC pin. It also is a tremendous aid for tuning the receiver, even with a meter.

A few oscilloscope screenshots on my web page may help with understanding this.

Finally, most FSK receivers have a Carrier Detect (CD) output which indicates when a signal is being received.
 

mas11

Member
I am using the transmitter and receiver sold by jaycar. How would I use pulsin to trigger a message? Would I have to use the word variable and check its state as to wether or not it is greater than zero? If not then do a sub routine, if greater than zero then, continue with program? Please check my code.

Code:
 'Relative Humidity, Temp, Volt, Receive
symbol  LCD_PIN = C.2
init:   

	serout LCD_PIN,T2400_8, ("?f")
	PAUSE 1000
	High LCD_PIN
	setfreq m8 
	Pause 2000
	serout LCD_PIN, T2400_8, ("?S2")
	pause 1000
	serout LCD_PIN, T2400_8, ("?f")
	pause 4000
	serout LCD_PIN,T2400_8, ("?C0      Digital         ?n")
	pause 2000
	serout LCD_PIN,T2400_8,("?C1    Thermometer       ?n")
	pause 2000
	serout LCD_PIN, T2400_8, ("?f")

main:	

	
	serin C.1, T2400_8, ("data"), b0,b1,b3,b4,b5,b6,b7,b8,b9
	pulsin C.1,1,w7
	pulsout B.1,100
	if w7=0 then gosub NoSignal
	'pulsout B.1,2000
	'serout C.2,N2400,(254,1) 'Use this line if you want to refresh screen constatnly
	'serout C.2,T9600_16, ("?f")
	pause 4000
	'serout C.2,N2400,(#b0,",",#b1,",",#b2,",",#b3)
	serout C.2,T2400_8, ("?x00?y0") 'Line one
	pause 400
	serout C.2,T2400_8,("Humidity ",#b3,"%")
	pause 400
	w2=b1*9/5+32
	
	'serout C.2,n2400, (254,192,",",#b4,",",#b5,",",#b6,",",#b7)
	serout C.2,T2400_8,("?x00?y1") 'Line 2
	pause 400
	serout C.2,T2400_8,("Temp ",#b1,$DF,"C","  ", #w2,$DF,"F")
	pause 400
	serout C.2,T2400_8,("?x00?y2") 'Line 3
	pause 400
	serout C.2,T2400_8,(#b8) 'Integer
	pause 400
	serout C.2,T2400_8,(".")
	pause 400
	serout C.2,T2400_8,(#b9) 'Decimal
	pause 400
	serout C.2,T2400_8,("volts")
	pause 400
	'display on LCD
	pause 400
	serout C.2,T2400_8, ("?c0")
	
	debug
	pause 400
	'serout C.2,T2400_8, ("?c0")	
	'pause 4000								; Show the data received
	goto main								; read the next data
	
	
NoSignal:
		serout C.2,T2400_8, ("?f")
		pause 1000
		serout C.2,T2400_8, ("?x00?y0")
		pause 1000
		serout C.2,T2400_8, ("No Signal")
		pause 1000
		serout C.2,T2400_8, ("?f")		
		goto main

Thank you,

mas11
 
Last edited by a moderator:

SAborn

Senior Member
You could just use Hserin and receive the serial into the background of the picaxe and then check in program if there is data there to use.

This way the program runs as normal and just checks the Hserin variable for data, and not get hung up with waiting for serial data on a serin command.

Just one word of warning with using background receive, when you enable Hserin it also enables the Hserout pin, i got caught on this as the Hserout pin was used for a different application in my circuit, and lots of wierd stuff happened that took a while to sort out why.
 

John West

Senior Member
mas11, if you type a left bracket, the word 'code', then a right bracket, then C&P your program, then follow it with a left bracket, a forward slash, the word 'code' again, and a right bracket, your code will appear in a nice compact scrolling window in your post.
 

Goeytex

Senior Member
Along the lines of what SAborn said ...

You could also use < setintflags %00100000,%00100000 > to detect when data is received
in the background via background receive. Or even test for a change in the value of the hserptr
system variable .

These both assume that you are using a Picaxe X1 or X2 that support background receive.
 

mas11

Member
I am using a 14m2 chip. Some of the suggestions are a little bit beyond my basic understanding. If a smal example is given, I could maybe understand a bit better.

mas11
 

SAborn

Senior Member
These both assume that you are using a Picaxe X1 or X2 that support background receive.
Much to my supprise the M2 range also supports background receive. ( very well a great option)
 

SAborn

Senior Member
For starters we set up the command, this is normally in the preamble before "main" something like.........

hsersetup B4800_8, %0

Then in program we check the Hserin variable for data........

If hserin > 0 then................?
if hserin = 123 then.....................?

In a basic understanding, any serial data received will be placed in "hserin" variable and its a matter of using that variable as any other variable would be used in program.
 

hippy

Technical Support
Staff member
Is there a way to check and see if a signal is coming in from the receiver on a 433mhz system. I would like to know if the transmitter is sending a signal or not sending a signal.
The problem with dumb RF modules is they will produce high and low outputs in the absence of any signal so you cannot rely on its output activity alone to indicate presence or absence of the transmitting signal.

You can attempt to detect valid data packets using SERIN with qualifiers ( or other similar techniques ) and timeout when you don't get a valid data packet and use that to flag a lack of signal, but the problem is that, while the SERIN sees the random noise from the RF module, it won't timeout.

The usual solution is to use two PICAXE; one looking for valid packets from the RF module and setting an output flag when those are received. A second PICAXE can instruct that to clear the flag, start looking for packets and looks to see if the flag has gone high. If after some time it has not then it can indicate there is no valid data signal.

Using NKM2401's the receiver part acts as if it were a second PICAXE which can make things easier.

You could perhaps use an X2 and background receive to accept all RF data, noise, garbage and all, and attempt to parse that to see if it contains a valid packet within a certain time frame but that is more complicated than a two PICAXE or NKM2401 solution.
 

Goeytex

Senior Member
Much to my supprise the M2 range also supports background receive. ( very well a great option)
Yes but they only have a 2 byte receive buffer and do not receive into the scratchpad. IMO it's pretty useless without some pretty tricky code to process incoming data on the fly. The M2 does not support setintflags or hserptr.
 

hippy

Technical Support
Staff member
The benefit of the M2 HSERIN is that it can receive data at any time and always have the last byte received available. That's handy for an M2 smart peripheral that can be controlled by a single byte as there's no worry for the sender as to whether or not it can send data.

It's not so useful for multi-byte commands unless the data received is taken before more is sent. It is possible to implement a 'polled background receive' if the data rate is not too high ...

Code:
Do
  b1 = 1
  HSerIn w0
  If b1 = 0 Then
    @bPtrInc = b0
  End If
Loop
 

mas11

Member
Thanks for the help guys. I think sometimes I try to do too much with too little knowledge. I am still a novice at this programming and there is still a lot I don't understand. But with your help, I am still learning. So I have to put a hsersetup first? I am running at 2400_16. Will that work or do I have to do someting different?

Thanks,

mas11
 

SAborn

Senior Member
I am running at 2400_16. Will that work or do I have to do someting different?
hsersetup B2400_16, %00

lookup hsersetup in the manual, albeit its not very clear to follow what is X2 or M2 related to this command.
 

mas11

Member
No, its not very clear. And being new at this stuff, I don't fully understand the baud rate vs frequency. So I gather that I cannot use %00. Do I need all five bits? I see that the M2 cannot use the automatic mode in scratchpad. Only the 20X2, 28X1,2 and 40X1,2 chips. Do I sound totally confused?

mas11
 

SAborn

Senior Member
Ok, hserin wont work for you as it is only 2 bytes allowed in the M2 range, and looking at your code you are wanting 9 bytes of data.

Time to find a planB solution.
 

mas11

Member
You are correct about the 9 bytes of data. Thanks for the help. I'll look for plan B.
Does the X2 chip support more than two?

mas11
 
Last edited:

Goeytex

Senior Member
The 20X2 can background receive 128 bytes into scratchpad memory. The 28X2 and 40X2 have a 1024 byte scratchpad.
 

ciseco

Senior Member
The new v1.5 XRF supports RSSI on pin 6 as a PWM output, a capacitor and read the resultant on a ADC will give you an easy way to see signal go up & down.
 

ciseco

Senior Member
Read the thread somewhat more, on an XRF you can pause communications whilst you go do something else. The device has it's own micro and memory so buffers until you wiggle a pin to "release" the data again. Means even on an 08M you can workaround the "blocking" serial in command so you dont need background recieve in many situations.
 
Top