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

Sending PWM duty cycle over RF

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



Joined: 30 Aug 2007
Posts: 144
Location: South Africa

View user's profile Send private message Send e-mail

Sending PWM duty cycle over RF
PostPosted: Mon Oct 29, 2007 2:57 pm     Reply with quote

Hi. I am trying to read the value of a adc and sent it over rf to the reciever, to use that value as the duty cycle for the PWM of a motor. Problem is that it is not a smooth change in speed as i am turnig the pot. It looks as if the delay between the sent and recieve influence the value so much that it is visible on the motor speed. Can you please give some recomendation as to do it better.

Transmit
Code:
set_adc_channel(1);   
delay_us(200);
speed = read_adc();
if(speed>160)
{
output_low(pin_A5);
output_high(pin_A4);
set_pwm1_duty(speed-200);
setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_C);
PutCC1000(PREAMBLE);
PutCC1000(0X0A);
PutCC1000(speed);
}


Recieve
Code:
set_adc_channel(0);
delay_us(20);
signal = read_adc();
if(signal<70)
{
if (CCRX_BUFFCOUNT >= 3) {   // As 3 bits ontvang is
temp = GetCC1000();
direction = GetCC1000();
speed = GetCC1000();            
if (temp == PREAMBLE) {   

if(direction==0x0A)
{                output_low(pin_A2);
                 output_low(pin_A4);
                 delay_ms(5);
                 set_pwm1_duty(speed-131);
                 setup_CCP1(CCP_PWM_H_H | CCP_PULSE_STEERING_C
                                        | CCP_PULSE_STEERING_B);
                 output_high(pin_A3);
                 output_high(pin_B4);
                 output_low(pin_A5);
                 output_low(pin_A1);
                 
}


On the recieve side the adc cahnnel 0 is only an RSSI to determine the signal strength.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 29, 2007 3:26 pm     Reply with quote

Quote:
if(speed>160)
{
output_low(pin_A5);
output_high(pin_A4);
set_pwm1_duty(speed-200);
setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_C);
PutCC1000(PREAMBLE);
PutCC1000(0X0A);
PutCC1000(speed);
}

You execute the code if the speed is 161 or higher.
But then you subtract 200 from the speed before you give it to the
pwm duty cycle function. Then you are giving the function a value
of -39. I'm sure you don't intend to do that.
Gerhard



Joined: 30 Aug 2007
Posts: 144
Location: South Africa

View user's profile Send private message Send e-mail

PostPosted: Mon Oct 29, 2007 8:31 pm     Reply with quote

Thanks, although it didn't solve the problem on the recieve side it helped on the transmit side LED.
Late night mistake.
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