|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Re: A few questions on programming the Control System
Quote:
|
|
#17
|
|||||
|
|||||
|
Re: A few questions on programming the Control System
Quote:
|
|
#18
|
||||||
|
||||||
|
Re: A few questions on programming the Control System
Here is how I would implement the code (from which you should be able to figure out how to implement your code with pointers)
Code:
void toggle_single_solenoid(unsigned char button, unsigned char *prev_button, unsigned char *relay_fwd)
{
if (button && !prev_button) //don't keep toggling if they hold the button
*relay_fwd = !(*relay_fwd);
*prev_button = button;
}
Code:
toggle_single_solenoid(p1_sw_trig, &prev_p1_sw_trig, &relay1_fwd); |
|
#19
|
|||
|
|||
|
Re: A few questions on programming the Control System
I haven't tried it, but can you have a pointer to a bit field? relay1_fwd is a macro with the value LATDbits.LATD0. Just curious.
|
|
#20
|
|||
|
|||
|
Re: A few questions on programming the Control System
What exactly is prev_button?
And thanks...I've been at this for too long... Shouldn't take me this long! |
|
#21
|
|||
|
|||
|
Re: A few questions on programming the Control System
Alright, I finally figured it out! Here is how I did it.
Code:
if (p1_sw_trig && rel1==0)
{
rel1++;
if (rel2==0)
{
relay1_fwd=1;
rel2++;
}
else
{
relay1_rev=1;
rel2--;
}
}
if (!p1_sw_trig)
{
rel1=0;
relay1_fwd=0;
relay1_rev=0;
}
rel1 and rel2 are simply declared as ints, where rel1 is initialized to 0, and rel2 to 1. This makes it go forward at first, then backwards the next time. |
|
#22
|
|||||
|
|||||
|
Re: A few questions on programming the Control System
Quote:
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What do you wish you knew about the new control system? | Joe Ross | Control System | 2 | 09-01-2004 21:47 |
| Need a FIRST Robotics control system | kershawrobotics | General Forum | 3 | 07-07-2003 09:49 |
| control system worth more than $500 | archiver | 2001 | 8 | 24-06-2002 02:00 |
| control system programming | archiver | 2000 | 17 | 23-06-2002 22:14 |
| Ok, how much is the control system worth? | archiver | 2001 | 6 | 23-06-2002 22:05 |