Shop OBEX P1 Docs P2 Docs Learn Events
Sx/b to spin or asm — Parallax Forums

Sx/b to spin or asm

datacpsdatacps Posts: 139
edited 2007-11-19 02:16 in Propeller 1
Hello fellow prop squad…..
I completed a project·using a sx/28 chip.
The program and the chip works perfectly. I can send a freqout up to 20Khz with 1 hz accuracy. ·I soon discovered that I needed to cover the entire freq range of a DDS chip with a range of 0 to 30 Mhz. I heard the Propeller can do it with no problem at all.
1. Is there anyway to convert my sx/b to spin or use the compiled ASM code to work with the prop? ·
2. Can the Prop send an accurate frequency from 0 to 30 mhz
3. I need to use a keypad to program the higher frequencies this should not be a problem
4. I use 2 encoders for some sweeps and precise adjustments.
5. I also show the freq readout ·in an 2X16 LCD display
If I stay with the SX chip I would have to ·add a DDS AD9850 chip 14.00 ·and a coprocessor chip for 19.95 plus my SX chip 2.75 . That equals over 36 dollars in chips alone..
I would rather use 1 prop chip for 12.95 and stay with Parallax products.
Any advice would be appreciated …..
·rolleyes.gif

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-11-17 08:41
    Nearly all what you describe has been done many times with a Prop...

    (1) The propeller can output square waves of 100 Mhz and above. An issue would be your requirement of 1 Hz precision, which however is not reasonable.
    Due to temperature variations you can hardly get anything above 0.01% = 3kHz/30 MHz without seriously tempering with your clock standard, which means paying considerably more than $36... You need calibration anyhow, which however can be accomplished by a cheap trim cap...


    Using the 32 bit timers wiil allow a raw NCO frequency of 8 MHz which can be translated to something between
    128 MHz and 1 MHz, below that things will become straight forward.

    Around 8 MHz you have a precision of 4MHz pr 12.5 ns = 1/20 i.e. a choice from 4 MHz, 4.2 Mhz, ....., 8 MHz
    This can most likely be improved much by using the PLL out of spec (which works fine according to my tests)


    Note however that this a fundamental issue with generating square waves digitally: Their length has to be a multiple of the clock time. Striving to 0.1% = 1/1000 will not allow more than 12.5 µs = 80kHz

    (2) You will not have the slightest chance to re-use any of your SX code

    Post Edited (deSilva) : 11/17/2007 8:58:16 AM GMT
  • BeanBean Posts: 8,129
    edited 2007-11-17 15:39
    I'm sorry I didn't get back to you. I though I was waiting for some info from you ?

    Anyway I would suggest that you DO go with the propeller route. It will make things easier in the long run (rather than adding a DDS to the SX/B project) and much more flexible.

    As deSilva pointed out, you will not have 1Hz resolution at the higher end (near 30MHz). But I don't think the DDS would either (I've never seen one that would).

    Send me an e-mail if you want any assistance. Again sorry if I didn't get back you on the SX project...
    Do you have a Prop Demo Board ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-11-17 19:03
    The Propeller has not one, but sixteen phase accumulators that are meant for this purpose. Just as in a DDS chip, e.g. the ADS9834, the phase accumulator is a numerical oscillator in which a certain phase value is added to the accumulator on every clock cycle. Once set, the Prop phase accumulators can free run. You can either output the most significant bit to a Propeller pin as a square wave, or with a short pasm loop, you can transfer the instantaneous phase value to an DAC more or less directly or via the SINE lookup table in the ROM. However, the added processing for SINE lookup precludes SINE output at 30mhz--But DDS chips don't make a pretty sine wave at high end frequencies either. A prop asm loop can also easily modulate the frequency parameter or directly access the phase accumulator. It is also possible to implement the phase accumulator in a register, and the 32 bit word of the Propeller makes that quite easy to do with high resolution. The word size and also the phase accumulators are 32 bits. By comparison, the phase accumulator on the ADS9834 is 28 bits.

    As to frequency resolution, the big accumulator allows the resolution, averaged over one cycle of the numerical oscillator, to be quite fine. However, put a stress on the phrase averaged over one cycle. One numerical cycle in general takes around one minute. The output at high frequencies may contain considerable amounts of jitter, and the finest frequency steps are the result of infrequent phase corrections, where infrequent may be down to the order of seconds. Whether that matters depends of course on the application. If a DDS chip like the ADS9834 would work, then the Propeller would too, because they have the same operating principle, at least so long as you are after square wave output.

    I'm not quite sure what DeSilva has in mind. There is a PLL associated with each of the 16 COG counters. The PLL could smooth out the short term jitter to some extent. The input to the PLL has to be between 4 and 8 mhz, but that can be stretched.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 11/17/2007 8:58:29 PM GMT
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-11-17 19:18
    The attached Excel worksheet has the formulae for calculating the phase increment that comes closest to a desired frequency, and then looks at the next 30 increments of frequency and calculates the the average frequency error.

    At 80mhz clkfreq and a desired frequency of 30mhz, the necessary FRQx value is 16106127360. That is added to the phase accumulator on every clock cycle. Then the example shows the FRQx values that are necessary for 30.000001 mhz, 30.000002 mhz and so on. You see, there is quite a separation in the FRQx values, and the error in the frequency is in the ballpark of millihertz. But remember the emphasis, that this is an average over a complete numerical cycle of about 1 minute. Some earlier threads have discussed these issues at length.

    attachment.php?attachmentid=50489

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • AleAle Posts: 2,363
    edited 2007-11-17 22:07
    I really doubt you get 1 Hz accuracy at 20 kHz without a phase accumulator system like a normal DDS, without having ns of accuracy to produce the signals via a high speed uP. Just make the calculations and you will see that for a 75 MHz signal you hardly get 20 Hz accuracy.
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-17 22:46
    What had deSilva in mind? Well certainly not the averaged number of rising slopes over some minutes smile.gif
    Talking of frequencies is sometimes different from talking about the period of a repeated square with duty cycle 0.5....

    When you are striving for the latter it is important to have as much "head room" to 2**31 as possible. A value of 2**21 in FRQA will generate a decent 12 µs high - 12 µs low pulse. The momentary sensitivity will be 25 ns, i.e. 1/1000, allowing you - immediately noticeable! - to change the pulse so that the "frequency" will change from 40,000 Hz to 40,040 Hz.
    When applying the PLL you can "boost" that into the 640 kHz area - alas absolutely out of spec, but it will work.

    Going to 30 MHz without PLL will not give you not the expected sensible signal but a mixture of 12.5 and 25 ns pulses - adding up well in the long run, no doubt....

    Using the PLL will improve this, allowing you to work with %16 values in the register, outputting - unaveraged! - around 20 different pulse lengthes now.
  • mparkmpark Posts: 1,305
    edited 2007-11-17 22:47
    Just a general request directed at no one in particular: Please use MHz (capital M) when you mean megahertz. Little m means milli.

    It would be nice if you capitalized the H in Hz as well.
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-17 22:50
    mpark said...
    It would be nice if you capitalized the H in Hz as well.
    http://forums.parallax.com/showthread.php?p=688736
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-11-17 23:09
    It must be MHz (Hz from Heinrich Rudolf·Hertz) and M from prefix mega
    SI prefixes:
    http://en.wikipedia.org/wiki/SI_prefix

    regards peter
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-11-18 00:27
    Sorry, good point, MHz, not mhz.

    Am I wrong that DDS chips like the AD9834 and the more advanced AD9850 work in the same manner as the Propeller? It comes down to a phase accumulator in NCO mode. The data sheet for the AD9834 is clear about the mechanism, but the data sheet for the AD9850 has more detail about the spectral properties. The big advantage those chips have over the Prop is that they have a very fast parallel SINE conversion and 10 bit parallel DAC. The advantage of the Prop is its programmability.

    I think we agree that the waveform is quantized in units of 1/clkfreq=12.5 ns at 80 MHz clock. (Did I abbreviate nanoseconds by the book?) The jitter is substantial at high frequencies where the output is made of high and low periods of only 12.5 or 25 ns. The jitter is substantially less and the spectral purity substantially better at low frequencies where the output is composed of periods of, N*12.5 and (N+!)*12.5 ns, N>>1.

    My points with the Excel table is (1) The formula (FRQx = frequency/clkfreq * 2^32) allows frequencies to be specified to the level of sub Hertz. (2) The frequency so calculated is a long term (~1 minute at most) average (3) On the short term there may be jitter and the main frequency component that will be slightly different from the target. All those observations also apply to a DDS chip like the AD9834 or AD9850. Some frequencies will be more "pure" than others, and that depends on the ratio of the desired frequency to the clkfreq.

    The PLLs on the propeller counters are quite fast, so I don't think they will allay much of the longer term jitter. The PLL output is still quantized in units of 1/clkfreq.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • mparkmpark Posts: 1,305
    edited 2007-11-18 01:39
    deSilva said...
    mpark said...
    It would be nice if you capitalized the H in Hz as well.
    http://forums.parallax.com/showthread.php?p=688736

    deSilva, what's your point here?
  • datacpsdatacps Posts: 139
    edited 2007-11-18 07:12
    Thanks Tracy for the info. Bean I sent you an email. I need to start to look at Spin now and see where I need to start. The AD9850 does not have 1 hz resolution at 30MHz too. Any links or threads that might get me started in the right direction????? Thanks again gentlemen
    ,,

    http://www.analog.com/Analog_Root/static/techSupport/designTools/interactiveTools/dds/ad9850.html
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-18 17:16
    mpark said...
    deSilva, what's your point here?
    Just to support your request and giving the explanation for it...

    @Tracy: Yes, "ns" is correct, still no one stood up claiming to be "Mr. Second" smile.gif "mS" is milli Siemens (=kOhm) as dicussed elsewhere...
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-11-19 02:16
    @datacps, download the counters app note, AN001, from the Parallax web site.

    Thanks also for the link to the Analog Devices applet for the AD9850. When I look at the results of the applet and the results presented, I still feel that they are missing something fundamental in their explanations. As you know, the AD9850 does not really have 1 hz resolution at 30 MHz, but the applet lets you calculate it anyway. It shows you how close it iis able to approximate that (well within 1 Hz) and shows you the SINC spectrum. But it does not address the subharmonic components that we have been talking about here.

    Numerical oscillators have much in common with periodically forced oscillators, where the limit cycle wobbles around on a very long path on the phase plane before it repeats. A numerical oscillator does not wobble, but it too can have a essentially the same long path on the phase plane. When I was in grad school, working on problems in mathematical biology and caught up in the excitement about deterministic chaos, I came across work in subharmonic entrainment by the influential Dutch Electrical Engineer, Balthazar van der Pol. (Does anyone these days name their offspring Balthazar?) I did some theory and experimental work in that area and published in the IEEE Circuits and Systems, and Physica, and American Math Monthly. It is just interesting to me to see this same sort of thing in a different context.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.