View previous topic :: View next topic |
Author |
Message |
uri
Joined: 24 Jan 2014 Posts: 11
|
|
Posted: Sun Jan 26, 2014 9:29 pm |
|
|
@Stinky
Am I in serious trouble then? Or could I just switch the GP2/AN2/CCP1/A2 > LM35 GND pin over to GP5/T1CK1/OSC1/A5 > LM35 GND pin and find my joy?
I'm really getting worried but hopefully I am still going to make it work with the feedback I am asking for please.
Thanks for helping me with this. My class partner had an emergency and had to go home for a few weeks. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Jan 27, 2014 9:35 am |
|
|
I think we need to take a step backwards.
You've explained what the ADC, PWM and fan are for.
Why do you need the pin toggling every 22us?
What does that pin do?
How important is it?
Mike |
|
|
uri
Joined: 24 Jan 2014 Posts: 11
|
|
Posted: Mon Jan 27, 2014 11:45 am |
|
|
Thanks. It is an oscillator for a high frequency target and is the main purpose for the application. Its a science project using frequency to create patterns in flour placed on top of a metal plate. The effect display in flour of symmetrical patterns. The others are to keep things running cool all day long without breaking.
Thanks for asking! I am also looking at other possible ways to do this without expecting too much from one forum, its not fair if I require too much. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Jan 27, 2014 3:36 pm |
|
|
consider using a second PIC for the project. One PIC is just the 22us ( 45KHz) oscillator to drive power amp that drives the plate.Simple and easy to implement.
The second PIC would be used to get the temperature(LM35) and control the fan.
The good thing about this approarch is that it breaks down the project into 2 easy pieces that are fast to build! I'd do the 45KHz PIC first as it's the quickest to design/build/test.
hth
jay |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Jan 27, 2014 3:40 pm |
|
|
Now we know a bit more, why not do things a different way round?
You could work on these lines:-
1) The oscillator is the main purpose. Use the hardware PWM set for 50% duty. You'll get a steady signal with very little jitter or fluctuation.
2) Change the frequency of the oscillator with two buttons. One button to increase the frequency, the other to decrease it. You'll then be able to get the metal plate to vibrate in different modes. Should be more interesting.
3) Get ADC signal from analogue input as now.
4) Generate software PWM signal for the fan. Since the fan speed is not all that critical, it's not a serious problem if the duty ratio wobbles a little.
Just my two pence worth.
Mike |
|
|
uri
Joined: 24 Jan 2014 Posts: 11
|
|
Posted: Tue Jan 28, 2014 12:25 pm |
|
|
I think splitting up the two applications onto two chips sounds good. I will do that. Thank you.
We were trying to do two applications on one chip and I don't think it was possible to do it even though the A1 output to the vibrator motor for the plate was not dependent on any input from the other pins, it was just using the internal clock. At first glance I thought it would be simple design but it could still be simple by isolating the two applications onto their own chips right?
We were actually intrigued to see how much we could place on a single chip though. I think its out of the question until I become a more brilliant programmer though. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Jan 28, 2014 3:28 pm |
|
|
It should be possible to do everything on the one chip.
The real problems are getting priority right and not running out of ROM.
Like Jay says, at your level, it's easier to keep things simple, and use two.
Best of luck.
Mike
PS Maybe you could try single chip solution after you submit.
I still think varying drive frequency to the metal plate is a good idea. |
|
|
uri
Joined: 24 Jan 2014 Posts: 11
|
|
Posted: Tue Jan 28, 2014 8:38 pm |
|
|
ok. thanks. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed Jan 29, 2014 2:22 am |
|
|
Key thing is to start with 'what has to happen', and then 'when'.
Then look at the features offered by the chip you want to use, and if all of the things you want can't be done in the constraints of 'pins' or 'timing', then think again.
Now the key problem question, is whether the 22uSec clock, must continue 'unbroken', while other things are happening?.
If this is the case, then _this_ has to be handled in hardware. Either using a PWM, or another chip.
If it can stop while other things are going on, then software solutions are possible.
Then look at the next clock, the one you currently use the PWM for. How accurate must this be?. Resolution needed?. Can this stop for a moment?.
If it can pause for a moment, or can be relatively slower, then this might be done with a software/timer solution. Realistically if this is only controlling a fan, then perhaps just 16 levels would probably give adequate control. As such, a timer based PWM, 'ticking' at perhaps 32KHz, would then give a 2KHz pulse rate. Should be fine.
The key is that the most important thing to be continuous and unbroken, is the 22uSec pulse train, not the fan train. As such it is the former that needs to use the hardware PWM.
Alternatively, look at a slightly larger chip (always easier....). There are PIC16's that offer programmable frequency outputs. Or the 22uSec pulse could be done by a simple CMOS divider chip, and just feed the clock out from the PIC, to one of these. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Jan 29, 2014 3:30 am |
|
|
I suggested how you re-assign the pins for this project.
Ttelmah has eloquently explained the rationale.
With just the one chip you've got enough pins for:-
1) Hardware PWM to drive metal plate.
2) 5 bit Software PWM for fan. Control via timer derived ISR.
3) Analogue I/P to measure temperature.
4) Button to increase hardware PWM frequency.
5) Button to decrease hardware PWM frequency.
6) Spare pin.
Have you tested the range of frequencies you actually need to drive the vibrating metal plate?
The 22us toggle you've got works out at ~23kHz.
(22us high, 22us low, is 44us total period.)
That sounds rather high to me.
You've either got a very small plate, or hoping to work on very high harmonics.
I suggest you ask to do some preliminary experiments with a lab oscillator.
Mike
PS. If you don't want to get involved with buttons you could just slowly sweep hardware PWM frequency.
The ~23kHz is ultrasonic so has the benefit of not being annoying if left to run continuously. |
|
|
|