I have a number of questions that I hope you can answer for me:
I have the robot mostly built, it runs fine but I haven’t added any sensors yet. When I added the wifi shield to the board the LED labelled ‘PWR’ went red. What does this mean and how can I fix it.
I am aware a lot of the pins conflict between the arduino and the wifi shield so how do I work around this? The motor controls use pins 5 - 8 which should not conflict but I am unsure what pins the encoders use to access them. My question is what do I need to do to get the wifi shield working and what workarounds are required. In another post you said that to work around the pin 7 handshake that you should make sure the motors and the handshake are never happening at the same time and it should be ok
I’ll obviously have to mount the DFRobot I/O Expansion Shield for Arduino v7 on top of the wifi shield so how does this affect things? I won’t be able to hook the 5V and IOREF ports up with a M/M jumper if the expansion shield is on top so how do I work around that? Also do I need to bend or remove the VIN pin as you suggested in this post arduino-wifi-shield-not-present-on-dfrobot-roverv2-t11893
Rather than make a new topic I’ll ask here, I tried using the counting code from the user guide for the encoders but all that is printed to the serial monitor is 1’s. Do I need to do something special?
What pins will be free on the expansion shield for the ultrasonic range finder and the pan tilt servo. Note: I don’t intend to use the infrared sensor.
It sounds like a power issue or pin conflict issue. The 3.7V battery should go directly to Vin on the Arduino, so if the shield requires 5 via Vin, double-check that the DFRobotShop Rover is provifing 5V or instead 3.7V.
The encoders would ideally be plugged into analog pins 0 and 1. They are not fixed, but be sure the pinout is correct if you plug them into the shield as opposed to directly to the DFRobotShop Rover PCB.
Detail each pin used by the WiFi shield vs which pins are used (hardwired) on the DFRobotShop Rover PCB. If there is any overlap, you can flex the pins outward on the WiFi shield so they do not go to those pins and use wires to re-rout them. Note that you’ll also need to change the sample code for the WiFi shield.
The IO shield should not interfere with anything so long as you don’t use the same pins used by the WiFi shield or Rover.
The encoder wheel needs to be in place at around 1-2mm away from the sensor, the motor needs to be rotating. Also note that you need to follow the pinout from the encoder to the board to ensure that 5V plugs into the 5V lins, GND to GND and signal to signal.
You’ll need to make a table of which pins are used already by the DFRobotShop Rover, the Encoders and the WiFi shield to see which pins are left (and if you have enough).
Regarding the red LED being on. It wasn’t on when I first built the robot and had the robot running but when I added in the wifi shield it turned on. I removed the wifi shield and just went back to the base robot and the red LED stayed on. Could it be a faulty LED? The motors appear to run fine while it’s on regardless. I assume I will have enough power to power the motors, the ultrasonic range finder, the pan tilt servo and the wifi shield with the 4xAA battery pack. Please confirm.
Regarding the encoders, I’m still not sure which pins the encoder is meant to go to on the board. There are 2 pins on each side that have A0 and A1 beside them so are they meant to go over those 2 and take the 3rd pin also closest the center of the board or are the 3 encoder pins meant to line up with the length of the board. How do I know which pin is the 5v, the GND and the signal
You say the IO shield won’t interfere with anything but isn’t it required that you join the 5V and IOREF on the wifi shield using M/M jumpers to make the wifi shield work?
If pins 4, 7 and I believe 10-13 are taken up by the wifi shield I’m left with the analog pins and 1,2,3 which should be enough for the pan tilt and the ultrasonic range finder. Can ultrasonic range finder use analog pings or do I have to use digital.
Can you upload an image of which LED you are referring to? Note that if you are using the 4xAA battery pack instead of the LiPo, you need to remove the LiPo jumper at the left rear of the board.
The A0 and A1 pins on the DFRobotShop Rover itself (right behind the green screw terminals) are meant for the encoders and you should be able to connect them directly.
The IO shield should just provide additional reference lines (GND and V) and does not use any of the digital or analog pins.
Analog pins can function as digital, but you’ll need to either create your own code or really adapt the sample code. It’s really good to make up a small table to know which pins are being used where.
Here’s the image of the LED I’m speaking of. Note: robot is off as the glare from the LED and the blue lights was messing the picture up.
Is this the jumper you are telling me to remove if I’m using the 4xAA battery pack?
Is it the 3 pins inside the green boxes or the the pins in the red boxes that the encoder attaches to? I currently have them i nthe pins marked by the green box but it doesn’t seem to work. There is a cover of some sort over 2 of the 3 pins in the red boxes
The red LED for PWR should always be on when it’s powered.
Bingo. Leave it in place when using a 3.7V LiPo battery to charge it from the USB port. If not, remove.
The area you highlighted in green (one on either side of the board) is where to connect the encoder pins
The red area (with jumpers) is to simply disconnect the A0/A1 pins if you want to use them elsewhere.
There are three pins provided simply so you have somewhere to keep the jumper if you remove it (only two pins are really needed for a jumper).
Ensure the jumpers are in place next to the white silkscreen indicating A0 (and on the other side indicating A1), if not, those pins are not connected.
Next, ensure the encoder pinout matches the board (ground to GND, 5V to V and signal to S).
Thank you for your help so far. The encoders seem to be working now. Can you tell me how they work exactly? I’m running the ‘counting’ code from the manual and my serial monitor looks like this:
text removed which shows numbers progressing from 1 to 6 ]
Why does it spam the same number varying numbers of time?
Upon further inspection of my robot I’ve noticed that I have put the encoder discs on backwards so the brown side is facing the encoders. Will this impact the readings and should I take the robot apart and turn the white side to the encoders?
You need to remove the brown part from both sides - it’s only a protective sheet for the cutting process.
The sensor gives one value when it encounters a spoke from the white disc in front of it, and a different value when there is no obstruction.
This is essentially a “high” and “low” and the code counts the number of changes this happens. If the values you are seeing repeat themselves (i.e. stay the same), then the wheel is not turning fast.
I have the encoders reading values now and printing to the serial monitor.
Have any code or advice on how to use the encoder data to dynamically change the robots speed as I believe that is the entire point of having encoders otherwise the robot will arc off course over time.
For some reason when I attach the wifi shield on its own the motors will start and then stop immediately. However if I take off the wifi shield and put on the expansion board with 2x servos attached everything appears to run fine. Surely the wifi shield shouldn’t consume THAT much power.
You would be surprised. However, the LiPo battery should be able to discharge at up to 2A continuously with minimal drop in voltage.
The onboard voltage regulator however which power the microcontroller (and all of the corresponding IO pins) can only provide so much current, so that may be the real issue.
Try the WiFi shield without the servos and see what happens. This issue has come up a few times before, and we may change the voltage regulator on the next version to be able to provide more current.
The test was actually without the wifi shield which is why I was surprised. To use the LiPo battery I assume I reattach the back left jumper cover and plug the lipo into the port that the 4xAA batteries were plugged in.
Correct. Note that a USB port can provide up to 400mA, but the MAXI555 charging chip here does not use it at max current, so it takes a few hours to charge.
I’m using the LiPo battery now and have had it charing for about 8 hours. When I have JUST the wifi shield on the board and turn the power on to the board the lights all come on for a second and then the board cuts out. The back left jumper IS on.
I took the wifi shield off and put on the IO shield with 2 servos attached and it powers it fine.
Is the wifi shield somehow draining power or what’s going on here
It really seems to be a power issue: Since the LiPo battery can discharge at around 5A, it’s likely that the onboard regulator simply cannot provide enough current for that shield.
If you really want WiFi, do you have the possibility of using a WiFi Bee?
It’s not a matter of wanting it, I NEED the robot to be able to talk to the computer.
Perhaps you can suggest to me the best way to do this with the kit I have. I’m open to bluetooth if that’s a viable option. It’s short range communication only. The laptop will be within 15 meters of the robot as it does it’s thing.
It needs to be compatible with the IO expansion board and everything else that comes with the kit obviously regarding pins etc.
Also a supplementary question the pins that the encoders use, can they be used as interrupt pins because from what I’ve researched you need to use encoders with interrupts to effectively monitor the motors.
then no they didn’t come with my kit that I’m aware of at least.
If I’m to buy the antenna and the xbee usb adapter that you mentioned will that work for sure and what pins does it take up? Also is the code to communicate with it the same as for the wifi shield I have or different?
The XBee pins you circled are not part of most of the kits. The IO shield will work nicely with XBee.
It uses the serial pins D0 and D1.
No - you’ll find it’s significantly easier to use than the WiFi shield (virtually no setup - just send and receive commands normally via the serial pins).
You should not need to do any configuration at all - they should be set to the same baud rate and simply send and receive serial commands.