Asked
— Edited

hi there,
Im working with the EZB-4 and 21x servos + a lot leds, camera and sensors..
the robot needs a lot power in action.
in the same second If my robot says: "my battery is low", he collapse..
I have no time for a reaction. its not good for the optical look.. I dont want scratches.. or a broken arm.. you know.
So I need to find a way to programming a better "battery is low warning". or a optical LED.. the best and coolest way is a live status inside the EZ-Robot Software..
thanks
Marty
Code:
I'm not 100% sure of the syntax in the code above (maybe Rich could confirm), but it should be close enough.
EDIT. Looks like Rich beat me to it.
Code:
However, a less than is better in case something drains it below 6.9 before the script spots it.
Looping the script with a sleep to constantly monitor would help. Or a waitforchange()
You don't need to assign the GetVoltage() to a variable. You can use it by itself.
See post #10
Yeah, I just saw your post. Thanks for clearing that up. I changed the code above to reflect what you said. I have a hard time as it is scripting with a computer, never mind doing it from memory, lol.
@Smarty.
Rich has you covered on this one with the script example he posted. That will get you sorted. Just to explain, in the example, the "x" in "$x" is where you can name a variable to anything you want and use it in your scripts, but not always nessasery.
thanks a lot
IF($voltage = 6.9)
or
If($GetVoltage<6.9)
is not working
Code:
Or, use GetVoltage() correctly
Code:
can you explain what you mean with: $voltage needs defining first.
please for dummies
GetVoltage()
Returns the EZ-B v4 Battery Voltage
Example: $x = GetVoltage()
In the $x part, the x is replaced with "voltage". This equals to the GetVoltage variable. So basicly your giving the "GetVoltage" variable the name "Voltage" which is called upon within the script. This is defining the variable. But as Rich said, this is not needed as $GetVoltage is already an existing variable code so you can simply use this without having to define a variable.
This is what I use. You can add commands you want.
$voltage=GetVoltage()
print($voltage)
$cputemp=GetCPUtemp()
print($cputemp)
if (GetVoltage() < 7.0)
say("EZB voltage now less than 7 volts")
endif
if (GetVoltage() <= 6.7)
say("My EZB positronic brain voltage is " + $voltage + " volts, temperature is " + $cputemp + "degrees C")
say("Steve, Voltage is now dangerously low, starting automatic shutdown soon, which may result in a neuralnet failure because I will lose the ability to send serial commands to my IRobot drive system. ")
endif
if (GetVoltage() > 6.7)
Say(" I am operating within normal parameters, Thank you father for asking ")
say("My EZB positronic brain voltage is " + $voltage + " volts, temperature is " + $cputemp + "degrees C")
Say("Steve hope you are doing ok on this " + $dayname + " in " + $monthname )
sleep(1500)
endif
Code:
code should be:
Code:
(with the loops and sleeps etc....)
Alan
Edited post to reflect this.
Alan
I misunderstood.
Code:
is working fine :-) thanks
I thought I have to use $voltage=GetVoltage()
or
If($voltage<6.9)
@Steve S thanks for the script, really cool :-)
No worries.
I forgot to add a sleep() command in post #24.
It just helps give the processor time to think. You can change the value to what you want. I put it as 500 milliseconds and Rich done it for a 1000 which essentually runs the script loop every half a second of sl1 second, so you can change this to what you want.
Code:
This warning message cannot be ignored.