![]() |
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? |
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. |
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 |
Re: Limit Switch for PCM
Try this
Code:
if ( GetDigitalInput ( 1 ) && Input > 127 )Then delete it and add this. Code:
Input = GetOIAInput ( 1 , 1 ) ; |
Re: Limit Switch for PCM
Many thanks for taking the time to post the code
GeorgeC |
| All times are GMT -5. The time now is 04:50. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi