|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Limit Switch for PCM
Try this
Code:
if ( GetDigitalInput ( 1 ) && Input > 127 )
{
Input = 127 ;
}
else if ( GetDigitalInput ( 2 ) && Input < 127 )
{
Input = 127 ;
}
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 ) ;
|
|
#5
|
|||
|
|||
|
Re: Limit Switch for PCM
Many thanks for taking the time to post the code
GeorgeC |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |