usb controlled function generator

24
USB Controlled USB Controlled Function Generator Function Generator Design and Implementation Design and Implementation by Kent Schonert by Kent Schonert (Kent.Schonert@sbcglobal. (Kent.Schonert@sbcglobal. net) net)

Upload: kent-schonert

Post on 21-Dec-2014

3.810 views

Category:

Self Improvement


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Usb Controlled Function Generator

USB Controlled Function USB Controlled Function GeneratorGenerator

Design and Implementation by Design and Implementation by Kent SchonertKent Schonert

([email protected])([email protected])

Page 2: Usb Controlled Function Generator

Function Generator FeaturesFunction Generator Features

Provides easily controlled signal Provides easily controlled signal generation at low cost. Ideal for hobbyists generation at low cost. Ideal for hobbyists and students. and students. Works with USB in order to hook up can Works with USB in order to hook up can control from any modern PC.control from any modern PC.Has programmable control (e.g. Has programmable control (e.g. automated signal sweeps ability)automated signal sweeps ability)Works over wide range of frequencies Works over wide range of frequencies Can run on spare computer power supplyCan run on spare computer power supply

Page 3: Usb Controlled Function Generator

OverviewOverview

Two main hardware components: XR-2206 and Two main hardware components: XR-2206 and C8056F340C8056F340

Advantages over completely digital designAdvantages over completely digital design

Hardware interfacing & circuitryHardware interfacing & circuitry

Software design from PC to microcontrollerSoftware design from PC to microcontroller

Demonstration screenshots and outputDemonstration screenshots and output

Cost breakdownCost breakdown

Planned improvements for next iterationPlanned improvements for next iteration

Page 4: Usb Controlled Function Generator

XR-2206 Monolithic Function XR-2206 Monolithic Function GeneratorGenerator

Function generator on single IC chipFunction generator on single IC chip

Can produce sine, triangle, sawtooth, Can produce sine, triangle, sawtooth, square, and pulse wavessquare, and pulse waves

Frequency range of 0.01Hz to 1+ MhzFrequency range of 0.01Hz to 1+ Mhz

Synchronization outputSynchronization output

Low cost (less than $4 for DIP package)Low cost (less than $4 for DIP package)

Amplitude and frequency can be voltage Amplitude and frequency can be voltage controlled . . .controlled . . .

Page 5: Usb Controlled Function Generator

XR-2206 ControlsXR-2206 Controls

Amplitude output is controlled by voltage at pin 1Amplitude output is controlled by voltage at pin 1

Frequency output is controlled by voltage at pin 7Frequency output is controlled by voltage at pin 7

Frequency and amplitude controls are orthogonalFrequency and amplitude controls are orthogonal

0

200

400

600

800

1000

0 1 2 3Control Voltage (V)

Freq

uenc

y (H

z)

Page 6: Usb Controlled Function Generator

Silicon Labs C8051F340 Silicon Labs C8051F340

48 MIPs mixed signal microcontroller48 MIPs mixed signal microcontroller

USB on board target, capable of USB on board target, capable of interfacing with USB PC host.interfacing with USB PC host.

5 8-bit Ports, mostly free by default5 8-bit Ports, mostly free by default

Capable of producing four PWM’s using Capable of producing four PWM’s using Programmable Counter Array (8 or 16 bit)Programmable Counter Array (8 or 16 bit)

Extensive documentation and examples Extensive documentation and examples available from manufactureravailable from manufacturer

Page 7: Usb Controlled Function Generator

Advantages over using DACAdvantages over using DAC

At 48MIPs, fastest DAC refresh rate is 813ns At 48MIPs, fastest DAC refresh rate is 813ns using 100% resourcesusing 100% resources 1.631.63µµs DAC refresh using more realistic 50% of s DAC refresh using more realistic 50% of

resourcesresources Limits 48MIPs device to 30kHz signal at 20 samples Limits 48MIPs device to 30kHz signal at 20 samples

per cycleper cycle

XR2206 can provide up to a 1 to 2 MHz analog XR2206 can provide up to a 1 to 2 MHz analog signalsignal

There are no Silicon Labs boards with both There are no Silicon Labs boards with both onboard USB target and DAConboard USB target and DAC

Page 8: Usb Controlled Function Generator

WaveformSelect

Timing Adjust(Frequency)

Out

FM InputAM Input

XR-2206DC

LPF

BufferLPF

Non-InvertingSummer

Buffer

DCOR

ADC

PWM

PWM

USB Host

Output to Target Input from Host

-Set Frequency

-Set Amplitude

-Set Waveform

-PCA Value for Freq.-PCA Value for Amp.-Device Warnings-ADC Value (partially

implemented)

Wave Form Switch

Timing Cap. Switch

DC

P1.4

P1.1

P1.7

P1.6

P2.5

P1.2

USB

Target

C8051F340

Software Running on Host PC

WaveformSelect

Timing Adjust(Frequency)

Out

FM InputAM Input

