Go to Post Good robots with bad drivers can lose. Bad robots with good drivers can win. Good robots with good drivers can dominate. - James Tonthat [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
  #17   Spotlight this post!  
Unread 01-05-2008, 02:24
yongkimleng yongkimleng is offline
deus ex programmeur
AKA: James Yong
FTC #0747
Team Role: Mentor
 
Join Date: Aug 2006
Rookie Year: 2004
Location: Singapore, West
Posts: 134
yongkimleng is a jewel in the roughyongkimleng is a jewel in the roughyongkimleng is a jewel in the rough
Send a message via MSN to yongkimleng
Re: Need help with PWM 1-2ms pulse control

on the software side, heres my take.

I read that you want to map the analog pot directly to the pwm out right, so heres what I'd do:

pwm01 = Get_Analog_Value(rc_ana_in01) >> 2;

Now for the question on having two "sets".

Assuming you are getting full 10 bits range now and you want two sets
char set = 1; // set to 0 for the other set, or hook a switch up to this variable.

if(set == 1) {
// 127 to 254
pwm01 = (Get_Analog_Value(rc_ana_in01) >> 3) + 127;
} else {
// 127 to 0
pwm01 = 127 - (Get_Analog_Value(rc_ana_in01) >> 3);
}

maybe you need to add some casting above but on overall it should be correct.

Explanation:
Get_Analog_Value(rc_ana_in01) >> 3

Previously it was '>> 2', because I'm doing a bit shift so that the range from 0-1023 becomes 0-254 (8bits)

Now its >>3 as I'm sizing the range to 0-127 (7 bits) to be used in the calculation to scale set 1 (127 to 254) or set 2 (127 to 0).
__________________
| jamesyong.net |
FVC2007, FTC2008
 


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
help with operator control d25inferno Programming 1 18-02-2008 11:36
we need help with PWM problem in autonomous steve d Programming 7 03-02-2008 12:46
Help with automatic relay control DRH2o Programming 5 23-01-2008 18:13
We need help with joystick control Team ICE #1611 Control System 4 24-01-2005 15:57
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46


All times are GMT -5. The time now is 00:15.

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