phase-shifted PWM
i'm trying make program quite simply, shifts phase of pwm numbers.
so have 2 variables, var1 , var2.
var1 moving , down between 0 , 255. want var2 30 degrees out of phase of this,
so when:
var1 = 0
var2 = 64
var 1 = 128
var2 = 192
but also,
var1 = 255
var2 = 192
now getting maths beyond small brain's capability, seeing didn't maths past gcse.
anyone care lend hand? or brain, rather?
so have 2 variables, var1 , var2.
var1 moving , down between 0 , 255. want var2 30 degrees out of phase of this,
so when:
var1 = 0
var2 = 64
var 1 = 128
var2 = 192
but also,
var1 = 255
var2 = 192
now getting maths beyond small brain's capability, seeing didn't maths past gcse.
anyone care lend hand? or brain, rather?
greetings,
doesn't simple work:
the variables start off fixed phase difference, , long incremented together, , wrap-around @ same point, stay in sync.
regards,
david
doesn't simple work:
code: [select]
setup() {
int var1 = 0;
int var2 = 64;
}
loop () {
var1 = (var1 + 1) % 256;
var2 = (var2 + 1) % 256;
}the variables start off fixed phase difference, , long incremented together, , wrap-around @ same point, stay in sync.
regards,
david
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > phase-shifted PWM
arduino
Comments
Post a Comment