|
Post by Robotman on Feb 21, 2007 8:14:28 GMT 10
Oops Me thinks I coupled the Tx and Rx modules tooooooo much by having them on the same breadboard, with the same power supply and with 170 mm aerials. After removing the aerials I found that the received signal is now the same phase (that's the term I was looking for previously re. inverted data - 180 degrees out of phase) as the transmitted signal. But this brings up the interesting question of expecting the system to work at close range, but also at distance with aerials... Maybe I have to make a design choice about the intended use and range because in one case you don't want antennas, but in the other you do! Maybe that means that the 100nF (0.1uF) capacitors aren't needed either. More later... Cheers
|
|
|
Post by michaelg on Mar 1, 2007 19:42:33 GMT 10
Hey Botman, Ive been trying to get this working, but with no luck. Forgive my noobness, but when when Data on the transmitter is latched high, should Data on the receiver also be high? Im trying a basic circuit, i latch Data to high on the transmitter, and measure Data on the receiver with a multi-meter, but it doesnt seem to work Am i going about this the wrong way? I just want to set up a very basic circuit to see this working, before I attempt to connect to PIC and transmit data. Cheers, Michael
|
|
|
Post by Robotman on Mar 2, 2007 11:40:24 GMT 10
Hi Michael
I've been busy experimenting with these 434 modules lately and I don't know why I listen to the rantings of people who have never actually used the dang things! (You know, that forum I provided the link for...) I can assure you now that there's no need for complicated Manchester Encoding or any other rubbish. A basic RS-232 style 2400 baud, 8-N-1 transmit and receive works brilliantly. Here's my findings (and I will also answer your question too):
Voltages + Currents:
Tx = 3V ~ 5V @ 15mA maximum Rx = 3V ~ 5V @ 4.3mA maximum
Range:
Is good across my smallish backyard and through all of the walls of the house (incl. brick) with the receiver sitting next to a monitor.
Baud:
Up to a maximum of 4800 baud. (Alas, 9600 seems not to work). Stick with 2400 as a "standard" that everybody will expect.
Transmit:
Send 0xAA three times before your message string. This significantly improves the Rx module's ability to lock on and correctly receive the rest of your data bytes.
Even sending all data zeroes (0x00) or ones (0xFF) works fine because you have the START and STOP bits providing a "clock".
* This explains why you can't send a straight DC signal, Michael. For some reason the modules don't like it. They want proper serial formatted data, or at least on/off pulses of at least 500 Hz (this is what I initially tested at using a 555 timer, but maybe it can go lower?).
There is no phase inversion of the data. Put a '1' into the Tx and the Rx will output a '1'.
There's no need for capacitors on the antennas.
I used a PIC16F628A and setup for 2400 baud Tx (pin RB2) - see the circuit and code that follows. The Rx module connects straight to the PC serial port via a transistor (see circuit that follows) without needing a PIC.
Still to do:
1) Turning off the Tx module when not in use, and turning it back on again without giving the Rx module a spasm. 2) Building a combined Tx and Rx unit (a transceiver).
---------- Copy the following ASCII art into your text editor (not Word!!!) with a monospaced font (e.g. Courier)
Tx Circuit:
.............+---------+------------+-------+------------+...... .............|.........|............|.......|............|...... \---/........|.........\............|.......|............|...... .\./......+--+--+....../.10k.....+--+--+....|............|...+3V ..|.......|.Vcc.|......\.........|.14..|....|..........-----.... ..|.......|.....|....../.........|.....|....|...........---..... ..+-------+ANT..|......|.........|.....|....|.+..........|...... ..........|.....|......|.........|.....|...---.0.1uF........BATT ..........|.DATA+------+---------+8....|...---.TANT......|...... ..........|.....|................|.....|....|............|...... ..........|.....|................|.....|....|..........-----.... ..........|.GND.|.Tx Module......|..5..|....|...........---..... ..........+--+--+................+--+--+....|............|...... .............|..............16F628A.|.......|............|...... .............|......................|.......|............|...... .............+----------------------+-------+------------+......
Rx Circuit:
............................................+---------+...|./|........ ............................................|.........|...|/.|........ ..+-------------+-------------------+-------+..78L05..+---|..|---< RTS ..|.............|...................|.......|.........|...|\.|........ ..|.............|...................|.......+---------+...|.\|........ ..|.............|......\---/........|....................1N4148....... ..|.............|.......\./.........|................................. ..|..........+--+--+.....|..........|................................. ..|..........|.Vcc.|.....|..........|...........................RS-232 ..|..........|.....|.....|..........|........................INTERFACE ..|..........|..ANT+-----+..........|...........................TO.PC. ..|.+........|.....|................|................................. .---.220uF...|.....|................|E................................ .---.16V.....|.....|.............../.................................. ..|..........|.....|.....470R....|/...BC327........................... ..|..........|.DATA+----/\/\/\---|....(PN200)......................... ..|..........|.....|.............|\................................... ..|..........|.....|...............\.................................. ..|..........|.GND.|.Rx Module......|C................................ ..|..........+--+--+................|.........10k..................... ..|.............|...................+-------/\/\/\----------------< TD ..|.............|...................|................................. ..|.............|...................|................................. ..|.............|...................+-----------------------------> RD ..|.............|..................................................... ..|.............|..................................................... ..+-------------+------------------------------------------------< GND
Tx Code (PIC16F628A):
;------------------------------------------------------------------ ; MAIN.ASM
LIST p=16F628A ; list directive to define processor #INCLUDE <p16F628A.inc> ; processor specific variable definitions
ERRORLEVEL -302 ; suppress message 302 from list file
;------------------------------------------------------------------ ; Set the processor's configuration word ; ; _CP_OFF = Code Protect OFF ; _DATA_CP_OFF = Data EEPROM CoPy (read) Protect OFF ; _LVP_OFF = Low Voltage Programming OFF ; _BOREN_OFF = Brown-out Reset Enable OFF (using 3V supply) ; _MCLRE_OFF = Master CLeaR Enable OFF ; _WDT_OFF = WatchDog Timer OFF ; _PWRTE_ON = PoWeR up Timer Enable OFF ; _INTOSC_OSC_NOCLKOUT = INTernal OSCillator (NO CLocK OUTput)
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_OFF & _INTOSC_OSC_NOCLKOUT
;------------------------------------------------------------------ ; Shared Variable Space ; (16 bytes)
RAMSHARED UDATA_SHR 0x0070
irqW RES 1 ; W and STATUS register save during IRQ handling irqSTATUS RES 1 ; (in shared RAM to avoid bank switching issues)
strIndex RES 1 ; message string indexing strLength RES 1 ; counter RES 1 ; general purpose counter bitDelay RES 1 ; bit delay counter
;------------------------------------------------------------------ ; Start up
RESET CODE 0x0000
bcf STATUS,RP0 ; set BANK #0 bcf STATUS,RP1 ;
bcf INTCON,GIE ; disable all interrupts
goto Main ; start
;------------------------------------------------------------------ ; Interrupt vector
INTERRUPT CODE 0x0004
movwf irqW ; save W register movf STATUS,w ; save STATUS register movwf irqSTATUS ;
bcf STATUS,RP0 ; set BANK #0 bcf STATUS,RP1 ;
;; call IrqHandler ; execute the IRQ handler
movf irqSTATUS,w ; restore STATUS register movwf STATUS ; swapf irqW,f ; restore W register swapf irqW,w ; retfie ; done
;------------------------------------------------------------------ ; Main program
PROGRAM CODE
Main
; initialize the I/O ports ; movlw B'00000000' ; set the data first (all low's) movwf PORTA ; movwf PORTB ;
bsf STATUS,RP0 ; select BANK #1
movlw B'11111111' ; set data direction for both ports movwf TRISA ; movlw B'11111011' ; RB2 = output (data sent to Tx Module) movwf TRISB ;
; initialize the OPTION register ; ; bit function ; 7 = PORTB pull-ups disabled ; 6 = interrupt on rising edge of RB0/INT ; 5 = TMR #0 clock source is internal ; 4 = TMR #0 clocked on rising edge of RA4/T0CKI ; 3 = prescaler assigned to TMR #0 ; 2:0 = prescaler rate is 1:2 ; movlw B'11000000' movwf OPTION_REG
movlw 25 ; 2400 baud (2404 @ 4 MHz Fosc), 8-N-1 movwf SPBRG ; movlw B'00100000' ; TX9=8-bit mode, TXEN=Tx enabled, SYNC=asynchronous, BRGH=clear movwf TXSTA ;
bcf STATUS,RP0 ; reset to BANK #0
movlw B'10010000' ; SPEN=serial comms enabled, RX9=8-bit mode, CREN=continuous receive movwf RCSTA ;
call DelayOneSec ; give Tx module (more than enough) time to power-up
; mainloop
MainLoop call TxPreamble ; send 0xAA three times
clrf strIndex ; reset to start of message string movlw 14 ; movwf strLength ;
SendNextChar ; call GetStringChar ; get character of message call TxCharacter ; and send it
decfsz strLength,f ; end of string? goto SendNextChar ; no, so keep sending
call DelayOneSec ; give Tx module (more than enough) time to power-up goto MainLoop ; and do it all again
;------------------------------------------------------------------ ; One second delay
DelayOneSec movlw 200 movwf counter
; delay for approximately 5 milliseconds (5000 us) ; @ 4MHz internal RC oscillator, each instruction = 1 us
Wait5ms movlw 250 ; 250 * 20 = 5000us per iteration
WaitDelayLoop ; goto $ + 1 ; 2 goto $ + 1 ; 4 goto $ + 1 ; 6 goto $ + 1 ; 8 goto $ + 1 ; 10 goto $ + 1 ; 12 goto $ + 1 ; 14 goto $ + 1 ; 16 addlw -1 ; 17 btfss STATUS,Z ; 18 goto WaitDelayLoop ; 19 (20)
decfsz counter,f ; count another 5ms period goto Wait5ms ; return ;
;------------------------------------------------------------------ ; String to be sent
GetStringChar movlw HIGH stringTable ; movwf PCLATH ; movf strIndex,w ; incf strIndex,f ; addlw LOW stringTable ; btfsc STATUS,C ; incf PCLATH,f ; movwf PCL ;
stringTable ; 0 1 2 3 4 5 6 7 8 9 0 1 2 3 DT 'H','e','l','l','o',' ','W','o','r','l','d','.',' ',' '
;------------------------------------------------------------------ ; Transmit character in W
TxCharacter movwf TXREG ; start the Tx going call DelayHalfBit ;
bsf STATUS,RP0 ; select BANK #1 WaitForSent ; btfss TXSTA,TRMT ; has the TX finished? goto WaitForSent ; bcf STATUS,RP0 ; reset to BANK #0
call DelayHalfBit ; ensure a full length STOP bit is sent goto DelayHalfBit ;
;------------------------------------------------------------------ ; Preamble ; ; Send 0xAA three times ; @ 2.4kHz (= 12.5 ms), 2400 baud (8-N-1) ; ; START = '0' ; DATA = '10101010' ; STOP = '1' ; ; This gives an output of: ; '010101010101010101010101010101'
TxPreamble movlw H'AA' call TxCharacter movlw H'AA' call TxCharacter movlw H'AA' call TxCharacter return
;------------------------------------------------------------------ ; Delay half a Tx bit period ; ; @ 2.4kHz, period = 416.667 us ; Half bit period => 416.667 / 2 = 208.333 us (rounded-down to 208 us)
DelayHalfBit movlw 67 ; 2: (66 * 3) + 2 = 200us movwf bitDelay ; 3
BitDelayLoop ; decfsz bitDelay,f ; 4 -> 201 goto BitDelayLoop ; 5 (6) -> 202
goto $+1 ; 206 return ; 208 (209)
;------------------------------------------------------------------
END
|
|
|
Post by michaelg on Mar 2, 2007 11:51:11 GMT 10
Thanks Botman Much appreciated, once again. I'm also using a PIC16F628A at the moment - I will give it another go over the next few days. Ive got my cheepo rc plane set up now with 4 micro servo's to control the flaps, cant wait to get the radio control thing working Cheers, Michael
|
|
|
Post by Robotman on Mar 2, 2007 11:53:29 GMT 10
Forgot to mention: If you need more detailed help Michael, email me. Just click on the appropriate icon in the left pane under my username. Buy yourself a CRO too! A multimeter is no good for looking at signals. One of those < $100 DSE jobbies will do just fine. They're got a small screen but just think of it as a "gameboy" Cheers Botman and, man... This forum message system really screws with code listings! Dingo, can we do anything about having a file repository with ProBoards? Thanks Rod
|
|
|
Post by Gillerire on Mar 12, 2008 12:20:39 GMT 10
Hi guys,
Obviously this thread is a little old, but I have just bought myself a 433MHz receiver and transmitter from Jaycar and I'm having some trouble setting them up.
I have read the thread so far and still no luck.
Is it possible to drive a LED directly from the Rx module? I'm trying to set it up so I simply push a button to apply +5V to the 'data' line of the Tx module and then the Rx module will turn the LED on (which is sitting on the Rx 'data' line, with appropriate resistor). No micro controllers involved at this stage.
The LED simply does not turn on and I can't detect any voltage change with my multimeter. Any advise?
Thanks.
|
|
|
Post by Gillerire on Mar 12, 2008 12:27:46 GMT 10
Oops, feel a little stupid now. Didn't realise there was a 2nd page to this thread, sorry. My problem is the same that michaelg was having (straight DC signal) so I'll try Botman's solution. Thanks.
|
|
|
Post by Robotman on Mar 21, 2008 14:14:59 GMT 10
Hi Gillerire
The 433 MHz modules definitely need to be "clocked". Straight DC levels won't work. If you want to push a button for on/off status transmission then wire up a 555 timer astable vibrator generating a 500 Hz signal. When your button is pushed it directly connects the output of the 555 to the input of the Tx module (remember to include the pull-up resistor).
I don't think the Rx module has enough current source or sink capability to drive an LED (not at any particular brightness, for sure). Use an NPN transistor to drive the LED. Your base resistor can be 4k7 and at 5V supply that's 1 mA of current. You can then drive 100 mA using a basic PN100 (2N3904) transistor.
Cheers Rod (aka Botman)
|
|
|
Post by Gillerire on Mar 22, 2008 16:40:27 GMT 10
Wow, was beginning to think this forum was dead.
Thanks for the reply Botman. I'll let you know how I get on.
|
|
|
Post by Gillerire on May 25, 2008 0:59:31 GMT 10
This is quite frustrating. Finally made some progress though.
I have a 555 timer set up and sending an approx 500Hz signal to the Tx module and I'm pretty sure that's going along happily.
At the other end however things are a little different. I have a NPN transistor set up (2N2222) to drive an LED from the data pin of the Rx module. I spent ages fiddling with it and got nothing until I (on a whim) removed the pull down resistor on the data pin. This caused the LED to light!
I then fiddled some more but can't get things quite right. When the Tx module is not transmitting, the Rx LED will flicker with low light. When the Tx module IS transmitting, the Rx LED will light with a steady illumination. It is however not a FULL power illumination.
I don't have a fantastic knowledge of transistors and I have a feeling this is the area which is causing the issue.
Questions:
1. Do I need a pull down resistor on the data line of the Rx module?
2. What value resistor should be between the data line and base pin of the transistor.
3. Any other help with setting up transistors...
Thanks.
|
|
|
Post by Robotman on May 26, 2008 17:45:54 GMT 10
Hi Gillerire Yes, this forum is virtually dead. But I do check back here occassionally - probably about 2 or 3 times a week. You are getting exactly what should happen. Congratulations! Your circuit is working. The LED doesn't light at full power because you are flashing it at 500 Hz with approx 50% duty cycle, courtesy of the 555 timer at the transmitting side. How amazingly cool it is to get that timer output all the way over to the other side of the room without using any wires! It blew my mind the first time I did it... When the Tx module is off the Rx module is just receiving random radiation. I saw this when I had my Rx module hooked up to HyperTerminal on the PC. It would display random characters every now and then, regularly. Once the Tx module is sending a good signal then all those random fluctations go away - mostly - but they sometimes return to corrupt your data transmission! You will need to use checksums and other methods to overcome this. Depending on how you wired the pull-down resistor on the transistor you may have created a voltage divider and reduced the voltage that gets applied to the base below 0.6 volts and so the transistor couldn't turn on. However, transistors are current-operated devices and so they don't need pull-downs in basic (ie. slow rising and falling edges) applications like this. Maybe you might like to pop on over to AusRobotics www.ausrobotics.com/drupal/, join up and continue this thread over there? I'm sure some of the other members might be interested. My username is Robotman, although I haven't posted in quite a while, so I should really do some posting, heh? Keep me updated on your progress. Cheers, Rod
|
|