PDA

View Full Version : problem with sending data using RF module



rano_zen06
- 2nd April 2008, 11:14
Hello everyone,
I have a problem with sending data using my RF module, I don't know what the problem is.I try to change the baud rate but nothing happens.Actually I want to send a character using my RF module.But before I accomplish that, I want to test my RF module whether it's function or not.So I use this simple program to test it but my LCD at the receiver board display nothing. I don't know how to troubleshoot the problem because I'm new to this thing.Please help me guys.
Here is the code and the schematic of my hardware.

Transmitter part

CMCON = 7 'Alla I/O Digitala
LEDPin VAR PORTB.4
TransmitterPIN VAR PORTA.0
INCLUDE "modedefs.bas"
Counter VAR BYTE
Synk VAR BYTE
Synk = $55
DEFINE CHAR_PACING 500
Counter = 0

Main:
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

SEROUT TransmitterPIN,T2400,[Synk,Synk,9,Counter]

HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

Counter = Counter + 1
PAUSE 600
GOTO Main
END


Receiver part

Define LOADER_USED 1

' Define LCD connections
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISC = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low

pause 1000 'wait until the LCD initializes

INCLUDE "modedefs.bas"
Counter VAR WORD
ReciverPIN VAR PORTC.0
ADCON1 = 7 ' Alla digitala
PAUSE 500

Main:
SERIN ReciverPIN,T1200,[9],Counter
GOSUB LCD
GOTO Main

LCD:
LCDOUT $FE,1
LCDOUT $FE,$80,#Counter
PAUSE 500
RETURN

END

mister_e
- 2nd April 2008, 11:30
On the receiver code, you must change your ReciverPIN to PORTA.0, Counter must be a Byte, also baudrate must be the same on both sides.

On the transmitter side, there's a missing DEFINE OSC 20.

I will suggest you to test it without the RF modules for now. Once you have something workable, just add the modules.

Make sure the PIC config fuses are correctly set. At least HS_OSC and LVP_OFF.

rano_zen06
- 2nd April 2008, 13:05
On the receiver code, you must change your ReciverPIN to PORTA.0, Counter must be a Byte, also baudrate must be the same on both sides.

On the transmitter side, there's a missing DEFINE OSC 20.

I will suggest you to test it without the RF modules for now. Once you have something workable, just add the modules.

Make sure the PIC config fuses are correctly set. At least HS_OSC and LVP_OFF.

first of all..thanks mister_e for reply.I already change the code and increase my baud rate.But the result goes the same.My LCD still display nothing, but something unexpectedly happens, when I disconnect the power supply at transmitter board, my LCD at receiver part shows a number.What's actually happens ?Do I need to use encoder/decoder IC? and one more ,how do I test it without RF modules? some tips please? your answer will be greatly appreciated.

here's my new code

Tx part

DEFINE OSC 20
CMCON = 7 'Alla I/O Digitala
LEDPin VAR PORTB.4
TransmitterPIN VAR PORTA.0
INCLUDE "modedefs.bas"
Counter VAR BYTE
Synk VAR BYTE
Synk = $55
DEFINE CHAR_PACING 1000
Counter = 0

Main:
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

SEROUT TransmitterPIN,T9600,[Synk,Synk,Synk,Synk,Synk,Synk,9,Counter]

HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

Counter = Counter + 1
PAUSE 600
GOTO Main
END

Rx Part


Define LOADER_USED 1

' Define LCD connections
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 3000 'Command delay time in us
DEFINE LCD_DATAUS 200 'Data delay time in us

TRISD = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low

INCLUDE "modedefs.bas"
Counter VAR byte
ReciverPIN VAR PORTA.0
ADCON1= 7
PAUSE 500

Main:
SERIN ReciverPIN,T9600,[9],Counter
GOSUB LCD
GOTO Main

LCD:
LCDOUT $FE,1
LCDOUT $FE,$80,#Counter
PAUSE 500
RETURN

END

mister_e
- 2nd April 2008, 13:14
when I disconnect the power supply at transmitter board, my LCD at receiver part shows a number.What's actually happens ?

What you receive is some kind of noise generated by the transmitter... kinda garbage stuff... normal thing.


Do I need to use encoder/decoder IC?
Not suppose to. Can you post your RF module model?


and one more ,how do I test it without RF modules? some tips please?
remove your RF module, and connect your transmitter PORTA.0 directly to your receiver PORTA.0 pin.

<hr>
Since you're using True mode, i will suggest you to add the following line in your transmitter code, just before the Main label

HIGH TransmitterPIN
PAUSE 100
This will ensure your TransmitterPin idle at the right logic level before sending your data.

HTH

mackrackit
- 2nd April 2008, 13:42
What PIC are you using? Does it have an ADC that needs disabled?

When testing the com link with wires, do not forget to also connect the ground between both circuits.

mister_e
- 2nd April 2008, 13:46
:o See pics in POST#1. 16F877A, and seems ADCON1 and CMCON settings are right.

Once the wire connection will work, i may suspect 2 other things.
1)open collector output of the receiver
2)use inverted mode instead. so the pin will idle low.

mackrackit
- 2nd April 2008, 14:20
877A
Well that is what happens when you do not look at the attachments.

But on the transmitter part I still do not see ADCON1 = 7.
And on the receiver part I do not see CMCON = 7.

And in the schematic pin 3 of the LCD goes straight to ground. No pot for contrast. I know on some modules this works, but are you sure it is this time.

not much help.

mister_e
- 2nd April 2008, 14:27
woopseee ... just saw that missing ADCON1 :o
but in theory... analog comparator are already disabled at POR...

dhouston
- 2nd April 2008, 16:03
As drawn, both Reset switches are shorting +5V to GND.

Can you provide details for your transmitter and receiver module manufactiurer/model/pinouts?

See http://davehouston.org/RFTipsTricks.htm

Archangel
- 2nd April 2008, 16:49
Hello rano_zen06,
Looking at your code . . . not however, trying it out . . . Is this all of it? I do not see anything to cause the transmitter to send data from the keypad, unless I have become legally blind . . . or stupid . . . that is why I asked is this all of it. As I said . . I see empty variables in the serout routine.
SEROUT TransmitterPIN,T2400,[Synk,Synk,9,Counter] I would try adding a string to the serout routine for test purposes only, something like
SEROUT TransmitterPIN,T2400,$FE,1,["1 2 3 "]

mister_e
- 2nd April 2008, 16:54
Joe, seems you missed the underlined section...


Main:
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

SEROUT TransmitterPIN,T9600,[Synk,Synk,Synk,Synk,Synk,Synk,9,Counter]

HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

Counter = Counter + 1
PAUSE 600
GOTO Main
END

mackrackit
- 2nd April 2008, 17:17
Maybe Joe has bifocals like me :)

rano_zen06
- 2nd April 2008, 19:09
As drawn, both Reset switches are shorting +5V to GND.

Can you provide details for your transmitter and receiver module
manufactiurer/model/pinouts?

See http://davehouston.org/RFTipsTricks.htm

Sorry for late reply guys,got a lot of homeworks to do. ; )
The fact is I have less information about my RF module.I just buy it from the nearest electronic store.Since I live here in Chiang Mai ,Thailand...It's hard for me to find a good types of RF module such as PArallax or TWS/RWS 434...For your reference I attach the picture of the RF modules .The link below may help. It was the datasheet of receiver chip used in my RF module.
http://www.himark.com.tw/images/pdf/product_pdf/RX3310A.zip



Hello rano_zen06,
Looking at your code . . . not however, trying it out . . . Is this all of it? I do not see anything to cause the transmitter to send data from the keypad, unless I have become legally blind . . . or stupid . . . that is why I asked is this all of it. As I said . . I see empty variables in the serout routine.
SEROUT TransmitterPIN,T2400,[Synk,Synk,9,Counter] I would try adding a string to the serout routine for test purposes only, something like
SEROUT TransmitterPIN,T2400,$FE,1,["1 2 3 "]

Actually what I want to do right now is display the counting numbers on my LCD at receiver board and it's nothing to do with my keypad.I just want to try send a data using my RF module first before I proceed with sending the data from my scanning keypad because I need to know if my RF module able to do it's job or not.


:o See pics in POST#1. 16F877A, and seems ADCON1 and CMCON settings are right.

Once the wire connection will work, i may suspect 2 other things.
1)open collector output of the receiver
2)use inverted mode instead. so the pin will idle low.

I already connect the Transmitter and the receiver pin directly but it's not work.my LCD only shows a bunch of black box .Maybe the major problem is from my coding or hardware??
Any other suggestion mister_e ? and how to use inverted mode??

mackrackit
- 2nd April 2008, 19:38
LCD only shows a bunch of black box
PIN 3 on the LCD is for contrast. Hook a pot up as a voltage divider with the wiper going to display pin #3. Then adjust until the black boxes go away. Then try sending "HELLO WORLD" to the display.

mister_e
- 2nd April 2008, 19:39
Hi, try a direct connection (porta to porta) with following. And of course don't forget to connect the Transmitter board GND with the Receiver board GND.

Receiver


@ __CONFIG _HS_OSC & _LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISC = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low

pause 1000 'wait until the LCD initializes

INCLUDE "modedefs.bas"
Counter VAR BYTE
ReciverPIN VAR PORTA.0
ADCON1 = 7 ' Alla digitala
PAUSE 500

Main:
SERIN ReciverPIN,T2400,[9],Counter
GOSUB LCD
GOTO Main

LCD:
LCDOUT $FE,1
LCDOUT $FE,$80,#Counter
PAUSE 500
RETURN

END

Transmitter


@ __CONFIG _HS_OSC & _LVP_OFF
DEFINE OSC 20
ADCON1=7
;CMCON = 7 'Alla I/O Digitala
LEDPin VAR PORTB.4
TransmitterPIN VAR PORTA.0
INCLUDE "modedefs.bas"
Counter VAR BYTE
Synk VAR BYTE
Synk = $55
DEFINE CHAR_PACING 500
Counter = 0

HIGH TransmitterPin
pause 200

Main:
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100
SEROUT TransmitterPIN,T2400,[Synk,Synk,9,Counter]
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

Counter = Counter + 1
PAUSE 600
GOTO Main
END

If you want to switch to the inverted mode, you just need to change T2400 to N2400, and the HIGH TransmitterPIN to LOW TransmitterPIN.

Work just fine here.

Unfortunately your picture don't help... it's a bit fuzzy

rano_zen06
- 3rd April 2008, 08:28
PIN 3 on the LCD is for contrast. Hook a pot up as a voltage divider with the wiper going to display pin #3. Then adjust until the black boxes go away. Then try sending "HELLO WORLD" to the display.

thanks for the advice mackrackit.I've tested my LCD before and I found nothing's wrong with it.Even I connect pin 3 directly to the ground, my LCD still can display variable words clearly.


Hi, try a direct connection (porta to porta) with following. And of course don't forget to connect the Transmitter board GND with the Receiver board GND.

Receiver


@ __CONFIG _HS_OSC & _LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISC = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low

pause 1000 'wait until the LCD initializes

INCLUDE "modedefs.bas"
Counter VAR BYTE
ReciverPIN VAR PORTA.0
ADCON1 = 7 ' Alla digitala
PAUSE 500

Main:
SERIN ReciverPIN,T2400,[9],Counter
GOSUB LCD
GOTO Main

LCD:
LCDOUT $FE,1
LCDOUT $FE,$80,#Counter
PAUSE 500
RETURN

END

Transmitter


@ __CONFIG _HS_OSC & _LVP_OFF
DEFINE OSC 20
ADCON1=7
;CMCON = 7 'Alla I/O Digitala
LEDPin VAR PORTB.4
TransmitterPIN VAR PORTA.0
INCLUDE "modedefs.bas"
Counter VAR BYTE
Synk VAR BYTE
Synk = $55
DEFINE CHAR_PACING 500
Counter = 0

HIGH TransmitterPin
pause 200

Main:
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100
SEROUT TransmitterPIN,T2400,[Synk,Synk,9,Counter]
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100

Counter = Counter + 1
PAUSE 600
GOTO Main
END

If you want to switch to the inverted mode, you just need to change T2400 to N2400, and the HIGH TransmitterPIN to LOW TransmitterPIN.

Work just fine here.

Unfortunately your picture don't help... it's a bit fuzzy

hi mister_e, I feel very sorry about the picture quality. I will attach the better one soon. Just try the code above but the error occur when I try to compile it using my microcode studio and it says " Error TRANSM~1.ASM 94 : [235] opcode expected instead of '0' "
After remove ' & _LVP_OFF ', microcode studio compile it succesfully. :)
The code works fine when I connect my transmitter and receiver pin directly and I can see the counting number display on my LCD.but It only works once when I try it using my RF modules.I got no result after try it the 2nd time.Only static number ( noise) shows up on my LCD.How do i reduce the noise??

mister_e
- 3rd April 2008, 15:50
There's a long long long way in between, i think you could try the Inverted mode first and then slow the baudrate, say 300bauds.

You should have a decent distance between the transmitter and receiver ... i think over 3 feets could be enough. Now , i don't know the RF receiver you have, but it's possible that it's output is an open-collector type. I would suggest you to add a 10K pull-up resistor between Vcc and RA.0 to see if it works better.

If you have any Scope, in the transmitter code, do a loop with SEROUT TransmitterPIN,N2400,[Synk] monitor the RF module output to see how good, bad the signal is.

On the transmitter AND the receiver module, use a 10-22uF tantalum+0.1uF as close as possible of your rf module. Same thing for your PICs. Try to sit your RF module away of your PICs.

You can also try to add 1-2 more Synk character at the begining of your transmission. For 1-2 bytes of data you shouldn't need any encoding/decoding even if.

Begin with it and see what happen. Without any spec of your module, it's a bit hard. Hope you have a scope :o
<hr>
For the compilation error, i used MPASM config fuse syntax, PM will use the following.

@ device HS_OSC, LVP_OFF

mister_e
- 3rd April 2008, 16:02
I'll also suggest you to follow Dave's post
http://www.picbasic.co.uk/forum/showpost.php?p=53579&postcount=9

If the transmitter output signal is a bit messy, you will need to 'shape it'. Probably the internal comparator could be used here..

mister_e
- 3rd April 2008, 16:24
Seems to be the one you're using right?
http://szyishi.en.alibaba.com/product/200054722/203652849/Superregenration_receiver/YS_CWC1_Superheterodyne_Receiver.html


5. Output of receiver module come with noise, also can be no noise in case of special requirement, but the receiving sensitivity will be reduced

rano_zen06
- 3rd April 2008, 18:29
Seems to be the one you're using right?
http://szyishi.en.alibaba.com/product/200054722/203652849/Superregenration_receiver/YS_CWC1_Superheterodyne_Receiver.html

yes, the model is what I'm using right now. It says the output come with noise and it seems like the main problem.Is there any chance for the receiver to get the sending data clearly without noise If I connect the data pin to LM 741 ?

mister_e
- 3rd April 2008, 20:13
as i said you could use the internal analog comparator instead.

dhouston
- 3rd April 2008, 20:21
yes, the model is what I'm using right now. It says the output come with noise and it seems like the main problem.Is there any chance for the receiver to get the sending data clearly without noise If I connect the data pin to LM 741 ?
If you read the page I referenced earlier, it gives you a method for dealing with the noise.

rano_zen06
- 3rd April 2008, 20:45
as i said you could use the internal analog comparator instead.

ok..now there is 3 pin for comparator inside the 16F877A. How do I connect it with my
Receiver..?? I'm just a little bit confuse with C1out and C2 out which is port A.4 and Port A.5. What's the different between these 2 pins ?? which one should I use? and what is the instruction to turn on the internal comparator??

mister_e
- 3rd April 2008, 20:53
OK, i'll start a new thread later about how using the internal comparators.

Do you have any oscilloscope?

In meantime you could do some test with an external comparator... LM339 and.. yeah lm741 or any other op-amp COULD work.

rano_zen06
- 3rd April 2008, 21:03
OK, i'll start a new thread later about how using the internal comparators.

Do you have any oscilloscope?

yes, there's a digital oscilloscope at my lab. But at this time, my lab still not open for student. It's just 6.30 in the morning here..so, must wait for 2 hour before I can use it. :D
I will use the oscilloscope later to check the output of RF module.Then I will attach the picture of TX and Rx signal for your review.

dhouston
- 3rd April 2008, 22:45
Almost all (in fact, all of the many that I've used) ASK RF receivers have a dataslicer just before the digital output. The dataslicer uses a comparator (as I explain at http://davehouston.org/RFTipsTricks.htm). Adding another comparator might be useful for educational purposes but is of little practical value (IMO). In this case, the only output from the receiver is digital so the noise pulses will have the same amplitude as the data and the duration of the noise pulses are likely to be nearly the same as the bit period. What kind of comparator circuit are you planning?

It is far simpler to use a relatively wide sync pulse followed by the data. The receiver can look for the sync pulse and only after receiving it, look for the data. The data can use almost any protocol desired, including RS232 with or without manchester coding. The single, wide sync pulse works much better than multiple $55 sync bytes. I also recommend sending 3 or more copies of each packet, including the wide sync pulse.

rano_zen06
- 4th April 2008, 16:11
Almost all (in fact, all of the many that I've used) ASK RF receivers have a dataslicer just before the digital output. The dataslicer uses a comparator (as I explain at http://davehouston.org/RFTipsTricks.htm). Adding another comparator might be useful for educational purposes but is of little practical value (IMO). In this case, the only output from the receiver is digital so the noise pulses will have the same amplitude as the data and the duration of the noise pulses are likely to be nearly the same as the bit period. What kind of comparator circuit are you planning?

It is far simpler to use a relatively wide sync pulse followed by the data. The receiver can look for the sync pulse and only after receiving it, look for the data. The data can use almost any protocol desired, including RS232 with or without manchester coding. The single, wide sync pulse works much better than multiple $55 sync bytes. I also recommend sending 3 or more copies of each packet, including the wide sync pulse.

I use oscilloscope to check the data pin for my Rx and Tx module without comparator and the result is not very good.The signal I got show a lot of noise especially at my receiver. You can see the waveform picture at my attachment. I also add the comparator using LM741 to my Rx but something bad happen.my LCD shows nothing and my voltage drop from 5v to 2.3V. I think there is something wrong with my comparator circuit.So..I attached together the schematic of my comparator.Anyone here..please help me to troubleshoot this problem.

JD123
- 4th April 2008, 16:22
Check your comp drawing. If it's correct, you're sending the comp to rails. I think you ment to take the output of the rec to the inverting input, not ground. The 100uf cap is a bit much. I'd use a 1uf or even a .1uf.

Also, what's the signal look like at 1.8khz (same speed as the tx). Your receiving scope pix says you'r reading at 19.3mhz. If your data is riding on the noise at 1.8khz, you'll need to filter the noise in a LF band pass amp.

mister_e
- 4th April 2008, 16:30
There's a load of noise indeed... with that signal.. i don't feel the comparator will be of any help... need something else indeed...

I have to ask, The RX signal is the one [from the Receiver Without your comparator connected too and a Pull-up on Vcc] or at the output of your LM741.. which will never work as is (forget pin 5 and 1, and connect pin 3 directly to RX pin).

Maybe the following link will help you a little bit
http://www.uoguelph.ca/~antoon/gadgets/741/741.html
http://www.ecircuitcenter.com/Circuits/op_comp/op_comp.htm

rano_zen06
- 4th April 2008, 16:53
There's a load of noise indeed... with that signal.. i don't feel the comparator will be of any help... need something else indeed...

I have to ask, The RX signal is the one [from the Receiver Without your comparator connected too and a Pull-up on Vcc] or at the output of your LM741.. which will never work as is (forget pin 5 and 1, and connect pin 3 directly to RX pin).

Maybe the following link will help you a little bit
http://www.uoguelph.ca/~antoon/gadgets/741/741.html
http://www.ecircuitcenter.com/Circuits/op_comp/op_comp.htm

It' s not the output from my LM741. At the moment my Rx data pin connected directly to port A.0. also not using pull up on vcc at that time. In your opinion., should I use filter??

mister_e
- 4th April 2008, 17:08
I'm really in between few things... it would be nice to have one of those receiver here to do some test on my side... as shown here there's a load of noise... but your Vmax measure says 80mv, Vamp 136mV (assuming the measure is good... we don't see the v/div input setting)... i don't think it's really the real big problem. the TX show an amplitude of 2.72V :eeK: not sure how good it is for your TX module.

What i suggest for now, is to use 2 channel on your scope, 1 for TX, 1 for RX, Use 5v/div probe scalling for TX, 500mV - 1 for RX, and post the result(screenshot) here.

dhouston
- 4th April 2008, 17:37
I have tested a SAW controlled transmitter and superregenerative receiver from the same company. http://www.yishi.net.cn/product_detail.asp?id=54&fid=177
http://www.yishi.net.cn/product_detail.asp?id=52&fid=161
Given that they use the same terminology to describe the outputs of both receivers (i.e. output signal is TTL and can be directly connected to decoder) I am confident that the output of your receiver is digital, as is the output of my test receiver. There is not much you can do with a comparator to reduce the noise. Your best bet is to use the techniques I've recommended repeatedly.

dhouston
- 4th April 2008, 18:05
Furthermore, if you look at the block diagram in the datasheet from the HiMark RX3310A chip, you will see the comparator in the output circuit. Adding another will not help.

Bruce
- 4th April 2008, 19:30
Wow that really is some sloppy output stage. Try sending a continuous data stream of an
equal number of 1's & 0's like 55h with a 1mS pause between each byte of data, and capture
a scope shot of this.

I'm curious is this data-slicer is ever squaring anything.

rano_zen06
- 5th April 2008, 18:29
Hello Guys..Thanks for all the advice :D
Now my Rx module works fine in a short distance around 5-6 feet.I just add 10k pull up resistor at Rx data pin and 10uF at Vcc.But If I move more than 6 feets, my Rx module start receiving noise and my LCD will display wrong counting numbers.But It's fine to me.At least it's work.I think maybe the problem is from the antenna.I just use a small wire with length 10cm each for my Tx an Rx.So anyone here have any ideas about the antenna??
Now I'm moving foward to send a data from my keypad. IF I pressed pad1,pad2 and so on..my LCD at transmitter board will display BUS01,BUS02....What I want to do is send the word "BUSxx" each time I pressed the keypad and display it on my LCD at receiver board. So with help and some advice from mister_e..I wrote the code below.But It's not work even I Connect the transmitter and receiver pin directly. :(
The FAct Is..I'm very poor with the coding..please help me guys..

Tx part

@ device HS_OSC, LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISC = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low

pause 1000 'wait until the LCD initializes

' Define program variables
col var byte ' Keypad column
row var byte ' Keypad row
key var byte ' Key value
TransmitterPIN VAR PORTA.0
YourByteVar var byte
INCLUDE "modedefs.bas"
Synk VAR BYTE
Synk = $55
DEFINE CHAR_PACING 500

ADCON1 = 7 ' Make PORTA and PORTE digital


Pause 100 ' Wait for LCD to start

Lcdout $fe, 1, "Key In Bus ID" ' Display sign on message

loop:
Gosub getkey ' Get a key from the keypad
Lcdout $FE, $C0, "BUS",DEC2 key ' Display ASCII key number
PAUSE 200
Goto loop ' Do it forever

' Subroutine to get a key from keypad
getkey:
Pause 50 ' Debounce

getkeyu:
' Wait for all keys up
PORTD = 0 ' All output pins low
TRISD = $f0 ' Bottom 4 pins out, top 4 pins in
If ((PORTD >> 4) != $f) Then getkeyu ' If any keys down, loop
Pause 50 ' Debounce
getkeyp:
' Wait for keypress
For col = 0 to 3 ' 4 columns in keypad
PORTD = 0 ' All output pins low
TRISD = (dcd col) ^ $ff ' Set one column pin to output
row = PORTD >> 4 ' Read row
If row != $f Then gotkey ' If any keydown, exit
Next col

Goto getkeyp ' No keys down, go look again

gotkey: ' Change row and column to key number 1 - 16
key = (col * 4) + (ncd (row ^ $f))
Return ' Subroutine over

Main:
High TransmitterPin
pause 200
SEROUT TransmitterPIN,T2400,[Synk,Synk,"~",YourByteVar]
pause 500
GOTO Main
END


Rx part

@ device HS_OSC, LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISC = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low

pause 1000 'wait until the LCD initializes

INCLUDE "modedefs.bas"
ReciverPIN VAR PORTA.0
ADCON1 = 7 ' Alla digitala
YourByteVar var byte


pause 100
LCDOUT $FE,1, " Receiving Bus ID"

Main:
SERIN ReciverPIN,T2400,["~"],YourByteVar
GOSUB LCD
GOTO Main

LCD:
LCDOUT $FE,1
Lcdout $FE,$C0,"BUS",DEC2 YourByteVar
PAUSE 500
RETURN

END

mister_e
- 5th April 2008, 22:20
Try those with direct connection.


'
' TX code
' =======
'
@ device HS_OSC, LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TransmitterPIN VAR PORTA.0

DEFINE CHAR_PACING 500

TRISA = 0 'Set port A as output
TRISB = 0 'Set port B as output
TRISC = 0 'Set port C as output
TRISD = 0 'Set port D as output

' Define program variables
INCLUDE "modedefs.bas"
col var byte ' Keypad column
row var byte ' Keypad row
key var byte ' Key value
Synk VAR BYTE
Synk = $55

ADCON1 = 7 ' Make PORTA and PORTE digital

low PORTB.6 'Set the R/W bit to low
High TransmitterPin
Pause 500 ' Wait for LCD to start
Lcdout $fe, 1, "Key In Bus ID" ' Display sign on message

loop:
Gosub getkey ' Get a key from the keypad
Lcdout $FE, $C0, "BUS",DEC2 key ' Display ASCII key number
SEROUT TransmitterPIN,T2400,[Synk,Synk,"~",KEY]
Goto loop ' Do it forever

' Subroutine to get a key from keypad
getkey:
PORTD = 0 ' All output pins low
TRISD = $f0 ' Bottom 4 pins out, top 4 pins in
WHILE PORTD != $F0 : wEND ' Wait 'till all key=up
PAUSE 50 ' Debounce

ScanKeypad:
For col = 0 to 3 '
TRISD=~(DCD COL) ' Set one I/O to output
PAUSEUS 5 ' wait a little bit to avoid
' erratic results
'
ROW=ncd((~(PORTD>>4)) & $f) ' read row
'
IF ROW THEN ' Any key pressed?
key = ((row-1)*4)+ col+1' --- YES convert key value
return ' and getout of here
ENDIF '
NEXT '
Goto ScanKeypad ' No keys down, go look again


Notice the change in the Keypad scanning routine... this one seems to never have any erratic results now.



'
' RX code
' =======
'
@ device HS_OSC, LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISA = 1 ' PORTA.0 input, other as output
TRISB = 0 ' Set port B as output
TRISC = 0 ' Set port C as output
TRISD = 0 ' Set port D as output

ReciverPIN VAR PORTA.0

ADCON1 = 7 ' Alla digitala

INCLUDE "modedefs.bas"
YourByteVar var byte

low PORTB.6 'Set the R/W bit to low
pause 500 'wait until the LCD initializes
LCDOUT $FE,1, " Receiving Bus ID"

Main:
SERIN ReciverPIN,T2400,["~"],YourByteVar
Lcdout $FE,$C0,"BUS", DEC2 YourByteVar
GOTO Main

Side note...There's no major advantage to use LCD in 8 bit mode.. R/W pin could also be tied directly to ground. This done you save 5 I/Os.

mackrackit
- 7th April 2008, 03:53
So anyone here have any ideas about the antenna??
To start learning about antennas, go here
http://www.linxtechnologies.com/Support/Application-Notes/
and read app notes AN-00500 and AN-00501.

Let us know if you need anything clarified.

mackrackit
- 7th April 2008, 04:34
Forgot to answer you question.

It looks like you could have the 315 or 434 MHz
The antenna length for

315 MHz = 22.63 cm
434 MHz = 16.43 cm

The above figures are just "ball park" starting lengths. Use the one for your frequency and even with out a good ground plane you should see improvement.

rano_zen06
- 8th April 2008, 16:42
Hello Steve,
Since I still receive noise..I decide to use Holtek encoder/decoder which is HT12E/HT12D. I construct the circuit following your advice and connect all data pins at HT12E/HT12D to port A0-PortA3.The decoder works fine but the encoder have a little bit problem.That's why I'm not receiving any signal because When I check OSC pin at encoder using logic probe,it show logic low at OSC 1 and show nothing at OSC 2.For your Information, I put 1M resistor between these 2 pins. Don't know what's really happen with my encoder. If you have any idea about the problem..can you please share it with me?? :)

mister_e
- 8th April 2008, 16:55
I never used those ICs... maybe you could some something in this document
http://rentron.com/remote_control/remotes.pdf

It show different value for the resistor. I didn't read the according datasheet to see if it affect anything though.

Maybe you screw the OSC signal with your probe.. use a scope instead, set your probe to 10X (or 100X if you have any) and see what happen.

TE pin should be tied low too unless the oscillator won't run.. as per Their Block Diagram (page 2) in their datasheet.
http://www.holtek.com/pdf/consumer/2_12ev110.pdf

As usual, Before you attach your RF modules, try direct connection, Dout to Din of your Holtek ICs.

HTH

rano_zen06
- 8th April 2008, 17:42
I never used those ICs... maybe you could some something in this document
http://rentron.com/remote_control/remotes.pdf

It show different value for the resistor. I didn't read the according datasheet to see if it affect anything though.

Maybe you screw the OSC signal with your probe.. use a scope instead, set your probe to 10X (or 100X if you have any) and see what happen.

TE pin should be tied low too unless the oscillator won't run.. as per Their Block Diagram (page 2) in their datasheet.
http://www.holtek.com/pdf/consumer/2_12ev110.pdf

As usual, Before you attach your RF modules, try direct connection, Dout to Din of your Holtek ICs.

HTH

Thanks for the reply.
I already test the holtek IC using direct connection but the result is still the same.No noise but The Rx cannot receive the data and my LCD just show static word "BUS15". Maybe there is something wrong with the code.I post the code below.Can you check it for me??

Tx part

'
' TX code
' =======
'
@ device HS_OSC, LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8;4 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TransmitterPIN VAR PORTA.0

DEFINE CHAR_PACING 500

TRISA = 0 'Set port A as output
TRISB = 0 'Set port B as output
TRISC = 0 'Set port C as output
TRISD = 0 'Set port D as output

' Define program variables
INCLUDE "modedefs.bas"
col var byte ' Keypad column
row var byte ' Keypad row
key var byte ' Key value
Synk VAR BYTE
Synk = $55

ADCON1 = 7 ' Make PORTA and PORTE digital

low PORTB.6 'Set the R/W bit to low
High TransmitterPin
Pause 500 ' Wait for LCD to start
Lcdout $fe, 1, "Key In Bus ID" ' Display sign on message

loop:
Gosub getkey ' Get a key from the keypad
Lcdout $FE, $C0, "BUS",DEC2 key ' Display ASCII key number
PORTA=KEY
Goto loop ' Do it forever

' Subroutine to get a key from keypad
getkey:
PORTD = 0 ' All output pins low
TRISD = $f0 ' Bottom 4 pins out, top 4 pins in
WHILE PORTD != $F0 : wEND ' Wait 'till all key=up
PAUSE 50 ' Debounce

ScanKeypad:
For col = 0 to 3 '
TRISD=~(DCD COL) ' Set one I/O to output
PAUSEUS 5 ' wait a little bit to avoid
' erratic results
'
ROW=ncd((~(PORTD>>4)) & $f) ' read row
'
IF ROW THEN ' Any key pressed?
key = ((row-1)*4)+ col+1' --- YES convert key value
return ' and getout of here
ENDIF '
NEXT '
Goto ScanKeypad ' No keys down, go look again


Rx Part

'
' RX code
' =======
'
@ device HS_OSC, LVP_OFF
define OSC 20

DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISA = 255 ' PORTA as input
TRISB = 0 ' Set port B as output
TRISC = 0 ' Set port C as output
TRISD = 0 ' Set port D as output

ReciverPIN VAR PORTA.0

ADCON1 = 7 ' Alla digitala

INCLUDE "modedefs.bas"
YourByteVar var byte

low PORTB.6 'Set the R/W bit to low
pause 500 'wait until the LCD initializes
LCDOUT $FE,1, "Receiving Bus ID"

Main:
YourByteVar=PORTA & $0F
Lcdout $FE,$C0,"BUS", DEC2 YourByteVar
GOTO Main

mister_e
- 8th April 2008, 18:58
There's nothing wrong in your code, has to be a hardware problem.

Scope the DO of your Encoder.. anything going out of it?

IF so, erm... why the decoder don't work... mmm let me guess, this Resistor for the OSC? Could be, did you tried with both value in the first PDF i sent you?

Bruce
- 8th April 2008, 21:00
Have you tested the HT-12E directly wired to the HT-12D (with a common ground), without
a microcontroller in the circuit, and still seen no response on the decoder outputs?

If the direct-connect test fails, then I would suspect one of the following;

1. You have a different address on the decoder than what's set on the encoder.
2. You have no common ground between the two ICs.
3. You have a bad encoder or decoder.

The encoder data out to decoder data in is the 1st test we recommend to anyone having
problems. This test helps determine if the problem is with the encoder/decoder ICs or the RF
stage.

mister_e
- 8th April 2008, 21:05
Bruce, just for curiosity sake, what happen if all addresses pins are left open?

Bruce
- 8th April 2008, 21:18
Hi Steve,

Most Holtek encder/decoder ICs have internal pull-ups, so floating these pins is the same
as connecting them to Vcc. This should be in the data sheet. The 8-bit series are tri-state.

But I never allow them to float. Especially in an application with an oscillator or embedded
controller that's going to indroduce a ton of digital switching noise to the power supply rails.

I've only seen maybe 1 in 10K failures with a set of Holtek encoder/decoder ICs. 9 times out
of 10 it's something simple like noise, a single bit difference in the address, bad connection,
wrong oscillator resistor value (voltage dependant), or just plain wired wrong that's the
cause of failure.

mister_e
- 8th April 2008, 21:21
As you know, i'm not a "left unused pin floating" fan. Was just for my own curiosity.. yeah datasheet says it could be left unconnected but.. erm... ;)

rano_zen06
- 9th April 2008, 10:59
There's nothing wrong in your code, has to be a hardware problem.

Scope the DO of your Encoder.. anything going out of it?

IF so, erm... why the decoder don't work... mmm let me guess, this Resistor for the OSC? Could be, did you tried with both value in the first PDF i sent you?

I use absolutely the same value of resistor in the PDF but the encoder/decoder still not function with direct connection.I can assure that Both Ground,Dout and Din pin was connected in the right position after chek it a few times. I'm curious about "transmitterPin Var portA.0"..
Do I need to put it in my program if use HT12E and HT12D ?

mister_e
- 9th April 2008, 15:29
There's no real big deal with that var, the only thing is HIGH TransmitterPIN at the begining... but this should send you some data at the begining, says your receiver should show BUS01 untill you press on your Keypad. no real harm at all...

rano_zen06
- 10th April 2008, 11:53
I already check my Dout and Din pin at HT12E/HT12D using Oscilloscope but the result show nothing .Only a long straight line shows at scope.It means No output/input from my HT12E and HT12D either I'm using direct connection or not.The resistor value for my OSC pin is exactly the same with what is listed in rentron pdf. But mr.Bruce said earlier that the resistor's value depends on voltage supply at HT12E/HT12D .So I check my voltage supply at vcc pin and I got 5.04 for HT12E and 5.06 for HT12D.Actually how to calculate the resistor value for OSC if it's really depends on voltage supply??

mister_e
- 10th April 2008, 16:42
Shouldn't be that critical for few millivolts. Are your Encoder/decoders address pins tied to ground as in the document i sent?

Bruce
- 10th April 2008, 16:54
You'll see a chart in the data sheet for the HT12E and HT12D that shows how to select
oscillator resistor values.

I normally use 33K for the decoder when operating at 5 volts. Locate 5 volts on the
bottom of the chart in your HT12D data sheet, and follow the vertical line up to where
the line from 33K on the right crosses it.

This indicates just a tad >200kHz internal oscillator speed at 5 volts with 33K.

Now look just below the chart where it states The recommended oscillator frequency is
fOSCD (decoder) should be about equal to 50 x fOSCE (HT12E encoder).

Now follow the vertical line up from 5 volts in the HT12E data sheet to where the line
from 750K crosses. Just short of 4kHz.

With +/- 5% resistors, you're in the ball-park.

If you have a scope you can experiment a bit with oscillator resistors to see the effect
changing them has on the encoder data output signal.

At any rate, if you're getting nothing on the data output pin of your HT12E when /TE is
at ground, then I would suspect you have a bad encoder.

rano_zen06
- 10th April 2008, 17:08
Shouldn't be that critical for few millivolts. Are your Encoder/decoders address pins tied to ground as in the document i sent?

Yes.All the Address pin for both encoder/decoder was tied low. I also connect the TE pin to GND for HT12E,but still no data receive at Rx. I'm not assuming that both encoder/decoder is damage because I have extra pair for HT12E and HT12D. when I use it, the result is same with the previous pair I have.the Holtek's data sheet say that the VT pin at HT12D will goes high to indicate valid transmission but my VT pin always LOW.