Raspberry Pi and co-op communication.

Questions and discussions about our Arduino add-on board for the Raspberry Pi

Raspberry Pi and co-op communication.

Postby Maximus789 » Thu Dec 11, 2014 10:28 am

Morning,

I was hoping someone would be able to clarify what pins are used to communicate between the co-op and the pi? Does this mean the remaining pins are all available to use as normal?

I have got the board up and running using the examples which were simple even for a noob :oops: !

I haven't tried, but is it possible to use share variables in real time? For example connecting a sensor to the Pi and using co-op to control a servo?

Any help will be much appreciated

Max
Maximus789
 
Posts: 7
Joined: Thu Dec 11, 2014 10:22 am

Re: Raspberry Pi and co-op communication.

Postby Alan » Thu Dec 11, 2014 11:24 am

Hi Max,

Welcome to the forum. :)

You can see the pins that are used by the Pi Co-op by looking at the schematic linked to on the product page, and then comparing it to the Pi GPIO pins. It can be a bit hard to read if you're not used to schematics, but the important part to look at is the 13x2 connector in the bottom left corner. This shows that the pins used are the TX and RX lines (the serial UART lines on the Pi GPIO), along with GPIO 22 which is used to trigger the RESET line of the Atmega328 pin.

All of the other GPIO pins are free for you to use, and the 5V, 3.3V and GND pins can be shared between the Pi Co-op and other peripherals.

In terms of 'sharing variables' i.e. reading sensor with a Pi and controlling a servo with the Co-op this should be really easy with PyMata as you can load up both PyMata and the RPi.GPIO library at the same time. If you've written your own Arduino sketch for the Pi Co-op then it's still possible, you just need to use a library like PySerial to pass data to and from the Pi Co-op over a serial connection.

Hope that helps. If you need more detail on any area, please let me know.

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am

Re: Raspberry Pi and co-op communication.

Postby Maximus789 » Thu Dec 11, 2014 11:32 am

Thanks for such a quick reply. I will look into this when I have some free time, but thanks for your assistance.

I have just noticed that when you have an LED in pin 13 and the reset button is pressed it gives it an out put. Does this mean that an input should not be placed into pin 13? Is there a schematic for the pins on the co-op?

Max
Maximus789
 
Posts: 7
Joined: Thu Dec 11, 2014 10:22 am

Re: Raspberry Pi and co-op communication.

Postby Alan » Thu Dec 11, 2014 11:42 am

Yes,

The schematic linked to earlier also shows the LED attached to pin 13 (marked on the schematic as SCK).

Having an LED attached to pin 13 is fairly standard for an Arduino. It does make it harder to use it as an input but it's still possible, see here for details.

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am

Re: Raspberry Pi and co-op communication.

Postby Maximus789 » Sun Dec 28, 2014 11:54 pm

Evening,

I have tried to continue with my project and have become slightly confused with the schematic and the numbering system which python uses.

I have the code:
POTENTIOMETER = 0
firmata.set_pin_mode(POTENTIOMETER, firmata.INPUT, firmata.ANALOG)

Which I have adapted from on-line, my potentiometer is connected to A0 and I there is no indication on the schematic that A0 was 0. From the schematic I thought it was pin 23. I am confused to how the schematic relates to the referencing within Python. For example on the pi co-op board there is A2 and 2, so am slightly confused which one would be 2.

Any help would be appreciated.
Maximus789
 
Posts: 7
Joined: Thu Dec 11, 2014 10:22 am

Re: Raspberry Pi and co-op communication.

Postby Alan » Mon Dec 29, 2014 12:53 pm

Hi there,

Arduino pin naming can be a bit confusing I'm afraid, especially because it bears bery little relation to the numbering of pins on the microcontroller (which is what you see on the schematic).

The microcontroller on the Pi Co-op is an Atmel Atmega328, and you can download its datasheet here. In the datasheet you can see a pinout for the microcontroller, and these pin numbers are the ones that you see on the schematic. The diagram on this page shows the pin mapping from microcontroller pins to Arduino pins. This is largely arbitrary and was chosen by the people who wrote the Arduino libraries.

When using PyMata, you would just use the Arduino pin numbers, and software further down (on the Pi Co-op) will work out how to translate the pin numbers properly. PyMata will usually be able to work out whether 2 refers to digital pin 2, or A2 by the function you're calling, or other parameters. So for example, when you called set_pin_mode, you also said that the pin was analog so it knew to use A0. If you want to use A0 as a digital input you'd need to pass in 14 as the pin. This is calculated by using the table on this page.

Hope this is of some help, and not too confusing. :)

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am


Return to Pi Co-op

Who is online

Users browsing this forum: No registered users and 0 guests