USB Controlled Function Generator Design and Implementation by Kent Schonert (Kent.Schonert@sbcglobal.net)
Function Generator Features Provides easily controlled signal generation at low cost.  Ideal for hobbyists and students.  Works with USB in order to hook up can control from any modern PC. Has programmable control (e.g. automated signal sweeps ability) Works over wide range of frequencies  Can run on spare computer power supply
Overview Two main hardware components: XR-2206 and C8056F340 Advantages over completely digital design Hardware interfacing & circuitry Software design from PC to microcontroller Demonstration screenshots and output Cost breakdown Planned improvements for next iteration
XR-2206 Monolithic Function Generator Function generator on single IC chip Can produce sine, triangle, sawtooth, square, and pulse waves Frequency range of 0.01Hz to 1+ Mhz Synchronization output Low cost (less than $4 for DIP package) Amplitude and frequency can be voltage controlled . . .
XR-2206 Controls Amplitude output is controlled by voltage at pin 1 Frequency output is controlled by voltage at pin 7 Frequency and amplitude controls are orthogonal
Silicon Labs C8051F340  48 MIPs mixed signal microcontroller USB on board target, capable of interfacing with USB PC host. 5 8-bit Ports, mostly free by default Capable of producing four PWM’s using Programmable Counter Array (8 or 16 bit) Extensive documentation and examples available from manufacturer
Advantages over using DAC At 48MIPs, fastest DAC refresh rate is 813ns using 100% resources 1.63 µ s DAC refresh using more realistic 50% of resources Limits 48MIPs device to 30kHz signal at 20 samples per cycle XR2206 can provide up to a 1 to 2 MHz analog signal There are no Silicon Labs boards with both onboard USB target and DAC
 
