Hello to all, Ok. Yes I'm new here, but not to electronics.
Today, I spent over 5 hrs reading over similar posts in this forum and I'm still unsure how to implement this.
I'm trying to replace a 555 adjustable Astable timer circuit (10Hz - 4KHz) , with a PIC12F1572 (aka as the inevitable 12F675 replacement), without inheriting the unavoidable change of duty cycle of the 555. In other words I would like to output a true square wave and be able to adjust the frequency. No PWM needed. My biggest hurdle is understanding what happens in the chip that converts "voltage" to digital?? Is it all black magic? Do I have to use the comparetor module or is the ADC enough?
How to best process the bits in ADRESH and convert it to a digital number to implement them into a useful variable time delay. From the delay on, I know how to turn the output on off.
I've look at quite a few tutorials and Yes the analog portion is somewhat overwhelming.
Maybe this is too simple for some, but I'm pushing 60 and things seem to get more difficult as years progress. Thanks for your time.
I think it was either Elektor or possibly the UK Everyday Practical Electronics magazine did a couple of articles on using a PIC as a 555.
I'll see if I can dig out which one it was and when - you should be able to still download the code from their site and have a look at how they did it (I think it was in assembler).
Will post details as soon as I find them if someone else doesn't beat me to it.
When you open the zip file, it is codes marked as 13 & 14 near the bottom of the list that use a pot to vary the frequency (listing 14 uses interrupts).
Thanks Augustinetez. I now have some reading to do. Looks like this has been done before and if the code is good, I'll just have to change it a bit to get it working with the new chip(12F1572). I'll update whether I have something working or not. Again thanks for the help.
It's a pretty trivial thing to do - just read a pot via the ADC, and use that value to set the PWM to the frequency you want (just set the PWM to 50%, and leave it at that). However, the ADC is only 10 bit, so you only have 1000 potential frequencies, but that should be plenty anyway - and represents 0.1%.
There are also a number of extra peripherals on some of the later enhanced devices, which might make a better oscillator than the PWM for you, such as the NCO - the 16F18313 is a pretty competent enhanced 8 pin PIC.
To be fair, it's really all about setting peripheral registers - so should be pretty easy to convert to assembler (or any language) anyway - it's the principle which is important.
And as usual, almost half of the code is setting the fuses
To be fair, it's really all about setting peripheral registers - so should be pretty easy to convert to assembler (or any language) anyway - it's the principle which is important.
And as usual, almost half of the code is setting the fuses
True, and setting registers is pretty much the same in any language, ADCON0=0b00001101; changes to MOVLW 0b00001101 movwf ADCON0 (plus bank selection).
And, true about the fuses.
Tomorrow is the time to have a play with the NCO. Beer time now. 8PM here on a Friday night.
True, and setting registers is pretty much the same in any language, ADCON0=0b00001101; changes to MOVLW 0b00001101 movwf ADCON0 (plus bank selection).
Thanks Nigel and Pommie. I didn't realize that MPLAB 8.92 didn't support 12F1572. I guess C is the way of the future since Microchip is more than likely abandoning assembly or it seems like it by not having it supported in MPLABX. I've downloaded and gone through Nigel's ADC tutorial and they've been a lot of help. Hmmm. Well I guess I will have to find another chip. One that will work with MPLAB 8 and a PicKit3.
To learn another programming language for me is just not worth it. The only other chips I have on hand is a 16f88. I'll look into the 12F1822 as I'm really limited by board space and being that it will be nothing more than a square wave generator it would fit nicely where the 555 used to be. I'll keep you guys posted.
Again Thanks for the suggestions.
If you want to use ASM with MPLABX, your best bet is to install MPLABX 5.35.
That's the last version that included the MPASM assembler v5.87, which supports both the 12F1572 and 12F1822.
Later versions of MPLABX include the new PIC-AS assembler as part of the XC8 compiler package, but PIC-AS isn't compatible with MPASM syntax.
MPLABX 5.35 is the last "32-bit" version. If you install it on a 64-bit win OS, MPLABX will complain about MPASM not being 64-bit but you can ignore that. It works.
Thanks Nigel and Pommie. I didn't realize that MPLAB 8.92 didn't support 12F1572. I guess C is the way of the future since Microchip is more than likely abandoning assembly or it seems like it by not having it supported in MPLABX. I've downloaded and gone through Nigel's ADC tutorial and they've been a lot of help. Hmmm. Well I guess I will have to find another chip. One that will work with MPLAB 8 and a PicKit3.
To learn another programming language for me is just not worth it. The only other chips I have on hand is a 16f88. I'll look into the 12F1822 as I'm really limited by board space and being that it will be nothing more than a square wave generator it would fit nicely where the 555 used to be. I'll keep you guys posted.
Again Thanks for the suggestions.