![]() |
using single solenoid like a double
We're wondering if it is possible to use a single solenoid like a double basically by having to only press a button once instead of holding it down. Tell me if I'm crazy about the solenoid thing, but it seems possible to edit the program so that pressing the thumb or trigger on a joytick (pX_sw_whatever) once will keep the relay attached to its corresponding relay output in forward mode. How would you go about doing this? I think I have an idea, but I am a n00b and don't wanna embarass myself....
|
Re: using single solenoid like a double
Quote:
|
Re: using single solenoid like a double
Quote:
|
Re: using single solenoid like a double
Sure, the "toggle" code you need is at the repository:
http://nrg.chaosnet.org/repository/viewcode?id=23 |
Re: using single solenoid like a double
if you mean you want to use two buttons like "on" and "off" buttons, here's one way to do it:
Code:
static char btn_status = 0; |
Re: using single solenoid like a double
Quote:
|
Re: using single solenoid like a double
either way you want to work it.
|
Re: using single solenoid like a double
Couldn't you do it with a simple XOR operation?
i.e. Code:
relay1_fwd ^= p1_sw_trig; |
Re: using single solenoid like a double
No, because the p1_sw_trig will remain true for more than one frame (unless your driver moves faster than light :) ). Thus, relay1_fwd would continuously switch from 0 to 1.
|
Re: using single solenoid like a double
Quote:
|
Re: using single solenoid like a double
ahhh merci SilverStar, I was thinking of using something similar with even or odd number of times pressing the button, this works
|
Re: using single solenoid like a double
If you do it this way, it should only toggle the relay output when the button transitions from one state to another. That should eliminate the problem of infinite toggling that was present in my last suggestion.
Code:
// declare this as a global variable |
Re: using single solenoid like a double
Quote:
|
Re: using single solenoid like a double
It's a little more concise, but yeah, you're right. I shouldn't attempt to think when I haven't slept much - this is what happens. Sorry.
|
Re: using single solenoid like a double
nothing really to be sorry about - posting the code here doesn't hurt.
also, instead of a global variable, i'd recommend a static - that way, you don't have any possible variable conflicts. |
| All times are GMT -5. The time now is 04:21. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi