Asked — Edited

Connecting Laptop Battery To Ez-B And Rover 5 Chasis, And Using Dagu Motor Contr

I started by buying the smaller sized H-Bridge from the website, found out that to run them i needed 2 H-Bridges. As for i didn't have the time to wait for another H-Bridge so i hooked up the Rover-5 by connecting the 2 motors from each side together on one power output on the H-Bridge. But having only 5 volts split between 2 motors wasn't nearly as fast as it could be and the battery drained way to fast. (5 volts on its own is way to slow)

My plans now is to implement the Dagu controller instead, and use a laptop battery to power up the system. I am not sure which battery to use and how to charge it though, without over powering anything, and b/c everything is being boxed in to my robot (since what i am doing is building a robot that can travel though H2S safely, but b/c H2S can blow up from a spark, etc, everything needs to be air tight)

I think i have a basic idea what i need to do with the PWM and Dir (direction) but i am curious about the Currents (not sure about what port to use, AC port? and do i need 1 or 4 current wires). Also if you know of a way to power up the Rover 5 (10-12 volts) and EZ-B/Dagu (5 volts) using a laptop battery, specific instructions will be amazing. I would also like to know if i can get a 9/6 pin cable on each end that can plug into the battery, and be used as an extension cable for wiring to devices, and/or getting a 9 pin plugin (like the one that is on the battery that i can put on the outside of the robot for plugin into and charging, having wiring run to the battery for extended length from each plug)

User-inserted image

and using one of these 2 laptop batteries to power the device. And using an external charger for the battery:

Apple Battery External Charger

Dell Battery External Charger

User-inserted image

I do believe that pins 1,2,4 are negative/ground (-) and 8,9 are positive (+) but still confused how i can do this all. If you can help i will greatly appreciate it. (apple has 6 pin, dell has 9 pin, not sure about apple yet) another forum seeing simular problems with motor controller


ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

United Kingdom
#1  

Dagu 4 Channel controller wiring has been detailed in this topic. Page 2 has details.

Also, I posted a project to the cloud for it, youc an download it here or open from the cloud within ARC.

#2  

ok, i think i have an idea with the Current Ports to AC Ports, but what exactly are the AC ports and the Current ports used for? You mentioned they monitor the current, how do i add current into the project that you have given? I seen a video where a guy controlled his dagu controller with an Arduino and he only used one current (also only used 2 motors) so i am also curious to how many current wires I should connect (1 or 1 for each [4])

User-inserted image

User-inserted image

if that picture doesn't work then open this link.

thanks for what you have given me, this file has everything i need for the digital ports (directional and PWM) the only thing left is hooking up current and then scripting the ADC. Which this I am a still confused about also, GetADC() , what do i need to put inside the parrametres and what do i put it inside, is there a control specifically for this, or do i have to use a script?

