Go to Post When your driver is the "world record holder in Mario Cart" you know it's going to be exciting for the students and stressful for the pit crew. :ahh: - lovelj [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-02-2007, 17:43
GeorgeC GeorgeC is offline
Registered User
FRC #1934
 
Join Date: Feb 2007
Location: London
Posts: 13
GeorgeC is an unknown quantity at this point
Limit Switch for PCM

Can anyone help with an easyC mindbender?

I've used all of my available spike relay controllers and programming limit switches using them in easyC was straightforward.

Now i need to control a motor using PWM and a limit switch but I can't think of how to code in a limit switch.

What I want to do is program something like if limit==0 then PWM1 ==<127. However in easyC I can't see the actual variable to assign my values to.

I guess that PWM outputs are to program drive motors which don't usually need limit switches.

Anyone got any ideas?
  #2   Spotlight this post!  
Unread 11-02-2007, 23:02
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Limit Switch for PCM

Create your own variable to hold the value of the limit switch (connected to a Digital Input, of course).

Then you can do something like:

switchstate = DigitalInput(10); // read DI 10 limit switch
if (switchstate == 1)
pwm = 127;
else
pwm = something else;

PWMOutput(2, pwm); // output pwm value to PWM2


You are correct, the EasyC functions provided for PWM output do not include support for limit switches.
  #3   Spotlight this post!  
Unread 12-02-2007, 14:08
GeorgeC GeorgeC is offline
Registered User
FRC #1934
 
Join Date: Feb 2007
Location: London
Posts: 13
GeorgeC is an unknown quantity at this point
Re: Limit Switch for PCM

Thanks That's got me on the right track.

Nice to hear from someone who talks in EasyC

Regards

GeorgeC

Last edited by GeorgeC : 12-02-2007 at 14:22.
  #4   Spotlight this post!  
Unread 12-02-2007, 15:06
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Limit Switch for PCM

Try this
Code:
if ( GetDigitalInput ( 1 ) && Input > 127 )
      {
            Input = 127 ;
      }
      else if ( GetDigitalInput ( 2 ) && Input < 127 )
      {
            Input = 127 ;
      }
If you are using an OI to PWM Block

Then delete it and add this.

Code:
Input = GetOIAInput ( 1 , 1 ) ;
      if ( GetDigitalInput ( 1 ) && Input > 127 )
      {
            Input = 127 ;
      }
      else if ( GetDigitalInput ( 2 ) && Input < 127 )
      {
            Input = 127 ;
      }
      SetPWM ( 1 , Input ) ;
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #5   Spotlight this post!  
Unread 16-02-2007, 13:21
GeorgeC GeorgeC is offline
Registered User
FRC #1934
 
Join Date: Feb 2007
Location: London
Posts: 13
GeorgeC is an unknown quantity at this point
Re: Limit Switch for PCM

Many thanks for taking the time to post the code

GeorgeC
Closed Thread


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
Limit Switch Basics JWSnedden Programming 6 30-11-2006 19:48
Limit switch in easy c? chadbarbe Programming 6 02-02-2006 09:51
How do you wire a limit switch? JMH Electrical 1 16-02-2005 17:44
gyro/accelecometer/limit switch help needed Anton Programming 4 04-02-2005 16:39
sample limit switch code??? tml240 Programming 5 17-02-2004 17:13


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

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