Go to Post I guess I should read the manual. - r_towle [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-05-2012, 14:04
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Arduino PWM output

I just got my Arduino Uno and I'm trying to learn how to use it so couple of questions. Can the Arduino support reverse PWM or can it only output values from 0-255 so only one direction? Would the PWM output be compatible with Jaguars, Victors and the VEX motor controllers? Would this be only in one direction?

I know that the RobotOpen shield gives ability to use the digital side car but is it worth the price?

Last edited by sand500 : 26-05-2012 at 17:20.
  #2   Spotlight this post!  
Unread 26-05-2012, 14:38
sjspry sjspry is offline
Registered User
FRC #1984
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Kansas
Posts: 125
sjspry has a spectacular aura aboutsjspry has a spectacular aura aboutsjspry has a spectacular aura about
Re: Arduino PWM output

To figure out if the analogWrite() function's default frequency and range of duty cycles is compatible with the Jaguars or Victors, you will need to read the data sheet and compare to what the Arduino documentation says. There's also the robotopen project, which seems to have done work with this.

If I had to guess, I would say no, the analogWrite() function will not be compatible with the Jaguars. Why? The code I've seen to control a hobby servo from the same port you can control a Jaguar from sets up the port the same way, and hobby servos do not actually use "PWM". They use pulse-position modulation, which is different.

So what I can suggest, if you need something to happen quickly, is looking for the Arduino Servo library and using that to generate the signal to feed the Jaguar.

For future reference, please know that "PWM" is often used to (some would say incorrectly) refer to about three different things:

1) pulse-width modulation (PWM), where the duty cycle of a fixed frequency signal is varied (what the analogWrite() function does);
2) pulse-position modulation (PPM), which has a fixed-time pulse separated by variable time pulses for the values (750µs to 2400µs, used in the VEX controllers and by hobby servos, and other various motor controllers);
3) pulse-length modulation (PLM, other), used in simple IR remote controls and usually proprietary thingies. Not very common. Usually a dead time of 600µs followed by a 1 (1200µs) or 0 (600µs), repeat as necessary.
  #3   Spotlight this post!  
Unread 26-05-2012, 15:56
NickE's Avatar
NickE NickE is offline
_
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: San Jose, CA
Posts: 620
NickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond repute
Re: Arduino PWM output

The standard Arduino PWM will likely not work with Victors. Check out the myservo.write() function in the Arduino Servo Library. The Arduino software should have a servo example which should work with the Victors.

Last edited by NickE : 26-05-2012 at 17:55.
  #4   Spotlight this post!  
Unread 26-05-2012, 16:18
Dad1279 Dad1279 is offline
Registered User
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: NJ
Posts: 511
Dad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud of
Re: Arduino PWM output

The same PWM code that controls a servo for Arduino will work to drive a speed controller. Disconnect the power (red) lead of a std pwm cable, just connect the white (signal) and ground.

Motor is off when servo receives the same signal as 'centering' a servo (90 degrees) 'Zero degrees' is full reverse to the motor, 180 degrees full forward. Signal should look like this:


Another very good explanation is here:http://team358.org/files/electrical/PWMGenerator.pdf

Last edited by Dad1279 : 26-05-2012 at 16:24.
  #5   Spotlight this post!  
Unread 26-05-2012, 17:20
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: Arduino PWM output

Quote:
Originally Posted by sjspry View Post
To figure out if the analogWrite() function's default frequency and range of duty cycles is compatible with the Jaguars or Victors, you will need to read the data sheet and compare to what the Arduino documentation says. There's also the robotopen project, which seems to have done work with this.

If I had to guess, I would say no, the analogWrite() function will not be compatible with the Jaguars. Why? The code I've seen to control a hobby servo from the same port you can control a Jaguar from sets up the port the same way, and hobby servos do not actually use "PWM". They use pulse-position modulation, which is different.

So what I can suggest, if you need something to happen quickly, is looking for the Arduino Servo library and using that to generate the signal to feed the Jaguar.

