Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Germany
Asked — Edited
Resolved Resolved by Steve G!

My Battery Is Low

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

United Kingdom
#10  
I'm not near a computer right now as I'm out of town and didn't bring it with me, but something like what I posted below should help...

Code:


#This script will trigger when the battery hits 6.9 volts.
#Change the voltage to what you want it to be.

:Loop

If($GetVoltage()<6.9)

#Enter your ControlCommand for your Auto Position action here.

EndIf

Sleep(500)

GoTo(loop)


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.:)
United Kingdom
#11  
The If condition needs wrapping in the brackets, you only have half in it. So

Code:

IF($voltage = 6.9)


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:)
United Kingdom
#12  
@Rich.

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.:P

@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.:)
Germany
#13  
yahoooo! perfect :-))

thanks a lot
Germany
#14  
variable not defined in line 2.. *sick*

IF($voltage = 6.9)
or
If($GetVoltage<6.9)

is not working
United Kingdom
#15  
$voltage needs defining first.

Code:

$voltage = GetVoltage()


Or, use GetVoltage() correctly

Code:

IF(GetVoltage() < 6.9)
Germany
#16  
hmm.. it says always: variable not defined for both.
can you explain what you mean with: $voltage needs defining first.
please for dummies:D
United Kingdom
#17  
In the example...

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.
PRO
USA
#18  
Smarty,
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
United Kingdom
#19  
So this won't work for you?...

Code:

$voltage=GetVoltage()
:loop
If($voltage<6.9)
#Your command code for auto position
Endif
Sleep(500)
GoTo(loop)
#20  
Minor error in Rich's code. $getvoltage() is not a system variable, it is a command which retreives a value..

code should be:

Code:


if (getvoltage() < 6.9)
#do something
endif


(with the loops and sleeps etc....)

Alan
United Kingdom
#21  
Alan spotted my deliberate mistake;)

Edited post to reflect this.
#22  
heh... lessons for the students..

Alan
Germany
#23  
@Steve G
I misunderstood.

Code:


$voltage=GetVoltage()
:loop
If($voltage<6.9)

is working fine :-) thanks
I thought I have to use $voltage=GetVoltage()
or
If($voltage<6.9)
:D:D:D

@Steve S thanks for the script, really cool :-)
United Kingdom
#25  
@Smarty.

No worries.:)
United Kingdom
#26  
@Smarty.

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.
#27  
Also in post #24 you need to put $voltage=GetVoltage() inside your loop or you are only reading the battery voltage just once....

Code:


:loop
$voltage=GetVoltage()

If($voltage<6.9)
saywait("warning, battery voltage is low")
endif
sleep(1000)
goto(loop)
PRO
Synthiam
#28  
If your battery is low and you run the battery less than the warning - it may explode. There are dozens of warnings all over the website and in the EZ_B. The message is there for a reason. LiPo batteries CANNOT run less than the specified voltage. The battery is low is there for a reason. It's a lot of code with a great deal of testing to ensure LiPo battery life expectancy and safety.

This warning message cannot be ignored.
Germany
#29  
thanks for the warning @DJ