1. Things you need to know about the new ‘Conversations’ PM system:

    a) DO NOT REPLY TO THE NOTIFICATION EMAIL! I get them, not the intended recipient. I get a lot of them and I do not want them! It is just a notification, log into the site and reply from there.

    b) To delete old conversations use the ‘Leave conversation’ option. This is just delete by another name.
    Dismiss Notice

vhf sig gen?

Discussion in 'd.i.y.' started by Jim Audiomisc, Jan 26, 2019.

  1. Jim Audiomisc

    Jim Audiomisc pfm Member

    Nope! :) It took me well over a decade to stop using FORTRAN. Too old to stop using 'C'. :)

    I'm still puzzled by the wild variety of problems you get with different setups. Having a system that tells you a file 'isn't there' when you can see it is weird.
  2. davidsrsb

    davidsrsb pfm Member

    If you have a dc coupled vco, you can measure voltage and frequency and curve fit
  3. Jim Audiomisc

    Jim Audiomisc pfm Member

    Yes, that'd work for 'static' distortions. But the sig gen modulation may also have modulation frequency (or slew rate) effects. However, yes, I should perhaps also have a mode for a slow triangle wave or dc offset. That said, an LF sinewave could also be used for this via examining the distortion. So its a question of what method would be most practical.
  4. Jim Audiomisc

    Jim Audiomisc pfm Member

    MJS. What leaf and full names does the program show before it fails? I'm suspecting these aren't 'correct' for some reason so the program can't then write anything out. The program doesn't check that the fopen worked.
  5. Jim Audiomisc

    Jim Audiomisc pfm Member

    BTW for 'mono' modulation sweeps, it should be possible to use my WAVGenerator program as it will let the user select from a sine/square/triangle/impulse/user waveform, etc. (The 'user' waveform is one the user can define for themself via a set of values.) Available from

  6. MJS

    MJS Trade: Consultant at WH Audio

    I was stupidly setting the Settings path to a file name path rather than just the directory path. No wonder it couldn't write to it as it wasn't a directory.
    It appears to be working now. If I have time later I'll throw it at some hardware and then try decoding it.
  7. Jim Audiomisc

    Jim Audiomisc pfm Member

    OK, relief! :)

    At the moment I'm checking an updated version which lets the user tweak the relative phase and size of the subcarrier. That should let people correct 1st order for any HF 'droop or delay' caused by their DAC or modulator arrangement.
  8. Jim Audiomisc

    Jim Audiomisc pfm Member

    I' ve updated the version now available from the same address as before as a tar. Two main changes.

    1) The program now has a 'C = Check' function and the ability to tweak the phase and amplitude of the nominal subcarrier. That allows for simple correction of DAC/modulator flaws in response.

    2) I've worked on the 'Help' file to try and make things a bit clearer. :)

    (1) Now lets the user create a file with the pilot on one channel and the subcarrier on the other. That can then be used to test the behaviour of DAC+modulator. The 'settings' file now lets the user correct for such flaws.

    As usual, I may have also added a bug. So try out whilst keeping the first version just in case. I'll stop work on this now until I get some feedback that makes me think further alterations may be useful. Hope the program is useful.

    All I have to do now if find *myself* a useful modulatable VHF sig gen! I still have my old CT7000 tuner, so am curious to see if that comes out nicely when I can test it.
  9. Paul R

    Paul R pfm Member

    I can do a Windows build of this, should anybody be interested.
  10. Jim Audiomisc

    Jim Audiomisc pfm Member

    FWIW I'd welcome that. I don't use Windows, so can't easily port such programs. But if people want a Windows version, fine with me!

    BTW I don't know the situation wrt Apple machines. But my reaction there is similar.

    And the same applies to my other Linux / RO programs. All have source code, and people are welcome to port/tweak/improve them as they wish.
  11. Jim Audiomisc

    Jim Audiomisc pfm Member

    BTW Anyone using a Linux box to make audio-range recordings with precision might find my ROXAudioRecorder program useful. I wrote this for two reasons.

    1) To ensure that the recording is made 'direct via ALSA'. i.e. no resamplings or rescalings or 'mixing' by the OS or other apps. Just shovel in the data as supplied by the ADC and write it into an LPCM wave file.

    2) To also have it show the PPM value over a reasonably wide range. Many level meters only cover about 20dB. This one covers more like 80dB. :)

    As usual, source code provided, etc.

    P.S. Occured to me to add this because at the moment I'm using it with a Benchmark ADC to make a 96k/24 recording. 8-]
  12. Paul R

    Paul R pfm Member

    I've put a 32 bit Windows build at http://www.epicyclism.com/upload/StereoMPX0.01.zip

    There are some pointer/long confusions in the code that mean a 64bit build will require some thought.

    I had to make a couple of conditional compilation mods to handle Windows using '\' as a directory separator, and to force the compiler to accept the insecure fprintf/sprint forms. Additionally there is a long standing JimBug where files are opened in 'wd' mode rather than 'wb' or 'w', and the Windows runtime library objects to the invalid mode. I think 'wb' would be compatible between Windows/Linux.

    And there's, I think, a real minor bug in the file name generator where 'filetag' is appended to the filename without ever being initialised, so I removed this and blobbed '.wav' on the end. Program produces sensible outputs in either form, but the extension makes it easier with Audacity or other programs.

    If you unzip the file somewhere, you will get a new sub directory 'StereoMPX' containing the binary, the help file (not all of which is relevant but beware the caveats about high level ultrasonics), a suitable 'Settings' file and a ready made subdirectory for output. You can simply double click on the binary from Explorer and get a console window to enter your parameters into, or start directly from a command line.
  13. Jim Audiomisc

    Jim Audiomisc pfm Member

    Guilty, m'lud! My main bad habit is that this program - like many - are ones I write by hacking away at an older program I'd written so deforming into doing the new task. Hence this example 'inherited' the JimBug 'features' of an ealier one.

    The bigger cause is that I never ever took any courses in computer programming and have simply picked up ways of getting programs to run and give me the results I wanted. Thus the code will be shambolic when viewed by someone who actually is a skilled programmer. And my early 'learning' about 'C' was using the ancient 'Norcroft' compiler for RISC OS - which I still use, and differs in various ways in what it allows from GCC's behaviour.

    I'll check the code, I'm particularly wanting to fix the filetage omission. I must have deleted a key line, but the results I get still seem to have a .wav suffix, so I must have muddled something.

    PaulR: I guess there is a GCC 24bit signed int type which matches the format of 24bit samples in a wave file in terms of 'endian-ness'. Can you tell me what it is, please? I can then adopt that and it should simplify the conversions. As it is I tend to hack about at the 8bit level which I can get to work, but seems clumsy, result of my ignorance!
  14. Jim Audiomisc

    Jim Audiomisc pfm Member

    Update: I've now fixed the 'missing tag', and a couple of other JimBugs. Apologies that the earlier version (1.01) lost the ability to add '.wav' to the file. I think I must have accidentally deleted the line that defined the tag! Now replaced. The new version is available from

  15. Paul R

    Paul R pfm Member

    I'm not aware of any modern system with a 24 bit word, (I'm assuming ICL1900 series mainframes aren't a target...) and so generating a packed 24bit wav always involves byte and bit bashing. The endian-ness isn't a problem, at least on x86/x64 and modern Arm, but the creation and packing of 24 bit signed values is.

    I wondered if taking the double ranging from -1.0 to 1.0, which is the natural internal format for all this stuff, multiplying it by 2^31 rather than 2^23 then taking the upper three bytes rather than the lower three would be a simplification. It removes the need to fake the sign bit...

    Tricksier would be to zero the low 8 bits and 'or' the whole thing into an output buffer at a byte address you then increment by 3. This requires unaligned access, and effectively writing a byte before the buffer we want as output, but inside a cache line perhaps we don't care.

    And compilers have got very clever indeed, so what look like simplifications or optimisations have mostly already been done. For example l1 through r3 in 'load_values' don't appear in the generated code. I'd remove them regardless because they don't make it more obvious, but that's a matter of taste.
  16. Jim Audiomisc

    Jim Audiomisc pfm Member

    Long time since I had to worry about ICL1900s :)

    The 'upper bytes' idea is interesting as it would save some fiddling about in the code. So I'll try and keep that in mind. Problem being that I'll probably forget next time I need to write a 'new' program and duly hack, starting with an old program with the familiar JimBugs. ( :-/ or :) as preferred!)
  17. Paul R

    Paul R pfm Member

    It really doesn't matter as long as the output is correct and you can more or less remember how it works. Sorry about the 'JimBug', I just remembered that one from the last time some years ago....

    Something that might be useful is to look at 'getcwd' to get the working directory, so where the program has started, rather than using argv[0] which gives you the location of the binary itself. This would let you have multiple settings files in different directories but use the same binary, for example.

    There's an engineering advantage in using source control, putting your boilerplate into a library of some form, minimising the use of globals, exploiting some of the enhancements 'modern C' (not my field...) or using C++ as a better C give you. But if it doesn't appeal for its own sake, who really cares? It's easy to end up polishing away on a program that gets run seldom and whether it takes 0.1s or 0.01s to execute really doesn't matter.
  18. Jim Audiomisc

    Jim Audiomisc pfm Member

    TBH I quite like 'JimBug' as it does sum up the way I tend to allow the same, erm, awkard features to propagate in the programs I write. :) My other problem, of course, is the common one: When writing up the user blurb I tend to forget to explain clearly some things because I take them for granted. Hence the directory/file confusion for people having to set things up. Removing the tag was a plain 'Oops!' on my part as I went about deleting sections from the orginal program I started from that weren't needed for the MPX one. That said, in future, maybe adding back in something like a triangle wave or dc level steps might be useful? MJS may be able to comment on that if/when he can give the MPX files a tryout.

    FWIW I'll be having a look at CPC later today to get a few things. One will be to see if they sell a cheap modulable VHF sig get I might be able to use.
  19. MJS

    MJS Trade: Consultant at WH Audio

    I've had a quick play with gnuradio and the limedsr. Let's just say I've produced something but it's not hi-fi by any stretch. GRC only reads 16bit wavs so I've had to change the bit depth, but a look at the spectrum suggests all the information is there where it should be. This is one of those occasions I'd love a proper bit of analogue kit to compare to.

    It didn't help that I've spent the last few days rebuilding my virtual machine library on my mac and updating Linux kernels and Windows 10.
  20. Jim Audiomisc

    Jim Audiomisc pfm Member

    Can you expand on the "not hi-fi" comment? Do you mean the stereo separation is poor, or that the signal is distorted? Or?... Note that the latest version of the program lets you tweak the subcarrier phase and amplitude. So if you're getting a problem because the sig gen modulation alters this, it should be possible to correct it to some extent.

    I did wonder about including the option for 16bit output, but decided that using something like sox is easy enough for it not to be needed given that I use that to pack the results into flac files anyway.

    FWIW I did look at CPC yesterday for VHF generators. But the closest I could find was one that has a stated modulation limit of 50kHz which seemed a bit tight as I don't know the full spec. So I may try blagging a loan one from my old research group. Done that before. :)

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice