Page 1 of 1

USB function generator

PostPosted: Fri Nov 10, 2017 8:32 pm
by DarioG
Am just posting the Full Code for an USB function generator based upon a
PIC24EP512GU810 (possibly a dsPIC33EP512MU810 should work pin-to-pin compatible).
Features 5..35000000Hz as Square Wave, with frequency approximation as close as possible (of course, not so perfect above 1MHz :) ), and I am going to go down to 0.1Hz using some further trick;
Same range for Rectangulare Wave, with duty-cycle selectable in 0.1% steps (same, and more, approximation rules apply);
0.1 .. 250KHz Sine, Triangle, Sawtooth Wave - generated with 16levels synthesis (8 at frequencies above 100KHz);
White Noise; and Pink in the to-do list (i.e. do something in software or add a low-pass filter at the output :) )

Schematic is basically "nothing" i.e. just decoupling capacitors, USB connector at its pins, a few debugging leds, a PWM output - and an I2C EEprom that we used to store waveform so that the device can run stand alone with the programmed wave (the EEprom was already there since we created this PCB for a CAN interface).
Output can be amplified using a large-bandwidth OpAmp such AD8007: USB interface already has an "Amplitude" parameter, unused at the moment.

One possible, simple improvement would be using an 8bit DAC (more is useless, due to IRQ overhead) in place of PWM.

have fun!

Re: USB function generator

PostPosted: Fri Nov 10, 2017 8:33 pm
by DarioG
usb_gen_funz1.jpg
usb_gen_funz1.jpg (47.64 KiB) Viewed 6220 times

Re: USB function generator

PostPosted: Fri Nov 10, 2017 8:34 pm
by DarioG
usb_gen_funz2.jpg
usb_gen_funz2.jpg (28.83 KiB) Viewed 6220 times

Re: USB function generator

PostPosted: Fri Nov 10, 2017 8:35 pm
by DarioG
firmware:

Re: USB function generator

PostPosted: Fri Nov 10, 2017 8:39 pm
by DarioG
and VB 2010 project (so far)

Re: USB function generator

PostPosted: Sun Nov 12, 2017 2:51 pm
by DarioG
Updated code that uses DMA - and reaches up to 2MHz/16levels sine/triangle/sawtooth waves!

Re: USB function generator

PostPosted: Mon Nov 13, 2017 4:08 am
by ChollyMo
How are you finding the VB Cinzia ? I used to use and love it, but I never could find a straight forward way to get it after version 6.0. I was just recommended to Visual Studio 2017 , C Sharp. Since I haven't used Basic in a decade and dabble with PICs in C, it seemed to make the most sense.

Re: USB function generator

PostPosted: Mon Nov 13, 2017 3:29 pm
by DarioG
I basically used only 2010, in the latest times (old 90s versions too but they were something different :) )

With VB2010 I prepare those simple software for connecting USB boards.