go_away

Author Topic: my new CYRF6936 howto.  (Read 5563 times)

0 Members and 1 Guest are viewing this topic.

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
my new CYRF6936 howto.
« on: April 20, 2009, 05:54:17 PM »
hi guys,
the Cypress CYRF6936 is a modern 2.4 GHz Direct Sequence Spread Spectrum (DSSS) radio transceiver.
it's very versatile and available in pre built module form suitable for interfacing to microcontrollers from a few vendors.
i've been using them in my latest radio control system.

when i first started working with the CYRF6936 i was surprised how little information there was online about how to get an initial test setup working.

i know there are people on here with an interest in this (and other) RF transceivers.

with this in mind i present the following page:
http://sites.google.com/site/mrdunk/interfacing-cypress-cyrf6936-to-avr-microcontrollers


dunk.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: my new CYRF6936 howto.
« Reply #1 on: April 22, 2009, 05:26:11 AM »
hi guys,
the Cypress CYRF6936 is a modern 2.4 GHz Direct Sequence Spread Spectrum (DSSS) radio transceiver.
it's very versatile and available in pre built module form suitable for interfacing to microcontrollers from a few vendors.
i've been using them in my latest radio control system.

when i first started working with the CYRF6936 i was surprised how little information there was online about how to get an initial test setup working.

i know there are people on here with an interest in this (and other) RF transceivers.

with this in mind i present the following page:
http://sites.google.com/site/mrdunk/interfacing-cypress-cyrf6936-to-avr-microcontrollers


dunk.

I played around with the CYMUSB6535 (if I'm right) module...
I wasn't satisfied with the IC communication... too complicated to operate... really...
I managed to make a 2.4GHz spectrum analyzer... but no wireless com... really...
Never tried...
I don't really know about this module you have... may be better... probably try to get some samples first for myself... then talk...
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: my new CYRF6936 howto.
« Reply #2 on: April 22, 2009, 07:53:16 AM »
Quote
I wasn't satisfied with the IC communication... too complicated to operate... really...
so to just communicate with the CYRF6936 chip it is just a simple SPI bus.
but there are hundreds of different configuration options with no easy documentation showing you a set of initialisation options that will allow you to send and receive data.

so yea, i agree it's not easy. that's why i wrote this doc.
it gives you a starting point which will work.
from there you can further customise the various options.

if all you want is simple wireless communications though there are easier platforms.
only use the CYRF6936 if you need the extra functionality.
(i needed low latency for my radio control system.)

dunk.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: my new CYRF6936 howto.
« Reply #3 on: April 22, 2009, 09:20:33 AM »
Yup... the SPI software or hardware isn't considered...

I have some months to work with that IC, and if I remember right, what annoyed me, after all,
wasn't the poor documentation...
It was the lack of functionality it showed as an IC design...

If I remember right, I had to activate the receiver before I would read a channel, again and again and again...
And there were other things I should repeat before any action, like register control and some other thiings,
that got me running to find another IC....
My university is developing some ZigBee devices, especially they design the devices (not the ICs...) to save energy,
as they are hand help applications and such...
But lacking any courage to let myself into wireless communications, I started studying control theory and such ( that robots are killing me)

I'll see what I can fetch from there since any ZigBee they test in on the 2.4GHz carrier...
Are you so interested in one IC only or you just need a solution on the 2.4GHz???


Best Regards,
Lefteris
Greece
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: my new CYRF6936 howto.
« Reply #4 on: April 22, 2009, 09:41:33 AM »
Quote
It was the lack of functionality it showed as an IC design...
the CYRF6936 has a *huge* amount of functionality.
it can do more than any of the other 2.4GHz systems i looked at.
the bad side of that is it is very complicated.

Quote
My university is developing some ZigBee devices
the ZigBee protocol is ok as long as you can live with the restrictions.
my main reason for not using ZigBee was it's high latency.

Quote
Are you so interested in one IC only or you just need a solution on the 2.4GHz???
i looked at several wireless devices but the only one that did what i needed were the CYRF6936 based ones.

if all you want is wireless communication then use a ZigBee.

but if you need to be able to switch channels on the fly,
low latency,
high bandwidth,
etc,
the ZigBee will not do what you want.


dunk.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: my new CYRF6936 howto.
« Reply #5 on: April 22, 2009, 10:30:26 AM »
I don't mean functionality.... wrong word....  :P
aaahhh.... my english....
I mean the way you get the device to do things...

Of course it has many many abilities... (from spectrum analyzer to whatever...)

ZigBee is a protocol... I'm neither for nor against it...
But isn't it better if you have a "surelink" between 2 or more devices???
Even then you are flying something (I know about your project.... although I never comment anything... I like for sure... :P)
When you are talking about models, and airmodels you want a link from the transmitter to the receiver that it's sure to work,
without any interference and you also don't mind at all the consumption cause the motor you are using, is probably using +10A to
fly (at full speed)....
Even wifi is an option... Instead of transmitting row data...

This is my opinion...

Best Regards,
Lefteris,
GReece
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: my new CYRF6936 howto.
« Reply #6 on: April 22, 2009, 02:40:15 PM »
Quote
aaahhh.... my english....
ha. no problem man. sorry for taking you too literally.

Quote
But isn't it better if you have a "surelink" between 2 or more devices???
for some applications yes.
but not for mine. if you have bad reception for a while i don't want the radio jammed trying to retransmit a failed packet.
i would rather it transmits new data if it is available.


dunk.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
Re: my new CYRF6936 howto.
« Reply #7 on: April 22, 2009, 04:10:00 PM »
thanks for the great tutorial dunk!
Your module is very similar to the one I working with - the AT86RF212 (http://www.atmel.com/dyn/products/product_card.asp?part_id=4349) Your tutorial helps a ton!
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: my new CYRF6936 howto.
« Reply #8 on: April 22, 2009, 04:40:24 PM »
i just had a glance at that datasheet Airman.
i'm not convinced this tutorial will be much help to you i'm afraid.
most of the problems with this sort of module are working out how to configure the various registers at startup.
i think the registers on the AT86RF212 are too different from the CYRF6936.

let us know when you find out though.


dunk.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: my new CYRF6936 howto.
« Reply #9 on: April 22, 2009, 04:55:16 PM »
Hehehe... That register set up is all the work with these modules....
Hey dunk did you have to set the register again after each transmit/reception and generally
any action related with the transceiver???
That was my problem with the CYMUSB6935.... They probably changed stuff cause yours seem to be the next model....
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
Re: my new CYRF6936 howto.
« Reply #10 on: April 22, 2009, 05:51:29 PM »
whoops guess you're right
the only thing we have in common is that they both use SPI , :P
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: my new CYRF6936 howto.
« Reply #11 on: April 23, 2009, 03:18:32 AM »
Quote
Hey dunk did you have to set the register again after each transmit/reception and generally
yes.
you set the "RX GO" bit then monitor it.
when the "RX GO" switches off it means the CYRF6936 has received data so you test for errors and read the data before either resetting "RX GO" or going to transmit mode instead.

it seems a bit strange when you first read it in the datasheet but it makes a lot of sense when you actually start writing the firmware.


dunk.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: my new CYRF6936 howto.
« Reply #12 on: April 23, 2009, 03:32:01 AM »
Here is the code for the spectrum analyzer I had made... Unfortunately it uses a
simple 4X20 character LCD.... I still need to practice using that GLCD I have....

Code: [Select]
' --------[ Device Config]----------------------------------------------------

$regfile = "m8535.dat"
$crystal = 16000000
$baud = 9600


' --------[ LCD Config ]------------------------------------------------------

Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.5
Config Lcdpin = Pin , Db7 = Portc.4 , E = Portc.1 , Rs = Portc.0
Config Lcd = 20 * 4


' --------[ SPI Config ]------------------------------------------------------

Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 1 , Clockrate = 16 , Noss = 1


' --------[ General Port Config ]---------------------------------------------

Config Portb = Output
Config Portb.2 = Input


' --------[ Port Sympolic Name ]----------------------------------------------

Resetline Alias Portb.0
Ss Alias Portb.4


' --------[ Constants ]-------------------------------------------------------

Const Reg_id = &H00
Const Reg_control = &H03
Const Reg_data_rate = &H04
Const Reg_config = &H05
Const Reg_serdes_ctl = &H06
Const Reg_rx_int_en = &H07
Const Reg_rx_int_stat = &H08
Const Reg_rx_data_a = &H09
Const Reg_rx_valid_a = &H0A
Const Reg_rx_data_b = &H0B
Const Reg_rx_valid_b = &H0C
Const Reg_tx_int_en = &H0D
Const Reg_tx_int_stat = &H0E
Const Reg_tx_data = &H0F
Const Reg_tx_valid = &H10
Const Reg_pn_code = &H11
Const Reg_threshold_l = &H19
Const Reg_threshold_h = &H1A
Const Reg_wake_en = &H1C
Const Reg_wake_stat = &H1D
Const Reg_analog_ctl = &H20
Const Reg_channel = &H21
Const Reg_rssi = &H22
Const Reg_pa = &H23
Const Reg_crystal_adj = &H24
Const Reg_vco_cal = &H26
Const Reg_pwr_ctl = &H2E
Const Reg_carrier_detect = &H2F
Const Reg_clock_manual = &H32
Const Reg_clock_enable = &H33
Const Reg_syn_lock_cnt = &H38
Const Reg_mid = &H3C


' --------[ Variables ]-------------------------------------------------------

Dim Brust As Bit
Dim Rw_select As Bit
Dim Address As Byte
Dim Carrier(8) As Byte
Dim Rssi_sample As Byte
Dim Channel As Byte
Dim I As Byte , J As Byte
Dim Bytenum As Byte
Dim Sum As Word


' --------[ Initialize ]------------------------------------------------------

Resetline = 1
' Set reset line to logic high to enable the IC
Ss = 1
' Set SS line to logic high to avoid data float
Brust = 0
Rw_select = 0
Address = 0
For I = 1 To 8
 Carrier(i) = 0
Next
' Set everything variable to zero to avoid possible float

' LCD messaging
Cls
Cursor Off
Lcd " CYWUSB6935  Report "

' Initialize SPI
Spiinit

' --------[ Main Program ]----------------------------------------------------

Do

J = 1

For Channel = 20 To 39
 Gosub Channel_set
 Gosub Rssi
 Locate 2 , J : Lcd Rssi_sample ; "  "
 J = J + 2
Next
Waitms 100

Loop





End                                                         ' End



' --------[ SubRoutines ]-----------------------------------------------------

Address_up:
' Check for Brust SPI mode
 If Brust = 1 Then
  Address = Address + 64
 End If
' Check for Read/Write sequence
' If 0 then Read command is issued
' If 1 then Write command is issued
 If Rw_select = 1 Then
  Address = Address + 128
 End If

Return                                                      ' Return


Spi_read:
' Read the device
 Ss = 0
' Set SS line low since it's disabled from the hardware SPI
 Spiout Address , 1
' Send the address to the CYWUSB6935
' Note that the command bits 6 and 7 are controller via the
' Address_up subroutine
 Spiin Carrier(1) , Bytenum
' Read what is sent to the AVR
' The number of bytes received is determined by Bytenum variable
 Ss = 1
' Set SS line to logic high and stop any transaction

Return                                                      ' Return


Spi_write:
' Write to the device
 Ss = 0
' Set SS line low since it's disabled from the hardware SPI
 Spiout Address , 1
' Send the address to the CYWUSB6935
' Note that the command bits 6 and 7 are controller via the
' Address_up subroutine
 Spiout Carrier(1) , Bytenum
' Write some bytes to the device
' The number of bytes sent is determined by Bytenum variable
 Ss = 1
' Set SS line to logic high and stop any transaction

Return                                                      ' Return


Get_pn_code:
' Reading the PN Code
' Set the variables for "PN Code" register reading
 Brust = 1
' Brust = 1 because we read 8 bytes in one circle
 Rw_select = 0
' We READ the pn code
 Bytenum = 8
' Eight bytes to read
 Address = Reg_pn_code
' See constant table above

' Issue everything needed to read the device
' and the certain register
 Gosub Address_up
 Gosub Spi_read

' LCD messaging
 Lowerline
 Lcd "PN: "
 For I = 8 To 1 Step -1
  Lcd Hex(carrier(i))
 Next

 Return                                                     'Return


Read_analog_contol:
' Reading the analog control register
' Set the variables for this task
 Brust = 0
' Only one byte to read
 Rw_select = 0
' We READ the analog control register
 Bytenum = 1
' One byte to read
 Address = Reg_analog_ctl
' See constant table above

' Issue everything needed to read the device
' and the certain register
 Gosub Address_up
 Gosub Spi_read
' LCD messaging
 Thirdline
 Lcd "An Cont: " ; Bin(carrier(1))

Return


Write_analog_contol:
' Writing to the analog control register
' Set the variables for this task
 Brust = 0
' Only one byte to write
 Rw_select = 1
' We WRITE the analog control register
 Bytenum = 1
' One byte to read
 Address = Reg_analog_ctl
' See constant table above

' Issue everything needed to read the device
' and the certain register
 Gosub Address_up
 Gosub Spi_write

Return                                                      ' return


Read_carrier_detect:
' Reading the carrier control register
' Set the variables for this task
 Brust = 0
' Only one byte to read
 Rw_select = 0
' We READ the analog control register
 Bytenum = 1
' One byte to read
 Address = Reg_carrier_detect
' See constant table above

' Issue everything needed to read the device
' and the certain register
 Gosub Address_up
 Gosub Spi_read
' LCD messaging
 Fourthline
 Lcd "Car Det: " ; Bin(carrier(1))

Return                                                      ' Return


Write_carrier_detect:
' Writing to the carrier control register
' Set the variables for this task
 Brust = 0
' Only one byte to write
 Rw_select = 1
' We WRITE the analog control register
 Bytenum = 1
' One byte to read
 Address = Reg_carrier_detect
' See constant table above

' Issue everything needed to read the device
' and the certain register
 Gosub Address_up
 Gosub Spi_write

Return                                                      ' Return


Channel_set:
' Writing to the channel register
' Set the variables for this task
 Brust = 0
' Only one byte to write
 Rw_select = 1
' We WRITE the channel register
 Bytenum = 1
' One byte to write
 Address = Reg_channel
' See constant table above
 Carrier(1) = Channel
' The byte sent is the Channel number setted above

' Issue everything needed to read the device
' and the certain register
 Gosub Address_up
 Gosub Spi_write

Return                                                      ' Return

Rssi:
' Receive Signal Strength Indicator
' First access analog control to permit writing to
' the carrier detect register.
' In this register we  enable the receiver of the IC
 Carrier(1) = &B01000000
' Set Reg Write Control to 1
 Gosub Write_analog_contol

 Sum = 0
 For I = 1 To 20
  Gosub Receive_mode_on
  Brust = 0
 ' Only one byte to write
  Rw_select = 0
 ' We READ the RSSI register
  Bytenum = 1
 ' One byte to read
  Address = Reg_channel
 ' See constant table above
  Gosub Address_up
  Gosub Spi_read

  If Carrier(1) < 32 Then
   Carrier(1) = &B10000000
    Gosub Write_carrier_detect
    Waitus 55
   Brust = 0
   ' Only one byte to write
   Rw_select = 0
   ' We READ the RSSI register
   Bytenum = 1
   ' One byte to read
   Address = Reg_channel
   ' See constant table above
    Gosub Address_up
    Gosub Spi_read
   Carrier(1) = Carrier(1) - 32
   Sum = Sum + Carrier(1)
   Carrier(1) = &B00000000
    Gosub Write_carrier_detect

  Else
   Carrier(1) = Carrier(1) - 32
   Sum = Sum + Carrier(1)
  End If

  Gosub Receive_mode_off

 Next

 Rssi_sample = Sum / 20

Return                                                      ' Return


Receive_mode_on:

 Carrier(1) = &B10000000
 ' Set the variables for this task
  Brust = 0
 ' Only one byte to write
  Rw_select = 1
 ' We WRITE the channel register
  Bytenum = 1
 ' One byte to read
  Address = Reg_control
 ' See constant table above

 Gosub Address_up
 Gosub Spi_write

Return                                                      'Return


Receive_mode_off:

 Carrier(1) = &B00000000
 ' Set the variables for this task
  Brust = 0
 ' Only one byte to write
  Rw_select = 1
 ' We WRITE the channel register
  Bytenum = 1
 ' One byte to read
  Address = Reg_control
 ' See constant table above

 Gosub Address_up
 Gosub Spi_write

Return                                                      'Return
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,855
  • Helpful? 53
Re: my new CYRF6936 howto.
« Reply #13 on: May 10, 2009, 12:34:31 AM »
It's on hack a day  ;D

Offline dunkTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: my new CYRF6936 howto.
« Reply #14 on: May 10, 2009, 04:00:13 AM »

 


Get Your Ad Here

data_list