Wave Form Switching Switch Replaced with Resistor  (no distortion) Switch in place to alternate waveform on demand (minimal distortion)
Frequency Range Switching CD4016 CMOS switch used R on  = 600 Ω  (Max) Adding resistance greater than 50 Ω  causes unacceptable distortion Feature wasn’t implemented.  A switch with lower R on  resistance is needed.  Newer technology exists with R on  low as 70m Ω  at DC, but wasn’t readily available.
Added Resistance Effect on Output Waveform Distortion. CD4016 Switch is replaced with resister in order to test distortion sensitivity to added resistance R = 300 R = 50
PC to Microcontroller Communication Silicon Labs provides ample examples and documentation for USB communication with the C8051F34x MCU’s The Si Labs example “Test Panel” was heavily modified to provide the XR Interface Code provided with “Test Panel” graphical user interface (Microsoft C#)  MCU firmware (Keil C51) Blinks LED based on GUI output Gets temperature reading and sends back to host for display Gets analog to digital conversion and displays on GUI USB libraries (SiLabs USBXpress)
Graphical User Interface 3 Outputs (from PC host, to target) 5 Inputs (to PC host, from target)
USB Data Buffer USBXpress drivers operate using endpoint 2 on the C8051F340 in split mode This gives 128bytes of input and128 bytes for output i.e. data can be queued XR-Control project uses 8 byte input and output packets 16 packets can be queued USB buffer memory on ‘F340, resides in XDATA address space.
USB Data Exchange PC Host Read Request In USB Buffer Out Data PC Host In USB Buffer Out Data Data to Target Device Data From Target Device Packet 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
Software on Host
Firmware on `F340 Target
 
 
Cost Analysis Initial Prototype Part Qty Price  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 Technology C8051F340 (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.16 USB B to PCB Price $53.06 Price (low) $28.65
Future Improvements Timing capacitance switching – Could use solid state relays  Power amplification! Amplitude measurements calculated by host.  Possible frequency measurements if acquisitions can be timed with reliability. Additional waveforms Ramp Sawtooth PWM More features on Host Software (e.g. frequency sweeps)
Questions?
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 6 Total: 39 Tolal/48Mhz : 8.125E-07s 50%*1/(20*Update time): 3.08E+04Hz
Full   Schematic XR-2206

Usb Controlled Function Generator

  • 1.
    USB Controlled FunctionGenerator Design and Implementation by Kent Schonert (Kent.Schonert@sbcglobal.net)
  • 2.
    Function Generator FeaturesProvides easily controlled signal generation at low cost. Ideal for hobbyists and students. Works with USB in order to hook up can control from any modern PC. Has programmable control (e.g. automated signal sweeps ability) Works over wide range of frequencies Can run on spare computer power supply
  • 3.
    Overview Two mainhardware components: XR-2206 and C8056F340 Advantages over completely digital design Hardware interfacing & circuitry Software design from PC to microcontroller Demonstration screenshots and output Cost breakdown Planned improvements for next iteration
  • 4.
    XR-2206 Monolithic FunctionGenerator Function generator on single IC chip Can produce sine, triangle, sawtooth, square, and pulse waves Frequency range of 0.01Hz to 1+ Mhz Synchronization output Low cost (less than $4 for DIP package) Amplitude and frequency can be voltage controlled . . .
  • 5.
    XR-2206 Controls Amplitudeoutput is controlled by voltage at pin 1 Frequency output is controlled by voltage at pin 7 Frequency and amplitude controls are orthogonal
  • 6.
    Silicon Labs C8051F340 48 MIPs mixed signal microcontroller USB on board target, capable of interfacing with USB PC host. 5 8-bit Ports, mostly free by default Capable of producing four PWM’s using Programmable Counter Array (8 or 16 bit) Extensive documentation and examples available from manufacturer
  • 7.
    Advantages over usingDAC At 48MIPs, fastest DAC refresh rate is 813ns using 100% resources 1.63 µ s DAC refresh using more realistic 50% of resources Limits 48MIPs device to 30kHz signal at 20 samples per cycle XR2206 can provide up to a 1 to 2 MHz analog signal There are no Silicon Labs boards with both onboard USB target and DAC
  • 8.
  • 9.
    Wave Form SwitchingSwitch Replaced with Resistor (no distortion) Switch in place to alternate waveform on demand (minimal distortion)
  • 10.
    Frequency Range SwitchingCD4016 CMOS switch used R on = 600 Ω (Max) Adding resistance greater than 50 Ω causes unacceptable distortion Feature wasn’t implemented. A switch with lower R on resistance is needed. Newer technology exists with R on low as 70m Ω at DC, but wasn’t readily available.
  • 11.
    Added Resistance Effecton Output Waveform Distortion. CD4016 Switch is replaced with resister in order to test distortion sensitivity to added resistance R = 300 R = 50
  • 12.
    PC to MicrocontrollerCommunication Silicon Labs provides ample examples and documentation for USB communication with the C8051F34x MCU’s The Si Labs example “Test Panel” was heavily modified to provide the XR Interface Code provided with “Test Panel” graphical user interface (Microsoft C#) MCU firmware (Keil C51) Blinks LED based on GUI output Gets temperature reading and sends back to host for display Gets analog to digital conversion and displays on GUI USB libraries (SiLabs USBXpress)
  • 13.
    Graphical User Interface3 Outputs (from PC host, to target) 5 Inputs (to PC host, from target)
  • 14.
    USB Data BufferUSBXpress drivers operate using endpoint 2 on the C8051F340 in split mode This gives 128bytes of input and128 bytes for output i.e. data can be queued XR-Control project uses 8 byte input and output packets 16 packets can be queued USB buffer memory on ‘F340, resides in XDATA address space.
  • 15.
    USB Data ExchangePC Host Read Request In USB Buffer Out Data PC Host In USB Buffer Out Data Data to Target Device Data From Target Device Packet 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
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
    Cost Analysis InitialPrototype Part Qty Price 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 Technology C8051F340 (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.16 USB B to PCB Price $53.06 Price (low) $28.65
  • 21.
    Future Improvements Timingcapacitance switching – Could use solid state relays Power amplification! Amplitude measurements calculated by host. Possible frequency measurements if acquisitions can be timed with reliability. Additional waveforms Ramp Sawtooth PWM More features on Host Software (e.g. frequency sweeps)
  • 22.
  • 23.
    Instruction Function MnemonicClk 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 6 Total: 39 Tolal/48Mhz : 8.125E-07s 50%*1/(20*Update time): 3.08E+04Hz
  • 24.
    Full Schematic XR-2206