[NXT-G] Battery Block question
-
- Posts: 30
- Joined: 07 Apr 2011, 16:42
- Location: Vernon BC Canada
- Contact:
[NXT-G] Battery Block question
The battery block has a compare value setting and a numerical output. What does the compare < or > do? I have block of code that reads [Battery Level] (< 6000mV) into a (600000 / [Battery Level]) with output to [Move] (CB forward with power value from . In the , the 600000 is 100% power times 6000mV.
So this being said, what I am doing is running the motors at 6V instead of what ever the batteries are giving out. Should I have the compare at < or > and what is the difference between the two?
So this being said, what I am doing is running the motors at 6V instead of what ever the batteries are giving out. Should I have the compare at < or > and what is the difference between the two?
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: [NXT-G] Battery Block question
I do not seem to have that block... < and > are likely comparing the voltage to another value. It probably outputs a logic state that you can use to determine something. An example would be to feed the logic into a loop, so that it loops until the voltage drops below a certain level.
Also, the motor speed control uses PWM, not analog voltage. Even at 1%, you are still powering them with the same voltage as with 100%. PWM % just determines the duty cycle, not voltage.
Also, the motor speed control uses PWM, not analog voltage. Even at 1%, you are still powering them with the same voltage as with 100%. PWM % just determines the duty cycle, not voltage.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 30
- Joined: 07 Apr 2011, 16:42
- Location: Vernon BC Canada
- Contact:
Re: [NXT-G] Battery Block question
Here is the program. Take a look at the way it supplies data. What I am trying to do is limit the motor to 6V. How do I set the Battery Level block. It is using a comparison but outputing a number. I have checked it using the display block with #totext.
- Attachments
-
- MoCoCrawler.zip
- (405.63 KiB) Downloaded 324 times
The definition of insanity is doing a repeated task over and over again, but expecting a different outcome everytime
Re: [NXT-G] Battery Block question
This how I used it :-
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
Re: [NXT-G] Battery Block question
As pointed out by matallen37, this method is not reducing the voltage but it does ensure that the motor is being supplied with a reasonably steady output.
If you just set a power level, the speed of the motor will drop off as the battery runs down. This method just starts off with reduced power and increases the required percentage to compensate for the reduction in voltage.
It would be far better, of course, to monitor the rotational speed and continually adjust the power level to try and keep the speed constant. This is just a simple way of getting some consistency where the robot will be required to do something repetitive and timing (not speed) is important. I thought of monitoring but was concerned that it might lead to 'hunting' as the power level was continually increased and decreased. It also takes a lot more programming.
If anyone has devised a way of doing it using PID or continual monitoring I would be very pleased to hear from them. Especially if they can supply some working NXC code or NXT-G blocks!
To answer (at last!) the original question, one could use the compare function to operate a switch block which would increment/ decrement the power percentage depending on whether the voltage was above or below the required level. This would achieve the same effect as the code example I supplied but would require a loop to keep changing the value until it was acceptable. It would have to be carefully designed to ensure the loop does not become infinite (especially if using NXT-G 2 with floating point arithmetic). If the power is being set as in the code example then there is no need to use the compare elements in the block.
Alternatively, the compare outputs could be used to operate a switch block in addition to the the code to issue a visual or audible warning when the battery level drops to an unacceptably low voltage (or is too low to begin with).
I used the battery level block in a short program which just displayed the battery voltage on the screen for 10 seconds or until it was switched off. Takes up little space but is handy because you can get an exact readout of the battery condition at any time.
If you just set a power level, the speed of the motor will drop off as the battery runs down. This method just starts off with reduced power and increases the required percentage to compensate for the reduction in voltage.
It would be far better, of course, to monitor the rotational speed and continually adjust the power level to try and keep the speed constant. This is just a simple way of getting some consistency where the robot will be required to do something repetitive and timing (not speed) is important. I thought of monitoring but was concerned that it might lead to 'hunting' as the power level was continually increased and decreased. It also takes a lot more programming.
If anyone has devised a way of doing it using PID or continual monitoring I would be very pleased to hear from them. Especially if they can supply some working NXC code or NXT-G blocks!
To answer (at last!) the original question, one could use the compare function to operate a switch block which would increment/ decrement the power percentage depending on whether the voltage was above or below the required level. This would achieve the same effect as the code example I supplied but would require a loop to keep changing the value until it was acceptable. It would have to be carefully designed to ensure the loop does not become infinite (especially if using NXT-G 2 with floating point arithmetic). If the power is being set as in the code example then there is no need to use the compare elements in the block.
Alternatively, the compare outputs could be used to operate a switch block in addition to the the code to issue a visual or audible warning when the battery level drops to an unacceptably low voltage (or is too low to begin with).
I used the battery level block in a short program which just displayed the battery voltage on the screen for 10 seconds or until it was switched off. Takes up little space but is handy because you can get an exact readout of the battery condition at any time.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
-
- Posts: 30
- Joined: 07 Apr 2011, 16:42
- Location: Vernon BC Canada
- Contact:
Re: [NXT-G] Battery Block question
Thanks for the explanation h-g-t.
The definition of insanity is doing a repeated task over and over again, but expecting a different outcome everytime
Re: [NXT-G] Battery Block question
In the unlikely event that anyone is interested, here are my battery level display files. I keep a copy of the NXC version on my brick so I can check the battery level at any time.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
Re: [NXT-G] Battery Block question
If you are just using the battery level output, then it will not make any difference what you set the trigger point or the > or < to be. That function is only to be used with the Yes/No plug. For example, if you write > 15000 that tells you if the battery level is less then 1500 mVolts. It does not affect the battery level output at all.pavementpilot wrote:The battery block has a compare value setting and a numerical output. What does the compare < or > do? I have block of code that reads [Battery Level] (< 6000mV) into a (600000 / [Battery Level]) with output to [Move] (CB forward with power value from . In the , the 600000 is 100% power times 6000mV.
So this being said, what I am doing is running the motors at 6V instead of what ever the batteries are giving out. Should I have the compare at < or > and what is the difference between the two?
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: [NXT-G] Battery Block question
Uh, not quite. If you were to write >15000, it would be true only if the battery level was greater than 15,000 mV (15 volts, which can never happen). The H-Bridges are rated for a max voltage of about 10.5v, and IIRC, at ~12.5v, the atmega shuts down the NXT.studbrickmaster wrote:... if you write > 15000 that tells you if the battery level is less then 1500 mVolts...
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: [NXT-G] Battery Block question
Yeah, well it was just an examplemattallen37 wrote:Uh, not quite. If you were to write >15000, it would be true only if the battery level was greater than 15,000 mV (15 volts, which can never happen). The H-Bridges are rated for a max voltage of about 10.5v, and IIRC, at ~12.5v, the atmega shuts down the NXT.studbrickmaster wrote:... if you write > 15000 that tells you if the battery level is less then 1500 mVolts...
Who is online
Users browsing this forum: No registered users and 3 guests