Hello,
I'm using the PWM output D0 at 128Hz to control an LED with a sine wave modulation using a characteristic curve lookup table. The index to the table is controlled by a ramp function having a step of 5, 5ms process rate and reset value to give a 1 Hz period. I now want to change the 1Hz period to faster or slower by use of a input variable. Unfortunately, dynamically changing the ramp step size from a control variable to effect the 1Hz period time was unsuccessful.
Q1: It appears that once started the ramp step size appears unchangeable. Please confirm.
Q2: In place of the ramp function block, how can I implement a simple counter with reset using a variable? The math function addition is straight forward. My question is how to use the Math Function "if greater or equal" to reset the rolling counter? Can you provide an example of the IF statement to change a variable?
The MIO PPCAN Editor2 Referance Doc, P59 references Parameter 5 LinesPerformedifTrue. I would like an example of this for MIO 32-Bit version hardware.
Q3: Is there a C compiler available for the MIO module?
Thanks,
Kevin
How to use IF math function
Re: How to use IF math function
Hello,
1) Function block "ramp counter" has a fixed stepsize of 1 which cannot be changed.
It is possible to create a ramp counter with variable stepsize using a sequence of functionblocks. An example is attached to this post.
start, end, stepsize and initial value of ramp counter is set using some default values.
pseudo code:
count=count+stepsize
if(count>end)
then count=start
2) See example. Function blocks run independently. To create a sequence please use the same cycle time for all function blocks that are used for a sequence. Use "if: ..." function block to exexute a configurable number of following function blocks in case the expression is true.
3) The compiler that we use for the development is not available for free, therfore we have not prepared a firmware package that a customer could use to start a development.
The compiler/IDE we use is from Renesas, M32C and HEW (High-Performance Embedded Workshop)
Rergards,
Gunnar Bohlen
1) Function block "ramp counter" has a fixed stepsize of 1 which cannot be changed.
It is possible to create a ramp counter with variable stepsize using a sequence of functionblocks. An example is attached to this post.
start, end, stepsize and initial value of ramp counter is set using some default values.
pseudo code:
count=count+stepsize
if(count>end)
then count=start
2) See example. Function blocks run independently. To create a sequence please use the same cycle time for all function blocks that are used for a sequence. Use "if: ..." function block to exexute a configurable number of following function blocks in case the expression is true.
3) The compiler that we use for the development is not available for free, therfore we have not prepared a firmware package that a customer could use to start a development.
The compiler/IDE we use is from Renesas, M32C and HEW (High-Performance Embedded Workshop)
Rergards,
Gunnar Bohlen
- Attachments
-
- ramp_counter_fb.ppproj
- Ramp counter example, created with function blocks
- (17.51 KiB) Downloaded 1909 times
Re: How to use IF math function
Thank you for the help. The ramp example worked well for my application.
I interested in using this module for another project but with more conditional processing.
Can conditional statements be nested?
I'm only aware of these documents for the MIO:
PCAN-MIO_UserMan_eng.pdf
PPCAN-Editor_References_eng.pdf
PCAN-MIO_Tutorial_eng.pdf
Is there a document or example I can refer to which describes the rules for the function blocks with nested condition statements?
Thanks,
Kevin
I interested in using this module for another project but with more conditional processing.
Can conditional statements be nested?
I'm only aware of these documents for the MIO:
PCAN-MIO_UserMan_eng.pdf
PPCAN-Editor_References_eng.pdf
PCAN-MIO_Tutorial_eng.pdf
Is there a document or example I can refer to which describes the rules for the function blocks with nested condition statements?
Thanks,
Kevin
Re: How to use IF math function
Hello,
conditional statements can be nested.
Please use the same cycle time for all function blocks that belong together.
There is no other document available than the ones you already know.
The "if" function blocks execute the following number of lines (set via parameter) in case the expression is true.
Regards,
Gunnar Bohlen
conditional statements can be nested.
Please use the same cycle time for all function blocks that belong together.
There is no other document available than the ones you already know.
The "if" function blocks execute the following number of lines (set via parameter) in case the expression is true.
Regards,
Gunnar Bohlen
Re: How to use IF math function
Hello,
Thank you for the information.
Cheers,
Kevin Hawes
Thank you for the information.
Cheers,
Kevin Hawes