XR-2206DC

LPF

BufferLPF

Non-InvertingSummer

Buffer

DCOR

ADC

PWM

PWM

USB Host

Output to Target Input from Host

-Set Frequency

-Set Amplitude

-Set Waveform

-PCA Value for Freq.-PCA Value for Amp.-Device Warnings-ADC Value (partially

implemented)

Wave Form Switch

Timing Cap. Switch

DC

P1.4

P1.1

P1.7

P1.6

P2.5

P1.2

USB

Target

C8051F340

Software Running on Host PC

Page 9: Usb Controlled Function Generator

Wave Form SwitchingWave Form Switching

Switch Replaced with Resistor (no distortion)

Switch in place to alternate waveform on demand (minimal distortion)

Page 10: Usb Controlled Function Generator

Frequency Range SwitchingFrequency Range Switching

CD4016 CMOS switch usedCD4016 CMOS switch used

RRonon = 600 = 600ΩΩ (Max) (Max)

Adding resistance greaterAdding resistance greaterthan 50than 50ΩΩ causes unacceptable distortion causes unacceptable distortionFeature wasn’t implemented. A switch with Feature wasn’t implemented. A switch with lower Rlower Ronon resistance is needed. resistance is needed.

Newer technology exists with RNewer technology exists with Ronon low as 70m low as 70mΩΩ at DC, but wasn’t readily available.at DC, but wasn’t readily available.

Page 11: Usb Controlled Function Generator

Added Resistance Effect on Output Added Resistance Effect on Output Waveform Distortion.Waveform Distortion.

CD4016 Switch is replaced with resister in CD4016 Switch is replaced with resister in order to test distortion sensitivity to added order to test distortion sensitivity to added resistanceresistance

R = 300R = 300

R = 50R = 50

Page 12: Usb Controlled Function Generator

PC to Microcontroller PC to Microcontroller CommunicationCommunication

