User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Thu Sep 27, 2012 12:10 am

Grumpy Mike wrote:
Can some explain SDA and SCL channels to me
These are the two signals Serial DAta and Serial CLock that are used in the I2C interface. Nothing to do with the PWM.

GPIO 18 can be assigned to be PWM0, the other PWM output, PWM1, can be assigned on the following pins:-
GPIO 13
GPIO 19
GPIO 41
GPIO 45
None of which are brought out on P1 or P5 of the issue 2 Pi.
If want to control a two motors using a double H-bridge, Which pins do I connect to? On the E14 forum, I am working with someone of a motor project and this is what he suggested:
Image
As you can see in the diagram, he has put the controls through SDA +SCL on pins 3 and 5. Will this give me varible speed control of the motors?

http://www.element14.com/community/mess ... rt=0#60348

User avatar
Grumpy Mike
Posts: 938
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: P5 Pinout partial information!

Thu Sep 27, 2012 9:38 am

Will this give me varible speed control of the motors?
No.
It looks like he is just using these pins as GPIO pins and you could use any two.

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Thu Sep 27, 2012 9:48 am

Grumpy Mike wrote:
Will this give me varible speed control of the motors?
No.
It looks like he is just using these pins as GPIO pins and you could use any two.
How can I get varrible speed control?

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Thu Sep 27, 2012 10:57 am

Ok. I just read this article: https://projects.drogon.net/raspberry-p ... m-library/ Which says this:
WiringPi includes a software-driven PWM handler capable of outputting a PWM signal on any of the Raspberry Pi’s GPIO pins.
Is this even possible? From what you said above...
Grumpy Mike wrote:
Will this give me varible speed control of the motors?
No.
It looks like he is just using these pins as GPIO pins and you could use any two.
...What the article says is total rubbish. Can you clarify if PWM can be done on ONLY the ONE Pulse Width Modulation channel or on any of the Raspberry PI's GPIOs.

User avatar
Grumpy Mike
Posts: 938
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 1:20 pm

What the article says is total rubbish
I think not.
Can you clarify if PWM can be done on ONLY the ONE Pulse Width Modulation channel or on any of the Raspberry PI's GPIOs.
Hardware PWM can only be done on one channel.
Software PWM can be done on any channel.

Do you appreciate the difference between software and hardware PWM?

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Fri Sep 28, 2012 1:32 pm

Grumpy Mike wrote:
What the article says is total rubbish
I think not.
Can you clarify if PWM can be done on ONLY the ONE Pulse Width Modulation channel or on any of the Raspberry PI's GPIOs.
Hardware PWM can only be done on one channel.
Software PWM can be done on any channel.

Do you appreciate the difference between software and hardware PWM?
I understand now. The software version is 'weak' compared to the hardware version. The Software PWM will not work for motors very well; I read through the rest of the article and this seems to be the case.

User avatar
Grumpy Mike
Posts: 938
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 4:56 pm

The Software PWM will not work for motors very well;
Yes it might stutter a bit but try it, it could suit your.

User avatar
jbeale
Posts: 3716
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 6:20 pm

The best-performing solution, assuming you need more than one PWM channel for motor speed control (or anything else) is to use a separate chip to do the PWM, which you control via I2C or SPI from the Pi. This is the standard approach to hardware control, you use a separate low-level part that is suited to "real time control" and then the main multi-tasking processor (the Pi, in this case) just gives it the directions, without needing microsecond timing accuracy on I/O.

For example, this board https://www.adafruit.com/products/815 has 16 PWM outputs and you can control it with one I2C link. Its PWM frequency is adjustable up to 1.6 kHz, which may or may not be suitable for your requirements.

User avatar
jbeale
Posts: 3716
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 6:57 pm

By the way Grumpy_Mike, I updated your P1 pinout graphic on the elinux wiki to show all the previously-marked-DNC pins. Given that Eben said these pins will stay as they are, we might as well show the actual connections, I find it quite useful to have the extra ground connections as I'm wiring various things up on the fly. I also made the UART pins yellow to match the table; before they were orange like the 3V3 pin.

http://elinux.org/RPi_Low-level_periphe ... .28GPIO.29

User avatar
Grumpy Mike
Posts: 938
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 7:42 pm

jbeale wrote:By the way Grumpy_Mike, I updated your P1 pinout graphic on the elinux wiki to show all the previously-marked-DNC pins. Given that Eben said these pins will stay as they are, we might as well show the actual connections, I find it quite useful to have the extra ground connections as I'm wiring various things up on the fly. I also made the UART pins yellow to match the table; before they were orange like the 3V3 pin
Well he only said they would stay as they are on revision 2. They still could be used in future. Would it not be better to have these still as a do not connect but put the fact that they are in fact power and ground in the hardware notes column?
Yes I find the extra grounds useful but I would not use them in a PCB layout.
Cheers

User avatar
jbeale
Posts: 3716
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 8:13 pm

JohnB: "...does that mean we can rely on the “DNC” pins on P1 being connected to ground?"
Eben on September 5, 2012 at 4:52 pm said: "Yes (note – 5V and 3V3 for some of the pins)."
http://www.raspberrypi.org/archives/1929#comment-31646
My take on "Yes [you can rely on it]" means that we can rely on it for now and in the future. If he was planning to change it later, I assumed he would have said so, but I don't know how to get further clarification as Eben only posts rarely in the forum. Maybe JamesH could weigh in...?

I also recall a comment from one of the Foundation members that it was a difficult choice to change the three P1 pins they did change for Rev2, but that no further changes would be made to P1. Unfortunately I can't find that reference so maybe I imagined it.

User avatar
jbeale
Posts: 3716
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: P5 Pinout partial information!

Fri Sep 28, 2012 9:26 pm

According to Liz: "They're not DNC anymore" and "barring catastrophe, Eben says he doesn’t expect to change the pinout connector." http://www.raspberrypi.org/archives/2081#comment-33577

And I infer that even if there was a catastrophe, the pins that change might not be the previously-DNC pins anyway, just like the P1 change from Rev.1 -> Rev.2 in fact. So I conclude the current full pinout image shown for Rev.1 P1 on the eLinux wiki is fine for now. (Except it would ideally show the Rev.2 pinout also)

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Sat Sep 29, 2012 3:11 am

jbeale wrote:The best-performing solution, assuming you need more than one PWM channel for motor speed control (or anything else) is to use a separate chip to do the PWM, which you control via I2C or SPI from the Pi. This is the standard approach to hardware control, you use a separate low-level part that is suited to "real time control" and then the main multi-tasking processor (the Pi, in this case) just gives it the directions, without needing microsecond timing accuracy on I/O.

For example, this board https://www.adafruit.com/products/815 has 16 PWM outputs and you can control it with one I2C link. Its PWM frequency is adjustable up to 1.6 kHz, which may or may not be suitable for your requirements.
This seems to be the solution coming from the E14 Forums as well.

How will I be able to get this to work? I don't know much about how these chips/ICs work - coding wise/programming them.

Could someone please explain how the SPI/I2C works? I have ordered a gertboard and I Know that the ATMEGA on there which has 6 PWM channels. How does the code work for this chip inparticular? I know that it is not hard to wire the motors etc to it but the coding side will be challenging for me.

Any help will be much apreciated. Thanks in advance.

DogEars
Posts: 44
Joined: Sun Jun 17, 2012 1:16 pm

Re: P5 Pinout partial information!

Sat Sep 29, 2012 11:02 am

Grumpy Mike wrote:I used the bent pin header that mahjongg posted.
I've got a shrouded version of the bent pin header, I've had to grind the P1 pins away a little bit with a dremel to get it sit flush but it looks good now I've done that!

The only problem is the soldering.. did you have to use a particularly fine tip to solder it in, I've not soldered since I was at school (about 23 years ago, that makes me sound old!) doesn't the tip of the iron have to touch both the track and the header to heat both surfaces before introducing the solder?

