ECIO40P16 PWM Chip Output

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
k00133150
Posts: 3
Joined: Tue Nov 18, 2014 9:36 pm
Has thanked: 1 time
Been thanked: 1 time

ECIO40P16 PWM Chip Output

Post by k00133150 »

I made a simple program on flowcode 6 using the ECIO40P16 chip using one PWM channel.
The program downloads to the chip fine but when I measure the voltage on the desired pin I am not getting any voltage reading.
I have attached a copy of the program.
I am new to Flowcode 6 so i would really appreciate any help

Thanks in advance.
Attachments
PWM Test ECIO.fcfx
(4.97 KiB) Downloaded 275 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO40P16 PWM Chip Output

Post by Benj »

Hello,

I think I have tracked down the problem. You will need to copy this file into your "C:\Program Files (x86)\Flowcode 6\CAL\PIC16BIT" directory before re-compiling your program to the device.
PIC16BIT_CAL_PWM.c
(13.31 KiB) Downloaded 297 times
There is another issue with a duty cycle of 0 giving approx 50% mark space at 1/2 the normal frequency. Duties of 1 and upwards seems to work as expected.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO40P16 PWM Chip Output

Post by Benj »

I found another bug in the way the prescaler was being assigned and calculated, this has now also been fixed.

The component needs placing into the "C:\Program Files (x86)\Flowcode 6\components" directory before restarting Flowcode.
cal_pwm.fcpx
(7.29 KiB) Downloaded 313 times

k00133150
Posts: 3
Joined: Tue Nov 18, 2014 9:36 pm
Has thanked: 1 time
Been thanked: 1 time

Re: ECIO40P16 PWM Chip Output

Post by k00133150 »

Thanks, that fixed it for me.
Is there there any way i can reduce the PWM frequency to 20 KHz.
The lowest i can get is 136 kHz.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO40P16 PWM Chip Output

Post by Benj »

Hello,

The hardware PWM currently only supports the speeds shown. There is advanced PWM on this chip but we have not bitten this functionality off in Flowcode yet.

You could probably use a timer interrupt to allow you to generate software PWM at a rate more like 20KHz. This article has an example of software PWM using a timer interrupt.

http://www.flowcode.co.uk/article.php?a=52

paulm
Posts: 36
Joined: Mon Mar 28, 2011 9:37 pm

Re: ECIO40P16 PWM Chip Output

Post by paulm »

Hi Ben,

I bought Flowcode 6 and purchased the ECIO40P16 to drive a 5-axis servo motor robot simply because there are multiple PWM channels. I'm very surprised that the chip cannot output PWM frequencies of 20KHz for DC motors without using software interrupts.

I'm curious as what you mean by advanced PWM?? My understanding is that driving PWM frequencies above 20KHz only increases switching losses in the H-Bridge and makes EMI issues a lot worse. Is it realistic or practical to drive DC motors with a PWM frequency of 136KHz?

Can you use multiple software interrupts to control multiple axis?

Finally, will the PWM support the 50Hz PWM frequency of RC Servo Motors with 1-2mSec pulse width?

Regards,
Paul

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: ECIO40P16 PWM Chip Output

Post by QMESAR »

paulm wrote: I'm very surprised that the chip cannot output PWM frequencies of 20KHz for DC motors without using software interrupts.

will the PWM support the 50Hz PWM frequency of RC Servo Motors with 1-2mSec pulse width?
In my opinion it is not the chip ,The chip can do that ,it is the way the FC PWM component is working at the moment

You will have to access the PWM modules yourself with C code component calls to drive 5 servo's is no job for a dsPIC it does that with a smile :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: ECIO40P16 PWM Chip Output

Post by QMESAR »

Hi
Just to show you an example below is the code I use to run 2 PWM's set at 10KHZ on an ECIO40P16 .
You can achieve any frequency you need by setting up the PTPER register with pre-scalers , then you can use multiple modes op operation for the PWM module check out the Referance manual on PWM for the dsPIC33EP256MU506
it is a matter of configuration to achieve your specification No need for interrupts

Hope this helps you :D
Attachments
2.jpg
(238.23 KiB) Downloaded 881 times
1.jpg
1.jpg (129.92 KiB) Viewed 6943 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO40P16 PWM Chip Output

Post by Benj »

Hello,

For clarity Flowcode supports CCP (capture compare) type PWM which most microcontrollers (PIC, dsPIC, AVR, ARM) have on-board. This works very well but can be limited in terms of pre-scaler values and so will run at a percentage of the osc speed.

Some devices including the dsPIC ECIO40 have CCP peripherals (from memory it has 16 of these) but also advanced PWM peripherals which are not as straightforward to use but massively more adjustable in terms of duty cycle and operations such as 3 phase. We have not bitten off the advanced PWM at the moment as it is very device dependent and would be a huge job to do well let alone explain how to use it.

Writing C code for the advanced PWM on a specific device is quite straight forward if you know which PWM channels you require. However again we do not know which PWM you might want to use so again making a generic component is difficult.

I will think on this and investigate the differences between devices to see if there are patterns we can adopt.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: ECIO40P16 PWM Chip Output

Post by QMESAR »

Hello

I had a few minutes and I played with your 50Hz PWM below is my FlowCode diagram and the C code I used to get 50Hz PWM on PWM1H(RE1)ECIO40P16 and 50% Duty cycle

Hope this helps you
Attachments
3.jpg
3.jpg (126.78 KiB) Viewed 6917 times
2.jpg
(274.38 KiB) Downloaded 855 times
1.jpg
1.jpg (21.24 KiB) Viewed 6920 times

Post Reply