+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Junior Member level 2
    Points: 693, Level: 5

    Join Date
    Aug 2009
    Posts
    21
    Helped
    0 / 0
    Points
    693
    Level
    5

    ultrasonic pwm

    Hey, hope everyones good.

    I am currently playing around with some ultrasound transmitters and receivers. Just some basic stuff for now before I attempt a project of mine.

    I have no used micro controllers before, so Im still pretty fresh in the area. However, I am willing to learn, and I am currently going through a couple of online tutorials.

    For now, I would like to somehow configure the MC (Im using PIC 16f690) to send a PWM signal of 40 KHz to the ultrasonic transmitter. Ive come across this website which does the code for you if you type in the requirements, but I rather start from scratch and understand everything.

    This is what the website says:

    /*
    * PWM registers configuration
    * Fosc = 4000000 Hz
    * Fpwm = 40000.00 Hz (Requested : 40000 Hz)
    * Duty Cycle = 50 %
    * Resolution is 6 bits
    * Prescaler is 1
    * Ensure that your PWM pin is configured as digital output
    * see more details on http://www.micro-examples.com/
    * this source code is provided 'as is',
    * use it at your own risks
    */
    PR2 = 0b00011000 ;
    T2CON = 0b00000100 ;
    CCPR1L = 0b00001100 ;
    CCP1CON = 0b00011100 ;

    And then I suppose you can use the following commands:

    * Pwm_Init()
    * Pwm_Change_Duty()
    * Pwm_Start()
    * Pwm_Stop()

    So is this how you go about it? Set your frequency, duty cycle and your off? Can somebody please explain why the website comes up with the above values for PR2,T2CON and so on. And what are they?

    Im sorry if this has been posted before, but ive been serching forums for hours on end without luck.

    Any help would be appreciated. Just want to send a PWM signal o a ultrasonic transmitter.

    Thanks!!!

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 1
    Points: 7,213, Level: 20
    pakitos's Avatar
    Join Date
    Nov 2005
    Posts
    457
    Helped
    113 / 113
    Points
    7,213
    Level
    20

    pic ultrasound pwm

    why are you using the pic to send the 40 khz?
    you can just use a 555 timer to do the job



    •   AltAdvertisement

        
       

  3. #3
    Junior Member level 2
    Points: 693, Level: 5

    Join Date
    Aug 2009
    Posts
    21
    Helped
    0 / 0
    Points
    693
    Level
    5

    Re: anyone played with ultrasound before?

    Yes im aware of that. However, creating a 40khz wave using a pic is only a small part of what im trying to do.

    Im trying to send RF and ultrasonic pulses together at the same time, and then measure the difference it takes for the two signals to arrive on the other side.

    So a 555 wont be able to do this accurately.

    From what ive read, I need to use the pwm function of a microcontroller. theres hardly any tutes on this topic, and im finding it extremely difficult to write code for this. Any ideas?



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 1
    Points: 7,213, Level: 20
    pakitos's Avatar
    Join Date
    Nov 2005
    Posts
    457
    Helped
    113 / 113
    Points
    7,213
    Level
    20

    anyone played with ultrasound before?

    are you making your search using that pic no?



  5. #5
    Junior Member level 2
    Points: 693, Level: 5

    Join Date
    Aug 2009
    Posts
    21
    Helped
    0 / 0
    Points
    693
    Level
    5

    Re: anyone played with ultrasound before?

    sorry, what do you mean by pic no?

    if you mean how im seperating incoming signals, its through the use of RF. Each rf transmitter will have its unique ID, and my receiver will be talking to one at a time.

    is that what you mean?

    thanks bud



    •   AltAdvertisement

        
       

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

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

    anyone played with ultrasound before?

    I just can't see an end to such questions!

    Go over to the CCS forum, download the PWMWizard (or even here) and copy paste into CCS IDE and you will be set.



--[[ ]]--