---
+ Post New Thread
Results 1 to 13 of 13
  1. #1
    Member level 4
    Points: 1,926, Level: 10
    Achievements:
    7 years registered
    kit_714's Avatar
    Join Date
    Jul 2006
    Posts
    70
    Helped
    0 / 0
    Points
    1,926
    Level
    10

    generate squarewave

    Dear All,

    I would like to ask which brand of MCU can generate 2MHz square wave by simply setting the port pin high and low alternatively?

    If you all have other recommendations like using particular ICs, please send me the reference materials. Note that the square wave can not generated by using signal generator...

    Many thanks....

    Thanks and best regards,

    Kit

  2. #2
    Full Member level 5
    Points: 3,323, Level: 13

    Join Date
    Jun 2006
    Location
    Middle Earth
    Posts
    297
    Helped
    42 / 42
    Points
    3,323
    Level
    13

    how to generate a square wave in 8051?

    Most AVRs with PWM can do that and I am sure PICs can also do that. If you have somthing without an internal PWM module then you simply toggle the pin. If you have nothing but a 89C51 microcontroller, just pick a version that runs at 24MHz and toggle the pin.

    Like always don't overload your microcontroller pins. Also, if all you need is a stable 2Mhz oscillator, you can configure a CMOS version of 555 for stable outputs. Or can simply use a TTL oscillator for 2Mhz. All you have to do is just provide the supply and your 2MHz will start comming out in perfect precision. You can easily get TTL oscillators with 4 digit precisions like 2.0000 MHz.

    http://www.national.com/pf/LM/LMC555.html
    http://www.uoguelph.ca/~antoon/gadgets/555/555.html
    The TTL oscillator will be something like this, http://www.parallax.com/detail.asp?product_id=252-00005

    If you want variable clock frequencies you can consider VCO's which stands for voltage controller oscillator.

    Correction: A standard 8051 microcontroller must operate in excess of 48MHz to generator a 2MHz square wave. IIRC, there is somemode that can make some 8051 controllers to execute in 6-phases instead of 12 in which case you can use a 24MHz controller.



    •   Alt21st June 2007, 03:54

      advertising

        
       

  3. #3
    Advanced Member level 2
    Points: 5,452, Level: 17

    Join Date
    Jun 2006
    Location
    VddVss
    Posts
    503
    Helped
    45 / 45
    Points
    5,452
    Level
    17

    generate square wave cmos

    For 2MHz.. a dsPIC or even better a 16 bit Renesas or ARM is suited...

    But I would like to stand corrected.



  4. #4
    Full Member level 5
    Points: 3,323, Level: 13

    Join Date
    Jun 2006
    Location
    Middle Earth
    Posts
    297
    Helped
    42 / 42
    Points
    3,323
    Level
    13

    8051 microcontroller, square waves

    Quote Originally Posted by vsmGuy
    For 2MHz.. a dsPIC or even better a 16 bit Renesas or ARM is suited...

    But I would like to stand corrected.
    Talk about overkill. Even the tinyAVR series from ATMEL boast super high clock frequencies in 10s of MHz range and cost less than a dollar.



  5. #5
    Member level 5
    Points: 2,530, Level: 11

    Join Date
    Mar 2002
    Posts
    80
    Helped
    3 / 3
    Points
    2,530
    Level
    11

    microcontroller generate square wave

    It depends!
    If accuracy is desired, an MCU with PWM (50%-50% duty) may be a better choice.
    If accuracy is not so important, a fast MCU (e.g. 40MHz or higher) may be used by
    toggling the IO port.



  6. #6
    Full Member level 5
    Points: 3,323, Level: 13

    Join Date
    Jun 2006
    Location
    Middle Earth
    Posts
    297
    Helped
    42 / 42
    Points
    3,323
    Level
    13

    tinyavr signal generator

    Quote Originally Posted by waterman
    It depends!
    If accuracy is desired, an MCU with PWM (50%-50% duty) may be a better choice.
    If accuracy is not so important, a fast MCU (e.g. 40MHz or higher) may be used by
    toggling the IO port.
    I beg to differ, the reason I am advocating so strongly is that I've done this and done it many times before. I used everything from simple RC oscillators to VCXOs, function generator ICs, PWMs etc etc. The speed of the microcontroller to choose depends on the microcontroller not some fixed value multiplied by the required frequency. For example:

    AVR and PIC, which are RISC, can execute most instructions in a signle cycle. So theoratically speaking a 4MHz AVR/PIC can do that job.



    •   Alt21st June 2007, 05:43

      advertising

        
       

  7. #7
    Advanced Member level 5
    Points: 14,575, Level: 29
    blueroomelectronics's Avatar
    Join Date
    Sep 2006
    Location
    Toronto, Canada
    Posts
    1,682
    Helped
    179 / 179
    Points
    14,575
    Level
    29

    generate a square wave of 50% duty 8051

    Using PIC Calc (link on my site)
    2MHz 50% duty can be generated in hardware at 16MHz on any PIC with a CCP module.



  8. #8
    Full Member level 4
    Points: 2,402, Level: 11

    Join Date
    Feb 2006
    Posts
    199
    Helped
    19 / 19
    Points
    2,402
    Level
    11

    generate square wave

    sorry, but if you need help setting a pin high and low at 2MHz, you're in the wrong business.



  9. #9
    Full Member level 5
    Points: 3,323, Level: 13

    Join Date
    Jun 2006
    Location
    Middle Earth
    Posts
    297
    Helped
    42 / 42
    Points
    3,323
    Level
    13

    atmel generate square waves

    Quote Originally Posted by jhbbunch
    sorry, but if you need help setting a pin high and low at 2MHz, you're in the wrong business.
    Everyone's a beginner at sometime or the other. After all the purpose of these forums is to help each other out and act as a place for discussions.



  10. #10
    Member level 5
    Points: 2,530, Level: 11

    Join Date
    Mar 2002
    Posts
    80
    Helped
    3 / 3
    Points
    2,530
    Level
    11

    12f629 square wavw generator

    If the only job of the MCU is to generate the square wave, a low-speed MCU could be used.

    If the MCU has to do something else besides generatig the square wave, a low-speed MCU may not be suitable to do this job.

    Consider this: 2MHz --> period = 500ns --> low/high interval = 250ns.

    For a 12T 8051, SET/CLR the IO port needs 1 instruction cycle. That is, 250ns to execute an instruction. Then the system clock should be 48MHz and the 8051 does not have spare time to do anything else.

    For a RISC like PIC16/PIC18, 4T for one instruction, the system clock my be lower. However, 16MHz is still needed.

    If AVR is used, one clock for one instruction. However, 4MHz is still needed for operation.

    Any comment is welcome.



  11. #11
    Advanced Member level 5
    Points: 40,208, Level: 49

    Join Date
    Apr 2002
    Location
    USA
    Posts
    3,944
    Helped
    651 / 651
    Points
    40,208
    Level
    49

    Help : Generate square wave...

    To bit-bang an I/O pin at 2 MHz continuously, you also need a jump instruction somewhere.
    Or do some microcontrollers provide zero-overhead looping?

    Code:
    loop: set output bit high
          nop
          set output bit low
          jump loop
    That would require an 8 MHz clock for 2 MHz output, assuming one instruction per clock.

    It would be nicer to simply configure a counter/timer or PWM, if available.



  12. #12
    Advanced Member level 5
    Points: 14,575, Level: 29
    blueroomelectronics's Avatar
    Join Date
    Sep 2006
    Location
    Toronto, Canada
    Posts
    1,682
    Helped
    179 / 179
    Points
    14,575
    Level
    29

    Help : Generate square wave...

    The PIC12F628 (8pin) can do it with zero cpu overhead in using the hardware PWM module.



  13. #13
    Advanced Member level 2
    Points: 5,452, Level: 17

    Join Date
    Jun 2006
    Location
    VddVss
    Posts
    503
    Helped
    45 / 45
    Points
    5,452
    Level
    17

    Help : Generate square wave...

    The 16F628 yes, 12F629 yes, but 12F628?



+ Post New Thread
Please login