I have one AVR, an ATTiny2313 which is programmed to transmit a short string “HALLELUJAH” every second on its TxD pin (built-in UART).
I connected this TxD pin to a Max232 and this to a computer and using HyperTerminal I can successfully see the word HALLELUJAH appear on my screen every second, so nothing wrong with the AVR or computer.
I then added the RF Transmitter and Receiver. All components (Transmitter/Receiver/AVR) are on the same breadboard and share the same regulated 5V power supply. I simply connected the AVCR TxD pin to the DataIn pin on the transmitter, and then the DataOut pin of the Receiver is connected to the Max232. I get no data whatsoever in HyperTerminal in windows on my computer.
I used my Digital Multimeter with scope to monitor the pin. I see quite a lot of noise on the Receiver DataOut pin, and no pulses that should be there every second when the data is transmitted. What could be wrong? I have the baud rate set to 2400 in the AVR, and I tried using 1200. I have small Antennas on both Receiver and Transmitter, and tried without as well. The distance between transmitter and receiver is only about 10cm.
In the end, when I get this working, I want to make this to allow two AVR’s to communicate wirelessly. I’m just using the computer now because it is easier to see what is going wrong.
What could be wrong? Could anyone please offer some help, I’d really like to get these modules working as soon as possible.
That sounds like what i see when there is no transmitter.
First, make sure you’ve got them wired up correctly. double check it…
you are using the digital output pin (3) of the receiver, right?
make a short antenna for both modules (6.8"). when I use solderless BB, I just cut a length of 22 or 24 ga wire (cat5 left-overs…) and stick it in the BB. crude but it works, I’ve gotten a few hundred feet with that on a 3.2V supply. I wouldn’t be suprised if that was your problem.
then, try a slower baud rate. 1200, 600, 300. just send a single character or two every 10 mS or so, look at the output from pin 3, you should see the pulses
look at the input to the transmitter to make sure you are actually sending something.
One thing I and others have found is that the high period is longer than the low period, even when inputting a 50% duty cycle square wave to the transmitter. I don’t know if that makes a difference for max232/rs232. I do manchester coded transmission.
Hi thanks a lot for your comments, I will definitely go through them and see if I can get anything to work.
The main problem though, agt, is that I can’t move the transmitter and receiver apart right now since they are on the same breadboard and sharing the same 5V regulated power supply. I will find a way around this and test this out.
Philba, I am not using digital output pin 3… I am using pin 2. All datasheets say that pin 2 is the digital output.
Also, I looked at the input to the transmitter and I can definitely see pulses there, so nothing wrong with that. The place where it goes wrong is either in the Transmitter, the Receiver, and the link in between.
Thanks, I’ll try the baud rate thing as well as moving them further apart.
Somewhat offtopic but… Could you please post the source code for the first program that just sends a string over UART? I am just getting started with AVRs, and some example code for UART would be really great.
I just wanted to say that I got it to work. I managed to transmit data wirelessly. I am unable to tell you however how I did it. I tried stuff, I rebuilt everything on my breadboard and it just worked. I am suspecting a problem with the crystal or the two capacitors, or a bad contact with the breadboard.
What I have noticed however, is that if I send for example “UF!” every 20mS wirelessly, I will get UF! showing on my computer screen correctly every single time. But if I put a 1s delay between the two "UF!"s, they might not transmit at all or very badly with lots of rubbish. What I did is that everytime I want to transmit something, I first send lots of “UU”, then I send a “X” then I send my data, and then I send lots of “UU” again. This allows me to detect the “X” and then get the data after it.
I am sure this is solved with maybe Manchester Encoding, but I don’t know how to implement it with my AVR. Any other ideas on how I can improve the integrity of my data? The transmitter/receiver are still 10cm apart, is that the problem?
SlackwareLinux, I am using BASCOM to program my AVR in a BASIC like language. It is great, because all I have to do to send something over the UART through the TxD pin is the command “print”. So if I want to send “Hallelujah” serially, I’d first set the Baud rate: “$baud = 2400” (without the “”) and then “print “Hallelujah””, it’s that easy.
you are learning about the need for error checking & handling. I would build a packet of data and add a checksum. when you get the packet, recompute the checksum and compare it against the transmitted one. If they are equal, you got a good packet, if not, it was bad. You could go to a crc scheme for some error correction if you wanted. Your packet might look like this:
where packet_data is the actual array of characters you are transmitting. yes, I know its not valid C…
by the way, if you make the checksum actually the inverse of the sum of the packet_data array, on the receive side, you can just add the checksum and data bytes together, if it’s 0, all is well.