Shop OBEX P1 Docs P2 Docs Learn Events
Squarewave Output / Signal Modulation — Parallax Forums

Squarewave Output / Signal Modulation

Areal PersonAreal Person Posts: 197
edited 2008-04-03 02:30 in Propeller 1
Hello,
·
I’m new to electronics (Ha, Ha…Still). I need some simple/basic, help/advise.
I’ve built a nice sine wave oscillator circuit and I want to modulate it in with intelligence.
·
I would like to use my propeller to generate a square wave which represents
binary information (0 & 1’s). I will then select some modulation method (ASK, FSK etc.)
and apply the signal to my carrier wave.
·
QUESTION:
·
1)
Do I need to convert the propeller output square wave to the same wave type as my carrier before I modulate it onto the carrier (using a DAC)? Or will it automatically convert when I merge the two signals ?
·
2)
In order to generate an intelligent square wave on my Propeller do I just toggle a pin correctly based on my binary output requirements & timing? Or is there something more I need to do to get the correct square wave ?
·
Thanks,
-Areal
·
·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but

what do you expect ? I'm a programmer.

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-02 08:06
    1. Your signal does not need to be the same wave type. However, you may want to perform some signal conditioning to get rid of high frequency components that may be present (by using a lowpass filter). You will need a modulator though...

    2. If you just want a square wave than you can either toggle the pin or you can use one of the timers. If you want to output data you could either write your own routine, use one of the existing drivers like fullDuplexSerial or you could use one of the video units so you have lots of options.
  • Areal PersonAreal Person Posts: 197
    edited 2008-04-02 15:53
    stevenmess2004 said...
    You will need a modulator though...
    ··I have two oscillators, one is running at 8MHz (my carrier wave) the other is running at 5MHz (This one
    ·· is my information wave)

    ·· I'm using the Propeller to drive·a transistors base which switches the 5MHz collector signal through a low-pass filter into the
    · 8MHz·carrier·wave that is free-balling of the emitter.

    ·· QUESTION:

    ·· It's my understanding that this will create FSK modulation. Is this correct ?

    ··

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-04-02 16:23
    FSK is switching between two frequencies, so if you were sending morse code you would send one frequency for the gaps and the other for the dots and dashes. So you could have one carrier that you can shift the frequency of or two that you switch between.

    I can't see how what you are suggesting is going to do that, to be honest I don't understand most of what you have said.

    Graham
  • Areal PersonAreal Person Posts: 197
    edited 2008-04-02 17:12
    Ok, so your saying that the two frequencies are never merged into one signal ?
    I thought thats what "shifted" ment

    The two frequencies are completly seperate ? but syncronized by some kind of clock at modulation / demodulation ?

    If so that may be where my problem is, currently there's always an 8MHz signal at my transistors emitter pin,
    the 5MHz signal flows through the transistor (from the collector to emitter) when a small current is applied to it's base.

    This has the effect of blending (I thought it was shifting) the signal, I was gonna try bandpass filters to demod it.

    Thanks,
    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-04-02 17:23
    I said:

    "So you could have one carrier that you can shift the frequency of"

    I think you need to read up on modulation schemes for FM, FSK is essentially FM with only two levels for modulation signal.

    One thing is for sure is that you can't just bung two signals into a transistor randomly and expect it to somehow work.

    Graham
  • Areal PersonAreal Person Posts: 197
    edited 2008-04-02 18:21
    FSK_1.gif

    @Graham

    Well, the design is based of this schematic, it works, and only uses one transistor with TTL input
    for the FSK input signal.

    These two signals do seem to be merged together through the inverter that's driving the crystal.

    It looks to me that your answer may be·incorrect.

    Unless you can correctly explain what the inverter is doing here ?

    Thanks,
    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.

    Post Edited (Areal Person) : 4/2/2008 6:32:44 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-04-02 20:00
    Why not use something like the Frequency Synthesizer object and Pre-calculate values for 5MHz and 8MHz.... then just update FRQA or FRQB as necessary to generate the required "Mark" / "Space" signal?

    Am I missing something?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Areal PersonAreal Person Posts: 197
    edited 2008-04-02 20:08
    WOW ! I can do that ?

    And here I am trying to work with discreet components.

    OMG I love my propeller !

    QUESTION:

    Could I then then add a class-C amplifier, configure a second propeller as a Superhet Recever
    and have an RF solution ?

    Thanks Beau,
    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-04-02 20:19
    "Could I then add a class-C amplifier, configure a second propeller as a Superhet Receiver
    and have an RF solution ?"


    That could be tricky, but not impossible.... Why not just measure the incoming pulse width?

    125nS - 8MHz - 5 Clocks @80MHz <- Returned clock numbers are halved, since you would likely be looking at the top half or bottom half of the signal
    200nS - 5MHz - 8 Clocks @80MHz <- Returned clock numbers are halved, since you would likely be looking at the top half or bottom half of the signal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Areal PersonAreal Person Posts: 197
    edited 2008-04-02 20:45
    Thank you for your help.

    I think it will work, however, I'm not sure about the PLL, VCO, charge pumps
    and all that stuff yet.

    It's going to be short range, 30-40 ft.

    It's also a learning project for me. There are still unknowns because of my skill level

    But ! I'm learning and making progress !

    Thanks again,

    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-04-02 23:56
    Areal,
    "WOW ! I can do that ?" - You can even get fancier and use MFSK (Multi Frequency Shift Keying)... Each frequency represents a symbol similar to QPSK(Quad Phase Shift Keying) , OPSK (Octal...), 16PSK, etc.
    My favorite at the moment that I have been fiddling with in my brain uses a combination of PSK and·Quadrature (I/Q) to nearly quadruple the Throughput on a low-bandwidth signal line.
    ·



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-03 00:14
    Beau, I think that you are saying that the propeller can be used as an FM receiver just by using the counters (plus maybe an antenna and filter and amp). Is this correct?
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-04-03 00:40
    stevenmess2004,
    ·
    FM frequencies might be too high.... Receiving FM is a little tough (4 Cogs though maybe) ... No, what I was saying, since FSK frequencies are generally pretty low, you could configure a counter or counters, to detect how long the incoming pulse duration ·is ; be it HIGH or LOW.·· At 8MHz the period is 125nS, which means that the time spent LOW is 62.5nS and the time spent HIGH is also 62.5nS.· For a Propeller running at 80MHz it would return a "count" of 5 or an incoming 8MHz signal, and a count of 8 for a 5MHz signal.
    ·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-03 01:17
    What about if we added a mixer with the LO produced by the propeller. Than if we shift the output up so that it doesn't go negative (or rectify it) we should be able to use the counters to read the frequency using the pos edge detector mode. If we set the Intermediate stage to around 10MHz and sample for 1/50kHz=20us. We would get 200 counts for 10MHz. The smallest increment we would be able to recoginize is 50kHz. Don't think that this is going to be very useful as its not really very accurate and requires a pretty large bandwidth. (unless we put in a frequency multiplier but that could be a fair bit of work).
  • DroneDrone Posts: 433
    edited 2008-04-03 01:20
    If you can get the FM signal into in-phase and quadrature (IQ, use 4X quadrature sampling perhaps) then I think you can demodulate FM with Arctan(I/Q), phase detection if you will. But doing this without floating point and a trig library sounds daunting.

    CORRECTION (Sorry):

    Get the phase with Arctan(I/O) then differentiate to demodulate FM, of course low-pass filter in the end. You might use finite-difference as an approximation to differentiation - take the phase difference at each sample interval.

    Regards, David

    Post Edited (Drone) : 4/3/2008 8:52:23 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-03 01:26
    Of course if you only wanted low data rates you could make the sample window wider if you had 1/2kHz=500us=0.5ms then you could measure a frequency change of 2kHz. So if you had one tone at 0kHz and the other at 6 or 8kHz than you might be able to get something to work but it will be a very low data rate (<2kbite/s).
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-03 01:28
    Drone, could you do it with a fixed point and the builtin trig tables? But what are you going to use to sample it? Even if you can sample at 10MHz for a 2.5MHz intermediate frequency you aren't going to have much processing time.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-04-03 01:31
    stevenmess2004,

    "What about if we added a mixer with the LO produced by the propeller."· ... I think that an "external" local oscillator is going to drown out and swamp the signal of interest...· Better results would be with a direct conversion style radio.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-03 01:47
    But don't direct conversion radios still need a mixer and a local oscillator? This is a bit out of my knowledge so I'm quite possible wrong but that is the impression I got from the wikipedia article.

    Or do you just mean sampling the signal at RF instead of down converting to an IF first?
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-04-03 01:54
    All,

    I don't mean to Hi-Jack this thread, but I thought that this might help with the current direction of this topic:


    E-mail Start

    I’ve looked around and done a bit more digging, and this is about the simplest implementation that I could find.

    It uses a 4066, which is a QUAD bilateral switch, and two NE5532’s which are nothing more than Dual Op Amps.· You could get away with using only one NE5532... I think in this design, two are used for different gain options.

    Imagine the attached image with 4 lines leaving the 4066 rather than the 2 lines in the block representation.· The output corresponding to Q-0 Deg and Q-180 Deg would go to one Op Amp ... the inverting vs. the non-inverting input respectively.· Same goes for the output corresponding to Q-90 Deg and Q-270 Deg going to the other Op Amp.

    Since this radio is designed to work with a soundcard on a computer, with a maximum sample rate of 44kHz,... after heterodyning the X4 input frequency going to the 4066, and combining it with the actual received "signal", the maximum audio frequency with this arrangement would be 11kHz or ¼ of the sample rate.· In this case dictated by the PC sound card.


    The 4066 itself can handle about 40MHz ON/OFF switching per bilateral switch.· Since you have two bilateral switches working together for each pole, and there are two poles, the maximum tunable input frequency would be about 80MHz The diagram indicates this at 70MHz being conservative.



    Simple Algorithm:
    Phase-0 …. If HIGH add to accumulator 1 ; else subtract
    Phase-90 …If HIGH add to accumulator 2 ; else subtract
    Phase-180 ..If LOW add to accumulator 1 ; else subtract
    Phase-270 ..If LOW add to accumulator 2 ; else subtract

    E-mail Finish

    Note: The signal strength is equal to Sqrt(accumulator 1^2 + accumulator 2^2)· ... yes, it's the Pythagorean theorem ·.... a^2 + b^2 = c^2

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 4/3/2008 2:02:45 AM GMT
    1240 x 592 - 86K
    SDR.JPG 86.4K
  • DroneDrone Posts: 433
    edited 2008-04-03 02:26
    I'm sure something's possible with fixed point tables. I'm no expert here - certainly not in Prop assembly and my gut feeling is you're going to need to do a lot of this in assembler.

    Beau's showing us a classic Tayloe Quadrature Sampling Detector (QSD) Software Defined Radio (SDR). There are quirks and traps with this kind of IQ demodulator. The example schematic he shows us for example is highly dependent on antenna impedance. The op-amps after the QSD are arranged such that the gain of the SDR will vary directly with antenna impedance. This can be fixed by using differential amplifiers. Whatever op-amps you use, they should be low-noise op-amps. On the order of several nV/rtHz or better.

    Beau, you do need both op-amps. In a typical SDR like shown, one passes in-phase (I) baseband, the other pases quadrature (Q) baseband to the stereo PC sound card line-in for DSP demodulation in the PC.

    Because there is no input pre-amplifier or isolation, the bandwidth of the QSD varies with antenna impedance too. You also need an input filter, the output of the 4X quadrature local oscillator that feeds the QSD is rich in harmonics and the QSD will respond to odd-order harmonics. The 4066 bi-lateral switch peters out at pretty low frequencies. Some say it is stressed at 10MHz. The 74CBT3253 is a better choice. I have seen bi-lateral switches before that can go to around 1GHz, but can't remember where at the moment.

    A nice introduction to SDR and DSP is presented in the QEX papers by Youngblood freely available for download at the following link:

    "Software Defined Radio for the Masses", 4-Part QEX Article by Youngblood

    www.arrl.org/tis/info/sdr.html

    There are other ways to get quadrature, take a look at this thread in the comp.dsp NNTP group:

    www.dsprelated.com/showmessage/38252/1.php

    If you can do AM modulation instead of FM, then AM demodulating a quadrature signal (IQ) is simply SQRT(I^2+Q^2). If the modulation index and frequency is very low, you "may" get away with generating I and Q in the propeller by delaying the sample stream by 90 degrees in a FIFO. I've never tried this before, but for low modulation index it "may" work (gotta think about that a bit more).

    Isn't there a PLL associated with the Prop crystal oscillator chain? Maybe something can be done with that? Just tossing out the idea; really haven't given it any thought.

    Rgds, David

    Post Edited (Drone) : 4/3/2008 5:46:51 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-03 02:30
    There are a total of 17 PLLs in the prop. 2 in each cog and 1 for the main system clock.
Sign In or Register to comment.