For future reference, please know that "PWM" is often used to (some would say incorrectly) refer to about three different things:

1) pulse-width modulation (PWM), where the duty cycle of a fixed frequency signal is varied (what the analogWrite() function does);
2) pulse-position modulation (PPM), which has a fixed-time pulse separated by variable time pulses for the values (750µs to 2400µs, used in the VEX controllers and by hobby servos, and other various motor controllers);
3) pulse-length modulation (PLM, other), used in simple IR remote controls and usually proprietary thingies. Not very common. Usually a dead time of 600µs followed by a 1 (1200µs) or 0 (600µs), repeat as necessary.
Yea I understand that PWM controls the speed of the motors, but I dont know if the duty cycle of the arduinos are the same as what a jag and victor takes.
  #6   Spotlight this post!  
Unread 26-05-2012, 18:19
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Arduino PWM output

Quote:
Originally Posted by sand500 View Post
Yea I understand that PWM controls the speed of the motors, but I dont know if the duty cycle of the arduinos are the same as what a jag and victor takes.
Check out the writeMicroseconds function. Snippet from my code that controls a jaguar (working and controls a robot and stuff):
Code:
Servo jag;
    jag.attach(9);
    int8_t jagspeed

    // ... set jagspeed to a value from -100 to 100

    // Jag datasheet says it wants a puse between .67ms and 2.33ms
    jag.writeMicroseconds(map(jagspeed, -100, 100, 670, 2330));
  #7   Spotlight this post!  
Unread 26-05-2012, 18:25
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Arduino PWM output

Quote:
Originally Posted by sand500 View Post
Can the Arduino support reverse PWM or can it only output values from 0-255 so only one direction?
Although this has been implied, there is no such thing as reverse PWM. Duty cycles can be anywhere between 0 and 255, with 0 being full reverse, 255 being forward, and a deadband in the middle for neutral.

Quote:
Originally Posted by sand500 View Post
Would the PWM output be compatible with Jaguars, Victors and the VEX motor controllers?
The Arduino PWM library will not. The Servo library will. See above for the reasons why.
Using the Servo library will give you the full range of control over a Victor. We have developed testing platforms which feed Arduinos an analog input to drive a Victor; no recalibration was necessary, but the code had to be tweaked a little.
You will have to either recalibrate the Jaguar or adjust the methods found in the Servo library to achieve a full range of control.

Quote:
Originally Posted by sand500 View Post
I know that the RobotOpen shield gives ability to use the digital side car but is it worth the price?
You don't need RobotOpen for a task like this. RobotOpen is designed to replace a cRIO, allowing teams to work with a larger budget and replace the core of their control systems with little hassle.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #8   Spotlight this post!  
Unread 26-05-2012, 22:37
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Arduino PWM output

At least for running Victors, you'll need a Signal Driver or create equivalent functionality, using a FET or similar. Not sure if Jaguars have the same requirement.
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
  #9   Spotlight this post!  
Unread 27-05-2012, 00:28
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 646
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
Re: Arduino PWM output

As stated above, a RobotOpen Shield is all about building a more complete control system that uses wifi to send wireless commands.

You can definitely control both Victors and Jaguars using an Arduino straight out of the box. This robot and this robot were created before we invented RobotOpen. They both use Arduino as the basis for their control system.

The complete code used can be downloaded here.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
  #10   Spotlight this post!  
Unread 27-05-2012, 00:51
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: Arduino PWM output

Quote:
Originally Posted by ajlapp View Post
As stated above, a RobotOpen Shield is all about building a more complete control system that uses wifi to send wireless commands.

You can definitely control both Victors and Jaguars using an Arduino straight out of the box. This robot and this robot were created before we invented RobotOpen. They both use Arduino as the basis for their control system.

The complete code used can be downloaded here.
are there any built in ways to communicate to a java program running on a computer via ethernet and ip? java has sockets but can arduino support that? Also, can I2C be used to communicate a arduino to crio
  #11   Spotlight this post!  
Unread 27-05-2012, 08:55
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Arduino PWM output

Quote:
Originally Posted by sand500 View Post
are there any built in ways to communicate to a java program running on a computer via ethernet and ip? java has sockets but can arduino support that? Also, can I2C be used to communicate a arduino to crio
No, you also need the Ethernet Arduino if you plan to use RobotOpen with ethernet. The Arduino will then support networked connections.

Yes, I2C can be used with a an Arduino. The cRIO has no direct I2C output, but there are I2C ports on the DSC.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #12   Spotlight this post!  
Unread 27-05-2012, 11:49
JoshSmith JoshSmith is offline
LED Junkie
FRC #0111 (WildStang)
Team Role: Mentor
 
Join Date: May 2011
Rookie Year: 2009
Location: Arlington Heights
Posts: 16
JoshSmith is an unknown quantity at this point
Re: Arduino PWM output

Quote:
Originally Posted by sand500 View Post
are there any built in ways to communicate to a java program running on a computer via ethernet and ip? java has sockets but can arduino support that? Also, can I2C be used to communicate a arduino to crio
Quick note one this, it will take some modifications to get it to work (a "stock" Arduino Wire library will not work). And you can use an ethernet shield for your Arduino Uno if you want to get communications over ethernet working (this will still work with a RobotOpen shield if you ever want to add that).

Here is the relevant shield on sparkfun: http://www.sparkfun.com/products/9026

Last edited by JoshSmith : 27-05-2012 at 11:51.
  #13   Spotlight this post!  
Unread 27-05-2012, 14:23
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Arduino PWM output

Quote:
Originally Posted by JoshSmith View Post
Quick note one this, it will take some modifications to get it to work (a "stock" Arduino Wire library will not work). And you can use an ethernet shield for your Arduino Uno if you want to get communications over ethernet working (this will still work with a RobotOpen shield if you ever want to add that).

Here is the relevant shield on sparkfun: http://www.sparkfun.com/products/9026
AFAIK we used the "stock" Arduino Wire library on this year's competition robot to communicate the shooter angular velocity with the cRIO.

We just had to use the transaction method of the I2C class.

relevant part of our code:
Code:
UINT8 valuesGotten[2] = {0, 0};
I2CArduino->Transaction(NULL, 0, valuesGotten, 2);
UINT16 fullNumber = (valuesGotten[1] << 8) | valuesGotten[0];
Full code for reading our sensor is attached. I don't currently have access to the arduino side, though.
Attached Files
File Type: zip ArduinoCommunication.zip (1.2 KB, 23 views)
  #14   Spotlight this post!  
Unread 27-05-2012, 21:06
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: Arduino PWM output

Quote:
Originally Posted by JoshSmith View Post
Quick note one this, it will take some modifications to get it to work (a "stock" Arduino Wire library will not work). And you can use an ethernet shield for your Arduino Uno if you want to get communications over ethernet working (this will still work with a RobotOpen shield if you ever want to add that).

Here is the relevant shield on sparkfun: http://www.sparkfun.com/products/9026

Both RobotOpen and the Ethernet Shield are a little bit expensive for personal use. If our team needs it next year, I guess we could use them. But using just the Ethernet Shield might be another possibility because we have our custom java dashboard so if we want, we might decide to ditch the CRIO and FRC system for our practice bots.
  #15   Spotlight this post!  
Unread 27-05-2012, 22:16
Michael Hill's Avatar
Michael Hill Michael Hill is online now
Registered User
FRC #3138 (Innovators Robotics)
Team Role: Mentor
 
Join Date: Jul 2004
Rookie Year: 2003
Location: Dayton, OH
Posts: 1,568
Michael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond repute
Re: Arduino PWM output

If you read the datasheet for Victors, you'll notice that they accept a "servo" PWM signal. Hence why you must use the servo library for Arduino.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 19:17.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi