Which pins can't be used when using the Wifi board?

Discussion related to "under the hood" OpenMV topics.
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Which pins can't be used when using the Wifi board?

Postby zlite » Fri Mar 24, 2017 2:50 pm

When you're stacking add-on boards, I assume there can be conflict between shared pins. I've looked at the Wifi board schematic and can see which pins are connected, but am not sure how they're used in the software and if those pins are totally out of commission for any other use if that board is attached.

In particular, I want to use the three PWM pins (p7-p9), the ADC pin (p6) and ideally four digital pins (high/low, p2-p4) to set motor direction on H-bridge motor driver. Does using the WIfi board take those pins out of commission?

(apols if there's a pin conflict matrix table somewhere that I've missed)
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Fri Mar 24, 2017 3:58 pm

So, here's the image:

http://cdn.shopify.com/s/files/1/0803/9 ... 1057263430

It looks like more or less all pins are in use. You can't just multiplex these pins without some issues for the wifi.

I'd just send serial data to an arduino to control the motors. Not ideal but it seems you'll have to do that for now.

(The next gen OpenMV Cam will solve this problem - but, until then).

...

Alternatively, instead of using the WiFi shield if you can just use a zigbee or ble module for debug that will only takeup 2 pins.
Nyamekye,
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Fri Mar 24, 2017 4:02 pm

wifi-pinout.png
wifi-pinout.png (847.93 KiB) Viewed 15857 times
Looking more at this, it looks like the WiFi board does nuke most of those other pins. It would be a bummer if it actually does disable two of the three PWMs (P7 and P8) and the ADC (P6) in operation. Am I reading that right?

-c
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Fri Mar 24, 2017 4:08 pm

Got it. That (serial to an Arduino to control motors and servos) was the way I had it before, but I was seduced by the extra PWM pin in the M7 and thought I could now do it all with one board. So be it -- back to Plan A while I wait for the next board. If I have to have a second board, I'd rather have video over Wifi with the official board than just basic text debugging with a serial radio.

(I think this may explain why I was getting funky PWM before with the Wifi board on. Might be worth noting this conflict in the Wifi board listing/notes)

-c
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Fri Mar 24, 2017 5:33 pm

I'll add video support to the firmware in a bit. It's a very easy add. I just haven't done it.

Um, I'll do that tomorrow morning.

Video support over blue/zigbee, etc.
Nyamekye,
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Sat Mar 25, 2017 1:04 pm

Hi here's a version of the firmware for the M7 camera which has the image streaming feature.

Just do:

print(img.compressed_for_ide(), end='') # works if you are connecting to the camera via usb or VCP to an "Open Terminal" window.

or

uart.write(img.compressed_for_ide())
spi.write(img.compressed_for_ide())
i2c.write(img.compressed_for_ide())

etc.

To send a compressed image. The "Open Terminal" window will automatically decode and display the image.

...

What compressed_for_ide() does is to send the binary data in 6-bit chunks. This makes the data to send larger but maps everything into a safe non-display character area 128-191. This allows for data transport over serial without the possibility of data being confused for printable characters.

If you were to just try to send JPEG compressed data otherwise it would work out horribly. The state machine in OpenMV IDE for parsing the data is robust so images can be but off mid stream and they won't break anything. You should literally be able to connect to a camera streaming image data at any point in time and everything should just work. No syncing required.

...

Finally, run your serial link faster than 1 Megabaud. Images are large...
Attachments
firmware.zip
(755.88 KiB) Downloaded 143 times
Nyamekye,
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Sat Mar 25, 2017 8:22 pm

Sweet! I've got to spin a custom shield for the cam one way or another to do both wifi and robot control. Given what you've now done, which of these two makes more sense?

1) Custom Arduino shield that communicates with the OpenMV via UART 3 and adds a bunch of I/O (downside: need to program the Arduino as well as the OpenMV)
2) Custom WIfi shield based on something like the ESP286 that just uses UART 1 and doesn't block all the other pins like the official shield (downside: can't control web server natively with OpenMV)

-c
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Sun Mar 26, 2017 1:26 pm

I'd use some serial to wireless solution that has a high baud rate. Like, you'll want to drive the uart on the OpenMV Cam at 2-3 megabuad. So, maybe the EPS32 or a bluetooth wireless chip.

Edit:

Upon examination on the market for high speed wireless stuff everything is slow except our wireless shield we already sell...

It looks like the zigbee wifi module using the AT command set is the best serial wifi solution. But, you'd have to spend some effort setting up the wifi module then.

