Announcement

Collapse
No announcement yet.

Looking for simple PIC or ARM to replace 555 VCO in PI detector

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking for simple PIC or ARM to replace 555 VCO in PI detector

    Hi All

    I am working on a simple PI project and need to replace the typical pi 555 VCO with a simple PIC or ARM VCO.

    I have searched for a long time and found and built this project , uses a 12f675, as you turn the pot the (square wave) frequency increases as the voltage increases.
    http://www.cuteminds.com/index.php/en/pulsegenerator

    It works ok and can be adapted for what I need for my PI project, but only goes down to 20 hertz which is a annoying frequency to listen to, the lowest frequency needs to be about 1 or 2 hertz, much easier to listen to.
    There is only a hex file supplied with this project, so I dont know if the 20 hertz frequency can be made lower.

    The other problem with that project is the max frequency is about 3 kilohertz which is a bit high.

    Does anybody know of a similar simple PIC or ARM vco project on the net, any info appreciated , thanks.

  • #2
    Have a look at HammerHead 2. They use a pic and drive the audio with it.
    http://www.geotech1.com/forums/showt...-1-source-code

    Not sure the frequency range used but the source is there so can be tweaked.

    Not sure why you need this on your project as a 555 is easy to tweak and the PIC will
    generate a whole lot more noise so if it is not giving you easy pulse generation the 555
    would be a better choice...

    Comment


    • #3
      Have a look at this Hack-A-Day post. http://hackaday.com/2013/01/17/makin...with-dual-pwm/

      That post has some links that might be of interest.

      Comment


      • #4
        I use the 10F222 for most simple tasks like generating clocks, etc.
        In CCS C, reading a pot connected to analogue pin 0 and converting that value into a square-wave on another pin is a trivial matter.
        The thing is to learn the language of whatever compiler you chose to use, which can be slow to start with but soon leads to very quick prototypes.

        Comment


        • #5
          Originally posted by 6666 View Post
          It works ok and can be adapted for what I need for my PI project, but only goes down to 20 hertz which is a annoying frequency to listen to, the lowest frequency needs to be about 1 or 2 hertz, much easier to listen to.
          There is only a hex file supplied with this project, so I dont know if the 20 hertz frequency can be made lower.

          The other problem with that project is the max frequency is about 3 kilohertz which is a bit high.
          If you run things off brute-force timers then you are limited by the range & resolution of the timer. Ferinstance, running the PIC at 8MHz and using a 16b timer results in a minimum frequency of 8,000,000/4/65536 = 30.5Hz. Sometimes the timer will have a prescaler so you can reduce this some more at the expense of maximum frequency, or you can just use a lower clock frequency.

          Hammerhead II uses a 12F683 with simple timers and is written in 'C' so it's very easy to read and modify. You can read a pot voltage to vary the frequency.

          - Carl

          Comment


          • #6
            I have an ARM4 pcb for sale that would do this for you. It's way overkill but could be fun to try!

            http://www.geotech1.com/forums/showt...dec-Bare-PCB-s

            Comment


            • #7
              Originally posted by Silver Dollar View Post
              Have a look at HammerHead 2. They use a pic and drive the audio with it.
              http://www.geotech1.com/forums/showt...-1-source-code

              Not sure the frequency range used but the source is there so can be tweaked.

              Not sure why you need this on your project as a 555 is easy to tweak and the PIC will
              generate a whole lot more noise so if it is not giving you easy pulse generation the 555
              would be a better choice...
              Hi Silver Dollar, thanks for the link, I have had a few posts in that thread , still cannot get the ADC function to work but will keep trying,
              one of the things I am trying to achieve is reduce the number of components and a pic chip and 1 resister meets that.

              Comment


              • #8
                Originally posted by greylourie View Post
                Have a look at this Hack-A-Day post. http://hackaday.com/2013/01/17/makin...with-dual-pwm/

                That post has some links that might be of interest.
                Thanks GL.

                Comment


                • #9
                  Originally posted by Beenthereuk View Post
                  I use the 10F222 for most simple tasks like generating clocks, etc.
                  In CCS C, reading a pot connected to analogue pin 0 and converting that value into a square-wave on another pin is a trivial matter.
                  The thing is to learn the language of whatever compiler you chose to use, which can be slow to start with but soon leads to very quick prototypes.
                  Hi Beenthereuk
                  Thanks yes you are right learning how to write code would be an advantage, I understand some things in code but its difficult when not trained in code, how would YOU write the code for a 10F222 ?

                  Comment


                  • #10
                    Originally posted by Silver Dollar View Post
                    I have an ARM4 pcb for sale that would do this for you. It's way overkill but could be fun to try!

                    http://www.geotech1.com/forums/showt...dec-Bare-PCB-s
                    Thanks for the offer,

                    Comment


                    • #11
                      Originally posted by Carl-NC View Post
                      If you run things off brute-force timers then you are limited by the range & resolution of the timer. Ferinstance, running the PIC at 8MHz and using a 16b timer results in a minimum frequency of 8,000,000/4/65536 = 30.5Hz. Sometimes the timer will have a prescaler so you can reduce this some more at the expense of maximum frequency, or you can just use a lower clock frequency.

                      Hammerhead II uses a 12F683 with simple timers and is written in 'C' so it's very easy to read and modify. You can read a pot voltage to vary the frequency.

                      - Carl
                      Thanks Carl, so thats why the lowest freq is 30hz, will try and have a bit more of an experiment with the 12f683 and your codes.

                      Comment


                      • #12
                        Sorry, just noticed the replies to this.

                        To code in CCS C for a PIC, the best thing is to setup an RS232 link to a PC running something like Hyperterminal on 9600 BAUD, 8 bits.

                        The following code will constantly read PIN_A0 on a 16F819 PIC (my suggested PIC for beginners...) and send its value to a PC terminal.

                        #include <16F819.h>
                        #DEVICE ADC = 8 //Could use 10 bits instead
                        #fuses INTRC_IO,NOWDT,NOPROTECT,NOMCLR,NOPUT,NOWDT,NOLVP
                        #use delay(clock=1000000)
                        #use rs232(BAUD=9600, XMIT=PIN_B1) //RS232 OUT pin
                        void main(){
                        unsigned char VPOT; //8 bit variable. Would use unsigned long for 10 bit number
                        SETUP_ADC_PORTS(AN0); //Setup ADCs on pin A0
                        SETUP_ADC(ADC_CLOCK_INTERNAL); //
                        SET_ADC_CHANNEL(0); // Set to ADC channel on PIN_A0
                        delay_us(100);
                        printf("\n\rRs232 ready...");


                        while(1){ //Loop forever
                        VPOT = read_adc(); //Read ADC
                        printf("\n\rADC = %u", VPOT); //Print ADC value to screen
                        delay_ms(500); //wait half a second
                        }
                        }

                        Once you have that working, the next step is to code a function to produce a tone on a pin, something like this, which you would call with: Tone(VPOT); :

                        void Tone(unsigned char value){
                        unsigned long time, n; //16 bit variable to hold our time value and n is a counter
                        if(value>120 && value < 130) time = 500; //produce 1 kHz tone if value roughly half-way
                        if (value > 130) time = 250; //2 kHz tone if > half way
                        if (value < 120) time = 750; //1500 Hz tone if < half way
                        for(n=0;n<100;n++){ //sound for 100 cycles
                        output_toggle(PIN_B0); //Output on PIN_B0
                        delay_us(time);
                        }
                        }


                        These 16F pics also allow the clock to be set quite low (min 31kHz) so hardware PWM may still be possible at low frequencies.
                        However, you can use delay_ms(time) in the code above to create lower output frequencies not possible with hardware PWM.

                        Comment


                        • #13
                          if (value > 130) time = 250; //2 kHz tone if > half way
                          250 microseconds toggle = period of 500 microseconds = 2kHz

                          if (value < 120) time = 750; //1500 Hz tone if < half way
                          750 microseconds toggle = period of 1500 microseconds = 666 Hz

                          Comment


                          • #14
                            Yep, 1 email written in a rush = bound to have some errors. The code will work though.
                            Also, as we are toggling a pin producing 1 cycle every 2 toggles, n=100 will produce 50 cycles, not 100...

                            Comment

                            Working...
                            X