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?
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:
pulse-width modulation (PWM), where the duty cycle of a fixed frequency signal is varied (what the analogWrite() function does);
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);
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.
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.
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:
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):
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));
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.
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.
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.
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.
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.
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).
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.
Interesting. I know for this year I changed the Wire library to run at 38.4khz (what I was told was the digital sidecar’s operating frequency for I2C) and just set the Arduino up as a slave device and it worked nicely. But anyways, I will stop myself now before I get too far off-topic. My recommendation on the shields is that if you plan on making more robots than cRIOs, then you should look at a shield as they will be cheaper than spending credits or money on an extra cRIO. Otherwise, if you have a cRIO lying around, just use that (providing you have a backup for your competition bot).
I have a VEX Motor Module(3-wires) that our teacher had from a Vex Kit. I have the Arduino to slowly rise the PWM from 0-255 and then lower it down. What I have found is that the motor starts moving when the PWM is at around 40. I know that around 120, the motor starts slowing down and at 170, it stops completely. Once it is at 200, the motor starts again but in the opposite direction, slow at first but gets faster around 250. At 255, the motor stops completely and at 254, it starts again. Again the motor doesnt move when the PWM is between 200 and 170 and after that, it turns again in the original direction and stops at 40.
I dont know why this is happening but the duty cycle frequency was wrong, then why does it stop completely at 255? When I hook up the pwm and ground on the arduino to a regular dc motor that you would find in an electronics kit, the motor works just like how pwm should.
I’m not too familiar with the VEX system, so take what I say with a grain of salt, but here’s what I see happening:
The VEX motor module has built-in deadbands at 1) the neutral, which allows a user to feed a noisy joystick signal straight to the motor and 2) the ends, which either acts as a safety, to facilitate interfacing with the VEX system (due to hardware/programming constraints etc), or it was a design decision.
Hooking up this signal to a regular DC motor produces exactly that kind of behavior, not because it’s how your signal “should” behave, but because it’s how motors are expected to behave in response to such signals.
Why does the higher end of the pwm, have a smaller range, 200-255, while the lower end of the pwm has a bigger range, 40-170. When I was running the motor, I could see the motor hit a higher speed in the 40-170 range than in the 200-255. So why would a motor rotate faster in one direction than in another direction?