|
|
View previous topic :: View next topic |
Author |
Message |
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Thu Aug 27, 2015 5:17 am |
|
|
Well I 'googled.MX-FS-03V ' and got 75,000 hits, so I suggest you download a copy of the 'virtual wire' driver for the 'other' compiler and create one in CCS C.
A fairly simple task and you'll learn a lot about assembler while doing so.
so
step 1 ) create a SIMPLE program using that driver,compile,confirm it works.
2) printout the disassembler( machine code) of that working program/driver.
3) create a CCS C equal to it,compile, test
4) printout the 'listing' and see if the code IS the same
Pay special attention to clock speed,delays, etc.
As these modules are only $2 for the PAIR I can understand why students/hobbyest want to use them BUT you NEED the 'driver' .
Without actual hardware I can't write the 'driver' and say that it will work.
Jay |
|
|
shipool
Joined: 22 Aug 2015 Posts: 15
|
|
Posted: Thu Aug 27, 2015 7:14 am |
|
|
man, thank you, i will do, and when i test this, i will give a feedback
thank you for now. |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Sat Aug 29, 2015 4:56 am |
|
|
Olá Shipool,
cheap RF modules need data that is balanced which means that there is equal amount of 0" and 1" in the data. For this they invented Manchester Code. You can read about it in Wikipedia and here:
www.nesweb.ch/downloads/doc9164.pdf
To simplify let's talk about baud rate = 500 bps (2ms for each bit). Later you can increase this to 2-4Kbps which is quite standard with simple RF modules.
The transmitter is very easy. For each bit, if you want to send 0 bit you send:
Code: |
// transmit 0 bit:
output_high(TX);
delay_ms(1);
output_low(TX);
delay_ms(1); |
To send 1 bit you send the opposite:
Code: |
// transmit 1 bit:
output_low(TX);
delay_ms(1);
output_high(TX);
delay_ms(1);
|
And you do this for 8 bits per byte and for all bytes in your data.
This ensures that the data sent to the receiver is balanced.
The link I sent explains the receiver side, synchronization.
For RF modules you also need a few milliseconds of preamble: a chain of 0-1-0-1-0... to balance the receiver before the data starts. |
|
|
shipool
Joined: 22 Aug 2015 Posts: 15
|
|
Posted: Thu Sep 03, 2015 10:26 am |
|
|
oh, i stay trying convert virtualwire for ccs but i do not understand nothing, i try others codes but i found the same result. but your post ''guy", i don't see before, i see only now, and i will try it, but...how i listen the port rx to see if received 0 or 1?
thank you guys |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Thu Sep 03, 2015 1:40 pm |
|
|
to decode, the receiver side waits for the preamble (but it will not be exactly like the signal that was transmitted), and then start decoding the transmitted data:
Code: |
Original data:
0 0 0 1 0 0 1 1
Encoded data:
1010100110100101
|
You can then improve the code to synchronize in the middle of each bit (because the tx and rx clocks are never 100% identical).
I suggest to use an oscilloscope on the receiver side. Otherwise it will be too difficult. |
|
|
shipool
Joined: 22 Aug 2015 Posts: 15
|
|
Posted: Thu Sep 03, 2015 2:02 pm |
|
|
thank you, i understand, but, how i checked if the signal is 1 or 0? look, i'm using this for received char:
and now, if i used this, will work?
receiver
Code: |
if (input(RX_pin) == 1)
{ //put 1 in array[0] } else
{//put 0 in array[0] }
delay_ms(20);
if (input(RX_pin) == 1)
{ //put 1 in array[1] }
else
{//put 0 in array[1] }
|
and the transmitter
Code: |
output_high(TX_pin);
output_low(TX_pin);
delay_ms(20);
output_low(TX_pin);
output_high(TX_pin);
|
thank you |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Thu Sep 03, 2015 2:31 pm |
|
|
your transmitter code is missing delays.
I suggest to start with the transmitter, send out a byte in loop and check it with the oscilloscope. After the transmitter works ok you can work on the receiver:
Code: | if (input(RX_pin) == 1)
{ //put 1 in array[0] } else
{//put 0 in array[0] }
delay_ms(20);
if (input(RX_pin) == 1)
{ //put 1 in array[1] }
else
{//put 0 in array[1] } |
The approach is correct (test the input, then decide if it's 0 or 1, then store in an array or shift into a byte). But if "10" represents 0 and "01" represents 1 then the decoding is a little different. |
|
|
shipool
Joined: 22 Aug 2015 Posts: 15
|
|
Posted: Thu Sep 03, 2015 2:49 pm |
|
|
hum.... okay, but, i not have a oscilloscope, and if i use in Proteus, will work? |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Fri Sep 04, 2015 12:18 am |
|
|
I never used Proteus so I don't know. The simulation is not like the real parts because for example the preamble (sending 010101 to balance the receiver) is not received the same way in the real world.
I really suggest that you get access to an oscilloscope. There are hacks like http://www.instructables.com/id/DIY-USB-OSCILLOSCOPE-IN-A-MATCHBOX/ .
You can also use a logic analyzer.
I use a cheap and excellent one with software from Saleae: http://www.ebay.com/bhp/usb-logic-analyzer
These tools are useful for many years! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Fri Sep 04, 2015 1:15 am |
|
|
You have chosen what are basically the hardest modules to drive. They are cheap for a reason. On these they respond to 'changes' in the signal, and are not designed or guaranteed to actually respond to 'steady' signals. So the transmission becomes a matter first of sending a pattern of 1's and 0's as a 'header' to get the radios to wake up properly, then sending the actual data in a manner a bit akin to Morse, with the actual data being sent as changes either in the timing of the patterns, or by using whether the retrieved data is in phase or out of phase with a regular clock (derived from the stream), to encode a 1 or a 0. This latter is most commonly used as Manchester encoding, but it is not nice simple 'one line' code. It requires quite a bit of work, and the fine details have be adapted for each individual hardware design. The timing approach is how things like TV remote's encode their data. In each case, receiving will involve measuring the times of the changes in the received signal.
Now, plenty of people here have done codes based on both approaches. A search here will find IR remote codes and receivers that can be adapted for such modules, and also several Manchester encoding/decoding examples. However these all involve significant code, and you are really going to need to learn slowly 'step by step' to reach the point where you can use these.
Now there are much easier to drive modules. For example:
<http://www.rfsolutions.co.uk/acatalog/info_SMARTALPHA_433.html>
The keywords here are the 'smart', and a look at the data, where the line:
"Preamble and CRC are automatically generated and added to the RF signal".
There are hundreds of others.
These modules send the data as complete 'messages'. Automatically adding a checksum, the header required, and removing these at the other end. With these you could just print a message onto the 'RS232' serial output, and receive this at the other end. With your current module, this involves a lot more code.....
So you have to make a decision, of whether you want to use this as a learning exercise, and take the time to understand how to send such data, and retrieve it, or whether you want to spend the time learning some other part of the program, and upgrade to better modules. |
|
|
shipool
Joined: 22 Aug 2015 Posts: 15
|
|
Posted: Fri Sep 04, 2015 10:21 am |
|
|
in truth, i want know how send and receive data with this modules, i want understand how this works, if possible, how i can build this modules RF. Thank you |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|