C Programming - Transmitter + Receiver basics

Thread Starter

West121

Joined Oct 9, 2017
8
Last week I purchased a transmitter and receiver from Ebay and found little to no documentation about them. All I know is:
Transmitter has 4 pins: +, -, data, enable. Receiver has 4 pins: ground, data, data, vcc.

I connected it all (+ and vcc to 5V, - and gnd to ground) and made two projects in C - one transmitter and one receiver.
First off, why does the receiver have two data pins? They seem to act exactly the same. Anyway, I used just one of them.

Now, all pins are configured and I'm sending 0s and 1s from the transmitter to the receiver and printing whatever is coming through in a never ending loop. I don't really know what the Enable pin does. I just keep it at 0. I tried setting it to 1 too, no difference.

When I set the databit on the transmitter to 1, the receiver understands this as 0 and the device prints just 0 over and over again. When I set the databit on the device with the transmitter to 1, the receiver seems to understand this as both 1s and 0s so the device prints 1s and 0s randomly on the screen. I have no idea how these work and I'd like to be able to send binary codes like 1011 etc to the device with the receiver. I see no pattern at all and I don't how to send information that I can actually interpret.
Could anyone shed some light on the matter?
 

joeyd999

Joined Jun 6, 2011
4,239
Throwing random bits at hardware seldom works. There is a protocol you need to learn and understand -- this will be in the datasheet (or programming reference manual) for the part.

And you will either need to write code for a driver, or use a canned library to sanely communicate with it.

You've provided no details (manufacturer, part number, datasheet, etc.) for the part you are working with -- therefore, no one can help you at this point.
 
  • Like
Reactions: xox

Thread Starter

West121

Joined Oct 9, 2017
8
Throwing random bits at hardware seldom works. There is a protocol you need to learn and understand -- this will be in the datasheet (or programming reference manual) for the part.

And you will either need to write code for a driver, or use a canned library to sanely communicate with it.

You've provided no details (manufacturer, part number, datasheet, etc.) for the part you are working with -- therefore, no one can help you at this point.
Of course.
Receiver says RX480-S on it. It looks like this is the one:
https://www.aliexpress.com/store/product/433mhz-RF-Receiver-Rolling-Code-Decoding-Receiving-Module-433-mhz-Wireless-4-Channel-output-module-With/1456073_32652500109.html

The transmitter only says 13.560. Looks like this is the pair:
https://www.aliexpress.com/item/433-92Mhz-Superheterodyne-RF-Receiver-and-Transmitter-Module-ASK-low-power-kits-FOR-Arduino-ARM-MCU/32737335032.html
 

AlbertHall

Joined Jun 4, 2014
8,330
The receiver in your first link will not work with the transmitter from your second link.
The transmitter and receiver shown in your second link will work together but you still can't just send random 1's and 0's and expect it to work.
You don't say what processor you are using so it is impossible to be specific but this is how to it with an Arduino.
 

Thread Starter

West121

Joined Oct 9, 2017
8
The receiver in your first link will not work with the transmitter from your second link.
The transmitter and receiver shown in your second link will work together but you still can't just send random 1's and 0's and expect it to work.
You don't say what processor you are using so it is impossible to be specific but this is how to it with an Arduino.
Yeah, sorry.

It's the pair that I linked that's correct. The processor is an ARM Cortex M4.
I'm googling but can't seem to find any instructions on that.
 

AlbertHall

Joined Jun 4, 2014
8,330
I don't know that processor so I can't help you with that.
Generally speaking before you send the data you need to transmit a header so the receiver can set it's AGC to be ready for the data. Then you send the data, perhaps a short pulse for '0' and a longer pulse for '1'. The pulse widths need to be within some limits determined by the transmitter/receiver bandwidth.
 

Thread Starter

West121

Joined Oct 9, 2017
8
I don't know that processor so I can't help you with that.
Generally speaking before you send the data you need to transmit a header so the receiver can set it's AGC to be ready for the data. Then you send the data, perhaps a short pulse for '0' and a longer pulse for '1'. The pulse widths need to be within some limits determined by the transmitter/receiver bandwidth.
I see! Something like this would be a pulse then?
transmit data pin: 1
blocking loop for x ns
transmit data pin: 0

How would one create this header and how do I prepare the receiver for data transfer? Do I need to match clock pulses?
Say, when the first 1 is transmitted, the system clock starts on the receiving end?
 

nerdegutta

Joined Dec 15, 2009
2,660
Hi.

I've played around with the same type transmitter/receiver form the second link. The uC I used was PICs, PICAXE's and Arduinos. The power to the transmitter was controlled with an I/O pin and NPN transistor from the uC. When I didn't send any data, the transmitter was off. When it was time to send data, the uC turned on the NPN which in turn turned on the transmitter, then a "synchronizing" string was sent, then the data, and the transmitter was shut off.

On the receiver side, the receiver had power all the time, and was receiving much noise. When it detected the "synchronizing" string from the transmitter, the "frequency got tuned in to the transmitters" and the data was received. (I don't remember the correct terminology.) Of course you have protocols/libraries for this. At least for Arduino.

I used uart to send and receive data.

I have no clue about the Arm Cortex M4, but this might give you an idea... :)
 

Thread Starter

West121

Joined Oct 9, 2017
8
Hi.

I've played around with the same type transmitter/receiver form the second link. The uC I used was PICs, PICAXE's and Arduinos. The power to the transmitter was controlled with an I/O pin and NPN transistor from the uC. When I didn't send any data, the transmitter was off. When it was time to send data, the uC turned on the NPN which in turn turned on the transmitter, then a "synchronizing" string was sent, then the data, and the transmitter was shut off.

On the receiver side, the receiver had power all the time, and was receiving much noise. When it detected the "synchronizing" string from the transmitter, the "frequency got tuned in to the transmitters" and the data was received. (I don't remember the correct terminology.) Of course you have protocols/libraries for this. At least for Arduino.

I used uart to send and receive data.

I have no clue about the Arm Cortex M4, but this might give you an idea... :)
Thank you for your post. The thing with the Cortex M4 is that, I'm afraid I have to re-invent the wheel. The protocol must be written from scratch since I don't have any library files and I'm trying to figure out the best way to sync them together. Hope someone has more information about this!
 

AlbertHall

Joined Jun 4, 2014
8,330
I used uart to send and receive data.
That reminds me: a standard UART signal can be a problem with this kind of receiver as it can include a string of 9 sequential bits of the same polarity and that can be long enough to lose the receiver AGC. It is more reliable to use manchester encoding which maintains an average 50% on/off ratio.
https://en.wikipedia.org/wiki/Manchester_code

This details using a UART to send manchester encoded data by spilitting the original data byte into two nibbles: http://www.quickbuilder.co.uk/qb/articles/Manchester_encoding_using_RS232.pdf
 

Thread Starter

West121

Joined Oct 9, 2017
8
That reminds me: a standard UART signal can be a problem with this kind of receiver as it can include a string of 9 sequential bits of the same polarity and that can be long enough to lose the receiver AGC. It is more reliable to use manchester encoding which maintains an average 50% on/off ratio.
https://en.wikipedia.org/wiki/Manchester_code

This details using a UART to send manchester encoded data by spilitting the original data byte into two nibbles: http://www.quickbuilder.co.uk/qb/articles/Manchester_encoding_using_RS232.pdf
How would you even use UART/USART? Those are registers called USART1, USART2.. and so on. All I have is one bit for transmitting.
 

nerdegutta

Joined Dec 15, 2009
2,660
How would you even use UART/USART?
In my transmitter program for a PIC:
1. Initialize the uart. (baud, transmit enable asynch/ synch mode, enable serial port ...)
2. Send a string of chars to the uart port.

Receiver:
1. Initialize the uart port, with matching settings as above.
2. Enable interrupt on receive

This is the short version.
 

Thread Starter

West121

Joined Oct 9, 2017
8
In my transmitter program for a PIC:
1. Initialize the uart. (baud, transmit enable asynch/ synch mode, enable serial port ...)
2. Send a string of chars to the uart port.

Receiver:
1. Initialize the uart port, with matching settings as above.
2. Enable interrupt on receive

This is the short version.
I get the initialization etc. What I don't get is the connection between UART port and the transmitter? I have one bit that's either 1 or 0 depending on if I want to send data on the transmitter. How do I use UART to manipulate the transmitters pin to send stuff? From what I can see is that when I write '0' to the transmitter's datapin, the receiver starts receiving 1s and 0s. When I write '1' to it, the receiver only collects '0's. How do I use this with UART?

I actually use USART for connecting between PC and the microcontroller over USB with everything initialized. I thought about using the same code, but how does the transmitter work together with UART/USART?
 
Last edited:

AlbertHall

Joined Jun 4, 2014
8,330
Connect the UART TXD pin to the transmitter. At the other end of the link connect the Receiver data pin to the UART RXD.
The acceptable BAUD rate is generally 4000 but you need to check what is acceptable for your TX/RX pair.
 

Thread Starter

West121

Joined Oct 9, 2017
8
Connect the UART TXD pin to the transmitter. At the other end of the link connect the Receiver data pin to the UART RXD.
The acceptable BAUD rate is generally 4000 but you need to check what is acceptable for your TX/RX pair.
Thank you! I tried this, no luck yet. Will keep trying. Thank you and everyone else for your help.
 

be80be

Joined Jul 5, 2008
1,928
Most of these you just key the data pin 1200baud is better if using uart there not fast to lock but after it picks up they work really good I could turn a light on 20 feet away. manchester encoded data give longer range.
 
Top