Arduino Radio Spectrum Analyzer prototype on a breadboard: Difference between revisions

From NURDspace
m (Text replacement - "ProjectNiche=" to "Niche=")
 
(25 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Project
{{Project
||ProjectParticipants=SmokeyD
|Name=ARSAPB
|ProjectSkills=Programming, Electronics, Soldering
|Skills=Programming, Electronics, Soldering
|ProjectStatus=Active
|Status=Dormant
|ProjectNiche=Electronics
|Niche=Electronics
|ProjectPurpose=Fun
|Purpose=Fun
|Picture=13.jpg
|ProjectParticipants=SmokeyD
}}
}}
I am building a Radio Spectrum Analyzer which measures signal strenght in the 2.4GHz band, using a CYWM6935 module and Atmega 328 MCU.
I am building a Radio Spectrum Analyzer which measures signal strenght in the 2.4GHz band, using a CYWM6935 module and Atmega 328 MCU.
Code is available on https://github.com/dolfandringa/arsa
I want to set it up in several steps:
I want to set it up in several steps:


==Atmega328 on a breadboard==
==Setting up an Arduino on a breadboard==
There are quite a few good "Arduino on a breadboard" tutorials out there. I suggest you take a look at
 
* [http://arduino.cc/en/Main/Standalone|Building an Arduino on a Breadboard]
I first setup an [[Arduino_on_a_breadboard|arduino on a breadboard]]
 
==Connecting the CYWM6935==
 
Before you do anything with the Radio board, you need it's datasheet. The datasheet not only tells you what each pin means, but also its operating voltage, current usage, exact method of communication, etc. The more you understand of this stuff, the more you will appreciate the datasheet.
 
In this case you actually need two datasheets. One is the one for the [http://www.cypress.com/?docID=30630|CYWM6935 module]. But this module is powered by a CYWMUSB6935 chip, so the [datasheet for the CYWMUSB6935 chip will tell you more, especially on page 25 about DC characteristics (power usage, voltage, etc).
 
In those datasheets you can find that the MCU can communicate to the radio board using the Serial Peripheral Interface (SPI) Bus. This is a smart way for controlling peripheral modules/circuitry/etc from an MCU. You can read more of how it works on http://en.wikipedia.org/wiki/Serial_Peripheral_Interface.  There is one snag here though. The breadboard and MCU run at 5V. The CYWM6935 runs at 3.3V though. So if you were to wire things up directly, you will blow up your radio module. This is the case both for the direct power supply to the radio module, but also for the SPI bus. So all voltages to the radio module need to be changed to 3.3V.
 
For the SPI you can use a simple voltage divider. I had to read up on what this was after someone told me to use one. I can very much recommend [http://www.amazon.com/Practical-Electronics-Inventors-2-E/dp/0071452818?ie=UTF8&qid=1359586555|the (e)book Practical Electronics for Inventors by Paul Scherz]. It is a good book that explains electronics theory well, and gives you enoug examples to see if you really understand what is explained. For the impatient though: a voltage divider divides the input voltage over two resistors, where part of the voltage goes to ground, and the other part is used as a (lower) output voltage, to a next part of the circuit. The ratio between the two resistors determines the output voltage. For the SPI Bus, I used a 2.2kOhm resistor, followed by a 1kOhm resistor. Between these two, there is a wire which provides the intermediate voltage of 3.4V to the radio module. This is where those resistors were for that you may have seen on the previous pictures. In the picture below you also see them. We'll hook them up later.
 
[[File:5.jpg|none|600px]]
 
In the picture above and the pictures below you see the connector that I used to hook up the breadboard to the CYWM6935 module. See [#cable_hack] for the exact way I hooked it up. For now it is important to notice the pin numbers on the connector. These are the pin numbers of the radio module, as specified in the datasheet. The order of the pins on the connector is a bit odd. The [#cable hack] part explains why, but they are the correct pin numbers from the datasheet.
 
First we'll hook up the ground (pins 1 and 9), and a PULLUP resistor to pin 10 (poweroff) to prevent the board from powering off unexpectedly.
 
[[File:7.jpg|none|600px]]
 
[[File:8.jpg|none|600px]]
 
[[File:9.jpg|none|600px]]


These were the components I bought (or borrowerd here on the nurdpspace):
[[File:10.jpg|none|600px]]


* [http://nl.mouser.com/Search/ProductDetail.aspx?R=A000048virtualkey24200000virtualkey782-A000048 1x Atmega328 MCU with Arduinno bootloader]
[[File:11.jpg|none|600px]]
* 3x 2.2 KOhm resistor
* 3x 1 KOhm resistor
* 2x 10 KOhm resistor
* 1x reset switch
* 1x red LED
* 4x jumpers
* [http://nl.mouser.com/Search/ProductDetail.aspx?R=561R10TCCQ18virtualkey59480000virtualkey75-561R10TCCQ18 2x 18pF ceramic disc capacitors]
* [http://nl.mouser.com/Search/ProductDetail.aspx?R=9B-16.000MAAJ-Bvirtualkey57230000virtualkey717-9B-16.000MAAJ-B 1x 16MHz crystal oscillator]
* [http://nl.mouser.com/Search/ProductDetail.aspx?R=CYWM6935virtualkey63930000virtualkey727-CYWM6935 1x CYWM6935 wireless USB radio module]
* Any breadboard. I bought a small one since I thought I would have plenty of space, but I was mistaken, and would recommend a large one. The larger the better really.
* FTDI cable
* A plate full of spaghetti. Aka: solid core red wire
* A few cases of beer
* A few pizzas


I will discribe the breadboard setup bit-by-bit. This is work in progress.
[[File:12.jpg|none|600px]]
[[File:Switch.jpg]]


==Connecting the CYWM6935==
[[File:13.jpg|none|600px]]


To connect the CYWM6935 module to the breadboard, I created my own cable. I found a 2.5" Harddisk adaptor plug, which fortunately has pins on one side with the spacing for my flat cables like floppydisk cables, and on the other side has holes with a smaller spacing, exactly the size of the CYWM6935. Using this plug, a flatdable, some simple PCB and a few jumpers, I soldered something together that allowed me to connect the radio module to the breadboard.
=== Cable hack ===
To connect the CYWM6935 module to the breadboard, I created my own cable. I found a 2.5" Harddisk adaptor plug, which fortunately has pins on one side with the spacing for flat cables like floppydisk cables, and on the other side has holes with a smaller spacing, exactly the size of the CYWM6935. Using this plug, a (cut-up floppy disk) flatcable, some simple PCB and a few jumpers, I soldered something together that allowed me to connect the radio module to the breadboard.


I split a floppy cable that was lying around, so it had 10 wires left. On one side I left the connector in place. On the other side I cut off the connector and stripped the wires.
I split a floppy cable that was lying around, so it had 10 wires left. On one side I left the connector in place. On the other side I cut off the connector and stripped the wires.
I soldered each of these free wires to a PCB. On each of the lanes for these wires, a jumper pin was soldered, so I ended up with a 10-pin connector which fits the breadboard. There is one thing you should know about this connection (and could be done better). If you connect the wires this was, the order of the pins on the breadboard correspond to the CYWM6935 pins in a weird order. Their order is: 2,1,4,3,6,5,8,7,10,9. If you want the pins on the breadboard side, to correspond to the CYWMUSB6935 module in the correct order, you should twist around each pair of wires.
I soldered each of these free wires to a PCB. On each of the lanes for these wires, a jumper pin was soldered, so I ended up with a 10-pin connector which fits the breadboard. There is one thing you should know about this connection (and could be done better). If you connect the wires this way, the order of the pins on the breadboard correspond to the CYWM6935 pins in a weird order. Their order is: 2,1,4,3,6,5,8,7,10,9. If you want the pins on the breadboard side, to correspond to the CYWMUSB6935 module in the correct order, you should twist around each pair of wires.
This is how the cable looks now.
This is how the cable looks now.


[[File:cywm6935_connector_cable.jpg]]
[[File:cywm6935_connector_cable.jpg|none|600px]]


Connecting this plug to it, you can plug in the CYWM6935 module directly.
Connecting this plug to it, you can plug in the CYWM6935 module.


[[File:connector_cable_with_cywm6935.jpg]]
[[File:connector_cable_with_cywm6935.jpg|none|600px]]


==Programming the Atmega328==
==Programming the Atmega328==

Latest revision as of 10:04, 25 August 2014

ARSAPB
13.jpg
Participants
Skills Programming, Electronics, Soldering
Status Dormant
Niche Electronics
Purpose Fun
Tool
Location
Cost
Tool category

ARSAPB

13.jpg {{#if:{{{Tool}}} | [[Tool Owner::SmokeyD | }} {{#if:{{{Tool}}} | [[Tool Cost::{{{Cost}}} | }}

I am building a Radio Spectrum Analyzer which measures signal strenght in the 2.4GHz band, using a CYWM6935 module and Atmega 328 MCU.

Code is available on https://github.com/dolfandringa/arsa

I want to set it up in several steps:

Setting up an Arduino on a breadboard

I first setup an arduino on a breadboard

Connecting the CYWM6935

Before you do anything with the Radio board, you need it's datasheet. The datasheet not only tells you what each pin means, but also its operating voltage, current usage, exact method of communication, etc. The more you understand of this stuff, the more you will appreciate the datasheet.

In this case you actually need two datasheets. One is the one for the module. But this module is powered by a CYWMUSB6935 chip, so the [datasheet for the CYWMUSB6935 chip will tell you more, especially on page 25 about DC characteristics (power usage, voltage, etc).

In those datasheets you can find that the MCU can communicate to the radio board using the Serial Peripheral Interface (SPI) Bus. This is a smart way for controlling peripheral modules/circuitry/etc from an MCU. You can read more of how it works on http://en.wikipedia.org/wiki/Serial_Peripheral_Interface. There is one snag here though. The breadboard and MCU run at 5V. The CYWM6935 runs at 3.3V though. So if you were to wire things up directly, you will blow up your radio module. This is the case both for the direct power supply to the radio module, but also for the SPI bus. So all voltages to the radio module need to be changed to 3.3V.

For the SPI you can use a simple voltage divider. I had to read up on what this was after someone told me to use one. I can very much recommend (e)book Practical Electronics for Inventors by Paul Scherz. It is a good book that explains electronics theory well, and gives you enoug examples to see if you really understand what is explained. For the impatient though: a voltage divider divides the input voltage over two resistors, where part of the voltage goes to ground, and the other part is used as a (lower) output voltage, to a next part of the circuit. The ratio between the two resistors determines the output voltage. For the SPI Bus, I used a 2.2kOhm resistor, followed by a 1kOhm resistor. Between these two, there is a wire which provides the intermediate voltage of 3.4V to the radio module. This is where those resistors were for that you may have seen on the previous pictures. In the picture below you also see them. We'll hook them up later.

5.jpg

In the picture above and the pictures below you see the connector that I used to hook up the breadboard to the CYWM6935 module. See [#cable_hack] for the exact way I hooked it up. For now it is important to notice the pin numbers on the connector. These are the pin numbers of the radio module, as specified in the datasheet. The order of the pins on the connector is a bit odd. The [#cable hack] part explains why, but they are the correct pin numbers from the datasheet.

First we'll hook up the ground (pins 1 and 9), and a PULLUP resistor to pin 10 (poweroff) to prevent the board from powering off unexpectedly.

7.jpg
8.jpg
9.jpg
10.jpg
11.jpg
12.jpg
13.jpg

Cable hack

To connect the CYWM6935 module to the breadboard, I created my own cable. I found a 2.5" Harddisk adaptor plug, which fortunately has pins on one side with the spacing for flat cables like floppydisk cables, and on the other side has holes with a smaller spacing, exactly the size of the CYWM6935. Using this plug, a (cut-up floppy disk) flatcable, some simple PCB and a few jumpers, I soldered something together that allowed me to connect the radio module to the breadboard.

I split a floppy cable that was lying around, so it had 10 wires left. On one side I left the connector in place. On the other side I cut off the connector and stripped the wires. I soldered each of these free wires to a PCB. On each of the lanes for these wires, a jumper pin was soldered, so I ended up with a 10-pin connector which fits the breadboard. There is one thing you should know about this connection (and could be done better). If you connect the wires this way, the order of the pins on the breadboard correspond to the CYWM6935 pins in a weird order. Their order is: 2,1,4,3,6,5,8,7,10,9. If you want the pins on the breadboard side, to correspond to the CYWMUSB6935 module in the correct order, you should twist around each pair of wires. This is how the cable looks now.

Cywm6935 connector cable.jpg

Connecting this plug to it, you can plug in the CYWM6935 module.

Connector cable with cywm6935.jpg

Programming the Atmega328

Creating desktop software for visualization

I chose to create a Java GUI using JFreeChart to read the data from the Arduino using an FTDI cable on a serial port (or actually USB) and visualize that in the GUI. The program can be found on Github.

This is a screenshot from the app. It allows you to reset the maxima by clicking the button.

Arsa screenshot.png

Assemble everything on a custom PCB