Open minkione opened 3 years ago
Hi, you can set the modulation using:
with cc1101.CC1101() as transceiver:
transceiver._set_modulation_format(cc1101.ModulationFormat.FSK2)
# or
transceiver._set_modulation_format(cc1101.ModulationFormat.FSK4)
# or
transceiver._set_modulation_format(cc1101.ModulationFormat.GFSK)
# or
transceiver._set_modulation_format(cc1101.ModulationFormat.MSK)
# or
transceiver._set_modulation_format(cc1101.ModulationFormat.ASK_OOK) # default: OOK
print(transceiver)
Would that work for you?
I have not yet made _set_modulation_format
"public" (removed the "_" prefix) and added it to the examples,
cause I only used and tested OOK
until now.
It would be great, if you could test one of the modulation formats above and report back if it works as expected.
If successful, I can then make _set_modulation_format
public and add it to the examples.
Me bad, I was too fast opening the issue before looking at the sources. Yeah, I'd definitely suggest to make that function public.
At the very moment I didn't connect yet the CC1101 over SPI to my RPi. Though is in my plans indeed to try out this library!
From my previous works with CC1101 on arduino and https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
In there, the different modulations worked pretty fine. And since its just a value in the cc1101 register... I guess there shouldn't be big issues in your library as well.
Anyway I'll let you know as I try it 👍
Me bad, I was too fast opening the issue before looking at the sources.
No problem, I also think that the method should be public in the future.
And since its just a value in the cc1101 register... I guess there shouldn't be big issues in your library as well.
I thought maybe FSK only makes sense, if I also change some other registers. But let's see if it works with _set_modulation_format
only.
Anyway I'll let you know as I try it +1
Great, thanks!
To be precise I guess you need to set both registers: m2MODFM and frend0 to the proper values, when changing modulation.
Ok, I'm in a hurry now. Will definetly check your sources in the evening.
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/0fed1565c699c328a8ede366498d52e77ff28f65/ELECHOUSE_CC1101_SRC_DRV.cpp#L352 sets FREND0.PA_POWER
to 0b000
for all modulations except from ASK/OOK (0b001
).
This library currently defaults to 0b001
for OOK.
You can mimic SmartRC-CC1101-Driver-Lib
's FREND0.PA_POWER
setting by calling transceiver._set_power_amplifier_setting_index(0)
Hello, I am developing a project with some colleagues to send tpms signals from a raspberry. We need to use FSK2 modulation. I have made this little code to test it but it does not change the modulation.
import cc1101
import sys #necessary for the arguments
def configCC1101(transceiver):
transceiver.set_base_frequency_hertz(433e6)
transceiver._set_modulation_format(cc1101.ModulationFormat.FSK2)#Is a private method but we need FSK2 modulation
transceiver.set_symbol_rate_baud(600)
transceiver.set_sync_mode(cc1101.SyncMode.NO_PREAMBLE_AND_SYNC_WORD)
transceiver.disable_checksum()
def transmitC1101(transceiver, frame):
transceiver.transmit(frame)
if __name__ == "__main__":
with cc1101.CC1101() as transceiver:
configCC1101(transceiver)
print(transceiver)
transmitC1101(transceiver, sys.argv[0].encode())
And the output is
CC1101(marcstate=idle, base_frequency=433.00MHz, symbol_rate=0.60kBaud, modulation_format=ASK_OOK, sync_mode=NO_PREAMBLE_AND_SYNC_WORD, packet_length≤255B)
Do you have any idea?
Hi @Martingf56, thanks for testing the FSK2 option. That must be a bug. Let's continue the discussion in https://github.com/fphammerle/python-cc1101/issues/23 I'll investigate the issue
I justed tested the following code with the new release v2.6.1
:
import logging
import time
import cc1101
logging.basicConfig(level=logging.INFO)
with cc1101.CC1101(lock_spi_device=True) as transceiver:
transceiver.set_base_frequency_hertz(433.92e6)
# API of private methods is unstable.
# Parameters and behaviour might change in upcoming releases.
transceiver._set_modulation_format(cc1101.ModulationFormat.FSK2)
transceiver._set_power_amplifier_setting_index(0)
transceiver.set_symbol_rate_baud(600)
print(transceiver)
while True:
time.sleep(0.2)
transceiver.transmit(b"\xff\x00\xaa\xff")
and tried to capture the signal with gnuradio companion (cc1101_fsk_test.grc.zip):
I do not have any experience with FSK, so no idea whether the flowchart makes sense,
but the bytes b"\xff\x00\xaa\xff"
are clearly visible between the sync word and checksum.
Thanks for solving it. It is a very useful library, apparently the FSK works well. I will do more exhaustive tests I will give you the feedback.
Thanks, feedback would be great!
If FSK works well, I'll consider making _set_modulation_format
public.
Hi, While quickly looking at the examples I noticed that is missing the set-modulation() option. This would be pretty handy to avoid hardcoding the wanted modulation in the library itself.