couldnt generate frequency and sinewave using ad9833 with atmega2560 - spi

I am using 4 AD9833, in which the 4 fsync signals are sent from atmega2560. I want to generate different frequencies from all the 4 AD9833, if I program it, I am getting some frequencies in 2 port pins, I could not change the frequency .. please help

For the Atmega2560, you may want to look up "SPI" programming at here:
http://arduino.cc/en/Main/arduinoBoardMega2560
Using the SPI library, u can then issue command to the AD9833 via SPI interfacing. For details lookup page 2 here:
http://www.analog.com/static/imported-files/data_sheets/AD9833.pdf
(and page 15 above described the details on specifying the frequencies).
More information on SPI programming for Atmel is here: http://www.atmel.com/Images/doc0943.pdf
For SPI example for Arduino:
http://www.youtube.com/watch?v=YE0wnom_7As
http://arduino.cc/en/Tutorial/BarometricPressureSensor (look for SPI.begin(), SPI.transfer() etc).
For the SPI library specification:
http://arduino.cc/en/Reference/SPI

Related

USB 2.0 "This device cannot start. (Code 10)"

This is probably a long shot question, but I try it anyway.
I'm developing hardware using PIC Microcontrollers (MicroChip). Communication is done through a FS USB 2.0 link.
I connect the microcontrollers to a Windows 10 Home edition, version 21H1, build 19043.1826. The processor is an AMD Ryzen 5 3600 6-Core Processor.
First I used the PIC18F45K50, for which everything worked fine from day one. But due to the shortages on the market, I now am experimenting with PIC18F47J53. Both microcontrollers are working fine, as I can (for example) control a MAX7219 controlled display (3 x 7-segment) and also control a bunch of LED's using an STP08CP05TTR. Clock timings seem also ok - I measured it with an oscilloscope.
These 2 microcontrollers are pretty much the same, at least for the core functionality such as USB. The differences that are relevant for the issue I'm reporting here are:
PIC18F45K50 uses internal clock of 8MHz, and has on board correction logic to keep clock synced for HS USB - this is a 5V processor
PIC18F47J53 uses a XTAL of 16MHz, all should be within the USB 2.0 specs - this is a 3.3V processor
I'm using the MPLab X IDE v5.45 with the MCC (MPLab Code Configurator) in which I setup the System Module (to set the correct clock frequencies including the 48MHz for USB) and where I configure the USB.
In both microcontrollers, the setup of the USB is exactly the same. I even checked the 4 files that are automatically generated by MCC, and except for the descriptors (I used different names), all is exactly the same.
When I connect the USB to my PC (same port), then the PIC18F45K50 works perfect. But the PIC18F47J53 gives error code 10.
This does not happen every time. For example, if I try 10 times (connect/disconnect the cable), then I had it 7 times. 1 time the device even didn't appear, and 2 other times I read "The device is working properly.". Although, in the latter case, my software that communicates with my controller isn't working, so there is still something wrong.
Based on the above, the first I would think of is some hardware issue. Although, the strange thing is that things like vendor ID (0x4D8), Product ID (0xA), BCD Device Release (0x100), Serial Number (12345678), etc... seem always to be read out correctly. If there would be a hardware problem, shouldn't I have more random issues with this as well? Or is this data read out in a slower mode than Full Speed (because that could of course explain this)?
Below are screenshots via "Device Manager / Ports (COM & LPT) / my serial device", then selecting the property in the Details.
If I compare the properties from the working microcontroller (PIC18F45K50) with the not working one (PIC18F47J53), it looks like all are exactly the same.
I also tried to compare the D- (CH1) and D+ (CH2) signals between the 2 microcontrollers with my oscilloscope. My USB knowledge is not detailed enough to interpret the signals, but what I can tell is that both look exactly the same to me, both timing wise and voltage level wise. Be aware that the CH2 signal on the PIC18F47J53 (D+), the second screenshot, is clipping in the picture below, but I measured it later and it shows the same voltage level as for the PIC18F45K50.
Does anybody here a single clue where I should look at in the first place? The good news is that I have a working and not working version, so I can start debugging step by step and compare. But some hints as where to start would be appreciated.
EDIT 24JUL2022
I did the measurement with my oscilloscope again. Now I soldered 2 wires to the USB port to be able to easily attach my probes. This time, both D- and D+ signals have a Vpp of about 3.3V. I put some cursors which also shows a pulse-width of about 84ns, which correlates with the USB HS frequency of 12MHz (should be 83.33ns).
I found the issue. The Vusb on my PIC18F47J53 had a bad (or was even not) connected. I gave it another touch of my soldering iron, and bingo! Now the "error 10" has disappeared completely, and each time I connect/disconnect it gives "This device is working properly.", and error 10 never appears. I now also see a continues signal on my oscilloscope - not one that is disappearing after a while. And I could send/receive already some commands.

Reading from 315MHz / 433MHz Rf reader module with Raspberry Pi GPIO

