Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DATA transmission/receiving using SCR Radio modules.

Status
Not open for further replies.
hi C,
The CONFIG settings are incorrect.
18LF2520 16MHz-EXT SX1278 OOK RX 180217 1100
'Define SIMULATION_WAITMS_VALUE = 1 'Comment in for SIM out for PIC
Define CLOCK_FREQUENCY = 16 'SX1278 CLKOUT 32MHz/2
Define SINGLE_DECIMAL_PLACES = 2
Define CONFIG1L = 0x00
Define CONFIG1H = 0x02 'HS CLKI
Define CONFIG2L = 0x1e 'BOR enabled
Define CONFIG2H = 0x00 'check
Define CONFIG3L = 0x00 'check
Define CONFIG3H = 0x80
Define CONFIG4L = 0x80 'Set for HVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
AllDigital
OSCCON = %01111100 '%01110010 'internal 8Mhz clock
'----------------------------------------------------------------------------------------------
 

Attachments

  • A001.gif
    A001.gif
    38.5 KB · Views: 444
  • A004.gif
    A004.gif
    36.5 KB · Views: 447
hi C,
The CONFIG settings are incorrect.
18LF2520 16MHz-EXT SX1278 OOK RX 180217 1100
'Define SIMULATION_WAITMS_VALUE = 1 'Comment in for SIM out for PIC
Define CLOCK_FREQUENCY = 16 'SX1278 CLKOUT 32MHz/2
Define SINGLE_DECIMAL_PLACES = 2
Define CONFIG1L = 0x00
Define CONFIG1H = 0x02 'HS CLKI
Define CONFIG2L = 0x1e 'BOR enabled
Define CONFIG2H = 0x00 'check
Define CONFIG3L = 0x00 'check
Define CONFIG3H = 0x80
Define CONFIG4L = 0x80 'Set for HVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
AllDigital
OSCCON = %01111100 '%01110010 'internal 8Mhz clock


'----------------------------------------------------------------------------------------------
Hi Eric,
Thanks for that.
Is it ok to use OSCCON = %01110111 as I would like port function on RA6?

Why did you highlight Define CONFIG1H = 0x02 'HS CLKI Is this incorrect?

EDIT: I've tried Define CONFIG1H = 0x05 but this didn't work.
It's possible I haven't got the SX1278 CLKOUT settings correct, I'll have a look.

C.
 
Last edited:
hi C,
I would put good money on saying if that SPI single end bit for the RX Wr/Rd, is the only SPI transfer I/O problem, it is not due to the SX and PIC clock sync.

E
 
hi C,
I would put good money on saying if that SPI single end bit for the RX Wr/Rd, is the only SPI transfer I/O problem, it is not due to the SX and PIC clock sync.

E
Hi Eric,

I bet you 50P it is then:)

Coincidentally, a friend of mine is starting a professional job using these very Chips, in a few weeks. They are in slightly different modules, but the same data sheet. He will be able to get to the bottom of my problem. (Lucky or what!)

C.
 
Coincidentally, a friend of mine is starting a professional job using these very Chips, in a few weeks. They are in slightly different modules, but the same data sheet. He will be able to get to the bottom of my problem. (Lucky or what!)
hi C,
It will be interesting hear what he finds, that is causing the problem.
E
I think my 50p is safe.;)
 
Hi,
Still trying to get the external clock to work.

There is a nice square wave from the SX1278 at PIN 9 RA7 1V 0.5uS/1 square. The Crystal on the SX is 32MHz and is set to /2 RegOsc = 0x01

When the clock is external does it need OSCCON?

When the CLK is external, why is setting/DEFINE the Frequency in Oshonsoft needed?

C.
 
hi C,
When the CLK is external, why is setting/DEFINE the Frequency in Oshonsoft needed?
So that OSH can calculate the correct time delays

When the clock is external does it need OSCCON?

To set the correct clock source and enable/disable others.

E
 
Hi Eric,
OK.

I tried this program: Left switched on and it started, but very slowly. The GLED switched ON/OFF 8SECS/8SECS and as you can see it should be 500Ms/500Ms.

Guess what! The LCD showed OOKRX = 45 which is what OOKRX should be. (Don't spend that 50P yet:) )

C.
 

Attachments

  • '18LF2520 16MHz-EXT SX1278 OOK RX 190217 1100.txt
    8.8 KB · Views: 462
hi,
I have checked the 500mS wait delay in the sim, it gives a start/finish of 251366uS > 751,744uS. which is 0.5Sec.

Put your scope or analyser on OSC2 pin#10 of the PIC, check the freq of what you see.

What is the 5sec delay for near the beginning of of your program.?
E
 
hi,
I have checked the 500mS wait delay in the sim, it gives a start/finish of 251366uS > 751,744uS. which is 0.5Sec.

Put your scope or analyser on OSC2 pin#10 of the PIC, check the freq of what you see.

What is the 5sec delay for near the beginning of of your program.?
E
Hi Eric,
Just realised that 0.5usON/0.5uOFF is actually 1MHz (Correctly if I'm wrong) I set the PIC to 1MHz and it is now flashing and showing 0x45 on the LCD which = 0x2d = OOKRX.

The settings are set to EXTERNAL CLOCK with no RA6 output. There is no signal from RA6.

The 5sec delay has been left from previous programs, it has been removed.

Now to try to speed up the CLKOUT from the SX1278 if possible.
C.
 
Hi,
I'm pretty sure I've nearly got it working!

I changed the SX1278 RegOsc CLKOUT to Crystal/2 = 16MHz

Reset 18LF2520 to 16MHz and now RA7 shows a not very square wave (Poss max for my Oscilloscope?) but GLED is switching ON/OFF as expected.

LCD still sows the expected 45 = 0x2d.

C.
 

Attachments

  • CLKOUT.jpg
    CLKOUT.jpg
    84.9 KB · Views: 423
Hi,
With a Logic analyser connected to RX DIO2 and DIO5. Ran it, started RX then started TX. Here is the output.

A signal can be seen when the RX is on for about 5secs, then when the TX is run for 2.5Beeps, the change in signal can be seen.

I'm puzzled why RX shows a signal, when the TX is off.

NOTE: TRY pic18f45k22

C.
 

Attachments

  • 2.5 beeps.jpg
    2.5 beeps.jpg
    79.7 KB · Views: 412
Last edited:
Hi,
I've been trying different combinations of settings (and there are lots) trying to get the OOK CONTINUOUS mode to work so I could send Morse, and finding there is too much delay, making it impossible for Morse. I've also been told, that these modules are not designed for this purpose.

I'm going to change to packet mode, which includes PSK and LORA modes.

I have attached some sections of code: I found that I couldn't 'OR' using CONST and had to do it the way shown, but it isn't very elegant. Is there a more elegant way of writing to the SX1278 module at initialisation?
EDIT: Open TXT in wordpad or better than notepad.
Camerart.
 

Attachments

  • Programming.txt
    1,006 bytes · Views: 428
hi C,
As you are declaring in the program code the value of the Constant, Oshonsoft will not allow that Constant value to be changed, it is a Constant.

Why are you using Const when Dim Value as Byte would IMO be easier.?

eg:
Dim dummyreg As Byte ' this would READ the Reg
dummyreg = 0x31 ' reg address

'within prog code
dummyreg = dummyreg Or 0x80 ' WRITE to Reg

another option would be, which I prefer as I don't have to keep track of Bit 7
Use rd or wr to suit action required.

rd_dummyreg = 0x31
wr_dummyreg = 0xB1

E
 
hi C,
As you are declaring in the program code the value of the Constant, Oshonsoft will not allow that Constant value to be changed, it is a Constant.

Why are you using Const when Dim Value as Byte would IMO be easier.?

E

Hi Eric,
Quick answer before I try your example.

True they are constants, as they are the SX1278 register addresses and never change. However, I can stop using CONST if it is better, as I don't think CONST allows: 'CONST or ox80'

What does IMO mean?
C.
 
hi C,
IMO aka In My Opinion, [ also IMHO, In My Honest Opinion]

Const OR 0x80 is not allowed in OSH

If you used the wr and rd prefix for all your Register addresses, it will make the code easier to follow.
eg: wr_regpkt2 ,,, rd_regpkt2

E
 
hi Eric
hi C,
IMO aka In My Opinion, [ also IMHO, In My Honest Opinion]

Const OR 0x80 is not allowed in OSH

If you used the wr and rd prefix for all your Register addresses, it will make the code easier to follow.
eg: wr_regpkt2 ,,, rd_regpkt2

E
Hi Eric,
I now see that e,g, ox31 or 0x80 = 0xB1. How do you find the 'OR 0x80' of each HEX? Do you calculate each time?

C.
 
Last edited:
Hi Eric,
Here's an example: If I use DIMs I have to use twice as many lines as CONSTs Is this ok?
C.
 

Attachments

  • Const.txt
    519 bytes · Views: 388
hi C,
As you are defining the Regs as a Byte value, it should only use a Byte of program space.
The Dim statement only specifies the start memory address of the data that you intend to store at that location.
The amount of memory space allocated from that start address depends upon the data definition.
Byte, Int, Long, String etc.
I have not checked how much memory space a Oshonsoft CONST uses.???

So Dim ..... as Byte ' would allow the Complier to allocate an address somewhere in memory.
What you put in that address location will be decided by the program Code.

You can if required type.
Dim ..... as Byte @ 0x20 ' this forces the Complier to allocate the memory address at 0x20.
[ Often Oshonsoft will 'burp' at this request and it may require editing, move it further up the memory space]

Your posted listing is incorrect.
E
EDIT:
You could of course use CONST for the regs.


'SX1278-8 register names-addresses

'##########BEFORE###############
Const regfifo = 0x00 'ADDRESS
Const regopmode = 0x01
Const regbitratemsb = 0x02
'#########BEFORE################


Dim rd_regfifo as byte
Dim wr_regfifo as byte
Dim rd_regopmode as byte
Dim wr_regopmode as byte
Dim rd_regbitratemsb as byte
Dim wr_regbitratemsb as byte

rd_regfifo= 0x00
wr_regfifo = 0x80
rd_regopmode = 0x01
wr_regopmode = 0x81
rd_regbitratemsb = 0x02
wr_regbitratemsb = 0x82


SPICSOn
SPISend wr_regfifo
SPISend '????????
SPICSOff
SPICSOn
SPISend rd_regfifo
SPIReceive '????????
SPICSOff
 
Last edited:
hi C,
You can if required type.
Dim ..... as Byte @ 0x20 ' this forces the Complier to allocate the memory address at 0x20.
[ Often Oshonsoft will 'burp' at this request and it may require editing, move it further up the memory space]

Your posted listing is incorrect.
E

'SX1278-8 register names-addresses

'##########BEFORE###############
Const regfifo = 0x00 'ADDRESS
Const regopmode = 0x01
Const regbitratemsb = 0x02
'#########BEFORE################


Dim rd_regfifo as byte
Dim wr_regfifo as byte
Dim rd_regopmode as byte
Dim wr_regopmode as byte
Dim rd_regbitratemsb as byte
Dim wr_regbitratemsb as byte

rd_regfifo= 0x00
wr_regfifo = 0x80
rd_regopmode = 0x01
wr_regopmode = 0x81
rd_regbitratemsb = 0x02
wr_regbitratemsb = 0x82


SPICSOn
SPISend wr_regfifo
SPISend '????????
SPICSOff
SPICSOn
SPISend rd_regfifo
SPIReceive '????????
SPICSOff

Hi Eric,
Oshonsoft doesn't allow CONST for SPI.

Just checking that our wires aren't crossed! The register addresses are on the radio module and are fixed, and have a default value which can be changed. I only need to write to the addresses I need to change. The long list of CONST was copied and pasted as reference for the addresses.

I'll continue using DIMs

What is incorrect about my example listing?
C.
 
Status
Not open for further replies.
Back
Top