- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
I would like to create a PWM signal ( so with the PWM function in PSoC Designer) with a potentiometer at the entrance (to modify the duty cycle of this signal). Everything works fine but I have a little problem: I would like a minimum value for the duty cycle. And when i see the signal at the exit, it's very strange ! It's not smooth. You can see it on the picture.
<a href="http://www.casimages.com/i/150417102525799789.png.html" title="Problem PSoC">Lien vers mon image</a>
Can you help me please ? I send you the code too.
<a href="http://www.casimages.com/i/150417102706438332.png.html" title="code">Lien vers mon image</a>
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, there is a little mistake with my first post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum, Jerome!
To see what is going wrong we need some more information: Can you post your complete project, so that we all can have a look at all of your settings? To do so, use for PSoC 3,4 and 5
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
for PSoC1 use the function "Archive Project"
What target are you referring to? PSoC1, 3, 4 or 5? What board do you use custom pcb? Kit? Which one??
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your answer.
I send you my project. I don't know what kind of card is it because this is a card which has been modified by the school.
But i think that the problem is not very complicated !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The attached .zip file has an error, please re-try to create and post. (Verify you can open the zip with windows explorer)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So some of the questions are already answered:
It is a PSoC1, custom board made by telecom.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you monitoring Port0_0 or Port0_6?
You write the pulsewidth first in line 29, then later you change it. That will produce a lot of glitches. Consider to have the result of the ADC as unsigned.
Read in datasheet the side-effects for changing the compare-value while counter is running.
A very proof concept would be to wait for counter overflow (using an interrupt), Stop the PWM, write new compare-value and restart PWM again. Interrupts in PSoC1 are not quite easy to handle, so if you are really controlling a drone you might need it.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Strange, I could open your file using 7zip, but your Designer should have used the windows zip...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't really use port0_0 and port0_6, you're right. I think it doesn't matter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You write multiple times in one cycle to the pulsewidth. This you should avoid!!!
You write in line 29 PWM8_1_WritePulseWidth(value);
and in lines 33 and 37. a corrected value
It would be better to first calculate the new value you want to write and write that to your pulsewidth. When you remember the last value written you may only write changes. Much room for "Thinking PSoC"
Try to set up a interrupt handler (see #pragma and modify the file Boot.tpl) fetching the terminal count of the PWM. There you may update the pulsewidth with a pre-calculated value. Do not read the ADC in the interrupt handler, that will take too long. Instead set a flag which you poll in your main-loop, When set, read ADC, calculate the new value to set and reset that flag.
Happy coding
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just see that you have configuration warnings for the ADC: Set both clocks (for analog and digital parts of ADC) to VC2 (or whatever you like to have..
Your document shows a timer capture interrupt and you will use a PWM terminal count interrupt, principially these have the same approach.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you set up an interrupt handler you can route your PWM Tc to a buffer and set
the buffer to ISR on rising edge of buffer 1.
Make sure in build settings you have interrupt generation checked -
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The PGA prevents yopu from having rail to rail measurement capability with the
A/D.
So delete PGA if you need R-R and set its + input to Port_2_1.
In either case set your global properties to
Specifically Op-Amp bias and A-Buff_Power to high, these also effect CMR.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you do an ISR don't forget to declare any variables used as volatile -
http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword Volatile
Regards, Dana.