if that is the case my existing soldering iron with a conical point with a flat tip of about 0.8-1mm is too fat, I think?

Cheers,
Ears.

DogEars
Posts: 44
Joined: Sun Jun 17, 2012 1:16 pm

Re: P5 Pinout partial information!

Sat Sep 29, 2012 3:35 pm

Here, I've uploaded some images:
Clockwise from top left:
  • Gound down the P1 pins that interfere with my header.
    The header in-situ
    My soldering iron tip looks huge in that image!
    The tiny pins visible from the top of the board ready for soldering
Image
In the last picture it appears that the iron tip wont touch the track, will it work?
The following originals are available but a bit big!
one, two, three, four.

User avatar
Grumpy Mike
Posts: 938
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: P5 Pinout partial information!

Sat Sep 29, 2012 9:02 pm

That iron looks like it will be alright. Wet the end first, that means put a little solder on it, so you have a very small blob of solder on the tip. That will make it thermally connect to both the pin and the track. Then apply a little solder, keep the iron on until you see the solder sucked down into the hole. Apply a spot more and remove the iron.

According to Liz: "They're not DNC anymore"
OK good enough for me, it will be handy to be able to finally use them.
Could someone please explain how the SPI/I2C works? I
Big ask for a reply, you can write whole books on both subjects. They are similar protocols but totally incompatible. Basically data is sent one bit at a time on a data line, and it is transferred to the receiving device at the instant the clock signal makes a certain transition. There are drivers for both on the Pi so you don't have to go into the detail of exactly how it works.
How does the code work for this chip inparticular?
It works like an arduino so when you write code for it a simple analogWrite(pin, value) will set the PWM going at the duty cycle of value (0 to 255) on pin number pin.
This is how PWM works http://www.thebox.myzen.co.uk/Tutorial/PWM.html

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Sun Sep 30, 2012 1:36 am

I will look at this stuff later. Thanks for the reply.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13370
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: P5 Pinout partial information!

Sun Sep 30, 2012 2:19 am

Could someone please explain how the SPI/I2C works?
Wikipedia has the basics.

http://en.wikipedia.org/wiki/Serial_Per ... erface_Bus
http://en.wikipedia.org/wiki/I2C

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Sun Sep 30, 2012 9:01 am

mahjongg wrote:
Could someone please explain how the SPI/I2C works?
Wikipedia has the basics.

http://en.wikipedia.org/wiki/Serial_Per ... erface_Bus
http://en.wikipedia.org/wiki/I2C
Thanks.

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: P5 Pinout partial information!

Tue Oct 23, 2012 6:36 am

Grumpy Mike wrote:That iron looks like it will be alright. Wet the end first, that means put a little solder on it, so you have a very small blob of solder on the tip. That will make it thermally connect to both the pin and the track. Then apply a little solder, keep the iron on until you see the solder sucked down into the hole. Apply a spot more and remove the iron.

According to Liz: "They're not DNC anymore"
OK good enough for me, it will be handy to be able to finally use them.
Could someone please explain how the SPI/I2C works? I
Big ask for a reply, you can write whole books on both subjects. They are similar protocols but totally incompatible. Basically data is sent one bit at a time on a data line, and it is transferred to the receiving device at the instant the clock signal makes a certain transition. There are drivers for both on the Pi so you don't have to go into the detail of exactly how it works.
How does the code work for this chip inparticular?
It works like an arduino so when you write code for it a simple analogWrite(pin, value) will set the PWM going at the duty cycle of value (0 to 255) on pin number pin.
This is how PWM works http://www.thebox.myzen.co.uk/Tutorial/PWM.html
Ok, The Gertboard has arrived and I need some help with the coding for ATMEGA.

I have written a sketch (not working yet) for an Ardunio Uno, which uses the ATMEGA368 (same as Gertboard). I was wondering if the sketch would be the same for both ATMEGA's?

Return to “Interfacing (DSI, CSI, I2C, etc.)”