The batteries i am slowly learning, if anyone knows how to connect a battery safely and be able to charge it while it is enclosed (meaning an extension to the outside plug that will need an on/off switch and possibly covered by a rubber cover, I will greatly appreciate a post.

United Kingdom
#3  

Going entirely from memory, you connect the curr ports to ADC ports and it reports the current.

So with that in mind you can do one of two things,

  1. Add an ADC control (graph, meter etc) and set it to the correct port, set up the multiplier where required (ADC is 0-255, but I believe the current is 0-5 so multiply ADC by 0.0196078 to get current in amps)

or 2. Use the GetADC EZ-Script command to check the ADC port and save it's value as a variable that you can use elsewhere in ARC.


:loop
$curr1 = GetADC(ADC0)
$curr2 = GetADC(ADC1)
$curr3 = GetADC(ADC2)
$curr4 = GetADC(ADC3)
Sleep(200)
Goto(loop)

I've written an introduction to scripting that covers the ADC ports and IR sensors, the principal is the same so it may pay to have a read and see what you can take away and use from that.

Chances are, if one motor is drawing a lot of current then all 4 will be since it indicates it's stuck however for better accuracy I'd use all 4 if you have the free ports.

Then a small script that checks the ADC values and if they are above a certain value, indicating something is stuck, reverse, turn and move on. Much like the Ping Roam script I have covered here but using current to detect rather than IR sensors.

#4  

thank you so much, i think i understand how to do this now, i haven't done much scripting with EZ-B specifically but i am pretty sure it will be way easier then when i code in Java or Python. I understand the point of the current now, and why you can choose to use one or multiple. Using multiple will be more accurate so i will do that, my robot will be setup to a camera that I can use when it is away from sight, both this too will be very handy.

When using the current do I just make an "if" statement to make a loop to what happens when over a certain value, ex:

if curr1 >= ADC_Limit and curr2 >= ADC_Limit and curr3 >= ADC_Limit and curr4 >= ADC_Limit:
       Set(D0,on)
       Set(D2,on)
       Set(D4,on)
       Set(D6,on)
       PWM(D1,100)
       PWM(D3,100)
       PWM(D5,100)
       PWM(D7,100) 
       Sleep(5000)

My if statement doesn't look like the proper langguage/sytanx but i wanted to quickly show this. I will look over your scripting tutorials, i am sure they will answer this question.

United Kingdom
#5  

Yeah that's pretty much it, the syntax is incorrect as you suspected but the idea is right.

Correct syntax for if, to save you trawling through the pages and pages of examples etc. is;


IF ($variable1 >= $variable2 and $variable3 < $variable4 or $variable5 <> $variable6)
  #Execute command
  Set(D0, on)
  Set(D1, off)
  PWM(D3,100)
ElseIf ($variable1 < $variable2 and $variable3 < $variable4)
  #Execute something else
  Set(D0, off)
  Set(D1, off)
  PWM(D3,50)
Else
  #Execute something different
  Set(D0, on)
  Set(D1, on)
  PWM(D3,75)
EndIf

Basically, all variables need the $ prefix and all IF commands have the statement within brackets. Each part of the statement must be complete i.e. ($variable1 >= $variable2 and $variable1 >= $variable3) rather than just using ($variable1 >= $variable2 and >= $variable3).

ElseIfs also have their own statements if you have more than one action/outcome.

Else is executed if the if and (if applicable) elseif are not satisfied.

All if statements must end with an EndIf.

It's pretty straight forward. If you have python, java etc. experience you will get the hang of it very quickly.

#6  

ok thanks that saves me some time, and i never would have figured out that you need and EndIf, i use if, elseif, and else clauses all the time when making apps for android. Never heard of and EndIf before, i see its purpose but i never would have figured out why i'd be getting an error. The $ could have been another issue that i would of had trouble figuring out, but having an idea of the if statements i am pretty sure i will get the rest figured out with the executing.

My only other concerns now are based around connecting that laptop battery, the Dagu motor controller I am pretty sure i can get hooked up now (which i thought I would never be able to do). Thanks a lot Rich that puts a lot of weight off my shoulders, as for when I get a dagu motor controller (i didn't buy one yet b/c i didn't think i would figure out the connection) it should be hooked up and ready to go simply.

I can't guarantee but i think the EZ-B can handle up to 17 volts going into it, if so I think I can hook up one of these batteries straight to the EZ-B (10.8 and 11.1 volts) and have it also go to the Dagu power input for the Rover 5 motors. And to charge I just need to find a cable that connects right onto the battery and can be plugged in by the charger (male to female with either 6pin/9pin on each side depending on the battery). I would like to use the apple laptop battery as for it is much smaller but i am unsure about the wiring for that battery. But I believe it should look like this: (not actually code but the chart is view easier as code)

pin 1: 1st +
pin 2: 2nd +
pin 3: 3ed +
pin 4: 1st -
pin 5: 2nd -
pin 6: 3ed -

and then the dell looks like this:

Pin	 Name	         Description
1	 BAT+	         Positive battery terminal
2	 BAT+	         Positive battery terminal
3	 SMB_CLK	 2- wire System Management Bus signal (SMbus)
4	 SMBD or SDA	 SM Bus Data, Serial Data - the positive signal is 3.3V
5	 GND	         Ground
6	 SYSPRES#
7	 ON/OFF	         (the positive signal is 3.3V)
8	 BAT-	         Negative battery terminal
9	 BAT-	         Negative battery terminal

once again, thank you so much Rich, if you or someone else can help me with this too, you will make my day!

#7  

I have come across a difficulty, i want to set it up so that when left pressed the left go in reverse, right go forward; going right vise-versa. I set this up simply, it's that i also want it set up so that if the forward arrow is held down and the button q is also pressed (using key control) then the left will be forward but at 50% speed, and right will still be at 100%. This can easily be done by just setting up so that q makes the 2 left motors go to 50%, but i want this to only be the case if both the "q" and forward key are pressed. This will allow me to use both ways of turning. Then the button to go right using this method will be "e", how do I make an if statement to the arrow key, when the arrow key is automatically used inside the key control, without any variables needed?

Also I want it so that when i let go of the "q" or "e" if the arrow key is still down, then it will put PWM back to 100; but if the arrow key is not still down and was let go before the "q" or "e" than the PWM of the two at 50% need to stay at 0 from the arrow key by putting them to 0 for PWM.

The main thing is how do I referance to the arrow key inside the script for buttons q and e?

United Kingdom
#8  

I'll have to have a play with ARC to figure that out (and re-read it when it's not past my bedtime...)

