Greetings,
I've just recently started to use ccsc. I've stumbled my way through setting up most everything i want. (reading this forum for help )
I'm using an 16f876 to control an H-Bridge and controling speed via PWM with the Duty controled via analog ala EX_PWM.C.
I would like to scale the output of the analog reading to match the responce of the motor to allow for a greater degree of control. I've developed a plan of attack but seem to be smashing the data during the scaling maths.
Here is the code.
Code:
if (input (PIN_C4)) {
value=read_adc();
delay_ms(1);
value = value*38;
value = value/256;
set_pwm1_duty(value + 175);
rtfwd();
}
My intention is to scale the 0 - 255 from the dac to values between 216 - 242. I've seperated the maths to improve clarity.
Any comments / help / intuition would be appreciated.
e.w.
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
Posted: Sat May 06, 2006 9:00 pm
Is value defined as an int16?
Picster
Joined: 04 May 2006 Posts: 2
Posted: Sat May 06, 2006 9:10 pm
Nope it was not. That seemed to take care of it.....now i just need to tweak the values more.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum