PWM pins in jumpers

All technical discussions and projects around startKIT
DavidHH
Junior Member
Posts: 4
Joined: Wed Nov 19, 2014 7:37 pm

PWM pins in jumpers

Post by DavidHH »

Hello everyone! I'm new with XCore and I'm looking for some XCore that provides my needs. I need to control several Servo Motors and to do that I need a lot of PWMs signals. I'm not sure if I can use the PWM signals that appears in the XS1-A8A-64-FB96-Datasheet. From page 74 to page 81 it shows two pins for PWM modulation in Jumpers 4 to 10.
The question is, Can I use this PWM's signals in the startKIT? Or I need to build my own board with an xCore?

Appreciate your help!



This is the Datasheet url:https://www.xmos.com/download/public/XS ... 1.3%29.pdf
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

The PWM references in the datasheets are about the PWM mode of the internal switching voltage regulators. They have nothing to do with regular PWM outputs.

With XMOS you usually implement your peripherals in software, including PWM.
You can use any port for it.

You may want to take a look at https://github.com/xcore/sc_pwm
DavidHH
Junior Member
Posts: 4
Joined: Wed Nov 19, 2014 7:37 pm

Post by DavidHH »

I read it before but I didn't understand very well how it worked, and it looked a bit strange for me that you could configure any pin as a PWM. But I don't understand when, in the readme file, says:
"PWM single bit component generates PWM signals on up to 16 1-bit ports from a single thread"
"PWM multi bit component generates the PWM signals on a single 4, 8 or 16 bit port."
What does it refer with PWM single bit and multi bit??

Thanks!
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

Unlike the average microcontroller, XMOS processors only have general purpose I/O (not counting ADC, and built-in USB in the newer chips). The physical I/O pins of a chip are multiplexed to ports.
These ports what you work with in the software. A port has a certain width, this can be 1, 4, 8, 16, 32 bits wide. Each port has a timer and you can also use clock blocks for more sophisticated timing behaviour. Add to this that ports can buffer (serialise / deserialize in the case of 1-bit width) incoming and outcoming data. Using these features one can implement sophisticated timing-accurate interfaces in software with low CPU usage (it is not bit-banging!).
DavidHH
Junior Member
Posts: 4
Joined: Wed Nov 19, 2014 7:37 pm

Post by DavidHH »

So I can work with several PWM signals with 1-bit width, isn't it?

And I suppose that the number of different PWM signals that I can run in parallel will depend on the ports that I use. Then, in J7 Header GPIO, different Ports are: P1F0, P1H0, P1G0, P1E0, etc. (P4C0 and P4C1 are the same I suppose), that means that I can run all that PWM signals?? Or each port is specified by its number (P1, P2, etc.)?

I haven't got the time to read the sc_pwm, but I suppose that it specify how to control a 0-100% PWM signal in 1-bit width.
User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1140
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

What PWM spec do you need - like any PWM source there is a tradeoff between bit depth and frequency. Some of the IP also has a tradeoff between channel count (for a single core function generating multiple PWM).
So I can work with several PWM signals with 1-bit width, isn't it?
Yes - there is IP to do that.
I haven't got the time to read the sc_pwm
- hmm, well I guess that's your choice. At least have a look at the header files and the app_pwm_xxx examples before you use it.

Also checkout http://www.xcore.com/questions/2848/i-require-8-pwm for an alternative.

PWM in XMOS is software driven with backup from some nice port features (buffers, serialisers, timers) and there are many ways to generate PWM, each with thier own pros and cons.

Knowing what it is you want to generate (channels, resolution, frequency, buffering, alignment..) and to drive what (LEDs... motors.. Servos etc.) would be useful so we can help point you at the right implementation.
DavidHH
Junior Member
Posts: 4
Joined: Wed Nov 19, 2014 7:37 pm

Post by DavidHH »

infiniteimprobability wrote:Knowing what it is you want to generate (channels, resolution, frequency, buffering, alignment..) and to drive what (LEDs... motors.. Servos etc.) would be useful so we can help point you at the right implementation.
I want to generate at least 3 PWM signals that runs in parallel to control multiple servos. What I want to make is that, first, 3 servos runs at the same time to different positions, and then, other 3 different servos runs at the same time to different positions. When I mean different positions it involves that each servo needs a different PWM signal. The Servos are analogue and the position change between 0 and 180 degrees.
Thank you very much for your help
User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1140
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Ahh - right. Well servos are very low speed things to be driving, so no problems. Users have been able to drive 32 channels of servo from a single port/core easily.

Here's the general idea:

Image

To be honest, this would be a very simple thing to do from scratch. Eg. 3 x 1b ports with timers. Or even a 4b port with 4 timers (one to reset and the other 3 for the transition).

Luckily plenty of users have done this before.. This is a really nice, straightforward example
https://www.youtube.com/watch?v=iqdLpQFa2MQ
http://www.xcore.com/projects/simple-servo-control

so you can use that to get going..
User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1140
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Here's an updated library and example if you want to re-use rather than write your own:

http://www.xcore.com/projects/simple-servo-driver
Schatz143
Member++
Posts: 31
Joined: Mon Jan 20, 2020 9:54 am

Post by Schatz143 »

Hi there !The links provided by infiniteimprobability are not working.
http://www.xcore.com/projects/simple-servo-driver
http://www.xcore.com/questions/2848/i-require-8-pwm
is there anyway i can get some info regarding those.
would be much appreciated.Thanks