As far as I know you cannot redefine the arrow keys, they are set to the forward, reverse, left and right of the movement panel. And I'm not sure that you can use both the arrows and the key commands at the same time since you need to have selected the Movement Panel for the arrow keys to work and need to have selected the key command control for the keys to work...

I'll have a look into it when I get chance though if nobody else comes forward with a solution.

As for the batteries, I'm no help there.

#9  

Actually I have figured this one out on my own now that i have posted. My plan is to refer to the PWM instead of the arrows, using if statements to numbers of the PWM. This is a left turn with q down (although i want an Else statement here but is there a "pass" in the EZ-B language, b/c if the PWM = 0 i want it to do nothing?

$Wheel1PWM = GetPWM(D1)
$Wheel2PWM = GetPWM(D3)
$Wheel3PWM = GetPWM(D5)
$Wheel4PWM = GetPWM(D7)

If(Wheel1PWM == 100 and Wheel2PWM == 100 and Wheel3PWM == 100 and Wheel4PWM == 100)
PWM(D1,50)
PWM(D3,50)
EndIf

For a left turn just change the last two from D1 and D3 to D5 and D7, then this is what to put on the up command:

$Wheel1PWM = GetPWM(D1)
$Wheel2PWM = GetPWM(D3)
$Wheel3PWM = GetPWM(D5)
$Wheel4PWM = GetPWM(D7)

If(Wheel3PWM == 100 and Wheel4PWM == 100)
PWM(D1,100)
PWM(D3,100)

ElseIf(Wheel3PWM == 0 and Wheel4PWM == 0)
PWM(D1,0)
PWM(D3,0)
EndIf

then for right turn just switch the port numbers for PWM and in the if statements change to Wheel1PWM and Wheel2PWM. Does this look right to you, and how do I specify an If statement to do nothing ("pass" in most syntax) see more on the next page

#10  

although if there is no pass I just came up with a way to fill up the gap, printing "Must be driving to use"

ElseIf(Wheel1PWM ==0 or Wheel2PWM == 0 or Wheel3PWM == 0 or Wheel4PWM == 0)
Print("Must be driving" )
Print("Forward to use" )
EndIf

But does everything look like this will work properly?

#11  

I am getting an error with the if statement, i guess i can't say If(Wheel1PWM == 100) or any number is there any way of fixing this, i am pretty sure PWM is what i need to be using for the if statement but how do i specify this b/c it should be inbetween 0-100, alike the ADC? Please help.

#12  

I managed to get this error fixed, ends up all the variables have to carry the $ throughout the code before the variable Ex:

ElseIf($Wheel1PWM == 100) 

when i you first explained this to me I thought it was just to specify the variable, didn't think it had to be used in all the code

United Kingdom
#13  

You're getting there:)

Yeah all variables everywhere need the $ prefix.

Also, for If statements as a rule of thumb, I use ($Wheel1PWM = 100) rather than ($Wheel1PWM == 100)

I found the best way to learn is to just play, it'll tell you if it's wrong:)

#14  

Yah i have been playing around a lot, adding more features as i go, the = sine i am so used to object oriented programming that == gets naturally used. As for EZ-B scripting is very simple, much similar to excel coding where it has a list of all terms and what to put inside, etc. Then you just use what it tells you and implement it into your design.

The one problem i am noticing with the code is that I haven't specified direction into the code, meaning when you let go of "q" or "e" it wont go back to normal if you were in reverse, etc. Can you get the direction ex:

$Wheel1Dir = GetPWM (D0) #or GetDir
#Wheel1PWM = GetPWM(D1)

If($Wheel1Dir = off and $Wheel1PWM = 100)
#execute all commands, etc
ElseIf($Wheel1Dir = on and $Wheel1PWM = 100)
#execute differrant command
EndIf

Also I am wonder about the quadrature encoders, I know they are very hard to hook up, has to be done with Arduino. My idea that I have came up with that I would like to know if it can be done is:

Can you hook up the EZ-B to the Arduino Board using the I2C, and then use the Arduino to connect to the Dagu Motor Controller's quadrature encoders. This may be a little complex and I really don't need to use the quadrature encoders much but I am curious if this is do-able.