CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Scaling issue.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Picster



Joined: 04 May 2006
Posts: 2

View user's profile Send private message

Scaling issue.
PostPosted: Sat May 06, 2006 8:38 pm     Reply with quote

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 Smile )
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

View user's profile Send private message

PostPosted: Sat May 06, 2006 9:00 pm     Reply with quote

Is value defined as an int16?
Picster



Joined: 04 May 2006
Posts: 2

View user's profile Send private message

PostPosted: Sat May 06, 2006 9:10 pm     Reply with quote

Nope it was not. Embarassed That seemed to take care of it.....now i just need to tweak the values more. Smile

Thanks for the quick response rberek!

Much obliged.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group