How do I use the PWM with flowcode?
How do I use the PWM with flowcode?
Hello, I've been trying to create a program to control the speed and direction of the motor. But first things first, to test out the PWM in flow code, I simply created a BYTE variable, named it "X" and made the ADC return value to be "x", prior to that I enabled PWM by the way, and then I set the duty cycle of the PWM to be, " 1,x ". When I check what's coming out of on the CC1 of my PIC, I get nothing .... What am I doing wrong ? can somebody help me or maybe put out an example that I can test out and learn from ? Thanks in advance....
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: How do I use the PWM with flowcode?
If you post your flowchart, will look at it for you.
What you have done so far Sounds OK to me.
If people don't get expected results, It is always a good idea to make a simple circuit to flash a LED at 1Hz. Then you know your config and oscillator settings (+running at correct speed) are correct . Also the config settings can determine which pin the pwm signal is sent 2
Are you using an internal or external osc?
What you have done so far Sounds OK to me.
If people don't get expected results, It is always a good idea to make a simple circuit to flash a LED at 1Hz. Then you know your config and oscillator settings (+running at correct speed) are correct . Also the config settings can determine which pin the pwm signal is sent 2
Are you using an internal or external osc?
Martin
Re: How do I use the PWM with flowcode?
Hey thanks for the quick reply, I posted the picture of the program, since it's little, just to test if the PWM is coming out of CC1 port. I am using an external crystal, 4 Mhz, so I set the PIC oscillator to run " HS " . Now, do I have to set some sort of timer for it to work, or this is already done by Flowcode for me ?
And again thanks for the help.
And again thanks for the help.
- Attachments
-
- test.jpg
- (234.39 KiB) Downloaded 7249 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: How do I use the PWM with flowcode?
You Don't need the input icon, just using ADC(0) is enough.
Not got a 16F876, but according to simulator the PWM module part is working OK.
I wanted to look at your test program so I could check your config settings and compile to hex, and run it in the simulator.
Did you try the LED 1 sec test?
Also If you could of put all the text outside see http://www.matrixmultimedia.com/mmforum ... =29&t=6781) I could of observed how PWM macro was set up.
Not got a 16F876, but according to simulator the PWM module part is working OK.
I wanted to look at your test program so I could check your config settings and compile to hex, and run it in the simulator.
Did you try the LED 1 sec test?
Also If you could of put all the text outside see http://www.matrixmultimedia.com/mmforum ... =29&t=6781) I could of observed how PWM macro was set up.
Martin
Re: How do I use the PWM with flowcode?
Exactly, it works fine in Flowcode, but when I simulate in Proteus Isis, I get nothing out of CC1 when I should be getting the duty time according to readings from the ADC. I don't know what to do, and I don't know if it is so straight forward like I did or I have to insert my own Tmr2 to work with the PWM. When I enable the PWM, and set the duty cicle, do I automatically get PWM signal out of CC1 of the PIC , that is my question... Thanks for patience ....
Re: How do I use the PWM with flowcode?
I put an oscilloscope on CC1 port using Proteus Isis, and that's how I know it is not moving .....
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: How do I use the PWM with flowcode?
Sorry, to expand information, the simulator I was referring too, is not a part of but external one to flowcode. (was not referring to flowcode simulator, I should of made that point clearer)
Basically if compiled hex file works in the simulator I use, then the real hardware should work. With 16F876, CCp1 is fixed at pin 13, you can't change that. With other devices, you can have the choice of two pins for ccp1, and that is set up using config.
settings.
You have created software OK. Just enable pwm channel1, set duty, change the settings (pwm properties, period register to run at correct frequency) then away you go! you should automatically get pwm signal out of pin 13. No need to alter timer 2 settings
Have you tried building with real hardware? It could be your proteus simulator not working properly?
Basically if compiled hex file works in the simulator I use, then the real hardware should work. With 16F876, CCp1 is fixed at pin 13, you can't change that. With other devices, you can have the choice of two pins for ccp1, and that is set up using config.
settings.
You have created software OK. Just enable pwm channel1, set duty, change the settings (pwm properties, period register to run at correct frequency) then away you go! you should automatically get pwm signal out of pin 13. No need to alter timer 2 settings
Have you tried building with real hardware? It could be your proteus simulator not working properly?
Martin
Re: How do I use the PWM with flowcode?
I just noticed something, when I go into properties of the PWM while flowcode is running frequency and period are zero, shouldn't they be showing something ??
- Attachments
-
- test.jpg
- (174.18 KiB) Downloaded 7208 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: How do I use the PWM with flowcode?
Sounds like you have the older (first) Version of V4. If you go to: 'Help about' menu you should have latest version of 4.2.3.58.
Latest version can be downloaded from:
http://www.matrixmultimedia.com/Flowcode3a-X.php
Links will be available when you put you email address in
Although with that older version, I tried 2 channel PWM on a 16f737, and channel 1 worked even though frequency showed 0.
Just a bug with properties display, and second channel. PWM with your device may or may not be bugged.
You should be posting any questions regarding V4 on V4 section.
You will see this on the index page
Flowcode V4
For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.
If you have already done this, them I believe someone from matrix has to enable your user name to access the V4 section.
If that is the case, just ignore the last bit :p
Latest version can be downloaded from:
http://www.matrixmultimedia.com/Flowcode3a-X.php
Links will be available when you put you email address in
Although with that older version, I tried 2 channel PWM on a 16f737, and channel 1 worked even though frequency showed 0.
Just a bug with properties display, and second channel. PWM with your device may or may not be bugged.
You should be posting any questions regarding V4 on V4 section.
You will see this on the index page
Flowcode V4
For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.
If you have already done this, them I believe someone from matrix has to enable your user name to access the V4 section.
If that is the case, just ignore the last bit :p
Martin