OK, so I have a 3 pin 315/433MHz rf reader module which I've connected to my raspberry pi 2. 2 pins are for Voltage and ground, and 3rd goes to a GPIO pin configured as input.
I've actually gotten all of this to work just fine. I can read data manually from the GPIO pin just fine, by accessing the file
/sys/class/gpio/gpio23/value
I can even place a car key next to the receiver press a button, and see the values change between 0 and 1.
The problem is that I cannot figure out how to read the clock, so I cannot figure out if there are supposed to be multiple ones or zeros in a row in the data its reading. There doesn't seem to be any time stamp that I can find to see when the last value was read.
How can I properly read the data the module is receiving?
There are two common protocols used for 315/434 MHz radio transmission by hobbyists (that I know of).
Keyfob type remote control devices tend to use Manchester Encoding.
General data transmission using the Virtual Wire protocol (as popular with Arduinos).
My pigpio library has a Python Virtual Wire implementation and C/Python keyfob Manchester Encoding example (for receive and transmit).
your RF reader should be outputting serial data at some known baud rate (check the manual?) assuming you haven't wired it up to the dedicated serial pins you could look at using the pigpio library, more specifically the bit banging serial commands here for python or here for C/C++ or here for pipes
This allows you to use any GPIO pin for reading serial data and the library has bindings for several methods of use as shown in the links above.

Retrieve data from USRP N210 device

The N210 is connected to the RF frontend, which gets configured using the GNU Radio Companion.
I can see the signal with the FFT plot; I need the received signal (usrp2 output) as digital numbers.The usrp_sense_spectrum.py output the power and noise_floor as digital numbers as well.
I would appreciate any help from your side.
Answer from the USRP/GNU Radio mailing lists:
Dear Abs,
you've asked this question on discuss-gnuradio and already got two
answers. In case you've missed those, and to avoid that people tell
you what you already know:
Sylvain wrote that, due to a large number of factors contributing to
what you see as digital amplitude, you will need to calibrate
yourself, using exactly the system you want to use to measure power:
You mean you want the signal power as a dBm value ?
Just won't happen ... Too many things in the chain, you'd have to
calibrate it for a specific freq / board / gain / temp / phase of the
moon / ...
And I explained that if you have a mathematical representation of how
your estimator works, you might be able to write a custom estimator
block for both of your values of interest:
>
I assume you already have definite formulas that define the estimator for these two numbers.
Unless you can directly "click together" that estimator in GRC, you will most likely have to implement it.
In many cases, doing this in Python is rather easy (especially if you come from a python or matlab background),
so I'd recommend reading at least the first 3 chapters of
https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorials
If these answers didn't help you out, I think it would be wise to
explain what these answers are lacking, instead of just re-posting the
same question.
Best regards, Marcus
I suggest that you write a python application and stream raw UDP bytes from the USRP block. Simply add a UDP Sink block and connect it to the output of the UDH: USRP Source block. Select an appropriate port and stream to 127.0.0.1 (localhost)
Now in your python application open a listening UDP socket on the same port and receive the data. Each sample from the UDH: USRP Source is a complex pair of single prevision floats. This means 8 bytes per sample. The I float is first, followed by the Q float.
Note that the you need to pay special attention to the Payload Size field in the UDP Sink. Since you are streaming localhost, you can use a very large value here. I suggest you use something like 1024*8 here. This means that each packet will contain 1024 IQ Pairs.
I suggest you first connect a Signal Source and just pipe a sin() wave over the UDP socket into your Python or C application. This will allow you to verify that you are getting the float bytes correct. Make sure to check for glitches due to overflowing buffers. (this will be your biggest problem).
Please comment or update your post if you have further questions.

Is it possible to do SPI operation using GPIO Pins?

I want to to execute the SPI protocol operation using GPIO Pins, want to configure to single slave operation, in which way I have to configure that, I am using STM32F100RB Microcontroller and Coocox IDE for this executing in windowsxp.
if any body have example source code regarding the configuration of SPI Protocol operation using GPIO pins, then please send me that.
it very helpful for my project, Thanks in advance.
Regards,
Pavan Neo.
You're asking about Bit banging. This is the process of using an IO (or several) to encode or decode a serial signal. Wikipedia has a good description of this process.
For SPI specifically, you will need two or three outputs (depending on whether or not chip select is needed) and one input. You'll have to ensure that your bits are set or read in the correct order to not violate any setup/hold requirements of your peripheral, and you'll need to pay attention to the polarity needed on the clock signal (to make sure you're reading/writing data on the correct edge).
The Wikipedia link has some example code for bit banging that you may find useful as a starting point.

Gadgeteer and SPI protocol (Digital potentiometer)

I'm trying to create a project that will allow me to control digital potentiometer using the .NET gadgeteer. They both use the SPI protocol so at first sight this should be easy.
The potentiometer is MCP4131:
http://farm9.staticflickr.com/8062/8240194093_87b2e5c9fb.jpg
and the gadgeteer socket is:
Pin 1 Pin 2 Pin 3 Pin 4 Pin 5 Pin 6 Pin 7 Pin 8 Pin 9 Pin 10
+3.3V +5V GPIO! GPIO GPIO GPIO MOSI MISO SCK GND
Unfortunately, I can't understand how to connect these two together.
Furthermore, I Don't really know how to program the gadgeteer in order to control the potentiometer.
Any help would come in handy,
Thanks in advance!
I have no experience controlling SPI (so don't mark this as the answer for at least a few days) but I did find example code showing how to program SPI interfaces through Gadgeteer on the GHI site: http://www.ghielectronics.com/docs/14/spi
It is also worth noting this post on the Gadgeteer CodePlex pointing out that to get the SPI library in 4.2 you need to add a reference to Gadgeteer.SPI to the project: http://gadgeteer.codeplex.com/discussions/362536
(N.B. I have not found StackOverflow a useful site to get help on Gadgeteer questions. I hope it gets better. In the mean time I have been posting questions on the GHI Gadgeteer Forum https://www.ghielectronics.com/community/forum/board?id=21 and finding I get useful and knowledgeable answers there.)