Hi, I need to add rf 433 communication between some modules, driven by MC9S08SH8 microcontrollers, and a server with an Arduino architecture.
For the Arduino part of this project I am going to use a VirtualWire library for this communication but I haven't found a similar library for the freescale microcontroller.
My plan is to duplicate the VirtualWire library, using I/O pins for the receiver and transmitter signals and a timer for synchronizing the transfer of the previously coded data.
Anyone can give me some suggestion? There is some code I could use for this project?
Thanks in advance
Hello, and welcome to the forum.
It should not be too difficult to adapt the code written by Mike McCauley, that I presume you already have, to suit the 'SH8 device. Of course you will need to alter vw_setup() to suit the HCS08 timer, presumably a TPM channel, to generate the sampling rate. Additionally, the various pin allocation functions will also not suit, but I cannot see a disadvantage in using fixed allocations within your code for receiver input, transmitter output, and PTT control. And the ISR function would also need modification to suit CodeWarrior.
The code sample seems to mostly assume a RF bit rate of 2000 bits/s (166.7 bytes per second after decoding), but the noise detection process within the receive algorithm requires sampling at eight times this rate, i.e. a timer interrupt every 62.5 microseconds.
For a trimmed bus frequency between 16MHz and 20MHz, this would give a period of 1000 to 1250 bus cycles between interrupts. The ISR code needs to be completed in considerably less than this period. With the rather complex code within vw_pll(), the receiver sampling function, I am not sure whether this is feasible. If not, you would need to reduce the RF bit rate.
I do have some gut held reservations about the robustness of the signalling when using on-off keyed (OOK) modulation. I might have preferred a self-clocking arrangement, such as Manchester encoding, or perhaps a PWM scheme. These can also potentially require a lower number of samples per bit, but do have a greater number of RF transitions.
A characteristic of OOK receivers is that, due to the action of a "bit slicer" circuit, and its minimum threshold level, when the received RF level reduces toward the threshold limit, the decoded pulse width will become narrower. Depending on the modulation scheme and the decodeing method, this may impose a sensitivity limit, rather than the noise level. Typically, the pulse narrowing effect will be worse on receivers that have less noise outpur in the absence of a signal.
With a maximum packet payload of 27 or 30 bytes, the use of a 16-bit CRC might seem excessive - I would have thought an 8-bit CRC would suffice. In practice, I would probably restrict the packet payload to about eight bytes.
Thanks for your help, I will think about your commentary about the frequency and timing... this is always a difficult part of microcontroller programming for me.
I am already working on the code so I will post again with the results... soon, I hope