Go to Post Maybe I'm just a chicken. Not to disparage the ThunderChickens. Those guys are a whole different breed of poultry. - Kevin Sevcik [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 14-01-2007, 20:31
Noah Kleinberg Noah Kleinberg is offline
Registered User
FRC #0395 (2TrainRobotics)
Team Role: Driver
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 196
Noah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to behold
Send a message via AIM to Noah Kleinberg
Re: PWM 13-16 Replacement Code Beta Test

Is there any reason that you couldn't use "int"s to store your motor speeds and have a greater range of values with the higher precision obtained by using the CCP (that is, instead of using the gain and center #defines)? I looked through the code and don't see why this wouldn't work, what i mean is something like this as a change to the PWM() function:

Code:
void PWM(unsigned int pwm_13, unsigned int pwm_14, unsigned int pwm_15, unsigned int pwm_16)
{
//	int temp_pwm_13;
//	int temp_pwm_14;
//	int temp_pwm_15;
//	int temp_pwm_16;

// .........
	// calculate the number of 100 ns timer ticks 
	// needed to match the desired PWM pulse width 
	temp_pwm_13 = (PWM_13_GAIN * ((int)pwm_13 - 127)) + PWM_13_CENTER;
	temp_pwm_14 = (PWM_14_GAIN * ((int)pwm_14 - 127)) + PWM_14_CENTER;
	temp_pwm_15 = (PWM_15_GAIN * ((int)pwm_15 - 127)) + PWM_15_CENTER;
	temp_pwm_16 = (PWM_16_GAIN * ((int)pwm_16 - 127)) + PWM_16_CENTER;

	// load the CCP compare registers
	CCPR2L = LOBYTE(pwm_13);
	CCPR2H = HIBYTE(pwm_13);

	CCPR3L = LOBYTE(pwm_14);
	CCPR3H = HIBYTE(pwm_14);

	CCPR4L = LOBYTE(pwm_15);
	CCPR4H = HIBYTE(pwm_15);

	CCPR5L = LOBYTE(pwm_16);
	CCPR5H = HIBYTE(pwm_16);

//..............
Also, could CCPR1L and CCPR1H (or 2-5) each be 255? I ask this because with the default GAIN and CENTER values, the maximum I believe is 21400 (that is for the two combined as one word), as opposed to 65535.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vex start up code run PWM outputs without Rx intellec7 Programming 3 05-05-2006 23:29
Pwm 11, 12 and CMU code Chris Bright Programming 3 01-02-2005 19:34
Victor Replacement JamesCH95 Electrical 4 15-12-2004 20:12
Replacement Parts archiver 1999 0 23-06-2002 22:01
replacement gears joni_m Technical Discussion 1 22-01-2002 18:01


All times are GMT -5. The time now is 20:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi