NickMu, If this is what you are looking for then maybe you should look at using an 12F1840. It has a DATA SIGNAL MODULATOR module that is quite usefull for generating waveform like this.
NickMu, If this is what you are looking for then maybe you should look at using an 12F1840. It has a DATA SIGNAL MODULATOR module that is quite usefull for generating waveform like this.
Dave Purola,
N8NTA
EN82fn
Hi Henrik,
Thank you for your help and my apologies for not making myself clear.
I am in need of a modulated high frequency source. The main frequency (carrier) should be between 250 kHz and 4 MHz pending some results of testing in progress. I will start with 1 MHz and move up or down on carrier frequency.
I need to be able to turn this carrier ON and OFF in bursts of 15 mS ON and 5 mS OFF.
My project is still in its infant stages, so right now I’m at the point of poking around to see what can be done with a minimum amount of components.
The larger project this is part of is a non-contact power and data transfer. This week and next week I will be doing a lot of testing on the power transfer part to find an optimal frequency that will make it easier to do both with as little loss as possible.
My first power transfer test is encouraging (I can transfer about 1.5 W which is more than I need) with about 66% efficiency. For this I’m using a Mosfet driven by a variable gated oscillator. It serves the purpose for testing but in the final design I would like to have something much simpler especially at the slave unit side where I have a lot of limitations space being one of them.
My research also shows that for power transfer lower frequencies (100 – 400 kHz) are better. For data transfer I would prefer to use higher frequencies since I already tested a wired 4 MHz power and data transfer. Also I understand that higher carrier frequency will allow higher data transfer rate. I must have 9600 but 19200 will be better.
This week I will do some research on employing the CCP module to do most of this part.
I will also study Dave’s example which seems to be doing almost what I need only at lower frequencies.
Dave, you are right and thanks for the suggestion, I will look into it. I am familiar with PIC12F683 but if I must learn new tricks I will.
So many things, so little time.
Thanks again for your help.
Regards,
Nick
Hi Nick,
No problem, I didn't have a 12F683 at home but I did have a 12F1840. Now, the 1840 has an ECCP module while the 683 has a standard CCP module so the following code MAY need to be changed slightly (the CCP1CON register) in order to work properly on the 683 (I'm not using the data modulator here). It sets the CCP module up to output a 1MHz, 50% dutycycle PWM on PortA.2. The main program then simply toggles the timebase (TMR2) for the CCP module on and off to modulate the output.I have a scope screen grab of the output but for some reason the file upload manager on the forum refuses to work, the upload just hangs...aarghh....Code:' *************************************************************** ' Pin Connections ' *************************************************************** ' RA0 -> Not used ' RA1 -> Not used ' RA2 -> CCP1 output ' RA3 -> Not used ' RA4 -> Not used ' RA5 -> Not used ' *************************************************************** ' Device Fuses ' *************************************************************** #CONFIG __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF __config _CONFIG2, _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF #ENDCONFIG ' *************************************************************** ' Compiler directives ' *************************************************************** DEFINE OSC 8 ; We're running at 16Mhz ' *************************************************************** ' Initialization ' *************************************************************** OSCCON = %01110000 ' 8MHz internal osc ANSELA = 0 ' Digital only for all PortA pins TRISA = %00000000 ' Make PORTA outputs CCP1CON = %00001100 ' Normal PWM PR2 = 1 ' 1MHz output @8MHz system clock CCPR1L = 0 ' 50% Dutycycle CCP1CON.5 = 1 CCP1CON.4 = 1 ' *************************************************************** ' Actual program ' *************************************************************** Main: T2CON.2 = 1 ' Timebase ON PAUSE 15 T2CON.2 = 0 ' Timebase OFF PAUSE 5 Goto Main
Now, if you intend to do other things with the PIC as well then this simple aproach obviously won't work. But you could use a timer interrupt in order to turn on and off the carrier at the correct intervals. I haven't personally used the data signal modulator module in the 12F1840 but it sure sounds like the "correct" way forward. The 12F1840 also allows you to run at 32MHz using the internal oscillator and 4x PLL which would allow you to get higher output frequency using the CCP module than on the 12F683 which tops out at 8MHz.
/Henrik.
Last edited by HenrikOlsson; - 23rd August 2013 at 18:22.
Hi Henrik,
I will try your code tonight. I only have 12F683 PICs and to change to 12F1840 will take some time for me (I’m still using an older version of PBP) which, more than sure, does not support this chip.
If I can get modulated 1 MHz from one chip for now it will save me a lot of time with the testing and a lot of space on the board.
I will post my findings as soon as I have results.
As always thank you for your help.
Regards,
Nick
I had to make few minor changes to Henrik’s code to adapt it to a 12F683 and make the code compatible with my old PBP 2.47.
Here is the working code that generates bursts of 15 mS ON and 5 mS OFF with a carrier frequency of 1MHz (Sorry Henrik for mutilating your nicely commentated code but REMing some of the lines makes it easier on my eyes).
This will make my testing a lot easier and fine tune the power transfer part. In the real life I will replace the fixed timing of the T2CON.2 control with some other mechanism (something like Dave did). Right now my first priority is to decide on the final frequency and tune my LC circuits for maximum efficiency on power transfer and maximum reliable speed on data transfer.Code:@ device pic12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off DEFINE OSC 8 ' We're running at 8 Mhz OSCCON=%01110111 ' 8MHz internal osc ANSEL = 0 ' Digital only for all PortA pins TRISIO=%00100000 ' Make PORTA outputs CCP1CON = %00001100 ' Normal PWM PR2 = 1 ' 1MHz output @8MHz system clock CCPR1L = 0 ' 50% Dutycycle CCP1CON.5 = 1 CCP1CON.4 =1 Main: T2CON.2 = 1 ' Timebase ON PAUSE 15 T2CON.2 = 0 ' Timebase OFF PAUSE 5 Goto Main
Unfortunately I do not have too much time to experiment with the new 12F1840 which is by far the best way to go. It involves so many more variables for me including complete upgrade of my hardware and software and I’m not ready for it yet.
One question for Dave:
You used a data speed of 3000 bps. Did you try to push your system to see what will be the maximum data speed that you could get?
And two questions for everyone:
Is there a 10F, 12F or low pin count 16F PIC, supported by my older 2.47 PBP that will have a 16 MHz internal clock?
What kind of minimal hardware / software upgrade to be able use PIC12F1840?
Thank you in advance.
Hi Nick,
Great, I'm glad you've got it working on the '683!
You'd need to check microchip.com and use the product selector tool they have to find which PICs have the oscillator options you want and then cross reference that with the supported devices list for the compiler version you have.
If you find yourself in a position where you need to consider upgrading to PBP3 I wouldn't hesitate a second. The big difference is how the CONFIG bits are handled - and it's a big step forward IMO. Then you have the conditional compilation features and (since you're even on pre 2.50) you'll get support for 32bit variables when using PIC18 series devices and a couple of new commands.
PBP doesn't really know much about the hardware but obviously your device programmer needs to support the chip you're programming for - you need to check the list for your particular device programmer. I have a PICKit3, it's cheap and it works.
/Henrik.
Thanks Henrik for your support and encouraging.
Switching to the latest software and hardware is one of my next priorities.
I was going to order a PICKit3 just to get familiar with it until I will cross the bridge. Your sample code will be my first try.
MeLabs use to have a really helpful PIC selection system. What happened to it? I wasn’t aware that Microchip has the product selection tool. I will use it from now on.
I’m sure that other members of the forum will be interested in some of the aspects of my project and I pledge to keep everyone posted with my progress. It’s time to order some parts and start testing.
Regards,
Nick
Bookmarks