Small computer-controlled square wave generator? - Page 1
Forum section: electronics / projects

author: Per Westermark
author_rank: Contributor
timestamp: October 07, 2023, 12:23:35 pm
content: Any programmable square wave module with programmable voltage?Looking for something small and practical to generate test pulses.- Frequency range 1 Hz to 100 kHz. Doesn't hurt if it can go lower than 1 Hz.- Square wave configured lower/upper voltage within 0-10V but preferably 0-20V- Controllable using RS-232, USB or maybe Ethernet- No need for sine wave, triangle wave etc. Square wave is enough. Programmable high/low ratio a bonus but not needed.- Preferably panel-mounted moduleIntended for an automatic test setup. I'm currently using a general signal generator but that is a bit too clumsy. Best is if I can panel-mount in a 19" chassis.Preferably if it could have similar footprint as these voltage modules:https://www.amazon.se/-/en/DollaTek-Bluetooth-Communication-Constant-Converter/dp/B07PLFZ3H2/

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 07, 2023, 01:49:00 pm
content: This seems like an easy task for any microcontroller with a PWM output. It is of course just a uC pin output, so you have to beef up the output to whatever signal levels you want, and there is a tradeoff between PWM speed, resolution and cost. The most time consuming part will be to design a communication protocol between the PC and implement it in software and firmware.

author: kripton2035
author_rank: Super Contributor
timestamp: October 07, 2023, 02:13:23 pm
content: this one is close. seems you only need a 20v supply to add.https://envistiamall.com/products/2-channel-5v-pwm-pulse-square-wave-generator-module-1hz-150khz-frequency

author: Per Westermark
author_rank: Contributor
timestamp: October 08, 2023, 05:04:24 am
content: Creating square wave is the trivial part. But I have almost zero time and it's a commercial project so money isn't an issue.If I build myself then I would, beside square wave, also need to- design an output stage that takes logic-level in and delivers programmable low and high levels in 0-20V range.- implement SCPI to control on/off, frequency and voltagesSo I can buy several full-size signal generators for the corresponding cost of building one myself.

author: Per Westermark
author_rank: Contributor
timestamp: October 08, 2023, 01:30:07 pm
content: Note that I want to be able to programmatically control the output voltage (low and high level) too within 0-10V or preferably within 0-20V.The goal is a simulate a square-wave signal with configurable amplitude and configurable offset.So it wouldn't be enough to just supply 20V and a transistor to get that module to deliver.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 08, 2023, 08:19:37 pm
content: Quote from: Per Westermark on October 08, 2023, 05:04:24 am?Then why ask in projects & designs , if you want commercial test equipment?You may find waveform generators easier to source, where you load the dac pattern with your hi and low levels, then set the playback speed.You get sine and triangle for freeAddit : A quick scan of aliexpress, finds items like thisJUNCTEK JDS8060 8080 Dual Channel Function Arbitrary Waveform Signal Generator Source 275MSa/s 14bits Frequency Meter 60M 80MHzhttps://www.aliexpress.com/item/1005005956668675.htmlthat looks to manage +/-12.5V range, USB and rs232.TTL connections.You could add an external amplifier, if the 20V is important ? example :https://www.aliexpress.us/item/3256803968826290.html

author: Per Westermark
author_rank: Contributor
timestamp: October 09, 2023, 09:21:44 am
content: I already have access to signal generators. That works for me at my desk. But I need to create a number of test systems and then it isn't practical to have a large set of full-size instruments - which I did mention in my original post.What I'm asking about is if anyone knows about a square wave generator *module* according to the requirements I specified.Ï selected this subforum because this *is* a project - fitting multiple *modules* into a 19" rack box. So this is more like "anyone seen an OP-Amp with xx specification" than it is asking about "What oscilloscope would you recommend for ..."

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 09, 2023, 12:45:33 pm
content: It was also not clear to me from your first post that you wanted to buy some ready made product and assumed you wanted to build a project.Your signal output requirements are quite modest, but SCPI (or at least programmability) is going to reduce your options quickly. I bought a JDS6600 (Similar to other chinese function generators, but max 15MHz and EUR80 or so) and it has programmability though USB, but not SCPI. These function generators are also mostly empty boxes. The whole function generator itself is a quite thin PCB (With an FPGA), and there is another PCB in the front panel. (With an STM32 clone, I think it's an GD variant, but that may vary)

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 09, 2023, 01:25:14 pm
content: I just did a simple search for "signal generator" on kickstarter and found the link below. It's apparently an open source project so that makes it easier to add things like SCPI.https://www.kickstarter.com/projects/nickjohnson/tsunami?ref=discovery&term=scpiAnd on similar crowd funding websites you can probably find other such projects.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 09, 2023, 09:31:54 pm
content: Quote from: Per Westermark on October 09, 2023, 09:21:44 amYet your original post missed that vitalmultiple *modules* part, you merely saidBest is if I can panel-mount in a 19" chassis.Simplest may be to find an Aliexpress DDS module that can waveform generate (RAM table), and make a rack motherboard for N of those, with buffer amplifier if needed.eghttps://www.aliexpress.us/item/3256802987667363.htmlcan piggyback

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 09, 2023, 11:01:40 pm
content: Quote from: Per Westermark on October 07, 2023, 12:23:35 pmA full DDS may be over-kill, but would be very flexible !What Frequency resolution and stability do you need ?A MCU with Dual DAC and a PWM output, could analog MUX between the two DAC levels to give you the variable VOL VOHParts like EFM8BB3 and EFM8LB1 have 4 x 12b DAC and 50/72MHz sysclks,If you are ok with PWM-DAC, modules like RP2040-Zero might do ?

author: aeg
author_rank: Regular Contributor
timestamp: October 10, 2023, 10:15:23 am
content: How many do you need and what is your target price?

author: coromonadalix
author_rank: Super Contributor
timestamp: October 10, 2023, 10:31:41 am
content: A simple Juntek like the JDS-2900 series, is easily controlled by its usb --- rs232 portWe have done at my job a simple gui who read an crafted csv sheet to navigate on 80 possible / selected frequencies and set the output voltage .... to help calibrate a filterAnd we will automate our test rig in the future, this gui was a fast solution ...no need to overthink a projectyes tons of projects too based on small dds modules on Ebay can be used, if the OP is not lazy, all the answers can be found on the web, time lost is money, just buy an already made generator and have funAND juntek have panel mount generators in the JDS-2800 series, they are worth to be checkedand finally all the protocols are given to control them ....

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 10, 2023, 11:15:41 pm
content: Checking into eval modules that might be used, I found some DACS have a toggle setting option, that allow alternate between two DAC values under HW control.eg EFM8BB3 / EFM8LB1 and EFM8BB52 do that.Note however, that many small MCUs like this, lack crystals on the eval boards, so the precision is lower.The RP2040 PiPIC0 also looks well suited here. I'm not sure how much register-access python gives, but code looks simple.There are many low cost RP2040 module choices, and it has 125MHz PCLK, so can go as low as 125M/65535/(255+15/16) = 7.45Hz, and 100kHz is ~0.1% stepsRP2040 has 8 PWM pairs, so you can do 8 channels of PWM-DAC for HI/LO setpoints, using 4 pairs and have independent any-kHz outputs on 4 remaining channels.Depending on how important below 7.45Hz is, you could nudge down the PCLK to get to 1Hz, or you could add a D-FF between two outputs and generate a 50% duty, low frequency-difference, that can go as low as 114 microHz (2.44 hours)A simple daughter card would have opamps for LPF and DAC -> 20V swing amplify, and the optional FF for sub-1Hz