View Single Post
  #22   Spotlight this post!  
Unread 03-01-2003, 13:28
Animator Animator is offline
Registered User
#0120
 
Join Date: Dec 2002
Location: Cleveland
Posts: 11
Animator is an unknown quantity at this point
1 Sensor Code

Here is some code that will allow you to use 1 sensor to control your pump if you need to save on weight.

Keep in mind, if you keep your executable code length short, your serin and serout commands will occur more frequently making your robot respond quicker to inputs and outputs.

Also, debug commands slow down the code execution. Comment them out after you're done with testing. If you want proof, watch the Basic Run light when the debug code is in the program and when it is out. That LED is controlled by:

Toggle 7 'Basic Run LED on the RC is toggled ON/OFF every loop.

in the default program. Everytime the code is executed, the LED is toggled. The faster it blinks. The faster your code is executing.

Sorry to go off the topic. Below is the code:

I tested it in RoboEmu 1.07

------------------------------------------------------------------
' Variables

Counter VAR w10
LowPres VAR rc_swA.bit1
PumpMan VAR oi_swA.bit2 'Aux input,
Pump VAR RelayA.bit0
Pump_rev VAR RelayA.bit1
Counterbit VAR Counter.bit0
CounterMax CON 501 'This number needs to be odd
Counter = CounterMax

MainProgram:

Serin...

'Pump Code for 1 sensor

LowPres = ~LowPres
Counter = ((LowPres) * (Counter + 2)) max CounterMax
LowPres = ~LowPres
Pump = ((LowPres | ~Counterbit) & ~PumpMan)
Pump_rev = 0

Serout...

----------------------------------------------------------------