...

Yeah, option 1 basically. I'd just buy a motor controller board you can talk serial to to drive the motors. This way you don't have to write any of that software. Then use the WiFi shield for high speed communication so you can stream images. Using a motor controller board makes sense too given the OpenMV Cam might not be driving the I/O perfectly.

Get a motor controller that talks serial... or i2c if you can't find one that does serial.
Nyamekye,
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Sun Mar 26, 2017 5:41 pm

Great. Option 1 it is. I'll share the design files later today
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Sun Mar 26, 2017 11:45 pm

Here's the first pass at an Arduino shield (using the Arduino Mini)

https://circuits.io/circuits/4446963-op ... ino-shield
Attachments
OpenMV_Arduino_shield___Autodesk_Circuits.png
OpenMV_Arduino_shield___Autodesk_Circuits.png (119.71 KiB) Viewed 15832 times
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Mon Mar 27, 2017 12:05 am

The tricky bit will be how to handle the 3.3v vs 5v issue between the Cam and the Arduino. The Arduino Mini comes in a 3.3v variant, which is probably the way to go, but I'm slightly worried about plugging 5v ESCs/BECs into that servo rail to power the servos. Alternatively, I can use the 5v Arduino Mini, which is very happy with 5v servos, but then I've got 3.3v Arduino serial logic talking to 5v serial logic on the Cam, which is a probably no-no.

On balance, I'm guessing the 3.3v Arduino is the better of the two options. What do you think?
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Mon Mar 27, 2017 1:18 am

The OpenMV Cam outputs 3.3v and can handle 5v. So, use the 5v Arduino.
Nyamekye,
User avatar
deshipu
Posts: 74
Joined: Sat Jan 09, 2016 5:36 am
Location: Zürich
Contact:

Re: Which pins can't be used when using the Wifi board?

Postby deshipu » Mon Mar 27, 2017 3:46 am

You probably want to power the servos and ESCs from the VIN pin, and not from the 3.3V pin on the OpenMV anyways, and you can have 5V there. I'm doing a similar thing in my hexapod robot for controlling the servos -- I'm using a 3.3V Pro Mini, which I power through the RAW pin with 5V, together with the OpenMV and the servos. The servos don't mind getting 3.3V control signal.

If you try to power the servos from the 3.3V regulator on the OpenMV or the Pro Mini, you are going to burn those regulators -- they can't handle more than maybe 200mA.
User avatar
deshipu
Posts: 74
Joined: Sat Jan 09, 2016 5:36 am
Location: Zürich
Contact:

Re: Which pins can't be used when using the Wifi board?

Postby deshipu » Mon Mar 27, 2017 3:49 am

By the way, I'm working on a PCA9685-based servo shield for the OpenMV, maybe that would be more useful?
shot.png
shot.png (225.95 KiB) Viewed 15829 times
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Mon Mar 27, 2017 10:39 am

Nice looking board! The reason I'm using an Arduino is that I'm also using the OpenMV Wifi board, which conflicts with almost all the pins but UART3, so I only output serial. Also I need to have some ADCs in for sensor reading. And I only need 2-3 servos.

I'm guessing that your board isn't designed to work alongside the Wifi board?
User avatar
deshipu
Posts: 74
Joined: Sat Jan 09, 2016 5:36 am
Location: Zürich
Contact:

Re: Which pins can't be used when using the Wifi board?

Postby deshipu » Mon Mar 27, 2017 10:52 am

My board uses I2C on pins P4 and P5 for communication. Looking at the picture at the top, those pins seem to be free, but I didn't test it yet.
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Mon Mar 27, 2017 11:01 am

P4/P5 are the UART/I2C pins.
Nyamekye,
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Mon Mar 27, 2017 1:34 pm

As you suggested, I've tweaked the design to power the PWM rail from the shared VIN/Raw of both OpenMV and the Arduino, rather than VCC, to avoid stressing the power regulators.
Attachments
Screenshot 2017-03-27 at 10.10.35 AM.png
Screenshot 2017-03-27 at 10.10.35 AM.png (150.54 KiB) Viewed 15820 times
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Mon Mar 27, 2017 3:45 pm

I'm confused at the pinout of the shield. It looks like you're connecting to pins used by the SPI bus for data transfer. Please double check the pin layout. http://docs.openmv.io/_images/pinout.png. It looks like you're connecting to UART 1 which is in use by the SPI bus. You want UART 3.
Nyamekye,
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Mon Mar 27, 2017 5:58 pm

Good catch! Fixed
Attachments
Screenshot 2017-03-27 at 2.57.40 PM.png
Screenshot 2017-03-27 at 2.57.40 PM.png (136.2 KiB) Viewed 15818 times
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Mon Mar 27, 2017 6:42 pm

Um, so is the image flipped? This mounts upside down?
Nyamekye,
User avatar
kwagyeman
Posts: 4658
Joined: Sun May 24, 2015 2:10 pm

Re: Which pins can't be used when using the Wifi board?

Postby kwagyeman » Mon Mar 27, 2017 6:43 pm

Wait, I think you need to swap the TX and RX pins. The TXO pin of the Arduino is connected to the TX pin of the OpenMV Cam. I think you want the TX pin ont he OpenMV Cam connected to the RXI pin on the Arduino.
Nyamekye,
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Mon Mar 27, 2017 11:49 pm

Yes, the shield is back-to-back with the OpenMV, so you can get access to the Arduino reset button and the PWM pins. I think I've got the RX and TX pins right. I've labelled the OpenMV pins now so it should be easier to follow:
Attachments
Capture.PNG
Capture.PNG (127.89 KiB) Viewed 15815 times
User avatar
deshipu
Posts: 74
Joined: Sat Jan 09, 2016 5:36 am
Location: Zürich
Contact:

Re: Which pins can't be used when using the Wifi board?

Postby deshipu » Tue Mar 28, 2017 4:00 am

I would consider using I2C instead of UART. You have the A4 and A5 pins free on the Arduino, so you can make it into an I2C slave. This way you can connect more things to those two pins.

Here's an example of a Pro Mini-based servo controller that uses I2C for communication: https://hackaday.io/project/9131-servo-controller (click on the 'code repository' to see the Arduino sketch used). I think you could easily modify this to suit your needs.
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Tue Mar 28, 2017 2:49 pm

You're probably right, but I've been traumatized by years of fighting I2C glitches and timing bugs in drones and I've got a bit of PTSD there (we now have a rule to only use SPI for mission critical stuff and we use Serial for everything else). At the end of the day, I always come back to Serial, which always works with every hardware combination I throw at it. It's like English -- not a great language, but ~everyone can speak it.

To be clear, I2C is very good for driving motors and servos. But I need this module to read sensors, too, and we've had trouble with I2C timing glitches introducing sampling biases in sensors. That's why we won't use it for any mission critical sensing.
User avatar
deshipu
Posts: 74
Joined: Sat Jan 09, 2016 5:36 am
Location: Zürich
Contact:

Re: Which pins can't be used when using the Wifi board?

Postby deshipu » Wed Mar 29, 2017 3:42 am

I suppose you could use the same SPI bus as the wifi shield uses, and use one of the free pins as CS...
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Fri Apr 07, 2017 10:11 pm

Here's the real thing. So far so good!
Attachments
IMG_20170407_185651.jpg
IMG_20170407_185651.jpg (599.66 KiB) Viewed 15732 times
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Sat Apr 08, 2017 2:26 pm

Slight update. I decided to move the Serial Rx and Tx pins on the Arduino that talk to the OpenMV to SoftwareSerial on Pins 2 and 3, so you can still use the hardware serial Rx and Tx pins for the FTDI cable to program it and monitor serial output while it's attached to OpenMV:
Attachments
Capture.PNG
Capture.PNG (149.92 KiB) Viewed 15720 times
User avatar
deshipu
Posts: 74
Joined: Sat Jan 09, 2016 5:36 am
Location: Zürich
Contact:

Re: Which pins can't be used when using the Wifi board?

Postby deshipu » Sat Apr 08, 2017 3:19 pm

Shame you didn't move them to A4 and A5, then you would have the option for I²C :)
zlite
Posts: 73
Joined: Sun Feb 05, 2017 9:26 pm

Re: Which pins can't be used when using the Wifi board?

Postby zlite » Sat Apr 08, 2017 4:20 pm

BTW, I tried both 3.3v and 5v Ardiuno Minis and they both worked fine (I guess the logic lines are tolerant of both). So might as well go with the 5v and get the faster clock speed
Drews
Posts: 1
Joined: Mon Jul 10, 2017 8:58 am

Re: Which pins can't be used when using the Wifi board?

Postby Drews » Mon Jul 17, 2017 2:28 am

deshipu wrote:
Sat Apr 08, 2017 3:19 pm
Shame you didn't move them to A4 and A5, then you would have option for I²C :)
Good idea, I'm going to give that a try on my project.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest