Rather, it should be this Thread here
http://www.picaxeforum.co.uk/showthread.php?20850-No-Timeout-When-Using-Serin-With-Qualifier
M.
http://www.picaxeforum.co.uk/showthread.php?20850-No-Timeout-When-Using-Serin-With-Qualifier
M.
I had the same problem with the timeout and qualifier, and found the answers offered in this thread to explain what I couldnt figure out. Thanks to all who contributed.
What I then did to get around the problem, is to use the timeout, and to include a dummy byte as the first byte sent in the serial data. On the receive side, the next line after the serin line, I simply do a 'if byte = dummy then goto...' line. If the byte does not equal the dummy then make another decision where to go. If it equals the dummy, ignore it as data, and continue with the next received data.
For more data security, this method could be expanded by multiplying all the sent data, (ignoring overflow) and sending the resulting byte (or Word) as a checksum. Then, receive all the data and the checksum, multiply all the data again and compare to the received checksum.
The answer to that is that it is not possible to do that with any reliability when using dumb RF modules. Any noise present on the RF module output which passes to the serial input will cause the timeout counter to reset and the timeout not to occur.The question is the same as the title to create Timeout When Using Serin With Qualifier for RF reception.
#picaxe 20X2
serin [timeout,toexit],S_out,baud,("A","B","C"),data1,data2,data3,data4
' From Hippy
Do
SerIn C.0, N1200, ($AA,$A5), b1,b2,b3
SerTxd( "b1=",#b1, TAB, "b2=",#b2, TAB, "b3=",#b3 ,CR,LF )
Loop
#Terminal 4800
#picaxe 14m2
#no_data
symbol RED = B.4
symbol GREEN = B.5
symbol rfsig = C.3
symbol beep = C.4
disabletime
low RED
high GREEN
b0 = 0
b1 = 0
main:
DO
b0 = 0:b1 = 0
serin [75,main],rfsig,N1200,("a9"),b0,b1 ;wait 75 milliseconds for start of a valid code
;if not received in time goto main
if b0 = 139 AND b1 = 213 then
toggle RED:toggle GREEN ;toggle bi-color LED
sertxd ("Codes Received -- ",#b0," and ",#b1,cr,lf)
high beep:pause 100:low beep ;energize beeper for 100 milliseconds
pause 1000 ;pause for one second
b0 = 0:b1 = 0
endif
LOOP
#picaxe 08M2
#no_data
symbol leg5 = C.2
low leg5
DO
serout leg5,N1200_4,("a9",139,213) ;send the code
pause 50 ;pause 50 milliseconds
LOOP
Hi pxgator, I don't know what the RF regulations for 315MHz transmissions are in your country but this sort of RF flooding would be illegal in Australia. I understand that 315MHz is used for car remotes and garage door openers and has many other uses in the USA.Transmitter Code:
Cheers To AllRich (BB code):#picaxe 08M2 #no_data symbol leg5 = C.2 low leg5 DO serout leg5,N1200_4,("a9",139,213) ;send the code pause 50 ;pause 50 milliseconds LOOP
P.S. I've tested this setup to 100 meters (open space) with 100% reliability
Good point Sir.Hi pxgator, I don't know what the RF regulations for 315MHz transmissions are in your country but this sort of RF flooding would be illegal in Australia. I understand that 315MHz is used for car remotes and garage door openers and has many other uses in the USA.
A transmitter that can reach 100m in open space and transmitting every 50mS will tend to swamp out use of anything else trying to use this shared band.
Sorry pxgator, but Pete is correct. I'm an RF specialist and I can assure you that if your range is around 100m in a fairly typical omni directional pattern, you will swamp EVERYTHING on that same band in that same range. It will cause interference. We have really strict regulations here. I'm not sure if you have a communication authority like we do in Australia, but if so, be really careful. If I was to do that, they would track me down, lock me up (in a cell with a huge guy called "Bubba") and never release me!!!Good point Sir.
This test was done with a 1/4 wavelength antenna ( 8.9" ) on the transmitter. With a PCB trace antenna
I don't think it would cause any interference.
Cheers to All
serin [75,main],rfsig,N1200,("a9"),b0,b1 ;wait 75 milliseconds for start of a valid code
Do you get locked up in the serin command line?[/QUOTE said:No Sir, no lock ups yet. So far I'm very pleased with the receiver's performance.
Cheers to All
P.S. With these cheap 315/433mhz receivers a superhetrodyne architecture
is a must for reasonable reliability. The superregen ones are way too noisy.
I found that the only reliable ASK receivers were the ones with an on-board crystal. Most ASK transmitters have a crystal anyway.P.S. With these cheap 315/433mhz receivers a superhetrodyne architecture
is a must for reasonable reliability. The superregen ones are way too noisy.