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.
ECIO40P16 PWM Chip Output
Moderator: Benj
- 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
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.
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.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
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.
The component needs placing into the "C:\Program Files (x86)\Flowcode 6\components" directory before restarting Flowcode.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ECIO40P16 PWM Chip Output
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
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
- QMESAR
- 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
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 momentpaulm 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?
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- 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
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
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
- Attachments
-
- 2.jpg
- (238.23 KiB) Downloaded 881 times
-
- 1.jpg (129.92 KiB) Viewed 6945 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- 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
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
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 (126.78 KiB) Viewed 6919 times
-
- 2.jpg
- (274.38 KiB) Downloaded 855 times
-
- 1.jpg (21.24 KiB) Viewed 6922 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR