Cannot get rfout and serin to work correctly or reliably

Tgrima

New Member
Hello,

Back in March i was having issues trying to get reliable radio communication working for a remote control car project. Due to a certain world pandemic I stopped working on the project for over a month and have only just begun working on it again. Back in march, Hippy advised that I strip down my programs and ensure that I had a firm foundation to start working on. As my last attempt at this car project was poorly documented and poorly executed, I've started the whole circuit and programs from scratch. This time I'm determined to have a good foundation circuit and program.

I'm starting with two 18m2 chips running programs very similar to what hippy recommended. The receiver receives bad packets every single time. I'm very confused and don't know what trouble shooting i should be doing. I've taken everything off the breadboards and wired it all up again, same issue. I'm very sorry if its a basic issue, i really just don't know what else to try except ask people that know what they're doing :)

Any advice at all would be massively helpful!
Thankyou,
Theo





Transmitter:
Code:
main:
    b0 = $A3
    let b4 = 20
    b7 = b0 + b1 + b2 + b3 + b4 + b5 + b6
    rfout b.0, (b0,b1,b2,b3,b4,b5,b6,b7)
    pause 500
    goto main
Receiver:
Code:
#no_data
#terminal 4800
main:
  low c.1
  if Pinb.6 =1 then main
  high c.1
  serin b.2, n2400, b0,b1,b2,b3,b4,b5,b6,b7
  low c.1
  if b0 <> $A3 then
    sertxd( "Bad packet", cr, lf )
  else
    b0 = b0 + b1 + b2 + b3 + b4 + b5 + b6
    if b0 <> b7 then
      sertxd( "Incorrect checksum", cr, lf )
    else
      sertxd( "Valid packet", cr, lf )
    end if
  end if
  goto main
Transmitter Datasheet
Receiver Datasheet
20200910_182514.jpg20200910_182540.jpg
 

Attachments

Technoman

Senior Member
Hi,
At first look, there is something wrong on the transmitter diagram according to the pinout of your TX2 module. Pin 2 should be connected to Vcc but is connected to GND considering a mirrored view, etc. The pinout of the TX2 should be identical to the datasheet.
 

Tgrima

New Member
Thanks for your reply! yes sorry, when i drew the transmitter diagram i was looking at the labels on the back of the chip and assumed it was the front. I forgot to draw the download circuits... sorry again ! I've updated the diagrams :)20200910_194330.jpg20200910_194350.jpg
 

AllyCat

Senior Member
Hi,

You appear to be using RFOUT (which is way more complex than just sending 8 bytes serially), but using only SERIN to receive the bytes ! Try using RFIN ! ;)

Cheers, Alan.
 

lbenson

Senior Member
Don't you need to match RFOUT with RFIN rather than SERIN? For initial testing, I would use a wired SEROUT on the sender and SERIN on the receiver, with a ground wire between modules, and when that works move to RFOUT and RFIN.
 

kranenborg

Senior Member
Hi Theo,

First a few basic questions:
Regarding the receiver: are you sure that the data signal from the transmitter is received and ported to the 18M2 correctly?. Do you have a scope to check?
Second: I agree with Allycat's and Ibensons remarks, try to make things even more simple. Try to really isolate things first and start very basic.

Finally, Maybe it helps a bit if your code is a little bit more clear on what the purpose is. For example, looking at the transmitter code, I am a bit puzzled what happens there.
(Sorry, checksum it is, clear now)
/Jurjen
 
Last edited:

Tgrima

New Member
Hi Alan, Ibenson and Jurjen!
Thanks for the help :)
I've connected the two chips directly with a wire as suggested! (it took me about 30 minutes because I put the common ground connector in the +V of one of the breadboards... oops) The program is running perfectly! I'm going to try using the rf chips now with the SERIN and SEROUT commands.
I don't have a scope to check if the signal is being received correctly, however, I should be able to do so in college tomorrow.

Are there benefits to using either SERIN/SEROUT or RFIN/RFOUT for when everything is working? on this page https://picaxe.com/basic-commands/digital-inputoutput/rfin/ it says the rfin command
provides much more reliable radio communication than using serin commands with low cost RF modules.
however, on the NKM4201 code examples it uses SERIN (https://picaxe.com/docs/axe213.pdf)


Thanks massively,
Theo
 

lbenson

Senior Member
It's been a long time since I looked at this, but I believe (after re-reading the manual), that RFIN/RFOUT are used to provide the Manchester encoding when you are using dumb RF units, but when you are using NKM2401 modules, you use SERIN and SEROUT.

You can use SERIN and SEROUT with the dumb modules, but you lose the reliability of the Manchester encoding.
 

Tgrima

New Member
I think this might half explain the problem i'm experiencing now. with serout and serin, nothing is received at all. however, only the receiver has an NKM4201 chip. so i tried using rfout and serin and suddenly the receiver was seeing the signals! but all of them were bad packets, i believe this is the point i was at with my original issue. I'm going to use an NKM2401 on the Transmitter then use SEROUT and hopufully this solves my problem :) if it doesn't, I'm going to try not using the NKM2401 chip on either the transmitter or the receiver and use rfout and rfin :)
 

AllyCat

Senior Member
Hi,

The NKM4201 contains the same software that is executed within the PICaxes by the RFIN and RFOUT commands. It converts between serial characters and the more complex format required for "Over The Air" communications. The requirements and behaviour of a radio link are far too complex to describe here: Run-In and Framing codes, Automatic Gain Control which "fights" the Amplitude Modulation (aka ASK or OOK) and interference from other transmitters must be expected on the 433 MHz "shared" band, so error detection is essential. That's some of the reasons for using the NKM4201s or RFIN/OUT.

Beware that some receivers are very sensitive to their supply voltage, and also antennas need to be chosen to suit the required range. But the starting point must be to get reliable (encoded) signals between PICaxes connected by a "hard wire" (+ earth).

Cheers, Alan.
 

Tgrima

New Member
Hi Alan

That makes a lot of sense, thanks for your insight. I've taken your advice and have connected the chips by a hard wire and common ground with sending serout/serin through nkm4201 encoder/decoder. I am getting the same problem, so it possibly wasn't a problem with my radio signals after all. I've triple checked the earth this time and its not the issue. I have tried replacing all the wires again and that wasn't the problem either.

Do you think it might be possible that I have a problem with one of my chips? Or is there more troubleshooting to be done before I can reach that conclusion? Possibly using a direct wire without the nkm4201 but using rfin and rfout instead. I'm going to draw up the circuit diagram in the morning encase there's an issue there that I'm blatantly missing :)

It sounds like it'll be worth adding a decoupling capacitor for the receiver too, so I'll be sure to do that

Thanks again,
Theo



(Updated Programs)
Code:
'Receiver
#no_data
#terminal 4800
main:
  low c.1
  sertxd( "Waiting for packet", cr, lf )
  if Pinc.7 = 1 then main
  sertxd( "receiving packet", cr, lf )
  high c.1
  serin b.2, N2400, b0,b1,b2,b3,b4,b5,b6,b7
  low c.1
  if b0 <> $A3 then
    sertxd( "Bad packet", cr, lf )
  else
    b0 = b0 + b1 + b2 + b3 + b4 + b5 + b6
    if b0 <> b7 then
      sertxd( "Incorrect checksum", cr, lf )
    else
      sertxd( "Valid packet", cr, lf )
    end if
  end if
  goto main
 
 
 
 
 
 
  'Transmitter
  #terminal 4800
main:
    b0 = $A3
    let b4 = 20
    b7 = b0 + b1 + b2 + b3 + b4 + b5 + b6
    if Pinb.4 = 1 then
        sertxd( "packet sending", cr, lf )
        goto main
    endif
    serout b.5, N2400, (b0,b1,b2,b3,b4,b5,b6,b7)
    sertxd( "packet sent", cr, lf )
    pause 250
    goto main
 

AllyCat

Senior Member
Hi,

It shouldn't be difficult to get communications working over a hard wire, but start as simple as possible and build up until it stops working. Connect two PICaxe pins and transfer a logic level, then single serial bytes, then a block of data and finally using RFOUT / RFIN. When that works, try introducing the NKM4201, using SERIN or SEROUT on the appropriate PICaxe. Only when all that is working perfectly should you attempt to introduce a RF transmitter and receiver.

As for the programs, you don't appear to be initialising most of b0 - b6 , they should be automatically set as zeros at power-on, but it's always best to check. With RFOUT/IN, the data is sent as blocks of 8, so any "spare" bytes may be stored at one end or the other. Also, if any check byte is "incorrect", then report its actual value via SERTXD, to see why or how it's wrong (maybe just one bit, all 0, inverted, or perhaps it's an adjacent byte?).

It's always possible that there is a "faulty" chip, but you have sufficient hardware to test alternative paths, and in practice, issues like this are nearly always caused by incorrect hardware or software construction, not faulty components.

Cheers, Alan.
 

Tgrima

New Member
Hi Alan,

Thanks for your patience with me. I've managed to get communication through a wire working flawlessly with the NKM4201 and serin/serout :)
Displaying the values of b0-b6 really helped, most of the time the right values were being sent but in the wrong bytes, I added a 25 ms delay to the transmitter program after the 8 bytes were sent and it all started working ! one of my cables was in the wrong place too which wasn't helping things.

Hopefully when I try to use the radio chips now, everything runs like clockwork :)

Thank-you!
Theo
 
Top