Silicon Labs provides ample examples and Silicon Labs provides ample examples and documentation for USB communication with the documentation for USB communication with the C8051F34x MCU’sC8051F34x MCU’sThe Si Labs example “Test Panel” was heavily The Si Labs example “Test Panel” was heavily modified to provide the XR Interfacemodified to provide the XR InterfaceCode provided with “Test Panel”Code provided with “Test Panel” graphical user interface (Microsoft C#) graphical user interface (Microsoft C#) MCU firmware (Keil C51)MCU firmware (Keil C51)

Blinks LED based on GUI outputBlinks LED based on GUI outputGets temperature reading and sends back to host for displayGets temperature reading and sends back to host for displayGets analog to digital conversion and displays on GUIGets analog to digital conversion and displays on GUI

USB libraries (SiLabs USBXpress)USB libraries (SiLabs USBXpress)

Page 13: Usb Controlled Function Generator

Graphical User InterfaceGraphical User Interface

3 Outputs (from PC host, to target)3 Outputs (from PC host, to target)5 Inputs (to PC host, from target)5 Inputs (to PC host, from target)

Page 14: Usb Controlled Function Generator

USB Data BufferUSB Data Buffer

USBXpress drivers operate using endpoint 2 USBXpress drivers operate using endpoint 2 on the C8051F340 in split modeon the C8051F340 in split mode

This gives 128bytes of input This gives 128bytes of input and128 bytes for outputand128 bytes for output i.e. data can be queuedi.e. data can be queued

XR-Control project uses 8 byte XR-Control project uses 8 byte input and output packetsinput and output packets 16 packets can be queued16 packets can be queued

USB buffer memory on ‘F340, resides in USB buffer memory on ‘F340, resides in XDATA address space.XDATA address space.

Page 15: Usb Controlled Function Generator

USB Data ExchangeUSB Data ExchangePacket type/# Information

In_Packet[0] Limit(s) Hit

In_Packet[1] A/D Conversion

In_Packet[2] Port1 Status

In_Packet[3] Amp. PCA Value

In_Packet[4] Freq. PCA Value

Out_Packet[0] Amp. Hi Byte

Out_Packet[1] Amp. Lo Byte

Out_Packet[2] Freq. Hi Byte

Out_Packet[3] Freq. Lo Byte

Out_Packet[4] Freq. Multiplier

Out_Packet[5]

Out_Packet[6] Waveform Select

PCHost

Read Request

InUSB Buffer

Out

Data

PCHost

InUSB Buffer

OutData

Data to Target Device

Data From Target Device

Page 16: Usb Controlled Function Generator

Software on HostSoftware on Host

Scroll Bar UpdateSet Update Target

flagExit

Read FIFO-In Buffer

50ms Timer tick

Update GUIPCACPH0 (Amp.)PCACPH1 (Freq.)ADC ValueRange PropertiesDevice Warninigs

Format Text box

Update Target Flag Set?

Store Amp., Freq, and Waveform Data to Buffer

Write to FIFO-Out Buffer

Break down Amplitude and

Frequency Values into Bytes

ExitClear Update Target Flag

yes

no

Page 17: Usb Controlled Function Generator

Firmware on `F340 TargetFirmware on `F340 Target

Set Frequency

Init TimerInit USB

If USB Update Sent (flag set) Set Amplitude Triangle

Requsted

Adjust Wave with Sine Conversions

Adjust Wave with Triangle

Conversions

yes

noAdjust Wave with Freq Conversions

Store Data for next USB Read:

ADC valuePort 1PCA0CPH0 for AmpPCA0CPH1 for Freq

Init ADC

yes

-Get limits hit in Frequency and Amp. Adjustments. -Store for Next USB Read

no

ADC Complete (interrupt)

Store ADC Value

Write to USB Out Buffer

Exit Interrupt

USB InterruptStore Packet to memory

Set USB update Flag

Exit Interrupt

Page 18: Usb Controlled Function Generator
Page 19: Usb Controlled Function Generator
Page 20: Usb Controlled Function Generator

Cost AnalysisCost Analysis

Part QtyPrice each

C8051F340 (Dev Kit) 1 $100 $100

XR-2206CP 1 $3.29 $3.29

CD4016 (Quad Switch) 1 $0.29 $0.29

LM741 (op-amp) 3 $1.10 $3.30

DM7406 (OC inverter) 1 $0.40 $0.40

Capacitors 5 $0.10 $0.50

Resistors <20 low $1.00

Bread Board 1 $3.50 $3.50

Power Supply 1 $15.00 $15.00

Total $127

Surface Mount TechnologyC8051F340 (SMT Unit) 1 $9.41 $9.41

XR-2206D 1 $10.00 $10.00

Power Supply 1 $15.00 $15.00

Capacitors 11 $0.10 $1.10

Resistors <20 low $1.00

Solid State Relay (2ohm) 1 $5.33 $5.33

PS7113L-2A-A (quad)

LMV934MA-ND 1 $1.66 $1.66

Op amp (quad)

sp0503baht 1 $0.40 $0.40

Diode Pack

PCB Board 1 $4.00 $4.00

Misc Pins/Jumpers x x $4.00

AU-Y1007-R

1 $1.16 $1.16USB B to PCB

Price $53.06

Price (low) $28.65

Initial Prototype

Page 21: Usb Controlled Function Generator

Future ImprovementsFuture Improvements

Timing capacitance switching – Could use solid state Timing capacitance switching – Could use solid state relays relays Power amplification!Power amplification!Amplitude measurements calculated by host. Possible Amplitude measurements calculated by host. Possible frequency measurements if acquisitions can be timed frequency measurements if acquisitions can be timed with reliability.with reliability.Additional waveformsAdditional waveforms

RampRamp SawtoothSawtooth PWMPWM

More features on Host Software (e.g. frequency sweeps)More features on Host Software (e.g. frequency sweeps)

Page 22: Usb Controlled Function Generator

Questions?Questions?

Page 23: Usb Controlled Function Generator

Instruction Function Mnemonic Clk Cycles

Push double pointer (Hi/Lo) PUSH direct (DPH/DPL) 4

Push A PUSH A 2

increment counter INC direct 2

move counter to A Mov A, direct 2

Subtract max ptr size from counter SUBB A, #data 2

Jump to reset pointer if at max JZ 2

Move offset to Double Pointer (Hi) MOV DPH, direct 2

Move offset to Double Pointer (Lo) MOV DPL, direct 2

Fetch Hi data from code memory MOVC A, @A+DTPR 2

Put Hi data into DAC register MOV direct, A 2

Increment A INC A 1

Fetch Lo byte from code memory MOVC A, @A+DTPR 2

Put Lo byte into DAC register MOV direct, A 2

POP A POP A 2

POP double pointer (Hi/Lo) POP direct (DHP/DPL) 4

Return from interrupt RETI 6Total: 39

Tolal/48Mhz: 8.125E-07s

50%*1/(20*Update time): 3.08E+04Hz

Page 24: Usb Controlled Function Generator

FullFull SchematicSchematic

R_C1k

10k

LM741

+3

-2

V+7

V-4

OUT6

OS11

OS25

C1uF

VCC_BAR

VEE

100k1uF

33kC1

1u

R100k

5.1k

5.1k

VCC_BAR10uF

VCC_BAR

LM741

+3

-2

V+7

V-4

OUT6

OS11

OS25

1k

1k

CD4016

IN1

OUT2

VC13

VDD

14VS

S7

1k

VCC_BAR

VEE

DM7406

1 2

VCC_BAR

1k

S1Port 1.1

C8051F340MCU

LM741

+3

-2

V+7

V-4

OUT6

OS11

OS25

VCC_BAR

VEE

Waveform Output

100k

S1Port 1.2

1uF

VCC_BAR

VEE

VEE-15Vdc

0

VCC_BAR

V115Vdc

0

1uF

Port 1.4

Port 1.7

XR-2206